/* * (non-Javadoc) * * @see net.kbserve.pyjdt.properties.models.ICPEType#getRealPath(org.eclipse. core.resources.IProject) */ @Override public String getRealPath(IProject project) { if (getPath().length() > 0) { Path internalPath = new Path(getPath()); IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(internalPath); if (workspaceResource == null) { try { workspaceResource = ResourcesPlugin.getWorkspace().getRoot().getFile(internalPath); } catch (IllegalArgumentException e) { workspaceResource = ResourcesPlugin.getWorkspace().getRoot().getFolder(internalPath); } } IPath rawLocation = workspaceResource.getLocation(); if (rawLocation != null) { return rawLocation.toOSString(); } // not a workspace path return internalPath.toOSString(); } return getPath(); }
private static boolean fileMatches( IProject project, String filePath, XmlMatchingStrategySupport matcher) { boolean matches = false; if (filePath != null && filePath.trim().length() > 0) { String rawPath = null; if (filePath.startsWith("file:")) { // $NON-NLS-1$ rawPath = filePath.substring(5); } else { IPath wholePath = project.getLocation().append(filePath); rawPath = wholePath.toPortableString(); } Path fp = new Path(rawPath); File nf = new File(fp.toOSString()); if (nf.exists() && nf.isFile()) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IPath location = Path.fromOSString(nf.getAbsolutePath()); IFile file = workspace.getRoot().getFileForLocation(location); matches = matcher.matches(file); } } return matches; }