Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 314354 - [common navigator] Project Explorer does not refresh on adding/removing library to a project
Summary: [common navigator] Project Explorer does not refresh on adding/removing libra...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.6 RC4   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-25 16:20 EDT by Deepak Azad CLA
Modified: 2010-06-03 06:51 EDT (History)
5 users (show)

See Also:
bokowski: review+
deepakazad: review+
daniel_megert: review+


Attachments
Fix (1.75 KB, patch)
2010-06-02 12:42 EDT, Markus Keller CLA
no flags Details | Diff
Fix 2 (1.51 KB, patch)
2010-06-02 15:16 EDT, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Deepak Azad CLA 2010-05-25 16:20:33 EDT
I20100520-1744

Steps
- New Workspace
- New Java project
- In 'Project Explorer' right click on the java project -> Build Path -> Configure Build Path
- 'Libraries' tab -> 'Add Library' -> add JUnit 3 and click Ok to close the dialog => The newly added library does not show up in Project Explorer
- Manually refresh the project (F5) => Library added in last step shows up

Auto refresh also does not happen when the library is removed.
Comment 1 Prakash Rangaraj CLA 2010-05-26 03:29:53 EDT
Isn't this JDT? Or its an issue with Common Navigator?
Comment 2 Prakash Rangaraj CLA 2010-05-31 00:52:28 EDT
(In reply to comment #1)
> Isn't this JDT? Or its an issue with Common Navigator?

   I guess this could be more of JDT rather than common navigator. Moving to JDT for comments
Comment 3 Markus Keller CLA 2010-06-02 10:57:26 EDT
Worked fine up to 3.6M6, broken in 3.6M7.
Comment 4 Markus Keller CLA 2010-06-02 11:55:55 EDT
Debugged change down into org.eclipse.ui.internal.navigator.NavigatorPipelineService.interceptRefresh(PipelinedViewerUpdate):

In M6,
  contentService.findOverrideableContentExtensionsForPossibleChild(refreshable)
returned a:
  Content[org.eclipse.ui.navigator.resourceContent(5) , "Resources"] Instance
, but in M7, it finds nothing for an IJavaProject.
Comment 5 Francis Upton IV CLA 2010-06-02 12:05:19 EDT
(In reply to comment #4)
> Debugged change down into
> org.eclipse.ui.internal.navigator.NavigatorPipelineService.interceptRefresh(PipelinedViewerUpdate):
> 
> In M6,
>   contentService.findOverrideableContentExtensionsForPossibleChild(refreshable)
> returned a:
>   Content[org.eclipse.ui.navigator.resourceContent(5) , "Resources"] Instance
> , but in M7, it finds nothing for an IJavaProject.
I will have a look.
Comment 6 Markus Keller CLA 2010-06-02 12:20:46 EDT
When I revert bug 285353, this works again. Hint: Change was in /org.eclipse.ui.navigator.resources/plugin.xml 1.44.
Comment 7 Markus Keller CLA 2010-06-02 12:42:24 EDT
Created attachment 170833 [details]
Fix

If I understood that correctly, we're not getting a refresh from the resource contribution for free any more, since bug 285353 stopped adapting the element to IProject (and the resource contribution does not know about IJavaProject).

This patch implements the necessary mapping from IJavaProject to IProject in JavaNavigatorContentProvider#postRefresh(List, boolean, Collection). In #postAdd(..) and in all the intercept*(..) methods, we already do the same.
Comment 8 Francis Upton IV CLA 2010-06-02 12:46:00 EDT
(In reply to comment #7)
> Created an attachment (id=170833) [details]
> Fix
> 
> If I understood that correctly, we're not getting a refresh from the resource
> contribution for free any more, since bug 285353 stopped adapting the element
> to IProject (and the resource contribution does not know about IJavaProject).
> 
> This patch implements the necessary mapping from IJavaProject to IProject in
> JavaNavigatorContentProvider#postRefresh(List, boolean, Collection). In
> #postAdd(..) and in all the intercept*(..) methods, we already do the same.

+1 this looks good to me. Thanks for tracking this down.
Comment 9 Dani Megert CLA 2010-06-02 13:11:48 EDT
The patch looks safe.

Markus, please check whether the navigator change causes other JDT functionality in the Project Explorer to be broken. If that's not the case then +1 to fix for RC4.
Comment 10 Markus Keller CLA 2010-06-02 13:39:42 EDT
(In reply to comment #9)
I didn't find other problems that could have been caused by bug 285353 and that would not be fixed with the proposed fix.

We should fix this for RC4. This bug is visible as soon as you try to apply any classpath changes. E.g. when you change the JRE System Library, the Project Explorer is also not refreshed. This will surely cause great confusion if we don't fix it. The fix is small, safe, and only targets the Project Explorer.

Boris, could you please review the fix and give your +1?
Comment 11 Boris Bokowski CLA 2010-06-02 14:47:37 EDT
Waiting for a new patch. There should be two loops, one to do the mapping, and a second one to detect the workspace root case.
Comment 12 Markus Keller CLA 2010-06-02 15:16:59 EDT
Created attachment 170866 [details]
Fix 2

The previous patch had a theoretical problem: If 'toRefresh' contains an IJavaModel and an IJavaProject after the model, then the IJavaProject will not be converted because of the early return statement inside the loop.

This cannot happen in practice, and if it happens, it's not a problem, since the IJavaModel refresh also refreshes the project. But since we're in RC4, we will play super-safe and use 2 loops.
Comment 13 Deepak Azad CLA 2010-06-02 15:24:25 EDT
Looks good! +1 for RC4.
Comment 14 Boris Bokowski CLA 2010-06-02 15:39:31 EDT
+1 from me as well.
Comment 15 Markus Keller CLA 2010-06-02 15:44:41 EDT
Thanks everybody. Fix 2 released to HEAD for I20100603-0100.
Comment 16 Dani Megert CLA 2010-06-03 06:51:13 EDT
Verified in I20100603-0100.