public IResource createResourceHandle() { IWorkspaceRoot workspaceRoot = parent.getWorkspace().getRoot(); IPath fullPath = parent.getFullPath().append(name); return workspaceRoot.getFile(fullPath); }
@Override public IResource createResourceHandle() { IWorkspaceRoot workspaceRoot = parent.getWorkspace().getRoot(); IPath fullPath = parent.getFullPath().append(name); return workspaceRoot.getFile(fullPath); }
@Override public IResource createResourceHandle() { IWorkspaceRoot workspaceRoot= parent.getWorkspace().getRoot(); IPath fullPath= parent.getFullPath().append(name); return workspaceRoot.getFile(fullPath); }
@Override public IResource createResourceHandle() { IWorkspaceRoot workspaceRoot= parent.getWorkspace().getRoot(); IPath fullPath= parent.getFullPath().append(name); return workspaceRoot.getFile(fullPath); }
/** * Creates a folder resource handle for the folder with the given name. * The folder handle is created relative to the container specified during * object creation. * * @param folderName the name of the folder resource to create a handle for * @return the new folder resource handle */ private IFolder createFolderHandle(String folderName) { IWorkspaceRoot workspaceRoot = fContainer.getWorkspace().getRoot(); IPath folderPath = fContainer.getFullPath().append(folderName); IFolder folderHandle = workspaceRoot.getFolder(folderPath); return folderHandle; }
/** * Creates a folder resource handle for the folder with the given name. * The folder handle is created relative to the container specified during * object creation. * * @param folderName the name of the folder resource to create a handle for * @return the new folder resource handle */ private IFolder createFolderHandle(String folderName) { IWorkspaceRoot workspaceRoot = container.getWorkspace().getRoot(); IPath folderPath = container.getFullPath().append(folderName); IFolder folderHandle = workspaceRoot.getFolder(folderPath); return folderHandle; }
static File getProgram(IContainer project) { IPath projectFile = ProjectFileAccessor.getProjectFile(project); String projectConfiguration = "Debug"; //$NON-NLS-1$ String[] frameworks = ProjectFileAccessor.getTargetFrameworks(project.getWorkspace().getRoot().getFile(projectFile).getLocation()); if (frameworks.length > 0) { return new File(project.getLocation().toFile().getAbsolutePath() + "/bin/" + projectConfiguration + "/" + frameworks[0] + "/" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + projectFile.removeFileExtension().addFileExtension("dll").lastSegment()); //$NON-NLS-1$ } return null; }
@Override public void dispose() { if (viewer != null) { IWorkspace workspace = null; Object obj = viewer.getInput(); if (obj instanceof IWorkspace) { workspace = (IWorkspace) obj; } else if (obj instanceof IContainer) { workspace = ((IContainer) obj).getWorkspace(); } if (workspace != null) { workspace.removeResourceChangeListener(this); } } super.dispose(); }
public void createWorkbenchResource(IContainer container, String fileName) { IPath path = container.getFullPath(); path = path.append(fileName); IFile file = container.getWorkspace().getRoot().getFile(path); if (!file.exists()) { try { file.create(null, true, null); } catch (CoreException e) { // XMLBuilderPlugin.getPlugin().getMsgLogger().write("Encountered // exception creating file: " + e.getMessage()); } } }
private RefactoringStatus checkNewPathValidity() { IContainer c = fType.getCompilationUnit().getResource().getParent(); String notRename = RefactoringCoreMessages.RenameTypeRefactoring_will_not_rename; IStatus status = c.getWorkspace().validateName(getNewElementName(), IResource.FILE); if (status.getSeverity() == IStatus.ERROR) { return RefactoringStatus.createWarningStatus(status.getMessage() + ". " + notRename); //$NON-NLS-1$ } status = c.getWorkspace().validatePath(createNewPath(getNewElementName()), IResource.FILE); if (status.getSeverity() == IStatus.ERROR) { return RefactoringStatus.createWarningStatus(status.getMessage() + ". " + notRename); //$NON-NLS-1$ } return new RefactoringStatus(); }
private RefactoringStatus checkNewPathValidity() { IContainer c= fType.getCompilationUnit().getResource().getParent(); String notRename= RefactoringCoreMessages.RenameTypeRefactoring_will_not_rename; IStatus status= c.getWorkspace().validateName(getNewElementName(), IResource.FILE); if (status.getSeverity() == IStatus.ERROR) return RefactoringStatus.createWarningStatus(status.getMessage() + ". " + notRename); //$NON-NLS-1$ status= c.getWorkspace().validatePath(createNewPath(getNewElementName()), IResource.FILE); if (status.getSeverity() == IStatus.ERROR) return RefactoringStatus.createWarningStatus(status.getMessage() + ". " + notRename); //$NON-NLS-1$ return new RefactoringStatus(); }
/** * Checks if the folder name is valid. * * @return <code>true</code> if validation was * correct, <code>false</code> otherwise */ private IStatus validateFolderName(String name) { if (name.length() == 0) { return new StatusInfo(IStatus.ERROR, NewWizardMessages.NewFolderDialog_folderNameEmpty); } IStatus nameStatus = fContainer.getWorkspace().validateName(name, IResource.FOLDER); if (!nameStatus.matches(IStatus.ERROR)) { return nameStatus; } IPath path = new Path(name); if (fContainer.findMember(path) != null) { return new StatusInfo(IStatus.ERROR, Messages.format(NewWizardMessages.NewFolderDialog_folderNameEmpty_alreadyExists, name)); } return nameStatus; } }
private RefactoringStatus checkNewPathValidity() { IContainer c= fType.getCompilationUnit().getResource().getParent(); String notRename= RefactoringCoreMessages.RenameTypeRefactoring_will_not_rename; IStatus status= c.getWorkspace().validateName(getNewElementName(), IResource.FILE); if (status.getSeverity() == IStatus.ERROR) return RefactoringStatus.createWarningStatus(status.getMessage() + ". " + notRename); //$NON-NLS-1$ status= c.getWorkspace().validatePath(createNewPath(getNewElementName()), IResource.FILE); if (status.getSeverity() == IStatus.ERROR) return RefactoringStatus.createWarningStatus(status.getMessage() + ". " + notRename); //$NON-NLS-1$ return new RefactoringStatus(); }
private RefactoringStatus checkNewPathValidity() { IContainer c= fType.getCompilationUnit().getResource().getParent(); String notRename= RefactoringCoreMessages.RenameTypeRefactoring_will_not_rename; IStatus status= c.getWorkspace().validateName(getNewElementName(), IResource.FILE); if (status.getSeverity() == IStatus.ERROR) return RefactoringStatus.createWarningStatus(status.getMessage() + ". " + notRename); //$NON-NLS-1$ status= c.getWorkspace().validatePath(createNewPath(getNewElementName()), IResource.FILE); if (status.getSeverity() == IStatus.ERROR) return RefactoringStatus.createWarningStatus(status.getMessage() + ". " + notRename); //$NON-NLS-1$ return new RefactoringStatus(); }
@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; } };
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; }
@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; }
/** * 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; }