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

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

Best Java code snippets using org.eclipse.core.runtime.IPath (Showing top 20 results out of 2,286)

Refine searchRefine arrow

  • IResource
  • Path
  • IProject
  • IWorkspaceRoot
  • IWorkspace
  • IFile
  • ResourcesPlugin
origin: org.eclipse/org.eclipse.jdt.ui

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;
  }
}

origin: org.eclipse.platform/org.eclipse.equinox.frameworkadmin.equinox

public static File fromOSGiJarToOSGiInstallArea(String path) {
  IPath parentFolder = new Path(path).removeLastSegments(1);
  if ("plugins".equalsIgnoreCase(parentFolder.lastSegment())) //$NON-NLS-1$
    return parentFolder.removeLastSegments(1).toFile();
  return parentFolder.toFile();
}
origin: org.eclipse.mylyn.versions/core

public static IResource findResource(String file) {
  IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
  IPath path = new Path(file);
  path.makeRelative();
  while (path.segmentCount() > 1) {
    IResource resource = root.findMember(path);
    if (resource != null) {
      return resource;
    }
    path = path.removeFirstSegments(1);
  }
  return null;
}
origin: org.eclipse.core/runtime

public Properties getProductTranslation() {
  initValues();
  URL transURL = null;
  if (customizationValue != null)
    transURL = FileLocator.find(customizationBundle, NL_DIR.append(customizationValue).removeFileExtension().addFileExtension(PROPERTIES_FILE_EXTENSION), null);
  if (transURL == null && InternalPlatform.DEBUG_PLUGIN_PREFERENCES)
    InternalPlatform.message("No preference translations found for product/file: " + customizationBundle.getSymbolicName() + '/' + customizationValue); //$NON-NLS-1$
  return loadProperties(transURL);
}
origin: org.eclipse.core/runtime

if (!path.toFile().exists()) {
  String msg = NLS.bind(PrefsMessages.preferences_fileNotFound, path.toOSString());
  throw new CoreException(new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, 1, msg, null));
InputStream input = null;
try {
  input = new BufferedInputStream(new FileInputStream(path.toFile()));
  service.importPreferences(input);
} catch (FileNotFoundException e) {
  String msg = NLS.bind(PrefsMessages.preferences_fileNotFound, path.toOSString());
  throw new CoreException(new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, 1, msg, e));
} finally {
origin: org.eclipse.core/runtime

/**
 * Private constructor to enforce singleton usage.
 */
private PerformanceStatsProcessor() {
  super("Performance Stats"); //$NON-NLS-1$
  setSystem(true);
  setPriority(DECORATE);
  BundleContext context = PlatformActivator.getContext();
  String filter = '(' + FrameworkLog.SERVICE_PERFORMANCE + '=' + Boolean.TRUE.toString() + ')';
  Collection<ServiceReference<FrameworkLog>> references;
  FrameworkLog perfLog = null;
  try {
    references = context.getServiceReferences(FrameworkLog.class, filter);
    if (references != null && !references.isEmpty()) {
      //just take the first matching service
      perfLog = context.getService(references.iterator().next());
      //make sure correct location is set
      IPath logLocation = Platform.getLogFileLocation();
      logLocation = logLocation.removeLastSegments(1).append("performance.log"); //$NON-NLS-1$
      perfLog.setFile(logLocation.toFile(), false);
    }
  } catch (Exception e) {
    IStatus error = new Status(IStatus.ERROR, Platform.PI_RUNTIME, 1, "Error loading performance log", e); //$NON-NLS-1$
    InternalPlatform.getDefault().log(error);
  }
  //use the platform log if we couldn't create the performance log
  if (perfLog == null)
    perfLog = InternalPlatform.getDefault().getFrameworkLog();
  log = perfLog;
}
origin: org.eclipse/org.eclipse.jst.jsp.core

private IFile getFile(IStructuredModel model) {
  if (model != null) {
    String location = model.getBaseLocation();
    if (location != null) {
      IPath path = new Path(location);
      if (!path.toFile().exists() && path.segmentCount() > 1) {
        return ResourcesPlugin.getWorkspace().getRoot().getFile(path);
      }
    }
  }
  return null;
}
origin: org.eclipse/org.eclipse.pde.core

private String getExpandedPath(String path) {
  if (path == null || path.length() == 0)
    return null;
  IResource resource = PDECore.getWorkspace().getRoot().findMember(new Path(path));
  if (resource != null) {
    IPath fullPath = resource.getLocation();
    return fullPath == null ? null : fullPath.toOSString();
  }
  return null;
}
origin: sdbg/sdbg

public IFile getMapSource() {
 String name = path.lastSegment();
 if (name.endsWith(SOURCE_MAP_EXT)) {
  name = name.substring(0, name.length() - SOURCE_MAP_EXT.length());
  IPath newPath = path.removeLastSegments(1).append(name);
  IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(newPath);
  if (resource instanceof IFile) {
   return (IFile) resource;
  }
 }
 return null;
}
origin: org.eclipse/org.eclipse.emf.codegen

public String getLocalFile() 
{
 String file = reader.getFile(fileid);
 if (file.startsWith("file:/"))
 {
  IWorkspaceRoot workspaceRoot =  ResourcesPlugin.getWorkspace().getRoot();
  IFile iFile = workspaceRoot.getFileForLocation(new Path(file.substring(6)));
  file = iFile.getFullPath().toString();
 }
 return file;
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

/**
 * Determine if there is a directory with the project name in the workspace path.
 *
 * @param projectName the name of the project
 * @return true if there is a directory with the same name of the imported project
 */
private boolean isProjectInWorkspacePath(String projectName){
  final IWorkspace workspace = ResourcesPlugin.getWorkspace();
  IPath wsPath = workspace.getRoot().getLocation();
  IPath localProjectPath = wsPath.append(projectName);
  return localProjectPath.toFile().exists();
}
origin: org.eclipse.pde/org.eclipse.pde.ui

@Override
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
  IResource resource = getResource();
  if (resource == null || !resource.exists())
    return RefactoringStatus.createFatalErrorStatus(MessageFormat.format(PDEUIMessages.RenameProjectChange_projectDoesNotExist, fResourcePath.toString()));
  if (ResourcesPlugin.getWorkspace().getRoot().getProject(fNewName).exists())
    return RefactoringStatus.createFatalErrorStatus(MessageFormat.format(PDEUIMessages.RenameProjectChange_destinationExists, fNewName));
  return new RefactoringStatus();
}
origin: org.eclipse.platform/org.eclipse.ltk.core.refactoring

private IResource getResource() {
  IResource resource= ResourcesPlugin.getWorkspace().getRoot().findMember(fResourcePath);
  if (resource == null && fResourcePath.segmentCount() == 1) {
    resource= ResourcesPlugin.getWorkspace().getRoot().getProject(fResourcePath.segment(0));
  }
  return resource;
}
origin: org.eclipse.jdt/org.eclipse.jdt.core

/**
 * The path is known to match a source/library folder entry.
 * @param path IPath
 * @return IPackageFragmentRoot
 */
public IPackageFragmentRoot getFolderPackageFragmentRoot(IPath path) {
  if (path.segmentCount() == 1) { // default project root
    return getPackageFragmentRoot(this.project);
  }
  return getPackageFragmentRoot(this.project.getWorkspace().getRoot().getFolder(path));
}
origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

public static boolean isExternalFolderPath(IPath externalPath) {
  if (externalPath == null)
    return false;
  String firstSegment = externalPath.segment(0);
  if (firstSegment != null && ResourcesPlugin.getWorkspace().getRoot().getProject(firstSegment).exists())
    return false;
  File externalFolder = externalPath.toFile();
  if (externalFolder.isFile())
    return false;
  if (externalPath.getFileExtension() != null/*likely a .jar, .zip, .rar or other file*/ && !externalFolder.exists())
    return false;
  return true;
}
origin: org.openl/org.openl.eclipse.ui

static public IResource findWorkspaceResource(IPath path) {
  IWorkspaceRoot ws = ResourcesPlugin.getWorkspace().getRoot();
  IPath wsPath = ws.getLocation();
  if (wsPath.isPrefixOf(path)) {
    path = path.removeFirstSegments(wsPath.segmentCount());
    path = path.setDevice(null);
  }
  return ws.findMember(path);
}
origin: org.eclipse.platform/org.eclipse.team.core

private IResource internalGetResource(IPath fullPath, boolean container) {
  if (container) {
    if (fullPath.segmentCount() == 1)
      return ResourcesPlugin.getWorkspace().getRoot().getProject(fullPath.segment(0));
    return ResourcesPlugin.getWorkspace().getRoot().getFolder(fullPath);
  }
  return ResourcesPlugin.getWorkspace().getRoot().getFile(fullPath);
}
origin: org.eclipse.jdt/org.eclipse.jdt.core

/**
 * @param path full absolute workspace path
 */
private static boolean isInternalContainerPath(IPath path) {
  IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
  // in case this is full workspace path it should start with project segment
  int segmentCount = path.segmentCount();
  if(segmentCount == 1 && wsRoot.getProject(path.segment(0)).exists()) {
    return true;
  }
  if(segmentCount > 1 && wsRoot.getFolder(path).exists()) {
    return true;
  }
  return false;
}
origin: org.eclipse.platform/org.eclipse.core.resources

private IResource createSourceResource(IResourceDelta delta) {
  IPath sourcePath = delta.getMovedFromPath();
  IResource resource = delta.getResource();
  IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
  switch (resource.getType()) {
    case IResource.PROJECT :
      return wsRoot.getProject(sourcePath.segment(0));
    case IResource.FOLDER :
      return wsRoot.getFolder(sourcePath);
    case IResource.FILE :
      return wsRoot.getFile(sourcePath);
  }
  return null;
}
origin: org.eclipse.jdt/org.eclipse.jdt.ui

/**
 * Gets the description file (as workspace resource).
 *
 * @return a file which points to the description
 */
public IFile getDescriptionFile() {
  IPath path= getDescriptionLocation();
  if (path.isValidPath(path.toString()) && path.segmentCount() >= 2)
    return JavaPlugin.getWorkspace().getRoot().getFile(path);
  else
    return null;
}
org.eclipse.core.runtimeIPath

Javadoc

A path is an ordered collection of string segments, separated by a standard separator character, "/". A path may also have a leading and/or a trailing separator. Paths may also be prefixed by an optional device id, which includes the character(s) which separate the device id from the rest of the path. For example, "C:" and "Server/Volume:" are typical device ids. A device independent path has null for a device id.

Note that paths are value objects; all operations on paths return a new path; the path that is operated on is unscathed.

UNC paths are denoted by leading double-slashes such as //Server/Volume/My/Path. When a new path is constructed all double-slashes are removed except those appearing at the beginning of the path.

This interface can be used without OSGi running.

This interface is not intended to be implemented by clients.

Most used methods

  • 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

  • Running tasks concurrently on multiple threads
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getContentResolver (Context)
  • compareTo (BigDecimal)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Github Copilot alternatives
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