public static void refresh(IPath path) { try { IResource r = ResourcesPlugin.getWorkspace().getRoot().findMember( path); if (r != null) return; IPath p = (IPath) path.clone(); while (p.segmentCount() > 0) { p = p.removeLastSegments(1); IResource resource = ResourcesPlugin.getWorkspace().getRoot() .findMember(p); if (resource != null) { resource.refreshLocal(2, null); return; } } } catch (Exception e) { Activator.getDefault().error("While refreshing path " + path, e); } System.out.println("Unexpectedly could not find path in workspace: " + path); }
public static void refresh(IPath path) { try { IResource r = ResourcesPlugin.getWorkspace().getRoot().findMember( path); if (r != null) return; IPath p = (IPath) path.clone(); while (p.segmentCount() > 0) { p = p.removeLastSegments(1); IResource resource = ResourcesPlugin.getWorkspace().getRoot() .findMember(p); if (resource != null) { resource.refreshLocal(2, null); return; } } } catch( ResourceException re ) { // TODO Ignore for now } catch (Exception e) { Activator.getDefault().error("While refreshing path " + path, e); } }
private File getProjectFolderForSourceFolder(File file) { final IPath filePath = Path.fromOSString(file.getAbsolutePath()); for (final String rawPath : this.candidates) { final IPath path = Path.fromPortableString(rawPath); IPath parent = null; IPath fp = (IPath) filePath.clone(); while (fp != null) { if (path.isPrefixOf(fp)) { if (parent == null) { return file.getParentFile(); } return parent.toFile(); } if (parent == null) { parent = Path.fromPortableString("/" + fp.segment(0)); //$NON-NLS-1$ } else { parent = parent.append(fp.segment(0)); } if (fp.segmentCount() > 1) { fp = fp.removeFirstSegments(1); } else { fp = null; } } } return null; }
private void addWebappAttr(ILaunchConfiguration configuration, List<String> runtimeVmArgs, String cfgAttr) throws CoreException { IJavaProject proj = this.getJavaProject(configuration); if (proj == null) return; String value = configuration.getAttribute(cfgAttr, ""); if ("/".equals(value)) { IPath path = (IPath) proj.getResource().getLocation().clone(); path.makeAbsolute(); value = path.toOSString(); } else { if (proj.getProject().getFolder(value).getLocation() == null) { throw new IllegalStateException( "raw location shouldn't be null"); } value = proj.getProject().getFolder(value).getLocation() .toOSString(); } if (value.length() == 0) return; String arg = "-Drjr" + "webapp" + "=" + value + ""; runtimeVmArgs.add(arg); return; }
IPath initPath = (IPath) path.clone();