private String relativePath(IPath path) { return path.removeFirstSegments(1).toPortableString(); } }
@Override public IPath computePath(File source) { IPath result = new Path(source.getAbsolutePath()); IPath rootPath = new Path(root.getAbsolutePath()); result = result.removeFirstSegments(rootPath.matchingFirstSegments(result)); return result.setDevice(null); }
public IPath computePath(File source) { IPath sourcePath = new Path(source.getAbsolutePath()); sourcePath = sourcePath.removeFirstSegments(Math.max(0, sourcePath.segmentCount() - segmentsToKeep)); return sourcePath.setDevice(null); }
@Override public boolean visit(IResourceProxy proxy) throws CoreException { if (proxy.getType() == IResource.FOLDER) { String path = proxy.requestFullPath().removeFirstSegments(this.segmentcount).toString(); return this.collector.add(path.replace(IPath.SEPARATOR, '.')); } return false; } }
@Override public IPath computePath(File source) { IPath sourcePath = new Path(source.getAbsolutePath()); sourcePath = sourcePath.removeFirstSegments(Math.max(0, sourcePath.segmentCount() - segmentsToKeep)); return sourcePath.setDevice(null); }
@Override public IPath getProjectRelativePath() { IPath full = getFullPath(); int count = full.segmentCount(); if (count < 0) return null; if (count <= 1) // 0 or 1 return Path.EMPTY; return full.removeFirstSegments(1); }
/** * Creates and returns the string that should be used as the name of the entry in the archive. * @param exportResource the resource to export * @param leadupDepth the number of resource levels to be included in the path including the resourse itself. */ private String createDestinationName(int leadupDepth, IResource exportResource) { IPath fullPath = exportResource.getFullPath(); if (createLeadupStructure) { return fullPath.makeRelative().toString(); } return fullPath.removeFirstSegments(fullPath.segmentCount() - leadupDepth).makeRelative().toString(); }
@Override public int visit(Entry sourceEntry) { IPath destinationPath = destination.append(sourceEntry.getPath().removeFirstSegments(source.segmentCount())); HistoryEntry destinationEntry = new HistoryEntry(destinationPath, (HistoryEntry) sourceEntry); // we may be copying to the same source bucket, collect to make change effective later // since we cannot make changes to it while iterating changes.add(destinationEntry); return CONTINUE; } }
@Override public int visit(Entry entry) { PropertyEntry sourceEntry = (PropertyEntry) entry; IPath destinationPath = destination.append(sourceEntry.getPath().removeFirstSegments(source.segmentCount())); PropertyEntry destinationEntry = new PropertyEntry(destinationPath, sourceEntry); changes.add(destinationEntry); return CONTINUE; } }
private IPath getResolvedPath(IPath path) { if (path != null) { String varName= path.segment(0); if (varName != null) { IPath varPath= JavaCore.getClasspathVariable(varName); if (varPath != null) { return varPath.append(path.removeFirstSegments(1)); } } } return null; }
@Override public int visit(Entry entry) { PropertyEntry sourceEntry = (PropertyEntry) entry; IPath destinationPath = destination.append(sourceEntry.getPath().removeFirstSegments(source.segmentCount())); PropertyEntry destinationEntry = new PropertyEntry(destinationPath, sourceEntry); changes.add(destinationEntry); return CONTINUE; } }
private IPath getFolderPath(IPath packPath, IPath relpath) { int remainingSegments= packPath.segmentCount() - relpath.segmentCount(); if (remainingSegments >= 0) { IPath common= packPath.removeFirstSegments(remainingSegments); if (common.equals(relpath)) { return packPath.uptoSegment(remainingSegments); } } return null; }
/** * @see org.eclipse.core.resources.IPathVariableManager#resolvePath(IPath) */ @Deprecated @Override public IPath resolvePath(IPath path) { if (path == null || path.segmentCount() == 0 || path.isAbsolute() || path.getDevice() != null) return path; IPath value = getValue(path.segment(0)); return value == null ? path : value.append(path.removeFirstSegments(1)); }
private static boolean addToExclusions(IPath entryPath, CPListElement curr) { IPath[] exclusionFilters= (IPath[]) curr.getAttribute(CPListElement.EXCLUSION); if (!JavaModelUtil.isExcludedPath(entryPath, exclusionFilters)) { IPath pathToExclude= entryPath.removeFirstSegments(curr.getPath().segmentCount()).addTrailingSeparator(); IPath[] newExclusionFilters= new IPath[exclusionFilters.length + 1]; System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length); newExclusionFilters[exclusionFilters.length]= pathToExclude; curr.setAttribute(CPListElement.EXCLUSION, newExclusionFilters); return true; } return false; }
private static boolean addToExclusions(IPath entryPath, CPListElement curr) { IPath[] exclusionFilters= (IPath[]) curr.getAttribute(CPListElement.EXCLUSION); if (!JavaModelUtil.isExcludedPath(entryPath, exclusionFilters)) { IPath pathToExclude= entryPath.removeFirstSegments(curr.getPath().segmentCount()).addTrailingSeparator(); IPath[] newExclusionFilters= new IPath[exclusionFilters.length + 1]; System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length); newExclusionFilters[exclusionFilters.length]= pathToExclude; curr.setAttribute(CPListElement.EXCLUSION, newExclusionFilters); return true; } return false; }
private String getVariableString(IPath path) { String name= path.makeRelative().toString(); IPath entryPath= JavaCore.getClasspathVariable(path.segment(0)); if (entryPath != null) { String appended= entryPath.append(path.removeFirstSegments(1)).toOSString(); return Messages.format(NewWizardMessages.CPListLabelProvider_twopart, new String[] { name, appended }); } else { return name; } }
protected boolean copy(UnifiedTreeNode node) { Resource source = (Resource) node.getResource(); IPath sufix = source.getFullPath().removeFirstSegments(segmentsToDrop); Resource destination = getDestinationResource(source, sufix); if (!copyProperties(source, destination)) return false; return copyContents(node, source, destination); }
private IResource getUnderlyingDirectory(EclipseSourceDirectory directory) { IProject project = this.project.getProject(); IPath path = project.getFullPath().append(directory.getPath()); if (path.segmentCount() == 1) { return project; } return project.getFolder(path.removeFirstSegments(1)); }
public static boolean openSchema(IPath path) { String pluginId = path.segment(0); IPluginModelBase model = PluginRegistry.findModel(pluginId); if (model != null && model.getUnderlyingResource() != null) { IProject project = model.getUnderlyingResource().getProject(); IFile file = project.getFile(path.removeFirstSegments(1)); return openSchema(file); } return false; }
private IPath getDiffPath(IFile file) { DiffProject project = getDiffProject(file.getProject()); if (project != null) { return file.getProjectRelativePath(); } return file.getFullPath().removeFirstSegments(getTarget().getFullPath().segmentCount()); }