KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > viewers > ViewerSorter


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jface.viewers;
12
13 import java.text.Collator JavaDoc; // can't use ICU - Collator used in public API
14

15 /**
16  * A viewer sorter is used by a {@link StructuredViewer} to reorder the elements
17  * provided by its content provider.
18  * <p>
19  * The default <code>compare</code> method compares elements using two steps.
20  * The first step uses the values returned from <code>category</code>.
21  * By default, all elements are in the same category.
22  * The second level is based on a case insensitive compare of the strings obtained
23  * from the content viewer's label provider via <code>ILabelProvider.getText</code>.
24  * </p>
25  * <p>
26  * Subclasses may implement the <code>isSorterProperty</code> method;
27  * they may reimplement the <code>category</code> method to provide
28  * categorization; and they may override the <code>compare</code> methods
29  * to provide a totally different way of sorting elements.
30  * </p>
31  * <p>
32  * It is recommended to use <code>ViewerComparator</code> instead.
33  * </p>
34  * @see IStructuredContentProvider
35  * @see StructuredViewer
36  */

37 public class ViewerSorter extends ViewerComparator {
38     /**
39      * The collator used to sort strings.
40      *
41      * @deprecated as of 3.3 Use {@link ViewerComparator#getComparator()}
42      */

43     protected Collator JavaDoc collator;
44
45     /**
46      * Creates a new viewer sorter, which uses the default collator
47      * to sort strings.
48      */

49     public ViewerSorter() {
50         this(Collator.getInstance());
51     }
52
53     /**
54      * Creates a new viewer sorter, which uses the given collator
55      * to sort strings.
56      *
57      * @param collator the collator to use to sort strings
58      */

59     public ViewerSorter(Collator JavaDoc collator) {
60         super(collator);
61         this.collator = collator;
62     }
63
64     /**
65      * Returns the collator used to sort strings.
66      *
67      * @return the collator used to sort strings
68      * @deprecated as of 3.3 Use {@link ViewerComparator#getComparator()}
69      */

70     public Collator JavaDoc getCollator() {
71         return collator;
72     }
73
74 }
75
Popular Tags