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.Key;
15: import org.eclipse.ui.keys.KeySequence;
16: import org.eclipse.ui.keys.KeyStroke;
17:
18: /**
19: * Formats the keys in the internal key sequence grammar. This is used for
20: * persistence, and is not really intended for display to the user.
21: *
22: * @since 3.0
23: */
24: public class FormalKeyFormatter extends AbstractKeyFormatter {
25:
26: /**
27: * A comparator that guarantees that modifier keys will be sorted the same
28: * across different platforms.
29: */
30: private static final Comparator FORMAL_MODIFIER_KEY_COMPARATOR = new AlphabeticModifierKeyComparator();
31:
32: /*
33: * (non-Javadoc)
34: *
35: * @see org.eclipse.ui.keys.KeyFormatter#format(org.eclipse.ui.keys.KeySequence)
36: */
37: public String format(Key key) {
38: return key.toString();
39: }
40:
41: /*
42: * (non-Javadoc)
43: *
44: * @see org.eclipse.ui.keys.AbstractKeyFormatter#getKeyDelimiter()
45: */
46: protected String getKeyDelimiter() {
47: return KeyStroke.KEY_DELIMITER;
48: }
49:
50: /*
51: * (non-Javadoc)
52: *
53: * @see org.eclipse.ui.keys.AbstractKeyFormatter#getKeyStrokeDelimiter()
54: */
55: protected String getKeyStrokeDelimiter() {
56: return KeySequence.KEY_STROKE_DELIMITER;
57: }
58:
59: /*
60: * (non-Javadoc)
61: *
62: * @see org.eclipse.ui.keys.AbstractKeyFormatter#getModifierKeyComparator()
63: */
64: protected Comparator getModifierKeyComparator() {
65: return FORMAL_MODIFIER_KEY_COMPARATOR;
66: }
67:
68: }
|