public final class Shortcut extends java.lang.Object
registerShortcut(java.lang.String, java.lang.String, int, int)
factory. Ignore everything else.
All: Use only public methods that are also marked to be used. The others are
public so the shortcut preferences can use them.Modifier and Type | Field and Description |
---|---|
static int |
ALT
Alt group
|
static int |
ALT_CTRL
Alt-Command group.
|
static int |
ALT_CTRL_SHIFT
Alt-Command-Shift group.
|
static int |
ALT_SHIFT
Alt-Shift group
|
private boolean |
assignedDefault
true if it got assigned what was requested.
|
private int |
assignedKey
the key that actually is used
|
private int |
assignedModifier
the modifiers that are used
|
private boolean |
assignedUser
true if the user changed this shortcut
|
private boolean |
automatic
true if the user cannot change this shortcut (Note: it also will not be saved into the preferences)
|
static int |
CTRL
Command group.
|
static int |
CTRL_SHIFT
Command-Shift group.
|
static int |
DIRECT
Direct group: no modifier
|
private static java.util.Map<java.lang.Integer,java.lang.Integer> |
groups |
private static boolean |
initdone |
private static int[] |
keys |
private java.lang.String |
longText
a human readable description that will be shown in the preferences
|
static int |
MNEMONIC |
private static int[] |
mods |
static int |
NONE
None group: used with KeyEvent.CHAR_UNDEFINED if no shortcut is defined
|
private int |
requestedGroup
the group, the caller requested
|
private int |
requestedKey
the key, the caller requested
|
static int |
RESERVED
Reserved group: for system shortcuts only
|
private boolean |
reset
true if the user requested this shortcut to be set to its default value
(will happen on next restart, as this shortcut will not be saved to the preferences)
|
static int |
SHIFT
Shift group
|
private static java.util.Map<java.lang.String,Shortcut> |
shortcuts |
private java.lang.String |
shortText
the unique ID of the shortcut
|
Modifier | Constructor and Description |
---|---|
private |
Shortcut(java.lang.String prefString) |
private |
Shortcut(java.lang.String shortText,
java.lang.String longText,
int requestedKey,
int requestedGroup,
int assignedKey,
int assignedModifier,
boolean assignedDefault,
boolean assignedUser) |
Modifier and Type | Method and Description |
---|---|
private static void |
doInit() |
private static int |
findModifier(int group,
java.lang.Integer modifier) |
private static int |
findNewOsxModifier(int requestedGroup) |
static Shortcut |
findShortcut(int requestedKey,
int modifier) |
int |
getAssignedKey() |
int |
getAssignedModifier() |
static javax.swing.KeyStroke |
getCopyKeyStroke()
Replies the platform specific key stroke for the 'Copy' command, i.e.
|
static javax.swing.KeyStroke |
getCutKeyStroke()
Replies the platform specific key stroke for the 'Cut' command, i.e.
|
private static int |
getGroupModifier(int group) |
javax.swing.KeyStroke |
getKeyStroke()
Use this to register the shortcut with Swing
|
java.lang.String |
getKeyText()
Returns a human readable text for the shortcut.
|
java.lang.String |
getLongText() |
static javax.swing.KeyStroke |
getPasteKeyStroke()
Replies the platform specific key stroke for the 'Paste' command, i.e.
|
java.lang.String |
getShortText() |
boolean |
isAssignedDefault() |
boolean |
isAssignedUser() |
boolean |
isAutomatic() |
boolean |
isChangeable() |
boolean |
isEvent(java.awt.event.KeyEvent e) |
private boolean |
isReset() |
private boolean |
isSame(int isKey,
int isModifier) |
static java.util.List<Shortcut> |
listAll()
Returns a list of all shortcuts.
|
private static Shortcut |
reassignShortcut(java.lang.String shortText,
java.lang.String longText,
int requestedKey,
Shortcut conflict,
int m,
int k,
int newmodifier) |
static Shortcut |
registerShortcut(java.lang.String shortText,
java.lang.String longText,
int requestedKey,
int requestedGroup)
Register a shortcut.
|
private static Shortcut |
registerShortcut(java.lang.String shortText,
java.lang.String longText,
int requestedKey,
int requestedGroup,
java.lang.Integer modifier) |
static Shortcut |
registerSystemShortcut(java.lang.String shortText,
java.lang.String longText,
int key,
int modifier)
FOR PLATFORMHOOK USE ONLY.
|
private boolean |
save() |
private void |
saveDefault() |
static boolean |
savePrefs() |
void |
setAccelerator(javax.swing.AbstractAction action)
use this to set a actions's accelerator
|
void |
setAssignedKey(int assignedKey)
FOR PREF PANE ONLY
|
void |
setAssignedModifier(int assignedModifier)
FOR PREF PANE ONLY
|
void |
setAssignedUser(boolean assignedUser)
FOR PREF PANE ONLY
|
void |
setAutomatic()
FOR PREF PANE ONLY
|
void |
setFocusAccelerator(javax.swing.text.JTextComponent component)
Sets the mnemonic key on a text component.
|
private void |
setLongText(java.lang.String longText) |
void |
setMnemonic(javax.swing.AbstractButton button)
use this to set a buttons's mnemonic
|
void |
setMnemonic(javax.swing.JMenu menu)
use this to set a menu's mnemonic
|
java.lang.String |
toString() |
private final java.lang.String shortText
private java.lang.String longText
private final int requestedKey
private final int requestedGroup
private int assignedKey
private int assignedModifier
private boolean assignedDefault
private boolean assignedUser
private boolean automatic
private boolean reset
private static java.util.Map<java.lang.Integer,java.lang.Integer> groups
public static final int NONE
public static final int MNEMONIC
public static final int RESERVED
public static final int DIRECT
public static final int ALT
public static final int SHIFT
public static final int CTRL
public static final int ALT_SHIFT
public static final int ALT_CTRL
public static final int CTRL_SHIFT
public static final int ALT_CTRL_SHIFT
private static int[] mods
private static int[] keys
private static boolean initdone
private Shortcut(java.lang.String shortText, java.lang.String longText, int requestedKey, int requestedGroup, int assignedKey, int assignedModifier, boolean assignedDefault, boolean assignedUser)
private Shortcut(java.lang.String prefString)
public java.lang.String getShortText()
public java.lang.String getLongText()
private void setLongText(java.lang.String longText)
public int getAssignedKey()
public int getAssignedModifier()
public boolean isAssignedDefault()
public boolean isAssignedUser()
public boolean isAutomatic()
public boolean isChangeable()
private boolean isReset()
public void setAutomatic()
public void setAssignedModifier(int assignedModifier)
public void setAssignedKey(int assignedKey)
public void setAssignedUser(boolean assignedUser)
public javax.swing.KeyStroke getKeyStroke()
private void saveDefault()
private boolean save()
private boolean isSame(int isKey, int isModifier)
public boolean isEvent(java.awt.event.KeyEvent e)
public void setMnemonic(javax.swing.JMenu menu)
public void setMnemonic(javax.swing.AbstractButton button)
public void setFocusAccelerator(javax.swing.text.JTextComponent component)
public void setAccelerator(javax.swing.AbstractAction action)
public java.lang.String getKeyText()
public java.lang.String toString()
toString
in class java.lang.Object
public static Shortcut findShortcut(int requestedKey, int modifier)
public static java.util.List<Shortcut> listAll()
private static void doInit()
private static int getGroupModifier(int group)
private static int findModifier(int group, java.lang.Integer modifier)
public static boolean savePrefs()
public static Shortcut registerSystemShortcut(java.lang.String shortText, java.lang.String longText, int key, int modifier)
This registers a system shortcut. See PlatformHook for details.
shortText
- an ID. re-use a "system:*"
ID if possible, else use something unique.longText
- this will be displayed in the shortcut preferences dialog. Better
use something the user will recognize...key
- the key. Use a KeyEvent.VK_*
constant here.modifier
- the modifier. Use a KeyEvent.*_MASK
constant here.public static Shortcut registerShortcut(java.lang.String shortText, java.lang.String longText, int requestedKey, int requestedGroup)
shortText
- an ID. re-use a "system:*"
ID if possible, else use something unique.
"menu:*"
is reserved for menu mnemonics, "core:*"
is reserved for
actions that are part of JOSM's core. Use something like
<pluginname>+":"+<actionname>
.longText
- this will be displayed in the shortcut preferences dialog. Better
use something the user will recognize...requestedKey
- the key you'd prefer. Use a KeyEvent.VK_*
constant here.requestedGroup
- the group this shortcut fits best. This will determine the
modifiers your shortcut will get assigned. Use the constants defined above.private static Shortcut registerShortcut(java.lang.String shortText, java.lang.String longText, int requestedKey, int requestedGroup, java.lang.Integer modifier)
private static int findNewOsxModifier(int requestedGroup)
private static Shortcut reassignShortcut(java.lang.String shortText, java.lang.String longText, int requestedKey, Shortcut conflict, int m, int k, int newmodifier)
public static javax.swing.KeyStroke getCopyKeyStroke()
public static javax.swing.KeyStroke getPasteKeyStroke()
public static javax.swing.KeyStroke getCutKeyStroke()