Codota Logo
IPath.makeRelativeTo
Code IndexAdd Codota to your IDE (free)

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

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

  • Common ways to obtain IPath
private void myMethod () {
IPath i =
  • Codota IconString fullPath;new Path(fullPath)
  • Codota IconIResource resource;resource.getLocation()
  • Codota IconIResource resource;resource.getFullPath()
  • Smart code suggestions by Codota
}
origin: stackoverflow.com

 IPath path = new Path(violation.getSourceFile().getAbsolutePath());
IPath workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
path = path.makeRelativeTo(workspacePath);
IFile toOpen = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

  @Override
  public String getText(Object element) {
    IPath rootLocation = new Path(job.getRoot().getAbsolutePath());
    IPath projectLocation = ((Entry<IPath, Exception>)element).getKey();
    return projectLocation.makeRelativeTo(rootLocation).toString();
  }
});
origin: org.eclipse.equinox.frameworkadmin/equinox

public static String makeRelative(String original, String rootPath) {
  IPath path = new Path(original);
  // ensure we have an absolute path to start with
  if (!path.isAbsolute())
    return original;
  //Returns the original string if no relativization has been done
  IPath result = path.makeRelativeTo(new Path(rootPath));
  return path.equals(result) ? original : result.toString();
}
origin: org.eclipse.platform/org.eclipse.equinox.frameworkadmin.equinox

public static String makeRelative(String original, String rootPath) {
  IPath path = new Path(original);
  // ensure we have an absolute path to start with
  if (!path.isAbsolute())
    return original;
  //Returns the original string if no relativization has been done
  IPath result = path.makeRelativeTo(new Path(rootPath));
  return path.equals(result) ? original : result.toString();
}
origin: eclipse/buildship

/**
 * Calculates the relative path from a base to a target path.
 *
 * @param base the base path to make the target path relative to
 * @param target the target file to which the relative path is calculated
 * @return the relative path from the base to the target location
 * @throws NullPointerException if an argument is {@code null}
 * @throws IllegalArgumentException if an argument does not denote an absolute path
 */
public static IPath getRelativePath(IPath base, IPath target) {
  Preconditions.checkNotNull(base);
  Preconditions.checkNotNull(target);
  Preconditions.checkArgument(base.isAbsolute());
  Preconditions.checkArgument(target.isAbsolute());
  return target.makeRelativeTo(base);
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.pde.core

/**
 * Returns the generated value of this entry for the build.properties file.
 *
 * @return value to enter into build.properties
 */
String getValue() {
  StringBuffer buf = new StringBuffer();
  IContainer root = PDEProject.getBundleRoot(fResource.getProject());
  buf.append(fResource.getFullPath().makeRelativeTo(root.getFullPath()).makeAbsolute());
  buf.append('[');
  buf.append(fEncoding);
  buf.append(']');
  return buf.toString();
}
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.tycho/org.eclipse.tycho.p2.resolver.impl

  private void addFileIfMatch(File file, FileToPathMap result, IPath baseDir, IPath destination) {
    IPath relativePath = Path.fromOSString(file.getAbsolutePath()).makeRelativeTo(baseDir);
    IPath destinationPath = destination.append(relativePath);
    if (matches(relativePath)) {
      result.put(file, destinationPath);
    }
  }
}
origin: jbosstools/m2e-wro4j

private IPath getReplacementPath(File originalFolder, IFolder webResourcesFolder, IPath defaultOutputPathPrefix)
  throws IOException {
 IPath originalDestinationFolderPath = Path.fromOSString(originalFolder.getCanonicalPath());
 
 if (!defaultOutputPathPrefix.isPrefixOf(originalDestinationFolderPath)) {
  return null;
 }
 
 IPath relativePath = originalDestinationFolderPath.makeRelativeTo(defaultOutputPathPrefix);
 IPath customPath = webResourcesFolder.getLocation().append(relativePath);
 return customPath;
}
origin: liferay/liferay-ide

@Override
public boolean visit(IResourceProxy resourceProxy) {
  String proxyName = resourceProxy.getName();
  if ((resourceProxy.getType() != IResource.FILE) || !proxyName.endsWith(PROPERTIES_FILE_SUFFIX)) {
    return true;
  }
  IResource resource = resourceProxy.requestResource();
  if (FileUtil.notExists(resource)) {
    return true;
  }
  IPath resourcePath = resource.getLocation();
  IPath path = resourcePath.makeRelativeTo(_entryResource.getLocation());
  String pathString = path.toString();
  String relativePath = pathString.replace(PROPERTIES_FILE_SUFFIX, "");
  try {
    if (relativePath.matches(_matchedRelativePath)) {
      _resources.add((IFile)resource);
    }
  }
  catch (Exception e) {
    // in case something is wrong when doing match regular expression
    return true;
  }
  return true;
}
origin: xzer/run-jetty-run

private String getLinkedResourceInResource(IContainer root,
    IContainer folder) {
  StringBuffer sb = new StringBuffer();
  try {
    for (IResource ir : folder.members()) {
      if (ir instanceof IFolder) {
        if (ir.isLinked()) {
          sb.append(ir.getProjectRelativePath().makeRelativeTo(
              root.getProjectRelativePath())
              + "=" + ir.getLocation() + ";");
        }
        sb.append(getLinkedResourceInResource(root, (IFolder) ir));
      }
    }
  } catch (CoreException e) {
    e.printStackTrace();
  }
  return sb.toString();
}
origin: io.sarl/io.sarl.eclipse

private static String makeRelativePath(IPath pathToConvert, IPath jarPath, IPath rootPath) {
  if (pathToConvert == null) {
    return null;
  }
  if (!jarPath.equals(pathToConvert) && rootPath.isPrefixOf(pathToConvert)) {
    return pathToConvert.makeRelativeTo(rootPath).toPortableString();
  }
  return pathToConvert.toPortableString();
}
origin: org.apache.uima/ruta-ep-ide-ui

private IFolder getScriptFolderOf(IScriptFolder scriptFolder, IScriptProject scriptProject)
    throws CoreException {
 List<IFolder> scriptFolders = RutaProjectUtils.getScriptFolders(scriptProject);
 for (IFolder each : scriptFolders) {
  if (each.equals(scriptFolder.getResource())) {
   return each;
  }
  IPath path = scriptFolder.getPath().makeRelativeTo(each.getFullPath());
  IResource findMember = each.findMember(path);
  if (findMember != null && findMember instanceof IFolder) {
   return each;
  }
 }
 return null;
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.pde.core

private static void addPath(ArrayList<IPath> result, IProject project, IPath path) {
  IPath resultPath = null;
  if (path.isAbsolute())
    resultPath = path;
  else if (path.segmentCount() > 0 && path.segment(0).equals(project.getName())) {
    IContainer bundleRoot = PDEProject.getBundleRoot(project);
    IPath rootPath = bundleRoot.getFullPath();
    // make path relative to bundle root
    path = path.makeRelativeTo(rootPath);
    if (path.segmentCount() == 0)
      resultPath = new Path(DOT);
    else {
      IResource resource = bundleRoot.findMember(path);
      if (resource != null)
        resultPath = path;
    }
  }
  if (resultPath != null && !result.contains(resultPath))
    result.add(resultPath);
}
origin: eclipse/eclipse.jdt.ls

private static IPath getWorkspacePath(IPath path) {
  PreferenceManager manager = JavaLanguageServerPlugin.getPreferencesManager();
  Collection<IPath> rootPaths = manager.getPreferences().getRootPaths();
  if (rootPaths != null) {
    for (IPath rootPath : rootPaths) {
      if (rootPath.isPrefixOf(path)) {
        return path.makeRelativeTo(rootPath.append(".."));
      }
    }
  }
  return path;
}
origin: eclipse/eclipse.jdt.ls

    parentSrcPaths.add(entry.getPath());
  } else if (sourcePath.isPrefixOf(entry.getPath())) {
    exclusionPatterns.add(entry.getPath().makeRelativeTo(sourcePath).addTrailingSeparator());
for (IPath exclusion : exclusionPaths) {
  if (sourcePath.isPrefixOf(exclusion) && !sourcePath.equals(exclusion)) {
    exclusionPatterns.add(exclusion.makeRelativeTo(sourcePath).addTrailingSeparator());
origin: org.apache.uima/ruta-ep-ide-ui

IPath relativeTo = path.makeRelativeTo(fullPath);
if (!relativeTo.isEmpty()) {
 sb.append("PACKAGE ");
origin: org.eclipse.pde/org.eclipse.pde.ui

  @Override
  protected void handleBuildCheckStateChange(boolean wasTopParentChecked) {
    IResource resource = fParentResource;
    String resourceName = fParentResource.getProjectRelativePath().makeRelativeTo(fBundleRoot.getProjectRelativePath()).toPortableString();
    IBuild build = fBuildModel.getBuild();
    IBuildEntry includes = build.getEntry(IBuildPropertiesConstants.PROPERTY_SRC_INCLUDES);
    IBuildEntry excludes = build.getEntry(IBuildPropertiesConstants.PROPERTY_SRC_EXCLUDES);

    resourceName = handleResourceFolder(resource, resourceName);

    if (isChecked)
      handleCheck(includes, excludes, resourceName, resource, wasTopParentChecked, IBuildPropertiesConstants.PROPERTY_SRC_INCLUDES);
    else
      handleUncheck(includes, excludes, resourceName, resource, IBuildPropertiesConstants.PROPERTY_SRC_EXCLUDES);

    deleteEmptyEntries();
  }
}
origin: org.eclipse.pde/org.eclipse.pde.ui

@Override
protected void handleBuildCheckStateChange(boolean wasTopParentChecked) {
  IResource resource = fParentResource;
  String resourceName = fParentResource.getProjectRelativePath().makeRelativeTo(fBundleRoot.getProjectRelativePath()).toPortableString();
  IBuild build = fBuildModel.getBuild();
  IBuildEntry includes = build.getEntry(IBuildPropertiesConstants.PROPERTY_BIN_INCLUDES);
  IBuildEntry excludes = build.getEntry(IBuildPropertiesConstants.PROPERTY_BIN_EXCLUDES);
  resourceName = handleResourceFolder(resource, resourceName);
  if (isChecked)
    handleCheck(includes, excludes, resourceName, resource, wasTopParentChecked, IBuildPropertiesConstants.PROPERTY_BIN_INCLUDES);
  else
    handleUncheck(includes, excludes, resourceName, resource, IBuildPropertiesConstants.PROPERTY_BIN_EXCLUDES);
  deleteEmptyEntries();
  fParentResource = fOriginalResource = null;
}
origin: cloudfoundry-attic/eclipse-integration-cloudfoundry

protected boolean containsDebugFiles(IJavaProject project) {
  try {
    IClasspathEntry[] entries = project.getResolvedClasspath(true);
    if (entries != null) {
      for (IClasspathEntry entry : entries) {
        if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
          IPath projectPath = project.getPath();
          IPath relativePath = entry.getPath().makeRelativeTo(projectPath);
          IFolder folder = project.getProject().getFolder(relativePath);
          if (getFile(folder, ".profile.d", "ngrok.sh") != null) {//$NON-NLS-1$ //$NON-NLS-2$
            return true;
          }
        }
      }
    }
  }
  catch (JavaModelException e) {
    CloudFoundryPlugin.logError(e);
  }
  catch (CoreException ce) {
    CloudFoundryPlugin.logError(ce);
  }
  return false;
}
org.eclipse.core.runtimeIPathmakeRelativeTo

Javadoc

Returns a path equivalent to this path, but relative to the given base path if possible.

The path is only made relative if the base path if both paths have the same device and have a non-zero length common prefix. If the paths have different devices, or no common prefix, then this path is simply returned. If the path is successfully made relative, then appending the returned path to the base will always produce a path equal to this path.

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

  • Reading from database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • requestLocationUpdates (LocationManager)
  • getContentResolver (Context)
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Set (java.util)
    A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now