public final class LegacyActionTools extends Object
Some static utility methods for handling labels on actions. This includes mnemonics and accelerators.
Clients may neither instantiate this class nor extend.
| Modifier and Type | Field and Description |
|---|---|
static char |
MNEMONIC_NONE
The constant to use if there is no mnemonic for this location.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
convertAccelerator(int keyCode)
Converts an accelerator key code to a string representation.
|
static int |
convertAccelerator(String acceleratorText)
Parses the given accelerator text, and converts it to an accelerator key
code.
|
static String |
extractAcceleratorText(String text)
Extracts the accelerator text from the given text.
|
static char |
extractMnemonic(String text)
Extracts the mnemonic text from the given string.
|
static int |
findKeyCode(String token)
Maps a standard keyboard key name to an SWT key code.
|
static String |
findKeyString(int keyCode)
Maps an SWT key code to a standard keyboard key name.
|
static int |
findModifier(String token)
Maps standard keyboard modifier key names to the corresponding SWT
modifier bit.
|
static String |
findModifierString(int keyCode)
Returns a string representation of an SWT modifier bit (SWT.CTRL,
SWT.ALT, SWT.SHIFT, and SWT.COMMAND).
|
static String |
removeAcceleratorText(String text)
Convenience method for removing any optional accelerator text from the
given string.
|
static String |
removeMnemonics(String text)
Convenience method for removing any mnemonics from the given string.
|
public static final char MNEMONIC_NONE
public static final String convertAccelerator(int keyCode)
keyCode - the key code to be translatedpublic static final int convertAccelerator(String acceleratorText)
acceleratorText - the accelerator textpublic static final String extractAcceleratorText(String text)
null if there is no accelerator text, and the empty string
if there is no text after the accelerator delimeter (tab or '@').text - the text for the action; may be null.nullpublic static final char extractMnemonic(String text)
text - The text from which the mnemonic should be extracted; may be
nullMNEMONIC_NONE if there
is no mnemonic;public static final int findKeyCode(String token)
The following key names are known (case is ignored):
"BACKSPACE""TAB""RETURN""ENTER""ESC""ESCAPE""DELETE""SPACE""ARROW_UP", "ARROW_DOWN",
"ARROW_LEFT", and "ARROW_RIGHT""PAGE_UP" and "PAGE_DOWN""HOME""END""INSERT""F1", "F2" through "F12"token - the key name-1 if no match was foundSWTpublic static final String findKeyString(int keyCode)
keyCode - the key code to be translatedSWTpublic static final int findModifier(String token)
"CTRL", "SHIFT",
"ALT", and "COMMAND". The given modifier
key name is converted to upper case before comparison.token - the modifier key name0 if no match was foundSWTpublic static final String findModifierString(int keyCode)
null if the
key code is not an SWT modifier bit.keyCode - the SWT modifier bit to be translatednull if the key code was not an SWT modifier bitSWTpublic static final String removeAcceleratorText(String text)
'\t'.text - the textGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.