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.ui.internal.dialogs;
11:
12: import org.eclipse.jface.viewers.IBasicPropertyConstants;
13: import org.eclipse.jface.viewers.ViewerComparator;
14: import org.eclipse.ui.internal.registry.WizardsRegistryReader;
15:
16: /**
17: * A Viewer element sorter that sorts Elements by their name attribute.
18: * Note that capitalization differences are not considered by this
19: * sorter, so a < B < c.
20: *
21: * NOTE exceptions to the above: an element with the system's reserved
22: * category for Other Wizards will always be sorted such that it will
23: * ultimately be placed at the end of the sorted result, and an elemen
24: * with the reserved category name for General wizards will always be
25: * placed at the beginning of the sorted result.
26: *
27: * @since 3.2
28: */
29: class DataTransferWizardCollectionComparator extends ViewerComparator {
30: /**
31: * Static instance of this class.
32: */
33: public final static DataTransferWizardCollectionComparator INSTANCE = new DataTransferWizardCollectionComparator();
34:
35: /**
36: * Creates an instance of <code>DataTransferWizardCollectionSorter</code>. Since this
37: * is a stateless sorter, it is only accessible as a singleton; the private
38: * visibility of this constructor ensures this.
39: */
40: private DataTransferWizardCollectionComparator() {
41: super ();
42: }
43:
44: public int category(Object element) {
45: if (element instanceof WizardCollectionElement) {
46: String id = ((WizardCollectionElement) element).getId();
47: if (WizardsRegistryReader.GENERAL_WIZARD_CATEGORY
48: .equals(id)) {
49: return 1;
50: }
51: if (WizardsRegistryReader.UNCATEGORIZED_WIZARD_CATEGORY
52: .equals(id)) {
53: return 3;
54: }
55: return 2;
56: }
57: return super .category(element);
58: }
59:
60: /**
61: * Return true if this sorter is affected by a property
62: * change of propertyName on the specified element.
63: */
64: public boolean isSorterProperty(Object object, String propertyId) {
65: return propertyId.equals(IBasicPropertyConstants.P_TEXT);
66: }
67: }
|