Skip to main content



      Home
Home » Eclipse Projects » JFace » How to change default sorting of ElementListSelectionDialog(How to change default sorting of ElementListSelectionDialog?)
How to change default sorting of ElementListSelectionDialog [message #1773243] Mon, 25 September 2017 06:17 Go to next message
Eclipse UserFriend
HI,

Im using Eclipse Oxygen for my custom plugin development.

Im using a SWT Dialog - ElementListSelectionDialog, to display the list of items.

My requirement is to retain the order of Items to be displayed in same order as specified in "setElements()" method. But when the Dialog is displayed, it always list the items in Alphabetical Order.

How to change this sorting order of the listed items in the dialog?

               ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new LabelProvider());
		dialog.setTitle("Select SCM Provider");
		dialog.setMessage("Select the SCM Provider for this project");
		Object[] unsortedList = new Object[] {  "GitHub", "RTC", "SVN","Others" };		
		dialog.setElements(unsortedList);
                dialog.open();


For above code, the Dialog always displays the items in Alphabetical order (ie., GitHub, Others, RTC, SVN).

I need to keep the "Others" item as last item in the Dialog, but it is always displayed as second element.


Regards
Suresh
Re: How to change default sorting of ElementListSelectionDialog [message #1773248 is a reply to message #1773243] Mon, 25 September 2017 09:10 Go to previous messageGo to next message
Eclipse UserFriend
Unfortunately the dialog is hardwired to sorting alphabetically. The dialog is an subclass of `AbstractElementListSelectionDialog` which uses a `FilteredList` to implement the list. `FilteredList` configures a sorter that uses a `LabelComparator`. There is an open bug requesting the capability of adding a sorter. But the bug points to using `FilteredItemsSelectionDialog ` instead, which is far more capable.
Re: How to change default sorting of ElementListSelectionDialog [message #1773287 is a reply to message #1773248] Tue, 26 September 2017 01:26 Go to previous message
Eclipse UserFriend
Thanks Brain for the quick response.

If possible, Can you share sample code snippet using 'FilteredItemsSelectionDialog' for listing the 4 items in the above code snippet.

The examples I can find in internet for using 'FilteredItemsSelectionDialog', are mostly referring to Resources/Files or using different sub-classes of this class.

Regards
Suresh
Previous Topic:adding wizardPages and get the result dynamically
Next Topic:How to remove the default the Filter Text Box from ElementListSelectionDialog
Goto Forum:
  


Current Time: Sun Jul 13 19:32:48 EDT 2025

Powered by FUDForum. Page generated in 0.06067 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top