How to change default sorting of ElementListSelectionDialog [message #1773243] |
Mon, 25 September 2017 10:17 |
Suresh P Messages: 27 Registered: May 2013 |
Junior Member |
|
|
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 13:10 |
Eclipse User |
|
|
|
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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03510 seconds