KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > ui > JavaElementSorter


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.jdt.ui;
12
13 import org.eclipse.jface.viewers.Viewer;
14 import org.eclipse.jface.viewers.ViewerSorter;
15
16
17 /**
18  * Sorter for Java elements. Ordered by element category, then by element name.
19  * Package fragment roots are sorted as ordered on the classpath.
20  *
21  * <p>
22  * This class may be instantiated; it is not intended to be subclassed.
23  * </p>
24  *
25  * @deprecated use {@link JavaElementComparator} instead.
26  * @since 2.0
27  */

28 public class JavaElementSorter extends ViewerSorter {
29     
30     private final JavaElementComparator fComparator;
31     
32     /**
33      * Constructor.
34      */

35     public JavaElementSorter() {
36         super(null); // delay initialization of collator
37
fComparator= new JavaElementComparator();
38     }
39         
40     /**
41      * @deprecated Bug 22518. Method never used: does not override ViewerSorter#isSorterProperty(Object, String).
42      * Method could be removed, but kept for API compatibility.
43      *
44      * @param element the element
45      * @param property the property
46      * @return always <code>true</code>
47      */

48     public boolean isSorterProperty(Object JavaDoc element, Object JavaDoc property) {
49         return true;
50     }
51
52     /*
53      * @see ViewerSorter#category
54      */

55     public int category(Object JavaDoc element) {
56         return fComparator.category(element);
57     }
58     
59     /*
60      * @see ViewerSorter#compare
61      */

62     public int compare(Viewer viewer, Object JavaDoc e1, Object JavaDoc e2) {
63         return fComparator.compare(viewer, e1, e2);
64     }
65     
66     /**
67      * Overrides {@link org.eclipse.jface.viewers.ViewerSorter#getCollator()}.
68      * @deprecated The method is not intended to be used by clients.
69      */

70     public final java.text.Collator JavaDoc getCollator() {
71         // kept in for API compatibility
72
if (collator == null) {
73             collator= java.text.Collator.getInstance();
74         }
75         return collator;
76     }
77 }
78
Popular Tags