Bug 29274 - Surface non-java projects as model non-java resources
Summary: Surface non-java projects as model non-java resources
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 3297 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-01-10 04:14 EST by Philipe Mulet CLA
Modified: 2003-04-02 06:10 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2003-01-10 04:14:18 EST
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.
Comment 1 Philipe Mulet CLA 2003-01-10 04:15:19 EST
To be consistent with other non-java resources elsewhere, these would likely be 
also IResource[].
Comment 2 Jerome Lanneluc CLA 2003-01-10 09:48:39 EST
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)
Comment 3 Erich Gamma CLA 2003-01-10 10:08:23 EST
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?
Comment 4 Jerome Lanneluc CLA 2003-01-10 10:41:27 EST
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.
Comment 5 Philipe Mulet CLA 2003-01-10 11:16:51 EST
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.
Comment 6 Jerome Lanneluc CLA 2003-01-13 06:47:47 EST
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.
Comment 7 David Audel CLA 2003-02-12 06:53:08 EST
Verified.
Comment 8 Philipe Mulet CLA 2003-04-02 06:10:39 EST
*** Bug 3297 has been marked as a duplicate of this bug. ***