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: import java.util.ResourceBundle;
14:
15: import org.eclipse.ui.internal.util.Util;
16: import org.eclipse.ui.keys.KeySequence;
17: import org.eclipse.ui.keys.KeyStroke;
18: import org.eclipse.ui.keys.ModifierKey;
19:
20: public final class KdeKeyFormatter extends AbstractKeyFormatter {
21:
22: private final static class KdeModifierKeyComparator extends
23: AbstractModifierKeyComparator {
24:
25: protected int rank(ModifierKey modifierKey) {
26: if (ModifierKey.ALT.equals(modifierKey)) {
27: return 0;
28: }
29:
30: if (ModifierKey.CTRL.equals(modifierKey)) {
31: return 1;
32: }
33:
34: if (ModifierKey.SHIFT.equals(modifierKey)) {
35: return 2;
36: }
37:
38: return Integer.MAX_VALUE;
39: }
40: }
41:
42: private final static Comparator MODIFIER_KEY_COMPARATOR = new KdeModifierKeyComparator();
43:
44: private final static ResourceBundle RESOURCE_BUNDLE = ResourceBundle
45: .getBundle(KdeKeyFormatter.class.getName());
46:
47: protected String getKeyDelimiter() {
48: return Util.translateString(RESOURCE_BUNDLE, KEY_DELIMITER_KEY,
49: KeyStroke.KEY_DELIMITER, false, false);
50: }
51:
52: protected String getKeyStrokeDelimiter() {
53: return Util.translateString(RESOURCE_BUNDLE,
54: KEY_STROKE_DELIMITER_KEY,
55: KeySequence.KEY_STROKE_DELIMITER, false, false);
56: }
57:
58: protected Comparator getModifierKeyComparator() {
59: return MODIFIER_KEY_COMPARATOR;
60: }
61: }
|