Bug 148859 - [model][delta] Package Explorer only shows default package after import
Summary: [model][delta] Package Explorer only shows default package after import
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows 2000
: P1 major (vote)
Target Milestone: 3.2.1   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-27 14:01 EDT by Kelvin Cheung CLA
Modified: 2006-09-18 10:39 EDT (History)
7 users (show)

See Also:


Attachments
J2EE view only shows default package (7.91 KB, image/pjpeg)
2006-06-27 14:02 EDT, Kelvin Cheung CLA
no flags Details
More package present in the project (in Resource view) (19.52 KB, image/pjpeg)
2006-06-27 14:03 EDT, Kelvin Cheung CLA
no flags Details
Import this *.ear file in a WTP environment. Notice the Package Explorer doesn't render the packages under testAppClient (2.72 KB, application/octet-stream)
2006-07-10 16:51 EDT, Michael D. Elder CLA
no flags Details
Proposed fix aginst R3_2_maintenance branch (1.44 KB, patch)
2006-08-21 11:38 EDT, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kelvin Cheung CLA 2006-06-27 14:01:31 EDT
To reproduce this, import an ear with a J2EE Application Client module in it (with source).  The import works fine by putting the Java files at the right location.

However, in the J2EE and Java perspectives, the Project Explorer only shows the default package although there are more packages present in the project (visible in Resource view).  You can take a look at my screen captures.

There are currently no workaround other than restarting the workbench, then the missing packages show up.
Comment 1 Kelvin Cheung CLA 2006-06-27 14:02:37 EDT
Created attachment 45398 [details]
J2EE view only shows default package
Comment 2 Kelvin Cheung CLA 2006-06-27 14:03:20 EDT
Created attachment 45399 [details]
More package present in the project (in Resource view)
Comment 3 Michael D. Elder CLA 2006-06-27 15:44:16 EDT
What build was this on?
Comment 4 Kelvin Cheung CLA 2006-06-27 15:55:30 EDT
WTP 1.5 RC5-200606161055
Comment 5 Michael D. Elder CLA 2006-06-27 15:58:04 EDT
Can you confirm if your environment has the "Empty Packages" and "Empty Parent Packages" filters enabled? If so, does disabling them bring the subpackages back?
Comment 6 Kelvin Cheung CLA 2006-06-27 16:56:17 EDT
By default, the Empty parent packages is enabled (with checkmark).  I tried disabling both but it does not show those packages.
Comment 7 Michael D. Elder CLA 2006-07-10 16:49:43 EDT
This issue was originally observed on the Project Explorer, but the problem is rooted somewhere in the JavaModel. 

In the scenario, a project is imported that creates a JDT Type directly (the Main.java class for the AppClient project), and then some other *.java files are created under the same folder. The existence of these folders is noted in the Resource Navigator, so I know the IResourceDelta events must be generated, but the Package Explorer doesn't respond to update the JavaElementInfo objects. Closing and reopening the project causes the necessary refresh. 

Moving to JDT/UI for further investigation. I will attach the test case to this defect. 
Comment 8 Michael D. Elder CLA 2006-07-10 16:51:02 EDT
Created attachment 46044 [details]
Import this *.ear file in a WTP environment. Notice the Package Explorer doesn't render the packages under testAppClient
Comment 9 Tim deBoer CLA 2006-07-19 11:02:39 EDT
Is there any chance that this will be fixed for 3.2.1? Most people won't realize that they have to restart and as an Eclipse adopter our testers are getting confused by this.
Comment 10 Michael D. Elder CLA 2006-07-19 11:35:54 EDT
Martin -- can you comment on the possibility of this making it into 3.2.1?
Comment 11 Michael D. Elder CLA 2006-07-19 16:27:49 EDT
Kicking this up a notch to garner some attention.
Comment 12 Martin Aeschlimann CLA 2006-07-21 08:29:07 EDT
reproduced in WTP 1.5.
- it seems the Java model missed an update. The classes 'Hello' and 'Hello2' are not contained in the Java element tree, but found by search engine
- when I tried first, all elements correctly showed up. On the second try I got the result as described above. 

Moving to jdt.core
Comment 13 Yen Lu CLA 2006-07-24 13:22:29 EDT
Would it be possible to get this into Eclipse 3.2.1?
Comment 14 Frederic Fusier CLA 2006-08-17 12:20:55 EDT
Debugging this test case shows that method doExecute(IProgressMonitor, IAdaptable) from org.eclipse.jst.j2ee.internal.common.operations.NewJavaClassOperation
create the Main.java file which populate JavaModel before than org.eclipse.jdt.internal.core.DeltaProcessor receive event of IProject creation through resourceChanged(IResourceChangeEvent).

Michael,
I'm not really a specialist of this code and Jerome is currently in vacation.
However, I've made a test with a simple java project or a jar file import and our DeltaProcessor first receives the IResourceChangeEvent and updates the java model. It seems that this order is necessary as otherwise, java model is wrongly initialized with no children in sourde folder appClientModule...

So, it sounds like there's something wrong in resources creation on your side.
If you think jst.j2ee behavior is correct while importing, could you explain me the reason?

Thanks
Comment 15 Jerome Lanneluc CLA 2006-08-21 11:34:59 EDT
The scenario from a JDT Core point of view is as follows.

In an IWorkspaceRunnable:
1. A Java project is created
2. IJavaProject#findType(...) is used (this populates the model's cache, and the pkg fragment root is cached with 1 child: the default package)
3. A new package is added
4. At the end of the IWorkspaceRunnable, the resource delta contains only the project addition (which is valid).

The DeltaProcessor should close the IJavaProject when it finds it is added as it does for other elements.
Comment 16 Jerome Lanneluc CLA 2006-08-21 11:38:51 EDT
Created attachment 48299 [details]
Proposed fix aginst R3_2_maintenance branch
Comment 17 Philipe Mulet CLA 2006-08-28 06:54:16 EDT
+1 for addressing in 3.2.1
Comment 18 Michael D. Elder CLA 2006-08-28 09:29:18 EDT
Jerome -- thanks for taking care of this issue for 3.2.1!
Comment 19 Angel Vera CLA 2006-08-29 13:00:59 EDT
Has the patch for this defect made it into the 3.2.1 mainstream? if it has in what built level. Thank you
Comment 20 Jerome Lanneluc CLA 2006-08-29 13:06:10 EDT
Sorry it is not in the 3.2.1 stream yet. This needs to be thoroughly tested first. We will indicate in this bug report when it is commited.
Comment 21 Frederic Fusier CLA 2006-09-06 06:28:56 EDT
Released for 3.2.1 in R3_2_maintenance stream.

Test case added in JavaProjectTests#testBug148859()
Comment 22 Olivier Thomann CLA 2006-09-11 14:28:47 EDT
Verified for 3.2.1 using build M20060908-1655.
This needs to be released in HEAD as well.
Comment 23 Frederic Fusier CLA 2006-09-12 06:32:32 EDT
Released for 3.3 M2 in HEAD stream
Comment 24 David Audel CLA 2006-09-18 10:39:01 EDT
Verified for 3.3 M2 using build I20060918-0010.