Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

FAQ How do I sort the contents of a viewer?

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

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.

Copyright © Eclipse Foundation, Inc. All Rights Reserved.