Jump to: navigation, search

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

 
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Structured viewers are sorted by plugging in an instance of
+
Structured viewers are sorted by plugging in an instance of <tt>ViewerSorter</tt>, using the <tt>StructuredViewer.setSorter</tt> method.  For simple sorting based on label text, use the generic <tt>ViewerSorter</tt> class itself, optionally supplying  a <tt>java.text.Collator</tt> instance to define how strings are compared.  For more complex  comparisons, you&#146;ll need to subclass <tt>ViewerSorter</tt>. You can override  the <tt>category</tt> 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 <tt>compare</tt> method, which acts much like the standard  <tt>java.util. Comparator</tt> interface.
<tt>ViewerSorter</tt>, using the <tt>StructuredViewer.setSorter</tt> method.  For simple sorting based
+
on label text, use the generic <tt>ViewerSorter</tt> class itself, optionally supplying
+
  a <tt>java.text.Collator</tt> instance to define how strings are compared.  For more complex
+
  comparisons, you&#146;ll need to subclass <tt>ViewerSorter</tt>. You can override
+
  the <tt>category</tt> 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 <tt>compare</tt> method, which acts much like the standard
+
  <tt>java.util. Comparator</tt> interface.
+
 
   
 
   
 
 
 
 
 
 
== See Also: ==
 
== See Also: ==
 +
*[[FAQ What is a viewer?]]
 +
*[[FAQ How do I use properties to optimize a viewer?]]
  
 
+
{{Template:FAQ_Tagline}}
[[FAQ_What_is_a_viewer%3F]]
+
 
+
 
+
[[FAQ_How_do_I_use_properties_to_optimize_a_viewer%3F]]
+
 
+
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
+

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.

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.