Community
Participate
Working Groups
We select the parent if an element is filtered. This works except for JarEntryFile objects (e.g. a resource in a JAR). Both getName and getFullPath return the handle relative to the JAR. How can we get the parent for such an element? I.e. we would like to get the IPackageFragment or IPackageFragmentRoot for that entry.
A JarEntryFile is a non-java resource and thus it is not a java element. It is just an IStorage. Thus it is not possible to navigate back to the IPackageFragment or IPackageFragmentRoot. You will have to remember the IPackageFragment or the IPackageFragmentRoot you selected to obtain this JarEntryFile.
Sorry but I still think it's a J Core problem: It's the J Core API that extends the workspace to return any Object(s) i.e. even non-IResource(s) namely: Object[] *.getNonJavaResources(). The Core/resource API is consistent because for IContainer.members() returns IResource(s) which allow to get the parent (IContainer). I would expect a similar thing from th J Core API i.e. *.getNonJavaResources() returning INonJavaResource(ren) from which I can get the parent.
Are you proposing to wrap every non-java resource in a INonJavaResource with a pointer to its parent?
Either that or having a Java Model method to get the parent for such an element. I mean at the end it is the model ;-) Resources also wrap (in a way) each file to get me the parent. Also, Java Elements allow me to get the parent (if any).
What about returning IAdaptable instead of Object. This could then be used/extended to get the parent (if needed). Note: both, IStorage and IResource are adaptable.
This would break existing APIs. Non-java resources are not meant to be part of the JavaModel. This is a commodity to visualize them in the package view. We don't support any action onto them, you directly have the raw resource in your hand and can operate on it as you would do with any resource. Resources are not connected back to the JavaModel. You should remember how you got this resource (which element you traversed). Alternatively you may try to iterate over containers until you hit one for which a corresponding element exists. Closing
The new support to navigate (F3 and later Ctrl+Click) from an NLS key in a properties file to the corresponding reference will not work for JARs due to this bug. Please reconsider.
It would already help if I could get the JAR (package fragment root) then I could locate the stuff myself.
The fix for bug 148944 will fix this bug as well (IJarEntryResource#getParent()).
Reopening to mark as dup
*** This bug has been marked as a duplicate of bug 148944 ***
Verified for 3.3 M6 using v_743.