Community
Participate
Working Groups
Build 2.1 M4 From EG's note: Now that more projects that we work with do not have the java nature (e.g. an update-site project, the documentation project) it becomes more annoying that the PackageExplorer doesn't show non-Java projects. The JavaCore API already supports to get at non-Java resources inside a JavaProject. I was therefore wondering whether we could also surface a corresponding JavaModel .getNonJavaResources or JavaModel.getNonJavaProjects. Similarly the delta would be handled in the same ways as for non-Java resources. I did a quick prototype by just surfaceing IProjects in the PackageExplorer as well. It works pretty well, with the exception of the deltas.
To be consistent with other non-java resources elsewhere, these would likely be also IResource[].
Erich, what should the delta be if a project gains or looses its Java nature? Do you expect just a IJavaElementDelta (indicating the project is added/removed)? Or do you want a IResourceDelta? Or both? (Note for us the first solution is easier)
There are different options: Assuming that the JavaNature can only be lost on closing a project I see two options: 1) show closed projects in the view. This would be consistent with the navigator. To do so the JavaElementDelta needs to tell us about the delete and the resource delta tells us about the add. 2) never show closed projects in the view This is what we are doing now and we provide a separate dialog to reopen a closed project. In this case we would only need the JavaElementDelta telling us that the project got removed. 1) would be better than 2) but I see the complications. Given that showing non- Java projects will be already a big improvement option 2) would be acceptable. I wonder whether we can get 1) by only receiving a JavaElementDelta, e.g., when a JavaProject is deleted we check whether the resource still exists. If it still exists we do a full refresh. However, I don't immediatly see how to handle the case of opening a closed project without always doing a full refresh. Does the resource delta contain information about the open/close state change?
The Java nature can also be added/removed when the .project file is edited (or by checking out a different .project file). But I agree the delta reporting is similar to opening/closing a project. I think 1) is not much more work than 2) (at least from the JDT Core point of view). If giving you the ResourceDelta when a project is opened/closed can avoid a full refresh, I think we should do it. So when a project is closed, you would get a JavaElementDelta indicating it is removed from the Java model, and a ResourceDelta (with the flag IResourceDelta.OPEN set) indicating a non-Java project open state has changed. Note you will have to determine yourself from this information that it is added to the non-Java projects (as we cannot create an added ResourceDelta). Symmetrically when a project is opened, you would get a JavaElementDelta indicating it is added to the Java model, and a ResourceDelta (with the flag IResourceDelta.OPEN set) indicating a non-Java project open state has changed. In the case a project gains/looses the Java nature (by modifying its .project file), the flag to check would be IResourceDelta.DESCRIPTION.
The point is indeed that we never create resource deltas, we just attach portions of it to the JavaElementDelta. Hiding relevant deltas seems loosing information which is important in the end.
Added IJavaModel.getNonJavaResources() and changed delta processor to report a ResourceDelta when a non-Java project is changed. If a Java project is closed or it looses its Java nature, a JavaElementDelta indicating it is removed is reported as well as the original ResourceDelta. Symmetrically when a Java project is opened or it gains the Java nature a JavaElementDelta and a ResourceDelta are reported.
Verified.
*** Bug 3297 has been marked as a duplicate of this bug. ***