Difference between revisions of "FAQ How do I sort the contents of a viewer?"

From Eclipsepedia

Jump to: navigation, search
m
m
 
Line 2: Line 2:
 
   
 
   
 
== See Also: ==
 
== See Also: ==
[[FAQ What is a viewer?]]
+
*[[FAQ What is a viewer?]]
[[FAQ How do I use properties to optimize a viewer?]]
+
*[[FAQ How do I use properties to optimize a viewer?]]
  
 
{{Template:FAQ_Tagline}}
 
{{Template:FAQ_Tagline}}

Latest revision as of 21:44, 29 May 2006

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.

[edit] See Also:


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.