private IContainer[] getSourceContainers(Element element) { String sourcePaths= element.getAttribute(SOURCEPATH); StringTokenizer tokenizer= new StringTokenizer(sourcePaths, String.valueOf(File.pathSeparatorChar)); ArrayList res= new ArrayList(); IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); while (tokenizer.hasMoreTokens()) { IPath path= makeAbsolutePathFromRelative(new Path(tokenizer.nextToken().trim())); if (path != null) { IContainer[] containers= root.findContainersForLocation(path); for (int i= 0; i < containers.length; i++) { res.add(containers[i]); } } } return (IContainer[]) res.toArray(new IContainer[res.size()]); }
private IContainer[] getSourceContainers(Element element) { String sourcePaths= element.getAttribute(SOURCEPATH); if (sourcePaths.endsWith(File.pathSeparator)) { sourcePaths += '.'; } IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); ArrayList res= new ArrayList(); String[] strings= sourcePaths.split(File.pathSeparator); for (int i= 0; i < strings.length; i++) { IPath path= makeAbsolutePathFromRelative(new Path(strings[i].trim())); if (path != null) { IContainer[] containers= root.findContainersForLocation(path); for (int k= 0; k < containers.length; k++) { res.add(containers[k]); } } } return (IContainer[]) res.toArray(new IContainer[res.size()]); }
/** * Returns the name of a {@link IProject} with a location that includes * targetDirectory. Returns null if there is no such {@link IProject}. * * @param targetDirectory * the path of the directory to check. * @return the overlapping project name or <code>null</code> */ private String getOverlappingProjectName(String targetDirectory){ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IPath testPath = new Path(targetDirectory); IContainer[] containers = root.findContainersForLocation(testPath); if(containers.length > 0){ return containers[0].getProject().getName(); } return null; }
private void refresh(IPath path) { if (fRoot.findContainersForLocation(path).length > 0) { try { fRoot.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { JavaPlugin.log(e); } } }
private void refresh(IPath path) { if (fRoot.findContainersForLocation(path).length > 0) { try { fRoot.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { JavaPlugin.log(e); } } }
/** * Returns the resource in the workspace associated with the given * absolute path, or <code>null</code> if none. The path may have * a device. * * @param path absolute path, or <code>null</code> * @return resource or <code>null</code> */ protected IResource getResource(IPath path) { if (path != null) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); // look for files or folders with the given path @SuppressWarnings("deprecation") IFile[] files = root.findFilesForLocation(path); if (files.length > 0) { return files[0]; } @SuppressWarnings("deprecation") IContainer[] containers = root.findContainersForLocation(path); if (containers.length > 0) { return containers[0]; } if (path.getDevice() == null) { // search relative to the workspace if no device present return root.findMember(path); } } return null; }
/** * Returns the resource in the workspace associated with the given * absolute path, or <code>null</code> if none. The path may have * a device. * * @param path absolute path, or <code>null</code> * @return resource or <code>null</code> */ protected IResource getResource(IPath path) { if (path != null) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); // look for files or folders with the given path @SuppressWarnings("deprecation") IFile[] files = root.findFilesForLocation(path); if (files.length > 0) { return files[0]; } @SuppressWarnings("deprecation") IContainer[] containers = root.findContainersForLocation(path); if (containers.length > 0) { return containers[0]; } if (path.getDevice() == null) { // search relative to the workspace if no device present return root.findMember(path); } } return null; }
/** * Returns the resource in the workspace assciated with the given * absolute path, or <code>null</code> if none. The path may have * a device. * * @param path absolute path, or <code>null</code> * @return resource or <code>null</code> */ private static IResource getResource(IPath path) { if (path != null) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); // look for files or folders with the given path IFile[] files = root.findFilesForLocation(path); if (files.length > 0) { return files[0]; } IContainer[] containers = root.findContainersForLocation(path); if (containers.length > 0) { return containers[0]; } if (path.getDevice() == null) { // search relative to the workspace if no device present return root.findMember(path); } } return null; } }
/** * Returns the selected workspace container,or <code>null</code> */ protected IContainer getContainer() { String path = getWorkingDirectoryText(); if (path.length() > 0) { IResource res = null; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); if (path.startsWith("${workspace_loc:")) { //$NON-NLS-1$ IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); try { path = manager.performStringSubstitution(path, false); IContainer[] containers = root.findContainersForLocation(new Path(path)); if (containers.length > 0) { res = containers[0]; } } catch (CoreException e) {} } else { res = root.findMember(path); } if (res instanceof IContainer) { return (IContainer)res; } } return null; }