KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > keys > KdeKeyFormatter


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