private IFile getFile(IStructuredModel model) { String location = model.getBaseLocation(); if (location != null) { IPath path = new Path(location); if (path.segmentCount() > 1) { return ResourcesPlugin.getWorkspace().getRoot().getFile(path); } } return null; }
/** * Initialize the change notifier. This method is called from the * constructor and registers a listener with the workspace and the * synchronization context. It also registers a listener with the context * cache which will unregister the listeners when the context is disposed. * Subclasses may extend this method. */ public void initialize() { ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); eventHandler = new InputChangeEventHandler(); }
@Override public void stop(BundleContext context) throws Exception { super.stop(context); IWorkspace workspace = ResourcesPlugin.getWorkspace(); workspace.removeResourceChangeListener(this.mavenUpdateConfigurationChangeListener); this.mavenUpdateConfigurationChangeListener = null; }
/** * @see AbstractMarkerAnnotationModel#listenToMarkerChanges(boolean) */ protected void listenToMarkerChanges(boolean listen) { if (listen) fWorkspace.addResourceChangeListener(this); else fWorkspace.removeResourceChangeListener(this); }
protected void runSaveOperation(IWorkspaceRunnable runnable, IProgressMonitor monitor) throws SaveFailedException { try { ResourcesPlugin.getWorkspace().run(runnable, ResourcesPlugin.getWorkspace().getRoot(), IWorkspace.AVOID_UPDATE, monitor); } catch (CoreException e) { throw new SaveFailedException(e); } }
public static IProject getProjectHandleFromProjectName(String projectName) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IStatus status = workspace.validateName(projectName, IResource.PROJECT); return (null != projectName && projectName.length() > 0 && status.isOK()) ? ResourcesPlugin.getWorkspace().getRoot().getProject(projectName) : null; }
public String getLocalFile() { String file = reader.getFile(fileid); if (file.startsWith("file:/")) { IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile iFile = workspaceRoot.getFileForLocation(new Path(file.substring(6))); file = iFile.getFullPath().toString(); } return file; }
@Override public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { IResource resource = getResource(); if (resource == null || !resource.exists()) return RefactoringStatus.createFatalErrorStatus(MessageFormat.format(PDEUIMessages.RenameProjectChange_projectDoesNotExist, fResourcePath.toString())); if (ResourcesPlugin.getWorkspace().getRoot().getProject(fNewName).exists()) return RefactoringStatus.createFatalErrorStatus(MessageFormat.format(PDEUIMessages.RenameProjectChange_destinationExists, fNewName)); return new RefactoringStatus(); }
private IPath getProjectPath() { String projName = (String)getProperty(FACET_PROJECT_NAME); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projName); if (project.exists()){ return project.getLocation(); } IDataModel projModel = (IDataModel)getProperty(MASTER_PROJECT_DM); if (projModel.getBooleanProperty(IProjectCreationPropertiesNew.USE_DEFAULT_LOCATION)){ return new Path(projModel.getStringProperty(IProjectCreationPropertiesNew.PROJECT_LOCATION)).append(projName); } return new Path(projModel.getStringProperty(IProjectCreationPropertiesNew.USER_DEFINED_LOCATION)).append(projName); }
public static IPath makeAbsolute(IPath p) { IPath absolutePath = p; if (p.toFile().exists()) { return p; } IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(p); if (resource != null && resource.exists()) { absolutePath = resource.getLocation(); } return absolutePath; }
@Override public final Object convertToObject(final String parameterValue) throws ParameterValueConversionException { final Path path = new Path(parameterValue); final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace() .getRoot(); final IResource resource = workspaceRoot.findMember(path); if ((resource == null) || (!resource.exists())) { throw new ParameterValueConversionException( "parameterValue must be the path of an existing resource"); //$NON-NLS-1$ } return resource; }
public static class ClasspathResolutionBreakpointListener { public void breakpoint(int bp) { // override in listener implementation } }
public static List<IProject> getVisibleProjects(IPath workspaceRoot) { List<IProject> projects = new ArrayList<>(); for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { if (project.exists() && isVisibleProject(project) && workspaceRoot.isPrefixOf(project.getLocation())) { projects.add(project); } } return projects; }
private String getExpandedPath(String path) { if (path == null || path.length() == 0) return null; IResource resource = PDECore.getWorkspace().getRoot().findMember(new Path(path)); if (resource != null) { IPath fullPath = resource.getLocation(); return fullPath == null ? null : fullPath.toOSString(); } return null; }
/** * The path is known to match a source/library folder entry. * @param path IPath * @return IPackageFragmentRoot */ public IPackageFragmentRoot getFolderPackageFragmentRoot(IPath path) { if (path.segmentCount() == 1) { // default project root return getPackageFragmentRoot(this.project); } return getPackageFragmentRoot(this.project.getWorkspace().getRoot().getFolder(path)); }
private boolean isDirectChildOfWorkspaceRootFolder(File location) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IPath rootLocationPath = workspace.getRoot().getLocation(); IPath locationPath = Path.fromOSString(location.getPath()); return rootLocationPath.equals(locationPath) || rootLocationPath.equals(locationPath.removeLastSegments(1)); }
private static File getRawLocationFile(IPath simplePath) { IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(simplePath); File file = null; if (resource != null) { file = ResourcesPlugin.getWorkspace().getRoot().findMember( simplePath).getRawLocation().toFile(); } else { file = simplePath.toFile(); } return file; }
private IPathVariableManager getManager(IPath workspacePath) { IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = workspaceRoot.findMember(workspacePath); if (resource != null) return resource.getPathVariableManager(); return workspaceRoot.getFile(workspacePath).getPathVariableManager(); }
public void run(IProgressMonitor monitor) throws InvocationTargetException { try { ResourcesPlugin.getWorkspace().run(workspaceRunnable, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } } }
private String makeAbsolute(String input, ILaunchConfiguration configuration) throws CoreException { IResource member = ResourcesPlugin.getWorkspace().getRoot().findMember(input); if (member != null) { return member.getLocation().toPortableString(); } return input; }