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.Viewer;
13: import org.eclipse.jface.viewers.ViewerComparator;
14: import org.eclipse.ui.internal.registry.IActionSetDescriptor;
15:
16: /**
17: * This is used to sort action sets in the perspective customization dialog.
18: */
19: public class ActionSetComparator extends ViewerComparator {
20:
21: /**
22: * Creates a new sorter.
23: */
24: public ActionSetComparator() {
25: }
26:
27: /**
28: * Returns a negative, zero, or positive number depending on whether
29: * the first element is less than, equal to, or greater than
30: * the second element.
31: */
32: public int compare(Viewer viewer, Object e1, Object e2) {
33: if (e1 instanceof IActionSetDescriptor) {
34: String str1 = DialogUtil
35: .removeAccel(((IActionSetDescriptor) e1).getLabel());
36: String str2 = DialogUtil
37: .removeAccel(((IActionSetDescriptor) e2).getLabel());
38: return getComparator().compare(str1, str2);
39: }
40: return 0;
41: }
42: }
|