Time for action – sorting items in a viewer
The TreeViewer
already shows data in a sorted list, but this is not a view-imposed sort. Because the data is stored in a TreeMap
, the sort ordering is created by the TreeMap
itself, which in turn is sorting on the value of the toString
method. To use a different ordering (say, based on the timezone offset) the choices are either to modify the TreeMap
to add a Comparator
and sort the data at creation time, or add a sorter to the TreeViewer
. The first choice is applicable if the data is only used by a single view, or if the data is coming from a large external data store which can perform the sorting more efficiently (such as a relational database). For smaller data sets, the sorting can be done in the ...
Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.