Mercurial > projects > dwt2
comparison org.eclipse.jface/src/org/eclipse/jface/bindings/keys/formatting/FormalKeyFormatter.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2004, 2005 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 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 | |
14 module org.eclipse.jface.bindings.keys.formatting.FormalKeyFormatter; | |
15 | |
16 import org.eclipse.jface.bindings.keys.formatting.AbstractKeyFormatter; | |
17 | |
18 import org.eclipse.jface.bindings.keys.IKeyLookup; | |
19 import org.eclipse.jface.bindings.keys.KeyLookupFactory; | |
20 import org.eclipse.jface.bindings.keys.KeySequence; | |
21 import org.eclipse.jface.bindings.keys.KeyStroke; | |
22 | |
23 import java.lang.all; | |
24 | |
25 /** | |
26 * <p> | |
27 * Formats the keys in the internal key sequence grammar. This is used for | |
28 * persistence, and is not really intended for display to the user. | |
29 * </p> | |
30 * | |
31 * @since 3.1 | |
32 */ | |
33 public final class FormalKeyFormatter : AbstractKeyFormatter { | |
34 alias AbstractKeyFormatter.format format; | |
35 | |
36 /* | |
37 * (non-Javadoc) | |
38 * | |
39 * @see org.eclipse.jface.bindings.keys.KeyFormatter#format(org.eclipse.ui.keys.KeySequence) | |
40 */ | |
41 public override String format(int key) { | |
42 IKeyLookup lookup = KeyLookupFactory.getDefault(); | |
43 return lookup.formalNameLookup(key); | |
44 } | |
45 | |
46 /* | |
47 * (non-Javadoc) | |
48 * | |
49 * @see org.eclipse.jface.bindings.keys.AbstractKeyFormatter#getKeyDelimiter() | |
50 */ | |
51 protected override String getKeyDelimiter() { | |
52 return KeyStroke.KEY_DELIMITER; | |
53 } | |
54 | |
55 /* | |
56 * (non-Javadoc) | |
57 * | |
58 * @see org.eclipse.jface.bindings.keys.AbstractKeyFormatter#getKeyStrokeDelimiter() | |
59 */ | |
60 protected override String getKeyStrokeDelimiter() { | |
61 return KeySequence.KEY_STROKE_DELIMITER; | |
62 } | |
63 | |
64 /* | |
65 * (non-Javadoc) | |
66 * | |
67 * @see org.eclipse.jface.bindings.keys.AbstractKeyFormatter#sortModifierKeys(int) | |
68 */ | |
69 protected override int[] sortModifierKeys(int modifierKeys) { | |
70 IKeyLookup lookup = KeyLookupFactory.getDefault(); | |
71 int[] sortedKeys = new int[4]; | |
72 int index = 0; | |
73 | |
74 if ((modifierKeys & lookup.getAlt()) !is 0) { | |
75 sortedKeys[index++] = lookup.getAlt(); | |
76 } | |
77 if ((modifierKeys & lookup.getCommand()) !is 0) { | |
78 sortedKeys[index++] = lookup.getCommand(); | |
79 } | |
80 if ((modifierKeys & lookup.getCtrl()) !is 0) { | |
81 sortedKeys[index++] = lookup.getCtrl(); | |
82 } | |
83 if ((modifierKeys & lookup.getShift()) !is 0) { | |
84 sortedKeys[index++] = lookup.getShift(); | |
85 } | |
86 | |
87 return sortedKeys; | |
88 } | |
89 } |