List of usage examples for org.eclipse.jdt.internal.core JarEntryResource getName
@Override
public String getName()
From source file:org.eclipse.che.plugin.java.server.JavaNavigation.java
License:Open Source License
private JarEntry getJarEntryResource(JarEntryResource resource) { JarEntry entry = DtoFactory.getInstance().createDto(JarEntry.class); if (resource instanceof JarEntryDirectory) { entry.setType(JarEntryType.FOLDER); }//from w ww . jav a2 s. c o m if (resource instanceof JarEntryFile) { entry.setType(JarEntryType.FILE); } entry.setName(resource.getName()); entry.setPath(resource.getFullPath().toOSString()); return entry; }
From source file:org.jboss.tools.common.model.ui.editor.ModelObjectStorageEditorInput.java
License:Open Source License
IJarEntryResource findJarEntryFile() {
XModelObject o = object;/*from www . jav a 2 s . c o m*/
JarEntryFile f = null;
JarEntryResource current = null;
String packageName = "";
List<String> parts = new ArrayList<String>();
List<XModelObject> os = new ArrayList<XModelObject>();
while (o != null && o.getFileType() != XModelObject.SYSTEM) {
String part = o.getFileType() == XModelObject.FILE ? FileAnyImpl.toFileName(o)
: o.getFileType() == XModelObject.FOLDER ? o.getAttributeValue(XModelObjectConstants.ATTR_NAME)
: null;
if (part != null) {
parts.add(0, part);
os.add(0, o);
if (f == null) {
f = new JarEntryFile(part) {
public InputStream getContents() throws CoreException {
return storage.getContents();
}
};
current = f;
} else {
if (packageName.length() > 0) {
packageName = part + "." + packageName;
} else {
packageName = part;
}
JarEntryDirectory d = new JarEntryDirectory(part);
current.setParent(d);
current = d;
}
}
o = o.getParent();
}
// if(!(o instanceof JarSystemImpl)) return null;
String file = Paths.expand(o.get(XModelObjectConstants.ATTR_NAME_LOCATION), o.getModel().getProperties());
IProject p = EclipseResourceUtil.getProject(o);
IJavaProject jp = EclipseResourceUtil.getJavaProject(p);
if (jp == null)
return null;
IPackageFragmentRoot root = null;
try {
IPackageFragmentRoot[] rs = jp.getAllPackageFragmentRoots();
for (IPackageFragmentRoot r : rs) {
if (r.getResource() != null && r.getResource().exists()
&& r.getResource().getLocation().toString().equals(file)) {
root = r;
} else if (r.getPath() != null && r.getPath().toString().equals(file)) {
root = r;
}
}
} catch (CoreException e) {
ModelUIPlugin.getDefault().logError(e);
}
if (root == null) {
root = jp.getPackageFragmentRoot(file);
}
if (root == null) {
return null;
}
if (current != null && !"META-INF".equalsIgnoreCase(current.getName()) && packageName.length() > 0) {
IPackageFragment pf = root.getPackageFragment(packageName);
f.setParent(pf);
} else {
current.setParent(root);
if (!(o instanceof JarSystemImpl)) {
Object q = root;
NonJavaResource nj = null;
for (int i = 0; i < parts.size(); i++) {
IResource ri = (IResource) os.get(i).getAdapter(IResource.class);
if (ri == null) {
return f;
}
nj = new NonJavaResource(q, ri);
q = nj;
}
if (nj != null) {
return nj;
}
}
}
return f;
}
From source file:org.jboss.tools.common.model.ui.jarproperties.JarPropertiesTest.java
License:Open Source License
JarEntryFile getJarEntryFileForResource(IProject p, IResource file, String packageName, String fileName) {
JarEntryFile f = new JarEntryFile(fileName);
JarEntryResource current = f;
IJavaProject jp = EclipseResourceUtil.getJavaProject(p);
if (jp == null)
return null;
IPackageFragmentRoot root = jp.getPackageFragmentRoot(file);
if (root == null)
return null;
if (current != null && !"META-INF".equalsIgnoreCase(current.getName()) && packageName.length() > 0) {
IPackageFragment pf = root.getPackageFragment(packageName);
f.setParent(pf);/*from ww w. j a v a 2s. c o m*/
} else {
current.setParent(root);
}
return f;
}