Tabnine Logo
IPath.matchingFirstSegments
Code IndexAdd Tabnine to your IDE (free)

How to use
matchingFirstSegments
method
in
org.eclipse.core.runtime.IPath

Best Java code snippets using org.eclipse.core.runtime.IPath.matchingFirstSegments (Showing top 20 results out of 315)

origin: org.eclipse/org.eclipse.jdt.ui

/**
 * 
 * @param path1 the first path
 * @param path2 the second path
 * @return <code>true</code> if path1 is a subfolder of 
 * path2, <code>false</code> otherwise
 */
private boolean isSubFolderOf(IPath path1, IPath path2) {
  if (path1 == null || path2 == null) {
    if (path1 == null && path2 == null)
      return true;
    return false;
  }
  return path2.matchingFirstSegments(path1) == path2.segmentCount();
}
origin: org.eclipse.jdt/org.eclipse.jdt.ui

/**
 *
 * @param path1 the first path
 * @param path2 the second path
 * @return <code>true</code> if path1 is a subfolder of
 * path2, <code>false</code> otherwise
 */
private boolean isSubFolderOf(IPath path1, IPath path2) {
  if (path1 == null || path2 == null) {
    if (path1 == null && path2 == null)
      return true;
    return false;
  }
  return path2.matchingFirstSegments(path1) == path2.segmentCount();
}
origin: org.eclipse.platform/org.eclipse.equinox.p2.core

@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);
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

/**
 *
 * @param path1 the first path
 * @param path2 the second path
 * @return <code>true</code> if path1 is a subfolder of
 * path2, <code>false</code> otherwise
 */
private boolean isSubFolderOf(IPath path1, IPath path2) {
  if (path1 == null || path2 == null) {
    if (path1 == null && path2 == null)
      return true;
    return false;
  }
  return path2.matchingFirstSegments(path1) == path2.segmentCount();
}
origin: org.eclipse.egit/ui

  public void handleEvent(Event e) {
    if (repositoryToCreate.getText().equals("")) { //$NON-NLS-1$
      createRepo.setEnabled(false);
      return;
    }
    IPath fromOSString = Path.fromOSString(repositoryToCreate
        .getText());
    createRepo.setEnabled(minumumPath
        .matchingFirstSegments(fromOSString) == fromOSString
        .segmentCount());
  }
});
origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.core

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);
}
origin: org.eclipse.equinox.p2/core

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);
}
origin: org.eclipse.platform/org.eclipse.equinox.p2.publisher.eclipse

@Override
public IPath computePath(File source) {
  String prefix = filesMap.get(source);
  IPath result = null;
  if (prefix.startsWith(PROVIDED_PATH)) {
    // the desired path is provided in the map
    result = new Path(prefix.substring(10));
  } else {
    //else the map contains a prefix which must be stripped from the path
    result = new Path(source.getAbsolutePath());
    IPath rootPath = new Path(prefix);
    result = result.removeFirstSegments(rootPath.matchingFirstSegments(result));
  }
  return result.setDevice(null);
}
origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.core

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);
}
origin: org.eclipse.osgi/org.eclipse.equinox.p2.publisher.eclipse

public IPath computePath(File source) {
  String prefix = filesMap.get(source);
  IPath result = null;
  if (prefix.startsWith(PROVIDED_PATH)) {
    // the desired path is provided in the map
    result = new Path(prefix.substring(10));
  } else {
    //else the map contains a prefix which must be stripped from the path
    result = new Path(source.getAbsolutePath());
    IPath rootPath = new Path(prefix);
    result = result.removeFirstSegments(rootPath.matchingFirstSegments(result));
  }
  return result.setDevice(null);
}
origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.publisher.eclipse

public IPath computePath(File source) {
  String prefix = filesMap.get(source);
  IPath result = null;
  if (prefix.startsWith(PROVIDED_PATH)) {
    // the desired path is provided in the map
    result = new Path(prefix.substring(10));
  } else {
    //else the map contains a prefix which must be stripped from the path
    result = new Path(source.getAbsolutePath());
    IPath rootPath = new Path(prefix);
    result = result.removeFirstSegments(rootPath.matchingFirstSegments(result));
  }
  return result.setDevice(null);
}
origin: org.eclipse/org.eclipse.jem.util

protected IFile getFileForMatchingPath(IPath containerPath, IPath sourcePath, IContainer container) {
  int matches = 0;
  matches = containerPath.matchingFirstSegments(sourcePath);
  if (matches > 0 && matches == sourcePath.segmentCount()) {
    IPath loadPath = containerPath.removeFirstSegments(matches);
    return primGetFile(container, loadPath);
  }
  return null;
}
origin: FeatureIDE/FeatureIDE

protected FileListener(AFileManager<T> fileManager) {
  this.fileManager = fileManager;
  IPath absolutePath2 = new org.eclipse.core.runtime.Path(fileManager.getAbsolutePath());
  final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
  final IPath rootLocation = root.getLocation();
  if (absolutePath2.matchingFirstSegments(rootLocation) != rootLocation.segmentCount()) {
    try {
      final IFile[] filesOfLocation = root.findFilesForLocationURI(URI.create("file:/" + absolutePath2.toString().replace(" ", "%20")));
      absolutePath2 = filesOfLocation[0].getFullPath().makeRelativeTo(rootLocation);
    } catch (final IndexOutOfBoundsException e) {
      Logger.logError(e);
      eclipseFile = null;
      return;
    }
  }
  this.eclipseFile = absolutePath2.makeRelativeTo(rootLocation);
}
origin: org.eclipse.platform/org.eclipse.update.configurator

/**
 * Returns a path which is equivalent to the given location relative to the
 * specified base path.
 */
public static IPath makeRelative(IPath base, IPath location) {
  if (location.getDevice() != null && !location.getDevice().equalsIgnoreCase(base.getDevice()))
    return location;
  int baseCount = base.segmentCount();
  int count = base.matchingFirstSegments(location);
  String temp = ""; //$NON-NLS-1$
  for (int j = 0; j < baseCount - count; j++)
    temp += "../"; //$NON-NLS-1$
  return new Path(temp).append(location.removeFirstSegments(count));
}
origin: org.eclipse/org.eclipse.pde.core

  private void addExtraLibrary(IPath path, IPluginModelBase model, ArrayList entries) throws CoreException {
    IPath srcPath = null;
    if (model != null) {
      IPath shortPath = path.removeFirstSegments(path.matchingFirstSegments(new Path(model.getInstallLocation())));
      srcPath = ClasspathUtilCore.getSourceAnnotation(model, shortPath.toString());
    } else {
      String filename = ClasspathUtilCore.getSourceZipName(path.lastSegment());
      IPath candidate = path.removeLastSegments(1).append(filename);
      if (PDECore.getWorkspace().getRoot().getFile(candidate).exists()) 
        srcPath = candidate;
    }
    IClasspathEntry clsEntry = JavaCore.newLibraryEntry(
        path,
        srcPath,
        null);
    if (!entries.contains(clsEntry))
      entries.add(clsEntry);                        
  }
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.pde.core

private IPath getPath(Object entry) {
  IPath path = null;
  if (entry instanceof IClasspathEntry) {
    IClasspathEntry cpes = (IClasspathEntry) entry;
    path = cpes.getPath();
  } else if (entry instanceof IPath) {
    path = (IPath) entry;
  }
  if (path != null && path.matchingFirstSegments(fProject.getFullPath()) > 0) {
    path = path.removeFirstSegments(1);
  }
  if (path != null) {
    return path.addTrailingSeparator();
  }
  return null;
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.pde.core

  private void addExtraLibrary(IPath path, IPluginModelBase model, ArrayList<IClasspathEntry> entries) {
    if (path.segmentCount() > 1) {
      IPath srcPath = null;
      if (model != null) {
        IPath shortPath = path.removeFirstSegments(path.matchingFirstSegments(new Path(model.getInstallLocation())));
        srcPath = ClasspathUtilCore.getSourceAnnotation(model, shortPath.toString());
      } else {
        String filename = ClasspathUtilCore.getSourceZipName(path.lastSegment());
        IPath candidate = path.removeLastSegments(1).append(filename);
        if (PDECore.getWorkspace().getRoot().getFile(candidate).exists())
          srcPath = candidate;
      }
      IClasspathEntry clsEntry = JavaCore.newLibraryEntry(path, srcPath, null);
      if (!entries.contains(clsEntry))
        entries.add(clsEntry);
    }
  }
}
origin: org.eclipse/org.eclipse.jdt.ui

private void updateClasspath(IPath newPath, IProgressMonitor monitor) throws JavaModelException {
  IClasspathEntry[] classpath= fProject.getRawClasspath();
  IPath jreContainerPath= new Path(JavaRuntime.JRE_CONTAINER);
  for (int i= 0; i < classpath.length; i++) {
    IClasspathEntry curr= classpath[i];
    if (curr.getEntryKind() == IClasspathEntry.CPE_CONTAINER && curr.getPath().matchingFirstSegments(jreContainerPath) > 0) {
      classpath[i]= JavaCore.newContainerEntry(newPath, curr.getAccessRules(), curr.getExtraAttributes(), curr.isExported());
    }
  }
  fProject.setRawClasspath(classpath, monitor);
}

origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

private boolean updateClasspath(IPath newPath, IProgressMonitor monitor) throws JavaModelException {
  boolean updated= false;
  
  IClasspathEntry[] classpath= fProject.getRawClasspath();
  IPath jreContainerPath= new Path(JavaRuntime.JRE_CONTAINER);
  for (int i= 0; i < classpath.length; i++) {
    IClasspathEntry curr= classpath[i];
    if (curr.getEntryKind() == IClasspathEntry.CPE_CONTAINER && curr.getPath().matchingFirstSegments(jreContainerPath) > 0) {
      if (! newPath.equals(curr.getPath())) {
        updated= true;
        classpath[i]= JavaCore.newContainerEntry(newPath, curr.getAccessRules(), curr.getExtraAttributes(), curr.isExported());
      }
    }
  }
  if (updated) {
    fProject.setRawClasspath(classpath, monitor);
  }
  return updated;
}
origin: org.eclipse.jdt/org.eclipse.jdt.ui

  public static boolean updateClasspath(IPath newPath, IJavaProject project, IProgressMonitor monitor) throws JavaModelException {
    boolean updated= false;

    IClasspathEntry[] classpath= project.getRawClasspath();
    IPath jreContainerPath= new Path(JavaRuntime.JRE_CONTAINER);
    for (int i= 0; i < classpath.length; i++) {
      IClasspathEntry curr= classpath[i];
      if (curr.getEntryKind() == IClasspathEntry.CPE_CONTAINER && curr.getPath().matchingFirstSegments(jreContainerPath) > 0) {
        if (!newPath.equals(curr.getPath())) {
          updated= true;
          classpath[i]= JavaCore.newContainerEntry(newPath, curr.getAccessRules(), curr.getExtraAttributes(), curr.isExported());
        }
      }
    }
    if (updated) {
      project.setRawClasspath(classpath, monitor);
    }
    return updated;
  }
}
org.eclipse.core.runtimeIPathmatchingFirstSegments

Javadoc

Returns a count of the number of segments which match in this path and the given path (device ids are ignored), comparing in increasing segment number order.

Popular methods of IPath

  • toString
    Returns a string representation of this path, including its device id. The same separator, "/", is u
  • toFile
    Returns a java.io.File corresponding to this path.
  • toOSString
    Returns a string representation of this path which uses the platform-dependent path separator define
  • append
    Returns the canonicalized path obtained from the concatenation of the given path's segments to the e
  • segmentCount
    Returns the number of segments in this path. Note that both root and empty paths have 0 segments.
  • removeLastSegments
    Returns a copy of this path with the given number of segments removed from the end. The device id is
  • lastSegment
    Returns the last segment of this path, ornull if it does not have any segments.
  • removeFirstSegments
    Returns a copy of this path with the given number of segments removed from the beginning. The device
  • segment
    Returns the specified segment of this path, ornull if the path does not have such a segment.
  • equals
    Returns whether this path equals the given object. Equality for paths is defined to be: same sequenc
  • isAbsolute
    Returns whether this path is an absolute path (ignoring any device id). Absolute paths start with a
  • isPrefixOf
    Returns whether this path is a prefix of the given path. To be a prefix, this path's segments must a
  • isAbsolute,
  • isPrefixOf,
  • toPortableString,
  • makeRelative,
  • makeAbsolute,
  • getDevice,
  • isEmpty,
  • addTrailingSeparator,
  • getFileExtension,
  • setDevice

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getApplicationContext (Context)
  • addToBackStack (FragmentTransaction)
  • getResourceAsStream (ClassLoader)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • JPanel (javax.swing)
  • Join (org.hibernate.mapping)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now