Project: Eclipse_Platform_UI
Bug 255793 [CommonNavigator] [CNF] Chosen label provider should match content provider
Reported: 2008-11-19 09:13:57 | Status: resolved fixed

Build ID: I20080918-0100 Steps To Reproduce: 1. Create 2 "org.eclipse.ui.navigator.navigatorContent" extension to provide "similar" content but needed to show different "labels" 2. Your trigger points will indicate "which types of nodes in the tree might be interesting to our extension"(M. Elder) 3. Implement your 2 content providers with the ITreePathContentProvider and use that to find out if you should provide content based on the initial content "root" of your extension point. Otherwise the content here should be the same (for the test) 4. Code your label provider to return different text/images for the same content 4. Run you explorer 5. You will notice that the content will end up coming from one label provider for both extension point. More information: In the NavigatorServiceContentLabelProvider, in the getStyledText(Object anElement) method, the label provider is determined from all the content provider with possible children and the first to return a label "wins" the race. The problem is that we define an extension point with a pair of provider (content and label) that are both required and thus would be expected to work in tandem. Here the first selected label provider will get the object and since it is one that it understands it will return a label for it. There is no way for this provider to know where the object is in the tree or who provided content for it. The label provider is a very focused class related to its content provider and responsible only to provide labels for such content. The CNF should keep track of which provider provided each element of content in the tree and delegate the label request to its paired label provider. There is no need to go around label providers to see who wants what. By definition from the extension point, content and label are required and paired.

Files changed in fix:
bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/ContributorTrackingSet.java bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/NavigatorContentService.java bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/NavigatorContentServiceContentProvider.java bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/extensions/NavigatorContentExtension.java bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/extensions/SafeDelegateTreeContentProvider.java bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/CommonViewer.java bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/CommonViewerSorter.java tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/LabelProviderTest.java tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestBase.java tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/SorterTest.java