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 |
escapeMnemonics(String text)
Convenience method for escaping all mnemonics in the given string.
|
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 delimiter (last tab or
last '@' if there's no tab).text
- the text for the action; may be null
.null
public static final char extractMnemonic(String text)
text
- The text from which the mnemonic should be extracted; may be
null
MNEMONIC_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 foundSWT
public static final String findKeyString(int keyCode)
keyCode
- the key code to be translatedSWT
public 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 foundSWT
public 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 bitSWT
public static final String removeAcceleratorText(String text)
'\t'
(or the last '@'
if there is no tab).text
- the textpublic static final String removeMnemonics(String text)
removeMnemonics("&Open")
will return
"Open"
.text
- the text
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.