KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others. All rights reserved.
3  * This program and the accompanying materials are made available under the
4  * terms of the Common Public License v1.0 which accompanies this distribution,
5  * and is available at http://www.eclipse.org/legal/cpl-v10.html
6  *
7  * Contributors: IBM Corporation - initial API and implementation
8  ******************************************************************************/

9
10 package org.eclipse.ui.internal.keys;
11
12 import java.util.Comparator JavaDoc;
13 import java.util.ResourceBundle JavaDoc;
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 WindowsKeyFormatter extends AbstractKeyFormatter {
21
22     private final static class WindowsModifierKeyComparator
23         extends AbstractModifierKeyComparator {
24
25         protected int rank(ModifierKey modifierKey) {
26             if (ModifierKey.CTRL.equals(modifierKey)) {
27                 return 0;
28             }
29
30             if (ModifierKey.ALT.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 JavaDoc MODIFIER_KEY_COMPARATOR =
43         new WindowsModifierKeyComparator();
44     private final static ResourceBundle JavaDoc RESOURCE_BUNDLE =
45         ResourceBundle.getBundle(WindowsKeyFormatter.class.getName());
46
47     protected String JavaDoc getKeyDelimiter() {
48         return Util.translateString(
49             RESOURCE_BUNDLE,
50             KEY_DELIMITER_KEY,
51             KeyStroke.KEY_DELIMITER,
52             false,
53             false);
54     }
55
56     protected String JavaDoc getKeyStrokeDelimiter() {
57         return Util.translateString(
58             RESOURCE_BUNDLE,
59             KEY_STROKE_DELIMITER_KEY,
60             KeySequence.KEY_STROKE_DELIMITER,
61             false,
62             false);
63     }
64
65     protected Comparator JavaDoc getModifierKeyComparator() {
66         return MODIFIER_KEY_COMPARATOR;
67     }
68 }
69
Popular Tags