Lines 16-21
Link Here
|
16 |
import java.awt.*; |
16 |
import java.awt.*; |
17 |
import java.awt.event.*; |
17 |
import java.awt.event.*; |
18 |
import java.beans.*; |
18 |
import java.beans.*; |
|
|
19 |
import java.util.Map; |
19 |
import java.util.Observable; |
20 |
import java.util.Observable; |
20 |
import java.util.Observer; |
21 |
import java.util.Observer; |
21 |
import javax.swing.*; |
22 |
import javax.swing.*; |
Lines 23-28
Link Here
|
23 |
import javax.swing.text.Keymap; |
24 |
import javax.swing.text.Keymap; |
24 |
|
25 |
|
25 |
import org.openide.ErrorManager; |
26 |
import org.openide.ErrorManager; |
|
|
27 |
import org.openide.modules.Dependency; |
28 |
import org.openide.modules.SpecificationVersion; |
26 |
import org.openide.util.Mutex; |
29 |
import org.openide.util.Mutex; |
27 |
import org.openide.util.actions.*; |
30 |
import org.openide.util.actions.*; |
28 |
import org.openide.util.HelpCtx; |
31 |
import org.openide.util.HelpCtx; |
Lines 181-202
Link Here
|
181 |
//Ampersand is last characted, use first character as shortcut |
184 |
//Ampersand is last characted, use first character as shortcut |
182 |
item.setText(text.substring(0, i)); |
185 |
item.setText(text.substring(0, i)); |
183 |
if (useMnemonic) { |
186 |
if (useMnemonic) { |
|
|
187 |
// Huh?? This disables the mnemonic. Intentional? |
184 |
item.setMnemonic (0); |
188 |
item.setMnemonic (0); |
185 |
} |
189 |
} |
186 |
} else { |
190 |
} else { |
187 |
item.setText(text.substring(0, i) + text.substring(i + 1)); |
191 |
item.setText(text.substring(0, i) + text.substring(i + 1)); |
188 |
if (useMnemonic) { |
192 |
if (useMnemonic) { |
189 |
char ch = text.charAt(i + 1); |
193 |
char ch = text.charAt(i + 1); |
190 |
if ((ch>='A' && ch<='Z') || (ch>='a' && ch<='z') || |
194 |
setDisplayedMnemonicIndex(item, i, ch); |
191 |
(ch>='0' && ch<='9')) { |
|
|
192 |
// it's latin character or arabic digit, |
193 |
// setting it as mnemonics |
194 |
item.setMnemonic(ch); |
195 |
} else { |
196 |
char latinChar = getLatinKeyboardChar(ch); |
197 |
item.setMnemonic (latinChar); |
198 |
setDisplayedMnemonicIndex(item, i, latinChar); |
199 |
} |
200 |
} |
195 |
} |
201 |
} |
196 |
} |
202 |
} |
197 |
} |
Lines 225-263
Link Here
|
225 |
private static Object actions14; |
220 |
private static Object actions14; |
226 |
/** Wrapper for the |
221 |
/** Wrapper for the |
227 |
* <code>AbstractButton.setDisplayedMnemonicIndex</code> method. |
222 |
* <code>AbstractButton.setDisplayedMnemonicIndex</code> method. |
|
|
223 |
* <ul> |
228 |
* <li>Under JDK1.4 calls the method on item |
224 |
* <li>Under JDK1.4 calls the method on item |
229 |
* <li>Under JDK1.3 adds the " (<latin character>)" |
225 |
* <li>Under JDK1.3 adds the " (<latin character>)" |
230 |
* to label and sets the latin character as mnemonics |
226 |
* to label and sets the latin character as mnemonic (ignores index parameter) |
231 |
* @param item AbstractButton or it's subclass |
227 |
* </ul> |
|
|
228 |
* @param item AbstractButton or its subclass |
232 |
* @param index Index of the Character to underline under JDK1.4 |
229 |
* @param index Index of the Character to underline under JDK1.4 |
233 |
* @param latinChar Latin Character to underline under JDK1.3 |
230 |
* @param char Character to underline under either JDK1.3 |
234 |
*/ |
231 |
*/ |
235 |
private static void setDisplayedMnemonicIndex (AbstractButton item, int index, char latinChar) { |
232 |
private static void setDisplayedMnemonicIndex (AbstractButton item, int index, char ch) { |
236 |
if (org.openide.modules.Dependency.JAVA_SPEC.compareTo ( |
233 |
if (Dependency.JAVA_SPEC.compareTo(new SpecificationVersion("1.4")) >= 0 && // NOI18N |
237 |
new org.openide.modules.SpecificationVersion("1.4") |
234 |
actions14 == null) { |
238 |
) >= 0) { // NOI18N |
235 |
try { |
239 |
if (actions14 == null) { |
236 |
Class c = Class.forName("org.openide.awt.Actions14"); // NOI18N |
240 |
try { |
237 |
actions14 = c.newInstance (); |
241 |
Class c = Class.forName ("org.openide.awt.Actions14"); |
238 |
((Map.Entry)actions14).setValue(new Object[] {item, new Character(ch), new Integer(index)}); |
242 |
actions14 = c.newInstance (); |
239 |
return; |
243 |
} catch (ClassNotFoundException cnfe) { |
240 |
} catch (ClassNotFoundException cnfe) { |
244 |
// OK, NB was compiled under 1.3 only. |
241 |
// OK, NB was compiled under 1.3 only. |
245 |
actions14 = cnfe; |
242 |
actions14 = cnfe; |
246 |
} catch (Exception ex) { |
243 |
} catch (Exception ex) { |
247 |
ErrorManager.getDefault().notify(ex); |
244 |
ErrorManager.getDefault().notify(ex); |
248 |
actions14 = ex; |
245 |
actions14 = ex; |
249 |
} |
|
|
250 |
} |
251 |
|
252 |
if (actions14 instanceof java.util.Map.Entry) { |
253 |
((java.util.Map.Entry)actions14).setValue(new Object[] { |
254 |
item, new Integer (index) |
255 |
}); |
256 |
} |
246 |
} |
|
|
247 |
} |
248 |
if (actions14 instanceof Map.Entry) { |
249 |
((Map.Entry)actions14).setValue(new Object[] {item, new Character(ch), new Integer(index)}); |
257 |
} else { |
250 |
} else { |
258 |
// under JDK 1.3 |
251 |
// under JDK 1.3 |
259 |
item.setText(item.getText()+" ("+latinChar+")"); |
252 |
if ((ch>='A' && ch<='Z') || (ch>='a' && ch<='z') || |
260 |
item.setMnemonic(latinChar); |
253 |
(ch>='0' && ch<='9')) { |
|
|
254 |
// it's latin character or arabic digit, |
255 |
// setting it as mnemonics |
256 |
item.setMnemonic(ch); |
257 |
} else { |
258 |
// Non-Latin character. Find some Latin character to use instead |
259 |
// as a mnemonic. |
260 |
char latinChar = getLatinKeyboardChar(ch); |
261 |
item.setText(item.getText() + " (" + latinChar + ")"); // NOI18N |
262 |
item.setMnemonic (latinChar); |
263 |
} |
261 |
} |
264 |
} |
262 |
} |
265 |
} |
263 |
|
266 |
|