List of usage examples for org.eclipse.jdt.core IJarEntryResource getPackageFragmentRoot
IPackageFragmentRoot getPackageFragmentRoot();
From source file:com.google.gwt.eclipse.core.dialogs.ModuleSelectionDialog.java
License:Open Source License
/** * Helper method to return the absolute workspace path of a GWT Module. * // ww w .j av a 2 s . co m * If the module file is located in a JAR, then the absolute path of the JAR * on the file system is returned. */ private static IPath getPathForModule(IModule module) { if (module == null) { return null; } if (!module.isBinary()) { ModuleFile moduleFile = (ModuleFile) module; IFile file = moduleFile.getFile(); return file.getFullPath(); } ModuleJarResource moduleJarResource = (ModuleJarResource) module; IJarEntryResource jarEntryResource = moduleJarResource.getJarEntryResource(); return jarEntryResource.getPackageFragmentRoot().getPath(); }
From source file:org.dev.toos.constcode.model.ConstModel.java
License:Apache License
/**Jar*/ private void iterateIJarEntryResource(IJarEntryResource atElement, final String resourceName, Map<String, Object> findRes) throws CoreException { if (atElement.getFullPath().toString().endsWith(resourceName) == true) { //System.out.println(atElement.getFullPath().toString()); JarPackageFragmentRoot root = (JarPackageFragmentRoot) atElement.getPackageFragmentRoot(); String name = root.getJar().getName(); findRes.put(name, atElement);//from w ww. j a v a 2s . c om } IJarEntryResource[] resourcesItem = atElement.getChildren(); if (resourcesItem != null) for (IJarEntryResource element : resourcesItem) iterateItem(element, resourceName, findRes); }
From source file:org.dev.toos.constcode.model.ConstModel.java
License:Apache License
/**?jar */ private void loadConst4Jar(String name, IJarEntryResource atElement) { //1.//from www . j av a 2s .c o m ConstGroup groupModel = this.constGroupMap.get(name); if (groupModel == null) { InputStream inStream = null; String resourceName = atElement.getName(); try { // if (atElement.) JarPackageFragmentRoot root = (JarPackageFragmentRoot) atElement.getPackageFragmentRoot(); ZipFile jar = root.getJar(); ZipEntry zipEntry = jar.getEntry(atElement.getFullPath().toString().substring(1)); if (zipEntry == null) return; inStream = jar.getInputStream(zipEntry); if (inStream == null) return; } catch (Exception e) { Message.errorInfo("load IJarEntryResource " + resourceName + "?", e); return; } // groupModel = new JARSourceConstCodeGroup(name, inStream); groupModel.initGroup(); this.constGroupMap.put(name, groupModel); this.constGroupList.add(groupModel); groupModel.loadData(); } else groupModel.reloadData(); }
From source file:org.eclipse.xtext.builder.smap.XbaseBreakpointUtil.java
License:Open Source License
public SourceRelativeURI getBreakpointURI(IEditorInput input) { Object adapter = input.getAdapter(IResource.class); if (adapter != null) return null; if (input instanceof IStorageEditorInput) { IStorage storage;//from w ww . j a v a2s . c om try { storage = ((IStorageEditorInput) input).getStorage(); if (storage instanceof IResource) return null; if (storage instanceof IJarEntryResource) { IJarEntryResource jarEntryResource = (IJarEntryResource) storage; if (!jarEntryResource.getPackageFragmentRoot().isArchive()) return null; Object parent = jarEntryResource.getParent(); if (parent instanceof IPackageFragment) { String path = ((IPackageFragment) parent).getElementName().replace('.', '/'); return new SourceRelativeURI(path + "/" + storage.getName()); } else if (parent instanceof IPackageFragmentRoot) { return new SourceRelativeURI(storage.getName()); } } } catch (CoreException e) { logger.error("Error finding breakpoint URI", e); return null; } } else if (input instanceof IClassFileEditorInput) { IClassFile classFile = ((IClassFileEditorInput) input).getClassFile(); if (classFile == null) { return null; } ITrace traceToSource = traceForTypeRootProvider.getTraceToSource(classFile); if (traceToSource == null) return null; for (ILocationInResource loc : traceToSource.getAllAssociatedLocations()) return loc.getSrcRelativeResourceURI(); return null; } return null; }
From source file:org.eclipse.xtext.common.types.ui.trace.JarEntryAwareTrace.java
License:Open Source License
protected AbsoluteURI resolvePath(IJarEntryResource jarEntry, SourceRelativeURI path) { IPackageFragmentRoot packageFragmentRoot = jarEntry.getPackageFragmentRoot(); try {//from www . j a v a 2 s . c o m Pair<URI, URI> pair = uriMapperExtensions.getURIMapping(packageFragmentRoot); if (pair != null) { URI first = pair.getFirst(); if (first != null) return new AbsoluteURI(URI.createURI(first + "/" + path)); } } catch (JavaModelException e) { log.error("Error resolving path", e); } return null; }
From source file:org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl.java
License:Open Source License
/** * @since 2.5//from w w w . j ava 2s . c o m */ @Override public URI getUri(/* @NonNull */ IStorage storage) { if (storage instanceof IJarEntryResource) { final IJarEntryResource casted = (IJarEntryResource) storage; IPackageFragmentRoot packageFragmentRoot = casted.getPackageFragmentRoot(); Map<URI, IStorage> data = getAllEntries(packageFragmentRoot); for (Map.Entry<URI, IStorage> entry : data.entrySet()) { if (entry.getValue().equals(casted)) return entry.getKey(); } if (packageFragmentRoot.exists() && packageFragmentRoot.isArchive()) { IPath jarPath = packageFragmentRoot.getPath(); URI jarURI; if (packageFragmentRoot.isExternal()) { jarURI = URI.createFileURI(jarPath.toOSString()); } else { jarURI = URI.createPlatformResourceURI(jarPath.toString(), true); } URI result = URI.createURI("archive:" + jarURI + "!" + storage.getFullPath()); return result; } } return null; }
From source file:org.jboss.tools.common.core.resources.XModelObjectEditorInput.java
License:Open Source License
private static IEditorInput convertStorageEditorInput(IStorageEditorInput input) { if (input instanceof JarEntryEditorInput) { IProject project = null;//w w w . j a v a 2 s . c o m JarEntryEditorInput j = (JarEntryEditorInput) input; if (j.getStorage() instanceof IJarEntryResource) { IJarEntryResource file = (IJarEntryResource) j.getStorage(); String jarFile = file.getPackageFragmentRoot().getPath().toString(); if (file.getPackageFragmentRoot().getResource() != null) { jarFile = file.getPackageFragmentRoot().getResource().getLocation().toString(); } String entry = file.getName(); IJarEntryResource r = file; while (r != null && r.getParent() instanceof IJarEntryResource) { r = (IJarEntryResource) r.getParent(); entry = r.getName() + "/" + entry; } if (r != null && r.getParent() instanceof IPackageFragment) { IPackageFragment pf = (IPackageFragment) r.getParent(); IJavaProject jp = pf.getJavaProject(); if (jp != null) project = jp.getProject(); while (pf != null) { String p = pf.getElementName(); entry = p + "/" + entry; if (pf.getParent() instanceof IPackageFragment) { pf = (IPackageFragment) pf.getParent(); } else { pf = null; } } } else if (r != null && r.getPackageFragmentRoot() != null) { IPackageFragmentRoot root = r.getPackageFragmentRoot(); if (root.getJavaProject() != null) { project = root.getJavaProject().getProject(); } } IEditorInput result = createJarEntryEditorInput(project, jarFile, entry); if (result != null) return result; } } String[] entryInfo = parseJarEntryFileInput(input); if (entryInfo == null) return input; String jarFile = entryInfo[0]; String entry = entryInfo[1]; IEditorInput result = createJarEntryEditorInput(null, jarFile, entry); return (result == null || result instanceof NullEditorInput) ? input : result; }
From source file:org.seasar.kijimuna.ui.editor.configuration.xml.XmlConfiguration.java
License:Apache License
protected IFile getFile() { IEditorInput input = editor.getEditorInput(); if (input instanceof IFileEditorInput) { return ((IFileEditorInput) input).getFile(); } else if (input instanceof JarEntryEditorInput) { IJarEntryResource jarEntry = (IJarEntryResource) ((JarEntryEditorInput) input).getStorage(); IProject project = jarEntry.getPackageFragmentRoot().getJavaProject().getProject(); return project.getFile(jarEntry.getFullPath()); }//from ww w. ja v a 2 s . c o m return null; }
From source file:org.summer.dsl.builder.smap.XbaseBreakpointUtil.java
License:Open Source License
public URI getBreakpointURI(IEditorInput input) { Object adapter = input.getAdapter(IResource.class); if (adapter != null) return null; if (input instanceof IStorageEditorInput) { IStorage storage;/*w w w . j a va 2 s .c om*/ try { storage = ((IStorageEditorInput) input).getStorage(); if (storage instanceof IResource) return null; if (storage instanceof IJarEntryResource) { IJarEntryResource jarEntryResource = (IJarEntryResource) storage; if (!jarEntryResource.getPackageFragmentRoot().isArchive()) return null; Object parent = jarEntryResource.getParent(); if (parent instanceof IPackageFragment) { String path = ((IPackageFragment) parent).getElementName().replace('.', '/'); return URI.createURI(path + "/" + storage.getName()); } else if (parent instanceof IPackageFragmentRoot) { return URI.createURI(storage.getName()); } } } catch (CoreException e) { logger.error(e); return null; } } else if (input instanceof IClassFileEditorInput) { IClassFile classFile = ((IClassFileEditorInput) input).getClassFile(); if (classFile == null) { return null; } ITrace traceToSource = traceForTypeRootProvider.getTraceToSource(classFile); if (traceToSource == null) return null; for (ILocationInResource loc : traceToSource.getAllAssociatedLocations()) return loc.getSrcRelativeResourceURI(); return null; } return null; }
From source file:org.summer.dsl.builder.trace.JarEntryAwareTrace.java
License:Open Source License
protected URI resolvePath(IJarEntryResource jarEntry, URI path) { IPackageFragmentRoot packageFragmentRoot = jarEntry.getPackageFragmentRoot(); try {/*ww w . j ava 2 s. c o m*/ Pair<URI, URI> pair = uriMapperExtensions.getURIMapping(packageFragmentRoot); if (pair != null) { URI first = pair.getFirst(); if (first != null) return URI.createURI(first + "/" + path); } } catch (JavaModelException e) { log.error(e); } return path; }