Java Code Examples for org.eclipse.core.runtime.IPath#removeTrailingSeparator()
The following examples show how to use
org.eclipse.core.runtime.IPath#removeTrailingSeparator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HostedSiteServlet.java From orion.server with Eclipse Public License 1.0 | 6 votes |
/** * Returns paths constructed by rewriting pathInfo using rules from the hosted site's mappings. * Paths are ordered from most to least specific match. * @param site The hosted site. * @param pathInfo Path to be rewritten. * @param queryString * @return The rewritten path. May be either:<ul> * <li>A path to a file in the Orion workspace, eg. <code>/ProjectA/foo/bar.txt</code></li> * <li>An absolute URL pointing to another site, eg. <code>http://foo.com/bar.txt</code></li> * </ul> * @return The rewritten paths. * @throws URISyntaxException */ private URI[] getMapped(IHostedSite site, IPath pathInfo, String queryString) throws URISyntaxException { final Map<String, List<String>> map = site.getMappings(); final IPath originalPath = pathInfo; IPath path = originalPath.removeTrailingSeparator(); List<URI> uris = new ArrayList<URI>(); String rest = null; final int count = path.segmentCount(); for (int i = 0; i <= count; i++) { List<String> base = map.get(path.toString()); if (base != null) { rest = originalPath.removeFirstSegments(count - i).toString(); for (int j = 0; j < base.size(); j++) { URI uri = (rest.equals("") || rest.equals("/")) ? new URI(base.get(j)) : URIUtil.append(new URI(base.get(j)), rest); uris.add(createUri(uri, queryString)); } } path = path.removeLastSegments(1); } if (uris.size() == 0) // No mapping for / return null; else return uris.toArray(new URI[uris.size()]); }
Example 2
Source File: StandardSREPage.java From sarl with Apache License 2.0 | 6 votes |
/** * Initialize the dialogs fields. */ private void initializeFields() { final IPath path = this.workingCopy.getJarFile(); String tooltip = null; String basename = null; if (path != null) { tooltip = path.toOSString(); final IPath tmpPath = path.removeTrailingSeparator(); if (tmpPath != null) { basename = tmpPath.lastSegment(); } } this.sreLibraryTextField.setText(Strings.nullToEmpty(basename)); this.sreLibraryTextField.setToolTipText(Strings.nullToEmpty(tooltip)); // final String name = this.workingCopy.getNameNoDefault(); this.sreNameTextField.setText(Strings.nullToEmpty(name)); // final String mainClass = this.workingCopy.getMainClass(); this.sreMainClassTextField.setText(Strings.nullToEmpty(mainClass)); // this.sreIdTextField.setText(this.workingCopy.getId()); }
Example 3
Source File: InvisibleProjectImporter.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static boolean isPartOfMatureProject(IPath sourcePath) { sourcePath = sourcePath.removeTrailingSeparator(); List<String> segments = Arrays.asList(sourcePath.segments()); int index = segments.lastIndexOf("src"); if (index <= 0) { return false; } IPath srcPath = sourcePath.removeLastSegments(segments.size() -1 - index); IPath container = srcPath.removeLastSegments(1); return container.append("pom.xml").toFile().exists() || container.append("build.gradle").toFile().exists(); }
Example 4
Source File: ImportTraceWizardPage.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static String getSourceDirectoryName(String sourceName) { IPath result = new Path(sourceName.trim()); if (result.getDevice() != null && result.segmentCount() == 0) { result = result.addTrailingSeparator(); } else { result = result.removeTrailingSeparator(); } return result.toOSString(); }
Example 5
Source File: CPListElement.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static CPListElement create(Object parent, IClasspathEntry curr, boolean newElement, IJavaProject project) { IPath path= curr.getPath(); IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); // get the resource IResource res= null; boolean isMissing= false; IPath linkTarget= null; switch (curr.getEntryKind()) { case IClasspathEntry.CPE_CONTAINER: try { isMissing= project != null && (JavaCore.getClasspathContainer(path, project) == null); } catch (JavaModelException e) { isMissing= true; } break; case IClasspathEntry.CPE_VARIABLE: IPath resolvedPath= JavaCore.getResolvedVariablePath(path); isMissing= root.findMember(resolvedPath) == null && !resolvedPath.toFile().exists(); break; case IClasspathEntry.CPE_LIBRARY: res= root.findMember(path); if (res == null) { if (!ArchiveFileFilter.isArchivePath(path, true)) { if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK() && root.getProject(path.segment(0)).exists()) { res= root.getFolder(path); } } IPath rawPath= path; if (project != null) { IPackageFragmentRoot[] roots= project.findPackageFragmentRoots(curr); if (roots.length == 1) rawPath= roots[0].getPath(); } isMissing= !rawPath.toFile().exists(); // look for external JARs and folders } else if (res.isLinked()) { linkTarget= res.getLocation(); } break; case IClasspathEntry.CPE_SOURCE: path= path.removeTrailingSeparator(); res= root.findMember(path); if (res == null) { if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) { res= root.getFolder(path); } isMissing= true; } else if (res.isLinked()) { linkTarget= res.getLocation(); } break; case IClasspathEntry.CPE_PROJECT: res= root.findMember(path); isMissing= (res == null); break; } CPListElement elem= new CPListElement(parent, project, curr.getEntryKind(), path, newElement, res, linkTarget); elem.setExported(curr.isExported()); elem.setAttribute(SOURCEATTACHMENT, curr.getSourceAttachmentPath()); elem.setAttribute(OUTPUT, curr.getOutputLocation()); elem.setAttribute(EXCLUSION, curr.getExclusionPatterns()); elem.setAttribute(INCLUSION, curr.getInclusionPatterns()); elem.setAttribute(ACCESSRULES, curr.getAccessRules()); elem.setAttribute(COMBINE_ACCESSRULES, new Boolean(curr.combineAccessRules())); IClasspathAttribute[] extraAttributes= curr.getExtraAttributes(); for (int i= 0; i < extraAttributes.length; i++) { IClasspathAttribute attrib= extraAttributes[i]; CPListElementAttribute attribElem= elem.findAttributeElement(attrib.getName()); if (attribElem == null) { elem.createAttributeElement(attrib.getName(), attrib.getValue(), false); } else { attribElem.setValue(attrib.getValue()); } } elem.setIsMissing(isMissing); return elem; }