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.keys;
11:
12: import java.util.Comparator;
13:
14: import org.eclipse.ui.keys.ModifierKey;
15:
16: /**
17: * Compares modifier keys lexicographically by the name of the key.
18: *
19: * @since 3.0
20: */
21: public class AlphabeticModifierKeyComparator implements Comparator {
22:
23: /*
24: * (non-Javadoc)
25: *
26: * @see java.lang.Comparable#compareTo(java.lang.Object)
27: */
28: public int compare(Object left, Object right) {
29: ModifierKey modifierKeyLeft = (ModifierKey) left;
30: ModifierKey modifierKeyRight = (ModifierKey) right;
31: return modifierKeyLeft.toString().compareTo(
32: modifierKeyRight.toString());
33: }
34: }
|