Reputation: 69
I'd like to sort the rows of my TreeViewer
alphabetically, because every time I start the simulation, the rows of the tree are ordered randomly.
I found some methods to sort only by column with setSortColumn(TreeColumn column)
. Is there an easy way to sort the tree by rows?
Upvotes: 0
Views: 864
Reputation: 111216
Call the setComparator
method of the viewer to provide a class based on ViewerComparator
to sort the entries in your view.
If you just want to sort by the values of the labels returned by your label provider you can just use the base ViewComparator
class:
viewer.setComparator(new ViewerComparator());
If your want your sorting to be more complex use a class extending ViewerComparator
and override the sort
method (perhaps also category
).
Upvotes: 2