KickJava   Java API By Example, From Geeks To Geeks.

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


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
16 import org.eclipse.ui.keys.Key;
17 import org.eclipse.ui.keys.KeySequence;
18 import org.eclipse.ui.keys.KeyStroke;
19
20 /**
21  * Formats the keys in the internal key sequence grammar. This is used for
22  * persistence, and is not really intended for display to the user.
23  *
24  * @since 3.0
25  */

26 public class FormalKeyFormatter extends AbstractKeyFormatter {
27
28     /**
29      * A comparator that guarantees that modifier keys will be sorted the same
30      * across different platforms.
31      */

32     private static final Comparator JavaDoc FORMAL_MODIFIER_KEY_COMPARATOR = new AlphabeticModifierKeyComparator();
33
34     /*
35      * (non-Javadoc)
36      *
37      * @see org.eclipse.ui.keys.KeyFormatter#format(org.eclipse.ui.keys.KeySequence)
38      */

39     public String JavaDoc format(Key key) {
40         return key.toString();
41     }
42
43     /*
44      * (non-Javadoc)
45      *
46      * @see org.eclipse.ui.keys.AbstractKeyFormatter#getKeyDelimiter()
47      */

48     protected String JavaDoc getKeyDelimiter() {
49         return KeyStroke.KEY_DELIMITER;
50     }
51
52     /*
53      * (non-Javadoc)
54      *
55      * @see org.eclipse.ui.keys.AbstractKeyFormatter#getKeyStrokeDelimiter()
56      */

57     protected String JavaDoc getKeyStrokeDelimiter() {
58         return KeySequence.KEY_STROKE_DELIMITER;
59     }
60
61     /*
62      * (non-Javadoc)
63      *
64      * @see org.eclipse.ui.keys.AbstractKeyFormatter#getModifierKeyComparator()
65      */

66     protected Comparator JavaDoc getModifierKeyComparator() {
67         return FORMAL_MODIFIER_KEY_COMPARATOR;
68     }
69
70 }
71
Popular Tags