Java Code Examples for org.eclipse.core.runtime.IPath#setDevice()

The following examples show how to use org.eclipse.core.runtime.IPath#setDevice() . 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: JarImportWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the target path to be used for the updated classpath entry.
 *
 * @param entry
 *            the classpath entry
 * @return the target path, or <code>null</code>
 * @throws CoreException
 *             if an error occurs
 */
private IPath getTargetPath(final IClasspathEntry entry) throws CoreException {
	final URI location= getLocationURI(entry);
	if (location != null) {
		final URI target= getTargetURI(location);
		if (target != null) {
			IPath path= URIUtil.toPath(target);
			if (path != null) {
				final IPath workspace= ResourcesPlugin.getWorkspace().getRoot().getLocation();
				if (workspace.isPrefixOf(path)) {
					path= path.removeFirstSegments(workspace.segmentCount());
					path= path.setDevice(null);
					path= path.makeAbsolute();
				}
			}
			return path;
		}
	}
	return null;
}
 
Example 2
Source File: NewGraniteProjectWizard.java    From aem-eclipse-developer-tools with Apache License 2.0 6 votes vote down vote up
private String calculateRelativePath(IProject from, IProject to) {
	IPath fromPath = from.getRawLocation();
	IPath toPath = to.getRawLocation();
	toPath.setDevice(null);
	fromPath.setDevice(null);
	int ssc = fromPath.matchingFirstSegments(toPath);
	fromPath = fromPath.removeFirstSegments(ssc);
	toPath = toPath.removeFirstSegments(ssc);
	StringBuffer relPath = new StringBuffer();
	for(int i=0; i<fromPath.segmentCount(); i++) {
		if (relPath.length()!=0) {
			relPath.append("/");
		}
		relPath.append("..");
	}
	if (relPath.length()!=0) {
		relPath.append("/");
	}
	relPath.append(toPath.toString());
	return relPath.toString();
}
 
Example 3
Source File: EclipseProjectImporter.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private IPath fixDevice(IPath path) {
	if (path != null && path.getDevice() != null) {
		return path.setDevice(path.getDevice().toUpperCase());
	}
	if (Platform.OS_WIN32.equals(Platform.getOS()) && path != null && path.toString().startsWith("//")) {
		String server = path.segment(0);
		String pathStr = path.toString().replace(server, server.toUpperCase());
		return new Path(pathStr);
	}
	return path;
}
 
Example 4
Source File: ProjectUtils.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static IPath resolveGlobPath(IPath base, String glob) {
	IPath pattern = new org.eclipse.core.runtime.Path(glob);
	if (!pattern.isAbsolute()) { // Append cwd to relative path
		pattern = base.append(pattern);
	}
	if (pattern.getDevice() != null) { // VS Code only matches lower-case device
		pattern = pattern.setDevice(pattern.getDevice().toLowerCase());
	}
	return pattern;
}
 
Example 5
Source File: RemoteAnnotationStorage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public IPath getFullPath() {
	ISVNRepositoryLocation location = file.getRepository();
	SVNUrl repositoryUrl = location.getRepositoryRoot();
	String[] segments = repositoryUrl.getPathSegments();
	
	IPath path = new Path(null, "/");
	for (int i = 0; i < segments.length; i++) {
		path = path.append(segments[i]);
	}
	
	path = path.setDevice(repositoryUrl.getHost() + IPath.DEVICE_SEPARATOR);
	path = path.append(file.getRepositoryRelativePath());
	return path;
}