@Override public String isValid(String newText) { if (newText == null || "".equals(newText) || res.getParent() == null) //$NON-NLS-1$ return INVALID_NAME_NO_MESSAGE; if (res.getParent().findMember(newText) != null) return ReorgMessages.ReorgQueries_resourceWithThisNameAlreadyExists; if (! res.getParent().getFullPath().isValidSegment(newText)) return ReorgMessages.ReorgQueries_invalidNameMessage; IStatus status= res.getParent().getWorkspace().validateName(newText, res.getType()); if (status.getSeverity() == IStatus.ERROR) return status.getMessage(); if (res.getName().equalsIgnoreCase(newText)) return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage; return null; } };
@Override public String isValid(String newText) { if (newText == null || "".equals(newText) || res.getParent() == null) //$NON-NLS-1$ return INVALID_NAME_NO_MESSAGE; if (res.getParent().findMember(newText) != null) return ReorgMessages.ReorgQueries_resourceWithThisNameAlreadyExists; if (! res.getParent().getFullPath().isValidSegment(newText)) return ReorgMessages.ReorgQueries_invalidNameMessage; IStatus status= res.getParent().getWorkspace().validateName(newText, res.getType()); if (status.getSeverity() == IStatus.ERROR) return status.getMessage(); if (res.getName().equalsIgnoreCase(newText)) return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage; return null; } };
@Override public IPath append(IPath tail) { //optimize some easy cases if (tail == null || tail.segmentCount() == 0) return this; //these call chains look expensive, but in most cases they are no-ops //the tail must be for the same platform as this instance if (this.isEmpty() && ((flags & IS_FOR_WINDOWS) == 0) == tail.isValidSegment(":")) //$NON-NLS-1$ return tail.setDevice(device).makeRelative().makeUNC(isUNC()); if (this.isRoot() && ((flags & IS_FOR_WINDOWS) == 0) == tail.isValidSegment(":")) //$NON-NLS-1$ return tail.setDevice(device).makeAbsolute().makeUNC(isUNC()); //concatenate the two segment arrays int myLen = segments.length; int tailLen = tail.segmentCount(); String[] newSegments = new String[myLen + tailLen]; System.arraycopy(segments, 0, newSegments, 0, myLen); for (int i = 0; i < tailLen; i++) { newSegments[myLen + i] = tail.segment(i); } //use my leading separators and the tail's trailing separator Path result = new Path(device, newSegments, (flags & (HAS_LEADING | IS_UNC | IS_FOR_WINDOWS)) | (tail.hasTrailingSeparator() ? HAS_TRAILING : 0)); String tailFirstSegment = newSegments[myLen]; if (tailFirstSegment.equals("..") || tailFirstSegment.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$ result.canonicalize(); } return result; }
@Override public IPath append(IPath tail) { //optimize some easy cases if (tail == null || tail.segmentCount() == 0) return this; //these call chains look expensive, but in most cases they are no-ops //the tail must be for the same platform as this instance if (this.isEmpty() && ((flags & IS_FOR_WINDOWS) == 0) == tail.isValidSegment(":")) //$NON-NLS-1$ return tail.setDevice(device).makeRelative().makeUNC(isUNC()); if (this.isRoot() && ((flags & IS_FOR_WINDOWS) == 0) == tail.isValidSegment(":")) //$NON-NLS-1$ return tail.setDevice(device).makeAbsolute().makeUNC(isUNC()); //concatenate the two segment arrays int myLen = segments.length; int tailLen = tail.segmentCount(); String[] newSegments = new String[myLen + tailLen]; System.arraycopy(segments, 0, newSegments, 0, myLen); for (int i = 0; i < tailLen; i++) { newSegments[myLen + i] = tail.segment(i); } //use my leading separators and the tail's trailing separator Path result = new Path(device, newSegments, (flags & (HAS_LEADING | IS_UNC | IS_FOR_WINDOWS)) | (tail.hasTrailingSeparator() ? HAS_TRAILING : 0)); String tailFirstSegment = newSegments[myLen]; if (tailFirstSegment.equals("..") || tailFirstSegment.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$ result.canonicalize(); } return result; }
@Override public RefactoringStatus checkNewElementName(String newName) throws CoreException { Assert.isNotNull(newName, "new name"); //$NON-NLS-1$ if (! newName.trim().equals(newName)) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_blank); IContainer c= fSourceFolder.getResource().getParent(); if (! c.getFullPath().isValidSegment(newName)) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_invalid_name); RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, IResource.FOLDER)); if (result.hasFatalError()) return result; result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), IResource.FOLDER))); if (result.hasFatalError()) return result; IJavaProject project= fSourceFolder.getJavaProject(); IPath p= project.getProject().getFullPath().append(newName); if (project.findPackageFragmentRoot(p) != null) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_already_exists); if (project.getProject().findMember(new Path(newName)) != null) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_alread_exists); return result; }
@Override public RefactoringStatus checkNewElementName(String newName) throws CoreException { Assert.isNotNull(newName, "new name"); //$NON-NLS-1$ if (! newName.trim().equals(newName)) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_blank); IContainer c= fSourceFolder.getResource().getParent(); if (! c.getFullPath().isValidSegment(newName)) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_invalid_name); RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, IResource.FOLDER)); if (result.hasFatalError()) return result; result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), IResource.FOLDER))); if (result.hasFatalError()) return result; IJavaProject project= fSourceFolder.getJavaProject(); IPath p= project.getProject().getFullPath().append(newName); if (project.findPackageFragmentRoot(p) != null) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_already_exists); if (project.getProject().findMember(new Path(newName)) != null) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_alread_exists); return result; }
public RefactoringStatus checkNewElementName(String newName) throws CoreException { Assert.isNotNull(newName, "new name"); //$NON-NLS-1$ if (! newName.trim().equals(newName)) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_blank); IContainer c= fSourceFolder.getResource().getParent(); if (! c.getFullPath().isValidSegment(newName)) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_invalid_name); RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, IResource.FOLDER)); if (result.hasFatalError()) return result; result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), IResource.FOLDER))); if (result.hasFatalError()) return result; IJavaProject project= fSourceFolder.getJavaProject(); IPath p= project.getProject().getFullPath().append(newName); if (project.findPackageFragmentRoot(p) != null) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_already_exists); if (project.getProject().findMember(new Path(newName)) != null) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_alread_exists); return result; }
public RefactoringStatus checkNewElementName(String newName) throws JavaModelException { Assert.isNotNull(newName, "new name"); //$NON-NLS-1$ IContainer c= fResource.getParent(); if (c == null) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceRefactoring_Internal_Error); if (c.findMember(newName) != null) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceRefactoring_alread_exists); if (!c.getFullPath().isValidSegment(newName)) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceRefactoring_invalidName); RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, fResource.getType())); if (!result.hasFatalError()) result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), fResource.getType()))); return result; }
public RefactoringStatus checkNewElementName(String newName) { Assert.isNotNull(newName, "new name"); //$NON-NLS-1$ IContainer c= fResource.getParent(); if (c == null) return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RenameResourceRefactoring.Internal_Error")); //$NON-NLS-1$ if (c.findMember(newName) != null) return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RenameResourceRefactoring.alread_exists")); //$NON-NLS-1$ if (!c.getFullPath().isValidSegment(newName)) return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RenameResourceRefactoring.invalidName")); //$NON-NLS-1$ RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, fResource.getType())); if (! result.hasFatalError()) result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), fResource.getType()))); return result; }
/** * Validates if the a name is valid. This method does not change the name settings on the refactoring. It is intended to be used * in a wizard to validate user input. * * @param newName the name to validate * @return returns the resulting status of the validation */ public RefactoringStatus validateNewElementName(String newName) { Assert.isNotNull(newName, "new name"); //$NON-NLS-1$ IContainer c= fResource.getParent(); if (c == null) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceProcessor_error_no_parent); if (!c.getFullPath().isValidSegment(newName)) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceProcessor_error_invalid_name); if (c.findMember(newName) != null) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceProcessor_error_resource_already_exists); RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, fResource.getType())); if (!result.hasFatalError()) result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), fResource.getType()))); return result; }
/** * Validates if the a name is valid. This method does not change the name settings on the refactoring. It is intended to be used * in a wizard to validate user input. * * @param newName the name to validate * @return returns the resulting status of the validation */ public RefactoringStatus validateNewElementName(String newName) { Assert.isNotNull(newName, "new name"); //$NON-NLS-1$ IContainer c= fResource.getParent(); if (c == null) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceProcessor_error_no_parent); if (!c.getFullPath().isValidSegment(newName)) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceProcessor_error_invalid_name); if (c.findMember(newName) != null) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceProcessor_error_resource_already_exists); RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, fResource.getType())); if (!result.hasFatalError()) result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), fResource.getType()))); return result; }