@Override public String toPlatformString(boolean decode) { return internalUri.toPlatformString(decode); }
@Override public String toPlatformString(boolean decode) { return uri.toPlatformString(decode); }
@Override public String toPlatformString(boolean decode) { return base.toPlatformString(decode); }
private Object toPath(URI uri) { return new Path(uri.toPlatformString(true)); }
protected Object toPath(URI uri) { return new Path(uri.toPlatformString(true)); }
@SuppressWarnings("unchecked") public <T> T getAdapter(Class<T> adapterType) { URI uri = resource.getURI(); if ((adapterType == IFile.class || adapterType == IResource.class) && uri.isPlatformResource()) { return (T) ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toPlatformString(true))); } return null; }
public static void validateFile(URI modelPath) { if (modelPath.isPlatformResource()) { IFile file; try { file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(modelPath.toPlatformString(true))); } catch (Exception e) { throw new RuntimeException(format("The model file '%s' does not exist.", modelPath)); } if (file == null || !file.exists()) { throw new RuntimeException(format("The model file '%s' does not exist.", modelPath)); } if (file.getType() != IResource.FILE) { throw new RuntimeException(format("The '%s' path is not a file.", modelPath)); } } }
/** * Make sure that all files that are about to be loaded are synchronized with the file system */ private void synchronizeResources(Collection<URI> toLoad) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); for(URI uri : toLoad) { Path path = new Path(uri.toPlatformString(true)); IFile file = root.getFile(path); try { if(!file.isSynchronized(IResource.DEPTH_ZERO)) { file.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor()); } } catch (CoreException e) { throw new RuntimeException(e); } } }
@Override protected Resource loadResource(URI uri, ResourceSet localResourceSet, ResourceSet parentResourceSet) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); if(workspace != null) { IWorkspaceRoot root = workspace.getRoot(); if(root != null) { IFile file = root.getFile(new Path(uri.toPlatformString(true))); if(!file.isSynchronized(IResource.DEPTH_ZERO)) { // don't bother trying to refresh it, this loading-thread doesn't own the project resource lock // we will recover & load the resource in the main builder thread (that owns the project resource lock) // (if we do try to load resources that are out of sync, we create a deadlock) return null; } } } return super.loadResource(uri, localResourceSet, parentResourceSet); }
@Override public Map<String, ?> getAttributes(URI uri, Map<?, ?> options) { String platformResourcePath = uri.toPlatformString(true); if (workspaceRoot != null) { return WorkbenchHelper.attributes(platformResourcePath, options); } else { URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath); return resolvedLocation == null ? Collections.<String, Object>emptyMap() : getURIConverter(options).getAttributes(resolvedLocation, options); } }
@Override public Map<String, ?> getAttributes(URI uri, Map<?, ?> options) { String platformResourcePath = uri.toPlatformString(true); if (workspaceRoot != null) { return WorkbenchHelper.attributes(platformResourcePath, options); } else { URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath); return resolvedLocation == null ? Collections.<String, Object>emptyMap() : getURIConverter(options).getAttributes(resolvedLocation, options); } }
/** * This implementation only gets called when platform's content describer throws an exception, i.e., when the resource doesn't exist. * For {@link URI#isPlatformResource() platform resource URIs}, it determines the character set from the workspace. * @since 2.9 */ @Override protected String getCharset(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException { if (uri.isPlatformResource() && PlatformResourceURIHandlerImpl.workspaceRoot != null) { return PlatformResourceURIHandlerImpl.WorkbenchHelper.getCharset(uri.toPlatformString(true), options); } else { return super.getCharset(uri, inputStream, options, context); } }
/** * This implementation only gets called when platform's content describer throws an exception, i.e., when the resource doesn't exist. * For {@link URI#isPlatformResource() platform resource URIs}, it determines the character set from the workspace. * @since 2.9 */ @Override protected String getCharset(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException { if (uri.isPlatformResource() && PlatformResourceURIHandlerImpl.workspaceRoot != null) { return PlatformResourceURIHandlerImpl.WorkbenchHelper.getCharset(uri.toPlatformString(true), options); } else { return super.getCharset(uri, inputStream, options, context); } }
public String initHandle(URI uri) { if (!uri.isPlatform()) return null; final IFile file = getWorkspaceRoot().getFile(new Path(uri.toPlatformString(true))); if (file == null) { return null; } final IProject project = file.getProject(); return project.getName(); }
/** * This implementation only gets called when platform's content describer throws an exception, i.e., when the resource doesn't exist. * For {@link URI#isPlatformResource() platform resource URIs}, it determines the line delimiter from the project/workspace preferences. * @since 2.9 */ @Override protected String getLineDelimiter(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException { if (uri.isPlatformResource() && PlatformResourceURIHandlerImpl.workspaceRoot != null) { return PlatformResourceURIHandlerImpl.WorkbenchHelper.getLineDelimiter(uri.toPlatformString(true), options); } else { return super.getCharset(uri, inputStream, options, context); } } }
@Override public boolean exists(URI uri, Map<?, ?> options) { String platformResourcePath = uri.toPlatformString(true); if (workspaceRoot != null) { return WorkbenchHelper.exists(platformResourcePath, options); } else { URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath); return resolvedLocation != null && getURIConverter(options).exists(resolvedLocation, options); } }
@Override public boolean exists(URI uri, Map<?, ?> options) { String platformResourcePath = uri.toPlatformString(true); if (workspaceRoot != null) { return WorkbenchHelper.exists(platformResourcePath, options); } else { URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath); return resolvedLocation != null && getURIConverter(options).exists(resolvedLocation, options); } }
public Iterable<Pair<IStorage, IProject>> getStorages(URI uri) { if (!uri.isPlatformResource()) { // support storage lookup by absolute file URI as it is possibly resolved by importURI references if (uri.isFile()) { IPath path = new Path(uri.toFileString()); if (path.isAbsolute()) { IFile file = getWorkspaceRoot().getFileForLocation(path); return getStorages(file); } } return emptySet(); } IFile file = getWorkspaceRoot().getFile(new Path(uri.toPlatformString(true))); return getStorages(file); }
protected boolean isValidTargetFile(Resource resource, StatusWrapper status) { IFile targetFile = projectUtil.findFileStorage(resource.getURI(), true); if (targetFile != null) return true; String path = (resource.getURI().isPlatformResource()) ? resource.getURI().toPlatformString(true) : resource.getURI().toString(); status.add(FATAL, "Rename target file '" + path + "' cannot be accessed", resource.getURI()); return false; }
protected IPackageFragmentRoot getPackageFragmentRoot(URI uri) { if (uri.isArchive() || !uri.isPlatform()) { return getJarWithEntry(uri); } final IFile file = getWorkspaceRoot().getFile(new Path(uri.toPlatformString(true))); if (file == null) { return getJarWithEntry(uri); } IPackageFragmentRoot root = getJavaElement(file); if (root == null) return getJarWithEntry(uri); return root; }