FAQ How do I sort the contents of a viewer?

From Eclipsepedia

Revision as of 16:19, 14 March 2006 by Claffra (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Structured viewers are sorted by plugging in an instance of ViewerSorter, using the StructuredViewer.setSorter method. For simple sorting based on label text, use the generic ViewerSorter class itself, optionally supplying

a java.text.Collator instance to define how strings are compared.  For more complex
comparisons, you’ll need to subclass ViewerSorter. You can override
the category method to divide the elements up into an ordered set of categories,

leaving the text collator to sort the elements within each category. For complete customization

of sorting, override the compare method, which acts much like the standard
java.util. Comparator interface.



See Also:

FAQ_What_is_a_viewer?


FAQ_How_do_I_use_properties_to_optimize_a_viewer?


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.