01: /*******************************************************************************
02: * Copyright (c) 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.ui.model;
11:
12: import java.util.Comparator;
13:
14: import org.eclipse.jface.viewers.IBasicPropertyConstants;
15: import org.eclipse.jface.viewers.ViewerComparator;
16:
17: /**
18: *
19: * A viewer comparator that sorts elements with registered workbench adapters by
20: * their text property. Note that capitalization differences are not considered
21: * by this sorter, so a > B > c
22: *
23: * @see IWorkbenchAdapter
24: * @since 3.3
25: */
26: public class WorkbenchViewerComparator extends ViewerComparator {
27:
28: /**
29: * Creates a workbench viewer sorter using the default collator.
30: */
31: public WorkbenchViewerComparator() {
32: super ();
33: }
34:
35: /**
36: * Creates a workbench viewer sorter using the given collator.
37: *
38: * @param comparator the comparator to use to sort strings
39: */
40: public WorkbenchViewerComparator(Comparator comparator) {
41: super (comparator);
42: }
43:
44: /* (non-Javadoc)
45: * Method declared on ViewerComparator.
46: */
47: public boolean isSorterProperty(Object element, String propertyId) {
48: return propertyId.equals(IBasicPropertyConstants.P_TEXT);
49: }
50: }
|