01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jface.viewers;
11:
12: import java.text.Collator; // can't use ICU - Collator used in public API
13:
14: /**
15: * A viewer sorter is used by a {@link StructuredViewer} to reorder the elements
16: * provided by its content provider.
17: * <p>
18: * The default <code>compare</code> method compares elements using two steps.
19: * The first step uses the values returned from <code>category</code>.
20: * By default, all elements are in the same category.
21: * The second level is based on a case insensitive compare of the strings obtained
22: * from the content viewer's label provider via <code>ILabelProvider.getText</code>.
23: * </p>
24: * <p>
25: * Subclasses may implement the <code>isSorterProperty</code> method;
26: * they may reimplement the <code>category</code> method to provide
27: * categorization; and they may override the <code>compare</code> methods
28: * to provide a totally different way of sorting elements.
29: * </p>
30: * <p>
31: * It is recommended to use <code>ViewerComparator</code> instead.
32: * </p>
33: * @see IStructuredContentProvider
34: * @see StructuredViewer
35: */
36: public class ViewerSorter extends ViewerComparator {
37: /**
38: * The collator used to sort strings.
39: *
40: * @deprecated as of 3.3 Use {@link ViewerComparator#getComparator()}
41: */
42: protected Collator collator;
43:
44: /**
45: * Creates a new viewer sorter, which uses the default collator
46: * to sort strings.
47: */
48: public ViewerSorter() {
49: this (Collator.getInstance());
50: }
51:
52: /**
53: * Creates a new viewer sorter, which uses the given collator
54: * to sort strings.
55: *
56: * @param collator the collator to use to sort strings
57: */
58: public ViewerSorter(Collator collator) {
59: super (collator);
60: this .collator = collator;
61: }
62:
63: /**
64: * Returns the collator used to sort strings.
65: *
66: * @return the collator used to sort strings
67: * @deprecated as of 3.3 Use {@link ViewerComparator#getComparator()}
68: */
69: public Collator getCollator() {
70: return collator;
71: }
72:
73: }
|