Mercurial > projects > dwt-addons
annotate dwtx/jface/action/LegacyActionTools.d @ 104:04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 15:01:33 +0200 |
parents | da5ad8eedf5d |
children |
rev | line source |
---|---|
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1 /******************************************************************************* |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2 * Copyright (c) 2005, 2006 IBM Corporation and others. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3 * All rights reserved. This program and the accompanying materials |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
5 * which accompanies this distribution, and is available at |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
6 * http://www.eclipse.org/legal/epl-v10.html |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
7 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
8 * Contributors: |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
9 * IBM Corporation - initial API and implementation |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
10 * Port to the D programming language: |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
11 * Frank Benoit <benoit@tionex.de> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
12 *******************************************************************************/ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
13 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
14 module dwtx.jface.action.LegacyActionTools; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
15 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
16 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
17 import dwt.DWT; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
18 import dwtx.jface.resource.JFaceResources; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
19 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
20 import dwt.dwthelper.utils; |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
21 import dwtx.dwtxhelper.Collection; |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
22 static import tango.text.Text; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
23 alias tango.text.Text.Text!(char) StringBuffer; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
24 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
25 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
26 * <p> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
27 * Some static utility methods for handling labels on actions. This includes |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
28 * mnemonics and accelerators. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
29 * </p> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
30 * <p> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
31 * Clients may neither instantiate this class nor extend. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
32 * </p> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
33 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
34 * @since 3.2 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
35 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
36 public final class LegacyActionTools { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
37 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
38 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
39 * Table of key codes (key type: <code>String</code>, value type: |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
40 * <code>Integer</code>); <code>null</code> if not yet initialized. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
41 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
42 * @see #findKeyCode |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
43 */ |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
44 private static Map keyCodes = null; |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
45 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
46 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
47 * Table of string representations of keys (key type: <code>Integer</code>, |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
48 * value type: <code>String</code>); <code>null</code>> if not yet |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
49 * initialized. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
50 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
51 * @see #findKeyString |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
52 */ |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
53 private static Map keyStrings = null; |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
54 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
55 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
56 * The localized uppercase version of ALT |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
57 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
58 private static String localizedAlt; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
59 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
60 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
61 * The localized uppercase version of COMMAND |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
62 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
63 private static String localizedCommand; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
64 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
65 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
66 * The localized uppercase version of CTRL |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
67 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
68 private static String localizedCtrl; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
69 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
70 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
71 * Table of key codes (key type: <code>String</code>, value type: |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
72 * <code>Integer</code>); <code>null</code> if not yet initialized. The |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
73 * key is the localalized name of the key as it appears in menus. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
74 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
75 * @see #findLocalizedKeyCode |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
76 */ |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
77 private static Map localizedKeyCodes = null; |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
78 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
79 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
80 * The localized uppercase version of SHIFT |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
81 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
82 private static String localizedShift; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
83 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
84 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
85 * The constant to use if there is no mnemonic for this location. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
86 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
87 public static const char MNEMONIC_NONE = 0; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
88 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
89 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
90 * Converts an accelerator key code to a string representation. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
91 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
92 * @param keyCode |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
93 * the key code to be translated |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
94 * @return a string representation of the key code |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
95 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
96 public static final String convertAccelerator(int keyCode) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
97 String modifier = getModifierString(keyCode); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
98 String fullKey; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
99 if (modifier.equals("")) { //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
100 fullKey = findKeyString(keyCode); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
101 } else { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
102 fullKey = modifier ~ "+" ~ findKeyString(keyCode); //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
103 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
104 return fullKey; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
105 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
106 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
107 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
108 * Parses the given accelerator text, and converts it to an accelerator key |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
109 * code. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
110 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
111 * @param acceleratorText |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
112 * the accelerator text |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
113 * @return the DWT key code, or 0 if there is no accelerator |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
114 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
115 public static final int convertAccelerator(String acceleratorText) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
116 int accelerator = 0; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
117 auto tokens = tango.text.Util.delimit( acceleratorText, "+" ); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
118 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
119 int keyCode = -1; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
120 foreach( idx, token; tokens ){ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
121 // bool hasMoreTokens = stok.hasMoreTokens(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
122 // while (hasMoreTokens) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
123 // String token = stok.nextToken(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
124 // bool hasMoreTokens = idx+1 < tokens.length;//stok.hasMoreTokens(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
125 // Every token except the last must be one of the modifiers |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
126 // Ctrl, Shift, Alt, or Command |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
127 if (idx+1 < tokens.length) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
128 int modifier = findModifier(token); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
129 if (modifier !is 0) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
130 accelerator |= modifier; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
131 } else { // Leave if there are none |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
132 return 0; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
133 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
134 } else { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
135 keyCode = findKeyCode(token); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
136 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
137 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
138 if (keyCode !is -1) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
139 accelerator |= keyCode; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
140 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
141 return accelerator; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
142 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
143 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
144 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
145 * Parses the given accelerator text, and converts it to an accelerator key |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
146 * code. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
147 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
148 * Support for localized modifiers is for backwards compatibility with 1.0. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
149 * Use setAccelerator(int) to set accelerators programatically or the |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
150 * <code>accelerator</code> tag in action definitions in plugin.xml. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
151 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
152 * @param acceleratorText |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
153 * the accelerator text localized to the current locale |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
154 * @return the DWT key code, or 0 if there is no accelerator |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
155 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
156 static final int convertLocalizedAccelerator(String acceleratorText) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
157 int accelerator = 0; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
158 auto tokens = tango.text.Util.delimit( acceleratorText, "+" ); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
159 // StringTokenizer stok = new StringTokenizer(acceleratorText, "+"); //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
160 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
161 int keyCode = -1; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
162 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
163 foreach( idx, token; tokens ){ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
164 // bool hasMoreTokens = stok.hasMoreTokens(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
165 // while (hasMoreTokens) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
166 // String token = stok.nextToken(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
167 // hasMoreTokens = stok.hasMoreTokens(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
168 // Every token except the last must be one of the modifiers |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
169 // Ctrl, Shift, Alt, or Command |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
170 if (idx+1 < tokens.length) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
171 int modifier = findLocalizedModifier(token); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
172 if (modifier !is 0) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
173 accelerator |= modifier; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
174 } else { // Leave if there are none |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
175 return 0; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
176 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
177 } else { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
178 keyCode = findLocalizedKeyCode(token); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
179 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
180 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
181 if (keyCode !is -1) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
182 accelerator |= keyCode; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
183 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
184 return accelerator; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
185 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
186 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
187 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
188 * Extracts the accelerator text from the given text. Returns |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
189 * <code>null</code> if there is no accelerator text, and the empty string |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
190 * if there is no text after the accelerator delimeter (tab or '@'). |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
191 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
192 * @param text |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
193 * the text for the action; may be <code>null</code>. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
194 * @return the accelerator text, or <code>null</code> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
195 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
196 public static final String extractAcceleratorText(String text) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
197 if (text is null) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
198 return null; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
199 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
200 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
201 int index = text.lastIndexOf('\t'); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
202 if (index is -1) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
203 index = text.lastIndexOf('@'); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
204 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
205 if (index >= 0) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
206 return text.substring(index + 1); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
207 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
208 return null; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
209 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
210 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
211 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
212 * Extracts the mnemonic text from the given string. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
213 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
214 * @param text |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
215 * The text from which the mnemonic should be extracted; may be |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
216 * <code>null</code> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
217 * @return The text of the mnemonic; will be {@link #MNEMONIC_NONE} if there |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
218 * is no mnemonic; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
219 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
220 public static final char extractMnemonic(String text) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
221 if (text is null) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
222 return MNEMONIC_NONE; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
223 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
224 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
225 int index = text.indexOf('&'); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
226 if (index is -1) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
227 return MNEMONIC_NONE; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
228 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
229 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
230 int textLength = text.length; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
231 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
232 // Ignore '&' at the end of the string. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
233 if (index is textLength - 1) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
234 return MNEMONIC_NONE; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
235 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
236 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
237 // Ignore two consecutive ampersands. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
238 while (text.charAt(index + 1) is '&') { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
239 index = text.indexOf('&', ++index); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
240 if (index is textLength - 1) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
241 return MNEMONIC_NONE; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
242 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
243 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
244 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
245 return text.charAt(index + 1); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
246 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
247 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
248 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
249 * Maps a standard keyboard key name to an DWT key code. Key names are |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
250 * converted to upper case before comparison. If the key name is a single |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
251 * letter, for example "S", its character code is returned. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
252 * <p> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
253 * The following key names are known (case is ignored): |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
254 * <ul> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
255 * <li><code>"BACKSPACE"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
256 * <li><code>"TAB"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
257 * <li><code>"RETURN"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
258 * <li><code>"ENTER"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
259 * <li><code>"ESC"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
260 * <li><code>"ESCAPE"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
261 * <li><code>"DELETE"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
262 * <li><code>"SPACE"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
263 * <li><code>"ARROW_UP"</code>, <code>"ARROW_DOWN"</code>, |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
264 * <code>"ARROW_LEFT"</code>, and <code>"ARROW_RIGHT"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
265 * <li><code>"PAGE_UP"</code> and <code>"PAGE_DOWN"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
266 * <li><code>"HOME"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
267 * <li><code>"END"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
268 * <li><code>"INSERT"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
269 * <li><code>"F1"</code>, <code>"F2"</code> through <code>"F12"</code></li> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
270 * </ul> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
271 * </p> |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
272 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
273 * @param token |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
274 * the key name |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
275 * @return the DWT key code, <code>-1</code> if no match was found |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
276 * @see DWT |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
277 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
278 public static final int findKeyCode(String token) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
279 if (keyCodes is null) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
280 initKeyCodes(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
281 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
282 token = token.toUpperCase(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
283 Integer i = cast(Integer) keyCodes.get(token); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
284 if (i !is null) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
285 return i.intValue(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
286 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
287 if (token.length is 1) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
288 return token.charAt(0); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
289 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
290 return -1; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
291 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
292 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
293 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
294 * Maps an DWT key code to a standard keyboard key name. The key code is |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
295 * stripped of modifiers (DWT.CTRL, DWT.ALT, DWT.SHIFT, and DWT.COMMAND). If |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
296 * the key code is not an DWT code (for example if it a key code for the key |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
297 * 'S'), a string containing a character representation of the key code is |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
298 * returned. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
299 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
300 * @param keyCode |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
301 * the key code to be translated |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
302 * @return the string representation of the key code |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
303 * @see DWT |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
304 * @since 2.0 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
305 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
306 public static final String findKeyString( int keyCode) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
307 if (keyStrings is null) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
308 initKeyStrings(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
309 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
310 int i = keyCode & ~(DWT.CTRL | DWT.ALT | DWT.SHIFT | DWT.COMMAND); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
311 Integer integer = new Integer(i); |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
312 String result = stringcast(keyStrings.get(integer)); |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
313 if (result !is null) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
314 return result; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
315 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
316 result = dcharToString( cast(dchar) i ); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
317 return result; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
318 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
319 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
320 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
321 * Find the supplied code for a localized key. As #findKeyCode but localized |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
322 * to the current locale. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
323 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
324 * Support for localized modifiers is for backwards compatibility with 1.0. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
325 * Use setAccelerator(int) to set accelerators programatically or the |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
326 * <code>accelerator</code> tag in action definitions in plugin.xml. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
327 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
328 * @param token |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
329 * the localized key name |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
330 * @return the DWT key code, <code>-1</code> if no match was found |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
331 * @see #findKeyCode |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
332 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
333 private static final int findLocalizedKeyCode(String token) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
334 if (localizedKeyCodes is null) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
335 initLocalizedKeyCodes(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
336 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
337 token = token.toUpperCase(); |
40
da5ad8eedf5d
debug prints, dwt.dwthelper restructure, ...
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
338 Integer i; |
da5ad8eedf5d
debug prints, dwt.dwthelper restructure, ...
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
339 if (localizedKeyCodes.containsKey(token) && (i = cast(Integer) localizedKeyCodes.get(token)) !is null ) { |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
340 return i.intValue(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
341 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
342 if (token.length is 1) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
343 return token.charAt(0); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
344 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
345 return -1; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
346 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
347 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
348 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
349 * Maps the localized modifier names to a code in the same manner as |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
350 * #findModifier. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
351 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
352 * Support for localized modifiers is for backwards compatibility with 1.0. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
353 * Use setAccelerator(int) to set accelerators programatically or the |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
354 * <code>accelerator</code> tag in action definitions in plugin.xml. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
355 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
356 * @see #findModifier |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
357 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
358 private static final int findLocalizedModifier(String token) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
359 if (localizedCtrl is null) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
360 initLocalizedModifiers(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
361 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
362 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
363 token = token.toUpperCase(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
364 if (token.equals(localizedCtrl)) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
365 return DWT.CTRL; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
366 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
367 if (token.equals(localizedShift)) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
368 return DWT.SHIFT; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
369 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
370 if (token.equals(localizedAlt)) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
371 return DWT.ALT; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
372 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
373 if (token.equals(localizedCommand)) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
374 return DWT.COMMAND; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
375 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
376 return 0; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
377 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
378 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
379 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
380 * Maps standard keyboard modifier key names to the corresponding DWT |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
381 * modifier bit. The following modifier key names are recognized (case is |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
382 * ignored): <code>"CTRL"</code>, <code>"SHIFT"</code>, |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
383 * <code>"ALT"</code>, and <code>"COMMAND"</code>. The given modifier |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
384 * key name is converted to upper case before comparison. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
385 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
386 * @param token |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
387 * the modifier key name |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
388 * @return the DWT modifier bit, or <code>0</code> if no match was found |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
389 * @see DWT |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
390 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
391 public static final int findModifier(String token) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
392 token = token.toUpperCase(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
393 if (token.equals("CTRL")) { //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
394 return DWT.CTRL; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
395 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
396 if (token.equals("SHIFT")) { //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
397 return DWT.SHIFT; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
398 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
399 if (token.equals("ALT")) { //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
400 return DWT.ALT; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
401 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
402 if (token.equals("COMMAND")) { //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
403 return DWT.COMMAND; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
404 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
405 return 0; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
406 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
407 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
408 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
409 * Returns a string representation of an DWT modifier bit (DWT.CTRL, |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
410 * DWT.ALT, DWT.SHIFT, and DWT.COMMAND). Returns <code>null</code> if the |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
411 * key code is not an DWT modifier bit. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
412 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
413 * @param keyCode |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
414 * the DWT modifier bit to be translated |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
415 * @return the string representation of the DWT modifier bit, or |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
416 * <code>null</code> if the key code was not an DWT modifier bit |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
417 * @see DWT |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
418 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
419 public static final String findModifierString(int keyCode) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
420 if (keyCode is DWT.CTRL) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
421 return JFaceResources.getString("Ctrl"); //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
422 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
423 if (keyCode is DWT.ALT) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
424 return JFaceResources.getString("Alt"); //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
425 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
426 if (keyCode is DWT.SHIFT) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
427 return JFaceResources.getString("Shift"); //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
428 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
429 if (keyCode is DWT.COMMAND) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
430 return JFaceResources.getString("Command"); //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
431 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
432 return null; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
433 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
434 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
435 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
436 * Returns the string representation of the modifiers (Ctrl, Alt, Shift, |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
437 * Command) of the key event. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
438 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
439 * @param keyCode |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
440 * The key code for which the modifier string is desired. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
441 * @return The string representation of the key code; never |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
442 * <code>null</code>. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
443 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
444 private static String getModifierString(int keyCode) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
445 String modString = ""; //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
446 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
447 if ((keyCode & DWT.CTRL) !is 0) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
448 modString = findModifierString(keyCode & DWT.CTRL); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
449 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
450 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
451 if ((keyCode & DWT.ALT) !is 0) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
452 if (modString.equals("")) { //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
453 modString = findModifierString(keyCode & DWT.ALT); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
454 } else { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
455 modString = modString |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
456 ~ "+" ~ findModifierString(keyCode & DWT.ALT); //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
457 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
458 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
459 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
460 if ((keyCode & DWT.SHIFT) !is 0) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
461 if (modString.equals("")) { //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
462 modString = findModifierString(keyCode & DWT.SHIFT); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
463 } else { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
464 modString = modString |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
465 ~ "+" ~ findModifierString(keyCode & DWT.SHIFT); //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
466 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
467 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
468 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
469 if ((keyCode & DWT.COMMAND) !is 0) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
470 if (modString.equals("")) { //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
471 modString = findModifierString(keyCode & DWT.COMMAND); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
472 } else { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
473 modString = modString |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
474 ~ "+" ~ findModifierString(keyCode & DWT.COMMAND); //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
475 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
476 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
477 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
478 return modString; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
479 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
480 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
481 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
482 * Initializes the internal key code table. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
483 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
484 private static final void initKeyCodes() { |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
485 keyCodes = new HashMap(); |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
486 |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
487 keyCodes.put(stringcast("BACKSPACE"), new Integer(8)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
488 keyCodes.put(stringcast("TAB"), new Integer(9)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
489 keyCodes.put(stringcast("RETURN"), new Integer(13)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
490 keyCodes.put(stringcast("ENTER"), new Integer(13)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
491 keyCodes.put(stringcast("ESCAPE"), new Integer(27)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
492 keyCodes.put(stringcast("ESC"), new Integer(27)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
493 keyCodes.put(stringcast("DELETE"), new Integer(127)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
494 |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
495 keyCodes.put(stringcast("SPACE"), new Integer(' ')); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
496 keyCodes.put(stringcast("ARROW_UP"), new Integer(DWT.ARROW_UP)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
497 keyCodes.put(stringcast("ARROW_DOWN"), new Integer(DWT.ARROW_DOWN)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
498 keyCodes.put(stringcast("ARROW_LEFT"), new Integer(DWT.ARROW_LEFT)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
499 keyCodes.put(stringcast("ARROW_RIGHT"), new Integer(DWT.ARROW_RIGHT)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
500 keyCodes.put(stringcast("PAGE_UP"), new Integer(DWT.PAGE_UP)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
501 keyCodes.put(stringcast("PAGE_DOWN"), new Integer(DWT.PAGE_DOWN)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
502 keyCodes.put(stringcast("HOME"), new Integer(DWT.HOME)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
503 keyCodes.put(stringcast("END"), new Integer(DWT.END)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
504 keyCodes.put(stringcast("INSERT"), new Integer(DWT.INSERT)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
505 keyCodes.put(stringcast("F1"), new Integer(DWT.F1)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
506 keyCodes.put(stringcast("F2"), new Integer(DWT.F2)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
507 keyCodes.put(stringcast("F3"), new Integer(DWT.F3)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
508 keyCodes.put(stringcast("F4"), new Integer(DWT.F4)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
509 keyCodes.put(stringcast("F5"), new Integer(DWT.F5)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
510 keyCodes.put(stringcast("F6"), new Integer(DWT.F6)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
511 keyCodes.put(stringcast("F7"), new Integer(DWT.F7)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
512 keyCodes.put(stringcast("F8"), new Integer(DWT.F8)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
513 keyCodes.put(stringcast("F9"), new Integer(DWT.F9)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
514 keyCodes.put(stringcast("F10"), new Integer(DWT.F10)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
515 keyCodes.put(stringcast("F11"), new Integer(DWT.F11)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
516 keyCodes.put(stringcast("F12"), new Integer(DWT.F12)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
517 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
518 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
519 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
520 * Initializes the internal key string table. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
521 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
522 private static void initKeyStrings() { |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
523 keyStrings = new HashMap(); |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
524 |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
525 keyStrings.put(new Integer(8), stringcast(JFaceResources.getString("Backspace"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
526 keyStrings.put(new Integer(9), stringcast(JFaceResources.getString("Tab"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
527 keyStrings.put(new Integer(13), stringcast(JFaceResources.getString("Return"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
528 keyStrings.put(new Integer(13), stringcast(JFaceResources.getString("Enter"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
529 keyStrings.put(new Integer(27), stringcast(JFaceResources.getString("Escape"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
530 keyStrings.put(new Integer(27), stringcast(JFaceResources.getString("Esc"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
531 keyStrings.put(new Integer(127), stringcast(JFaceResources.getString("Delete"))); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
532 |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
533 keyStrings.put(new Integer(cast(int)' '), stringcast(JFaceResources.getString("Space"))); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
534 |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
535 keyStrings.put(new Integer(DWT.ARROW_UP), stringcast(JFaceResources |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
536 .getString("Arrow_Up"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
537 keyStrings.put(new Integer(DWT.ARROW_DOWN), stringcast(JFaceResources |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
538 .getString("Arrow_Down"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
539 keyStrings.put(new Integer(DWT.ARROW_LEFT), stringcast(JFaceResources |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
540 .getString("Arrow_Left"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
541 keyStrings.put(new Integer(DWT.ARROW_RIGHT), stringcast(JFaceResources |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
542 .getString("Arrow_Right"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
543 keyStrings.put(new Integer(DWT.PAGE_UP), stringcast(JFaceResources |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
544 .getString("Page_Up"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
545 keyStrings.put(new Integer(DWT.PAGE_DOWN), stringcast(JFaceResources |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
546 .getString("Page_Down"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
547 keyStrings.put(new Integer(DWT.HOME), stringcast(JFaceResources.getString("Home"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
548 keyStrings.put(new Integer(DWT.END), stringcast(JFaceResources.getString("End"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
549 keyStrings.put(new Integer(DWT.INSERT), stringcast(JFaceResources |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
550 .getString("Insert"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
551 keyStrings.put(new Integer(DWT.F1), stringcast(JFaceResources.getString("F1"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
552 keyStrings.put(new Integer(DWT.F2), stringcast(JFaceResources.getString("F2"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
553 keyStrings.put(new Integer(DWT.F3), stringcast(JFaceResources.getString("F3"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
554 keyStrings.put(new Integer(DWT.F4), stringcast(JFaceResources.getString("F4"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
555 keyStrings.put(new Integer(DWT.F5), stringcast(JFaceResources.getString("F5"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
556 keyStrings.put(new Integer(DWT.F6), stringcast(JFaceResources.getString("F6"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
557 keyStrings.put(new Integer(DWT.F7), stringcast(JFaceResources.getString("F7"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
558 keyStrings.put(new Integer(DWT.F8), stringcast(JFaceResources.getString("F8"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
559 keyStrings.put(new Integer(DWT.F9), stringcast(JFaceResources.getString("F9"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
560 keyStrings.put(new Integer(DWT.F10), stringcast(JFaceResources.getString("F10"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
561 keyStrings.put(new Integer(DWT.F11), stringcast(JFaceResources.getString("F11"))); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
562 keyStrings.put(new Integer(DWT.F12), stringcast(JFaceResources.getString("F12"))); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
563 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
564 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
565 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
566 * Initializes the localized internal key code table. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
567 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
568 private static void initLocalizedKeyCodes() { |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
569 localizedKeyCodes = new HashMap(); |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
570 |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
571 localizedKeyCodes.put(stringcast(JFaceResources |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
572 .getString("Backspace").toUpperCase()), new Integer(8)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
573 localizedKeyCodes.put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
574 stringcast(JFaceResources.getString("Tab").toUpperCase()), new Integer(9)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
575 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
576 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
577 stringcast(JFaceResources.getString("Return").toUpperCase()), new Integer(13)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
578 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
579 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
580 stringcast(JFaceResources.getString("Enter").toUpperCase()), new Integer(13)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
581 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
582 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
583 stringcast(JFaceResources.getString("Escape").toUpperCase()), new Integer(27)); //$NON-NLS-1$ |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
584 localizedKeyCodes.put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
585 stringcast(JFaceResources.getString("Esc").toUpperCase()), new Integer(27)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
586 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
587 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
588 stringcast(JFaceResources.getString("Delete").toUpperCase()), new Integer(127)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
589 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
590 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
591 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
592 stringcast(JFaceResources.getString("Space").toUpperCase()), new Integer(' ')); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
593 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
594 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
595 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
596 stringcast(JFaceResources.getString("Arrow_Up").toUpperCase()), new Integer(DWT.ARROW_UP)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
597 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
598 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
599 stringcast(JFaceResources.getString("Arrow_Down").toUpperCase()), new Integer(DWT.ARROW_DOWN)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
600 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
601 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
602 stringcast(JFaceResources.getString("Arrow_Left").toUpperCase()), new Integer(DWT.ARROW_LEFT)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
603 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
604 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
605 stringcast(JFaceResources.getString("Arrow_Right").toUpperCase()), new Integer(DWT.ARROW_RIGHT)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
606 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
607 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
608 stringcast(JFaceResources.getString("Page_Up").toUpperCase()), new Integer(DWT.PAGE_UP)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
609 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
610 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
611 stringcast(JFaceResources.getString("Page_Down").toUpperCase()), new Integer(DWT.PAGE_DOWN)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
612 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
613 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
614 stringcast(JFaceResources.getString("Home").toUpperCase()), new Integer(DWT.HOME)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
615 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
616 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
617 stringcast(JFaceResources.getString("End").toUpperCase()), new Integer(DWT.END)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
618 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
619 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
620 stringcast(JFaceResources.getString("Insert").toUpperCase()), new Integer(DWT.INSERT)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
621 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
622 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
623 stringcast(JFaceResources.getString("F1").toUpperCase()), new Integer(DWT.F1)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
624 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
625 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
626 stringcast(JFaceResources.getString("F2").toUpperCase()), new Integer(DWT.F2)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
627 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
628 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
629 stringcast(JFaceResources.getString("F3").toUpperCase()), new Integer(DWT.F3)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
630 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
631 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
632 stringcast(JFaceResources.getString("F4").toUpperCase()), new Integer(DWT.F4)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
633 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
634 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
635 stringcast(JFaceResources.getString("F5").toUpperCase()), new Integer(DWT.F5)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
636 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
637 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
638 stringcast(JFaceResources.getString("F6").toUpperCase()), new Integer(DWT.F6)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
639 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
640 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
641 stringcast(JFaceResources.getString("F7").toUpperCase()), new Integer(DWT.F7)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
642 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
643 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
644 stringcast(JFaceResources.getString("F8").toUpperCase()), new Integer(DWT.F8)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
645 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
646 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
647 stringcast(JFaceResources.getString("F9").toUpperCase()), new Integer(DWT.F9)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
648 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
649 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
650 stringcast(JFaceResources.getString("F10").toUpperCase()), new Integer(DWT.F10)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
651 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
652 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
653 stringcast(JFaceResources.getString("F11").toUpperCase()), new Integer(DWT.F11)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
654 localizedKeyCodes |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
655 .put( |
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
656 stringcast(JFaceResources.getString("F12").toUpperCase()), new Integer(DWT.F12)); //$NON-NLS-1$ |
16
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
657 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
658 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
659 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
660 * Initialize the list of localized modifiers |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
661 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
662 private static void initLocalizedModifiers() { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
663 localizedCtrl = JFaceResources.getString("Ctrl").toUpperCase(); //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
664 localizedShift = JFaceResources.getString("Shift").toUpperCase(); //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
665 localizedAlt = JFaceResources.getString("Alt").toUpperCase(); //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
666 localizedCommand = JFaceResources.getString("Command").toUpperCase(); //$NON-NLS-1$ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
667 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
668 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
669 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
670 * Convenience method for removing any optional accelerator text from the |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
671 * given string. The accelerator text appears at the end of the text, and is |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
672 * separated from the main part by a single tab character <code>'\t'</code>. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
673 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
674 * @param text |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
675 * the text |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
676 * @return the text sans accelerator |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
677 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
678 public static final String removeAcceleratorText(String text) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
679 int index = text.lastIndexOf('\t'); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
680 if (index is -1) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
681 index = text.lastIndexOf('@'); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
682 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
683 if (index >= 0) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
684 return text.substring(0, index); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
685 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
686 return text; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
687 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
688 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
689 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
690 * Convenience method for removing any mnemonics from the given string. For |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
691 * example, <code>removeMnemonics("&Open")</code> will return |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
692 * <code>"Open"</code>. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
693 * |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
694 * @param text |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
695 * the text |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
696 * @return the text sans mnemonics |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
697 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
698 public static final String removeMnemonics(String text) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
699 int index = text.indexOf('&'); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
700 if (index is -1) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
701 return text; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
702 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
703 int len = text.length; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
704 StringBuffer sb = new StringBuffer(len); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
705 int lastIndex = 0; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
706 while (index !is -1) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
707 // ignore & at the end |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
708 if (index is len - 1) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
709 break; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
710 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
711 // handle the && case |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
712 if (text.charAt(index + 1) is '&') { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
713 ++index; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
714 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
715 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
716 // DBCS languages use "(&X)" format |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
717 if (index > 0 && text.charAt(index - 1) is '(' |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
718 && text.length >= index + 3 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
719 && text.charAt(index + 2) is ')') { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
720 sb.append(text.substring(lastIndex, index - 1)); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
721 index += 3; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
722 } else { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
723 sb.append(text.substring(lastIndex, index)); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
724 // skip the & |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
725 ++index; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
726 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
727 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
728 lastIndex = index; |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
729 index = text.indexOf('&', index); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
730 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
731 if (lastIndex < len) { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
732 sb.append(text.substring(lastIndex, len)); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
733 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
734 return sb.toString(); |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
735 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
736 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
737 /** |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
738 * This class cannot be instantiated. |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
739 */ |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
740 private this() { |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
741 // Does nothing |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
742 } |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
743 |
e0f0aaf75edd
PopupDialog, bindings and actions
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
744 } |