|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.gudy.azureus2.ui.swt.KeyBindings
public final class KeyBindings
Facilitates localization-specific and platform-specific keyboard shortcut handling through the use of keybinding values.
A keybinding value is a line of String that can be specified in the localization bundle properties file for a particular menu item. To do so, a localization key/value pair is used, with the key being the same as menu item's key plus ".keybinding".
For instance, if a keyboard shortcut needs to be specified for "MainWindow.menu.file.open", then a key/value pair with the key of "MainWindow.menu.file.open.keybinding" is created. The value is what would be used as the keyboard accelerator, with the following special values:
As of version 1.2, keybindings are only set if the following conditions are met:
The keys were chosen to more conveniently address the issue on platforms like Windows where vanilla SWT does not display the shortcuts, as opposed to higher-level API like JFace or some platforms' native rendering.
For example, if File / Open / .torrent File is set to be Meta+O (Command+O or Ctrl+O), then in MessageBundle.properties (or the localization- specific equivalent), MainWindow.menu.file.open.torrent.keybinding=Meta+O will be entered. The label will be adjusted to Ctrl on non-OS X platforms (OS X will draw the glyph for Cmd).
As another example, if File / Exit is set to be Alt+F4, then in MessageBundle.properties (or the localization-specific equivalent), MainWindow.menu.file.exit.keybinding=Alt+F4 will be entered.
To accommodate for the variety of locales and platforms running on Azureus, platforms and localizations can "override" the default keybinding value.
The order of parsing is as follows:
For instance, to refer to the above example, if the Mac OS X target for Azureus wants to handle File / Exit as Command+Q, then MainWindow.menu.file.exit.keybinding.mac=Meta+Q is entered. If it is not entered, the value for the 'default' key MainWindow.menu.file.exit.keybinding will be used.
The platform suffix can be attached to the end of the localization key. Valid suffixes are:
Nested Class Summary | |
---|---|
static class |
KeyBindings.KeyBindingInfo
A basic bean object containing the SWT accelerator and its display name. |
Constructor Summary | |
---|---|
KeyBindings()
|
Method Summary | |
---|---|
static KeyBindings.KeyBindingInfo |
getKeyBindingInfo(String localizationKey)
|
static void |
main(String[] args)
Runs simple tests on KeyBindings keybinding values |
static void |
removeAccelerator(org.eclipse.swt.widgets.MenuItem menu,
String localizationKey)
Removes the keyboard accelerator for a SWT MenuItem |
static void |
setAccelerator(org.eclipse.swt.widgets.MenuItem menu,
String localizationKey)
Sets the keyboard accelerator for a SWT MenuItem. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public KeyBindings()
Method Detail |
---|
public static void removeAccelerator(org.eclipse.swt.widgets.MenuItem menu, String localizationKey)
Removes the keyboard accelerator for a SWT MenuItem
menu
- SWT MenuItemlocalizationKey
- The MenuItem's localization key for the localization resource bundlepublic static void setAccelerator(org.eclipse.swt.widgets.MenuItem menu, String localizationKey)
Sets the keyboard accelerator for a SWT MenuItem.
There is a specific order of accelerator setting in consideration with different platforms and localizations. Specifically:
menu
- SWT MenuItemlocalizationKey
- The MenuItem's localization key for the localization resource bundlepublic static KeyBindings.KeyBindingInfo getKeyBindingInfo(String localizationKey)
public static void main(String[] args)
args
- Command-line arguments; they are not used
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |