KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > dialogs > ActionSetComparator


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.ui.internal.dialogs;
12
13 import org.eclipse.jface.viewers.Viewer;
14 import org.eclipse.jface.viewers.ViewerComparator;
15 import org.eclipse.ui.internal.registry.IActionSetDescriptor;
16
17 /**
18  * This is used to sort action sets in the perspective customization dialog.
19  */

20 public class ActionSetComparator extends ViewerComparator {
21
22     /**
23      * Creates a new sorter.
24      */

25     public ActionSetComparator() {
26     }
27
28     /**
29      * Returns a negative, zero, or positive number depending on whether
30      * the first element is less than, equal to, or greater than
31      * the second element.
32      */

33     public int compare(Viewer viewer, Object JavaDoc e1, Object JavaDoc e2) {
34         if (e1 instanceof IActionSetDescriptor) {
35             String JavaDoc str1 = DialogUtil.removeAccel(((IActionSetDescriptor) e1)
36                     .getLabel());
37             String JavaDoc str2 = DialogUtil.removeAccel(((IActionSetDescriptor) e2)
38                     .getLabel());
39             return getComparator().compare(str1, str2);
40         }
41         return 0;
42     }
43 }
44
Popular Tags