本文整理匯總了Java中org.eclipse.core.resources.IWorkspace.validateName方法的典型用法代碼示例。如果您正苦於以下問題:Java IWorkspace.validateName方法的具體用法?Java IWorkspace.validateName怎麽用?Java IWorkspace.validateName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IWorkspace
的用法示例。
在下文中一共展示了IWorkspace.validateName方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: validateProjectName
import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
public static IStatus validateProjectName(final IWorkspace workspace, final String name) {
final IStatus status = workspace.validateName(name, IResource.PROJECT);
if (!status.isOK()) {
return status;
}
if (name.startsWith(".")) //$NON-NLS-1$
{
return new Status(
IStatus.ERROR,
TFSCommonClientPlugin.PLUGIN_ID,
Messages.getString("EclipseProjectInfo.NameStartsWithDotError")); //$NON-NLS-1$
}
return Status.OK_STATUS;
}
示例2: validateProjectName
import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
/**
* Check if there already is a project under the given name.
* @param text
*/
private void validateProjectName(String text) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IStatus status = workspace.validateName(text, IResource.PROJECT);
if (status.isOK()) {
if (workspace.getRoot().getProject(text).exists()) {
status = createStatus(IStatus.ERROR,
TexlipsePlugin.getResourceString("projectWizardNameError"));
}
attributes.setProjectName(text);
}
updateStatus(status, projectNameField);
}
示例3: getErrorMessage
import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
@Override
protected String getErrorMessage() {
if (isBlank(dictionaryNameText)) {
return "error.translation.dictionary.name.empty";
}
final String fileName = dictionaryNameText.getText().trim();
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IStatus result = workspace.validateName(fileName, IResource.FILE);
if (!result.isOK()) {
return result.getMessage();
}
final File file = new File(PreferenceInitializer.getTranslationPath(fileName));
if (file.exists()) {
return "error.translation.dictionary.name.duplicated";
}
return null;
}
示例4: getErrorMessage
import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
@Override
protected String getErrorMessage() {
if (isBlank(this.dictionaryNameText)) {
return "error.translation.dictionary.name.empty";
}
String fileName = this.dictionaryNameText.getText().trim();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IStatus result = workspace.validateName(fileName, IResource.FILE);
if (!result.isOK()) {
return result.getMessage();
}
File file = new File(PreferenceInitializer.getTranslationPath(fileName));
if (file.exists()) {
return "error.translation.dictionary.name.duplicated";
}
return null;
}
示例5: validatePage
import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
/**
* Returns whether this page's controls currently all contain valid
* values.
*
* @return <code>true</code> if all controls are valid, and
* <code>false</code> if at least one is invalid
*/
protected boolean validatePage() {
IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
String projectFieldContents = getProjectNameFieldValue();
if (projectFieldContents.equals("")) { //$NON-NLS-1$
setErrorMessage(null);
setMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectNameEmpty);
return false;
}
IStatus nameStatus = workspace.validateName(projectFieldContents,
IResource.PROJECT);
if (!nameStatus.isOK()) {
setErrorMessage(nameStatus.getMessage());
return false;
}
IProject handle = getProjectHandle();
if (handle.exists()) {
setErrorMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectExistsMessage);
return false;
}
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
getProjectNameFieldValue());
locationArea.setExistingProject(project);
String validLocationMessage = locationArea.checkValidLocation();
if (validLocationMessage != null) { // there is no destination location given
setErrorMessage(validLocationMessage);
return false;
}
setErrorMessage(null);
setMessage(null);
return true;
}
示例6: validate
import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
private void validate() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
// check whether the project name is empty
String projectName = projectData.projectName;
if (projectName == null || projectName.trim().isEmpty()) {
setErrorMessage("Project name must not be empty");
setPageComplete(false);
return;
}
// check whether the project name is valid
final IStatus projectNameStatus = workspace.validateName(projectName, IResource.PROJECT);
if (!projectNameStatus.isOK()) {
setErrorMessage(projectNameStatus.getMessage());
setPageComplete(false);
return;
}
// check whether the project with the name already exists
IProject handle = workspace.getRoot().getProject(projectData.projectName);
if (handle.exists()) {
setErrorMessage("A project with name '" + projectData.projectName + "' already exists in the workspace");
setPageComplete(false);
return;
}
// check whether the location is empty
String location = projectData.projectLocation;
if (location == null || location.isEmpty()) {
setErrorMessage("Enter a location for the project.");
setPageComplete(false);
return;
}
// check whether the location is a syntactically correct path
if (!Path.EMPTY.isValidPath(location)) {
setErrorMessage("Invalid project contents directory");
setPageComplete(false);
return;
}
IPath projectPath = null;
if (!useDefaultsButton.getSelection()) {
projectPath = Path.fromOSString(location);
if (!projectPath.toFile().exists()) {
if (!canCreate(projectPath.toFile())) {
setErrorMessage("Cannot create project content at the given external location.");
setPageComplete(false);
return;
}
}
}
// check whether the location is valid
final IStatus locationStatus = workspace.validateProjectLocation(handle, projectPath);
if (!locationStatus.isOK()) {
setErrorMessage(locationStatus.getMessage());
setPageComplete(false);
return;
}
setErrorMessage(null);
setPageComplete(true);
}
示例7: validatePage
import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
/**
* Returns whether this page's controls currently all contain valid values.
*
* @return <code>true</code> if all controls are valid, and
* <code>false</code> if at least one is invalid
*/
protected boolean validatePage() {
boolean valid = true;
if (!resourceGroup.areAllValuesValid()) {
// if blank name then fail silently
if (resourceGroup.getProblemType() == ResourceAndContainerGroup.PROBLEM_RESOURCE_EMPTY
|| resourceGroup.getProblemType() == ResourceAndContainerGroup.PROBLEM_CONTAINER_EMPTY) {
setMessage(resourceGroup.getProblemMessage());
setErrorMessage(null);
} else {
setErrorMessage(resourceGroup.getProblemMessage());
}
valid = false;
}
String resourceName = resourceGroup.getResource();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IStatus result = workspace.validateName(resourceName, IResource.FILE);
if (!result.isOK()) {
setErrorMessage(result.getMessage());
return false;
}
IStatus linkedResourceStatus = null;
if (valid) {
linkedResourceStatus = validateLinkedResource();
if (linkedResourceStatus.getSeverity() == IStatus.ERROR) {
valid = false;
}
}
// validateLinkedResource sets messages itself
if (valid
&& (linkedResourceStatus == null || linkedResourceStatus.isOK())) {
setMessage(null);
setErrorMessage(null);
// perform "resource exists" check if it was skipped in
// ResourceAndContainerGroup
if (resourceGroup.getAllowExistingResources()) {
String problemMessage = NLS.bind(
IDEWorkbenchMessages.ResourceGroup_nameExists,
getFileName());
IPath resourcePath = getContainerFullPath().append(
getFileName());
if (workspace.getRoot().getFolder(resourcePath).exists()) {
setErrorMessage(problemMessage);
valid = false;
}
if (workspace.getRoot().getFile(resourcePath).exists()) {
setMessage(problemMessage, IMessageProvider.WARNING);
}
}
}
if (isFilteredByParent()) {
setMessage(
IDEWorkbenchMessages.WizardNewFileCreationPage_resourceWillBeFilteredWarning,
IMessageProvider.ERROR);
setupLinkedResourceTarget();
valid = false;
}
return valid;
}