Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 150592 - [API] Unable to sort generic folders on DSE
Summary: [API] Unable to sort generic folders on DSE
Status: RESOLVED FIXED
Alias: None
Product: Data Tools
Classification: Tools
Component: Data Source Explorer (show other bugs)
Version: 0.9   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: future   Edit
Assignee: Brian Fitzpatrick CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 162330
Blocks:
  Show dependency tree
 
Reported: 2006-07-13 22:38 EDT by Anil Samuel CLA
Modified: 2013-08-01 14:57 EDT (History)
2 users (show)

See Also:


Attachments
DSE without parentExpression in the navigatorContent.commonSorter (8.61 KB, image/png)
2006-10-03 19:41 EDT, Anil Samuel CLA
no flags Details
DSE with parentExpression in the navigatorContent.commonSorter (12.00 KB, image/png)
2006-10-03 19:42 EDT, Anil Samuel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anil Samuel CLA 2006-07-13 22:38:02 EDT
The following extension point is used to manage the DSE content.
   <extension point="org.eclipse.ui.navigator.navigatorContent">
      <navigatorContent
            name="Database_Explorer_Oracle_Content_Extension"
            priority="high"
            activeByDefault="true"
            contentProvider="oracle.dbtools.connectivity.ui.explorer.providers.ServerExplorerContentProvider"
            labelProvider="oracle.dbtools.connectivity.ui.explorer.providers.label.ServerExplorerlabelProvider"
            id="oracle.dbtools.connectivity.ui.explorer.providers.ServerExplorerContentProvider">
        		<commonSorter
					id ="oracle.dbtools.connectivity.ui.explorer.providers.Sorter"
					class="oracle.dbtools.connectivity.ui.explorer.providers.Sorter">
				</commonSorter>
                <triggerPoints>
                     <or>
                        <instanceof
                              value="org.eclipse.datatools.modelbase.sql.schema.Schema" />
						<instanceof
						      value="oracle.dbtools.modelbase.db.ComposedType" />
                     </or>
                </triggerPoints>
                <possibleChildren>
                   <or>
                        <instanceof
                                value="org.eclipse.datatools.connectivity.sqm.core.internal.ui.explorer.virtual.IVirtualNode" />
                        <instanceof
                              value="oracle.dbtools.modelbase.db.MaterializedView" />
                        <instanceof
                              value="oracle.dbtools.modelbase.db.ComposedType" />
                   </or>
                </possibleChildren>
      </navigatorContent>
   </extension>

oracle.dbtools.connectivity.ui.explorer.providers.Sorter.compare(..) is invoked, when navigating into a Schema, for folders created by the plugin but not for the generic folders like Tables, Views, Stored Procedures etc. So currently it is not possible to sort all the folders in any order.
Comment 1 Rob Cernich CLA 2006-08-14 13:41:52 EDT
No estimate at this time.

Brian, please investigate whether or not this is a navigator framework issue or if we just need to figure out the proper settings in the extension point.
Comment 2 Brian Fitzpatrick CLA 2006-09-12 16:44:34 EDT
I suspect that the reason the sorter isn't working is that the other nodes are being sorted by the ExplorerSorterProvider in *.connectivity.sqm.core.ui. The sorter framework in the 3.2 navigator doesn't have a way to simply override an existing sorter. If your content provider doesn't provide the content to those nodes, you can't sort them. 

We could ask the navigator folks to provide a way to override a sorter in a particular context, but I'm not sure how they'd manage it with the way the sorters are currently implemented.
Comment 3 Brian Fitzpatrick CLA 2006-09-18 11:37:08 EDT
Anthos, can you try something in regards to this sorter issue? Can you try using "enablement" instead of "triggerPoints"? And if that doesn't work, can you have both an enablement and triggerPoints section? I'm just curious as to whether the nav framework is looking at these two (enablement/triggerPoints) differently as far as the sorter goes.
Comment 4 Brian Fitzpatrick CLA 2006-10-03 11:45:50 EDT
Anthos, after digging into this more, I'm confused. Is it that you make a mix of framework and your nodes and they're always out of order? I've seen this with some Sybase profiles we're developing with the Catalogs folder being added after I add my own nodes beneath the Database object. Is something similar happening? Can you attach some screens? Or describe the behavior you're seeing?
Comment 5 Brian Fitzpatrick CLA 2006-10-03 14:04:35 EDT
Also, can you try adding the following to your sorter tag in the example you provided? I discovered the "parentExpression" tag for sorters and it may provide more clues into why the sorter isn't being triggered for the nodes you've mentioned.

            <commonSorter
                  class="oracle.dbtools.connectivity.ui.explorer.providers.Sorter"
                  id="oracle.dbtools.connectivity.ui.explorer.providers.ServerExplorerContentProvider">
               <parentExpression>
                     <instanceof value="org.eclipse.datatools.connectivity.sqm.core.internal.ui.explorer.virtual.IVirtualNode"/>
               </parentExpression>
            </commonSorter>
Comment 6 Anil Samuel CLA 2006-10-03 19:35:02 EDT
(In reply to comment #4)
> Anthos, after digging into this more, I'm confused. Is it that you make a mix
> of framework and your nodes and they're always out of order? I've seen this
> with some Sybase profiles we're developing with the Catalogs folder being added
> after I add my own nodes beneath the Database object. Is something similar
> happening? Can you attach some screens? Or describe the behavior you're seeing?
> 
What is the recommended way of doing this ?

Comment 7 Anil Samuel CLA 2006-10-03 19:37:53 EDT
(In reply to comment #5)
> Also, can you try adding the following to your sorter tag in the example you
> provided? I discovered the "parentExpression" tag for sorters and it may
> provide more clues into why the sorter isn't being triggered for the nodes
> you've mentioned.
> 
>             <commonSorter
>                  
> class="oracle.dbtools.connectivity.ui.explorer.providers.Sorter"
>                  
> id="oracle.dbtools.connectivity.ui.explorer.providers.ServerExplorerContentProvider">
>                <parentExpression>
>                      <instanceof
> value="org.eclipse.datatools.connectivity.sqm.core.internal.ui.explorer.virtual.IVirtualNode"/>
>                </parentExpression>
>             </commonSorter>
> 
I tried this; with this change the oracle.dbtools.connectivity.ui.explorer.providers.Sorter's compare method did NOT get called and all the elements were sorted alphabetically. See the screen shot attachments with and without the parentExpression element.
Comment 8 Anil Samuel CLA 2006-10-03 19:41:43 EDT
Created attachment 51390 [details]
DSE without parentExpression in the navigatorContent.commonSorter
Comment 9 Anil Samuel CLA 2006-10-03 19:42:22 EDT
Created attachment 51391 [details]
DSE with parentExpression in the navigatorContent.commonSorter
Comment 10 Brian Fitzpatrick CLA 2006-10-03 21:54:28 EDT
Yes. Unfortunately, that's pretty much what I've found to be the case also. At least we're getting the sorter to be triggered for our content with the parentElement piece in there. I will have to check a few more things with the navigator framework folks to see what we can do about this. It should be using one sorter per level in the tree I would think. But that doesn't seem to be the case, as evidenced by your screen shots. 

Looks like I have more digging to do. Thanks for the additional information. I just had to make sure we were both seeing the same behavior before I went back to the Platform folks.
Comment 11 Brian Fitzpatrick CLA 2006-10-04 12:32:00 EDT
Received some new information from the platform team:

"The sorting algorithm checks for the source of a given element; if the source of two elements is the same, then the contributing extension gets to order them (extension A contributes a, a', a'', ... then A's sorter is used to sort them), and uses the relative priority of the contributing extensions of two elements if they originated from different extensions (so extension A adds a, extension B adds b, then a and b are sorted based on the order of the priorities of A and B). If the priorities match, then the elements are sorted alphabetically by their labels. 

If the elements were viewer.add()ed to the tree, then the framework has no notion of source (it doesn't know what extension added them), so the "source" is determined from the possibleChildren expressions, taking the highest priority extension it finds that declares it might have contributed an element like the current one."

So, since the navigator framework is working as designed, we're going to have to come up with a slightly different approach to sorting items in the DSE. More information to come.

Anthos, I believe I can fix this issue for you pretty easily now that I understand it a bit better, but it's going to involve an API change (hopefully low impact) to the DSE for your profile. I'll have more details shortly.
Comment 12 Brian Fitzpatrick CLA 2006-10-04 15:22:16 EDT
Since we anticipate many different contributions to the DSE in the form of navigator content extensions, and we want those contributions to be consistently sorted when presented in the DSE, we need a slightly different solution to this problem.

What I propose is this... We override the default sorter in the DSE (which extends the CommonNavigator) to use our own custom sorter. We'll call it:

	org.eclipse.datatools.connectivity.ui.dse.DSESorter.java

This sorter will use the label provider for the view, which gets its labels from the various content extensions to the navigator. The sorter will use the ICU code to get a locale-specific collator and sort the entries appropriately.

I have tested this locally and it is a simple solution to this problem. 

Anthos, do you seeany issues with sorting everything in the DSE consistently? The only issue I can possibly see is where someone wants to override the sort order to do something other than a basic alphabetical sort. This simple solution to override the default sorter will not allow that sort of custom sorting to occur. 
Comment 13 Anil Samuel CLA 2006-10-09 19:16:14 EDT
the sorting of the DSE content MUST BE left to the content provider, thereby to the extension provider, since the provider may wish to have the view in some particular order that is consistent with their other products.
Comment 14 Brian Fitzpatrick CLA 2006-10-24 15:48:19 EDT
Still investigating with the Platform team.
Comment 15 Brian Fitzpatrick CLA 2006-10-25 18:44:51 EDT
Created platform bug 162330 for sorters in the navigator framework.
Comment 16 Rob Cernich CLA 2006-11-20 14:27:01 EST
Currently working with the platform team to see if this is a DTP issue or a navigator framework issue.
Comment 17 Rob Cernich CLA 2007-05-14 17:24:15 EDT
Still working with the platform team.  Moving off to Ganymede.
Comment 18 Brian Fitzpatrick CLA 2008-07-02 13:37:29 EDT
Hey Anil... Is this still an issue and something we should pursue with the platform team? 
Comment 19 Brian Payton CLA 2013-08-01 14:57:43 EDT
I'm going to assume this problem is fixed with platform Bug 121724.  You can reopen if the problem still exists.