public final class Shortcut extends 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 Map<Integer,Integer> |
groups |
private static boolean |
initdone |
private static int[] |
keys |
private 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 Map<String,Shortcut> |
shortcuts |
private String |
shortText
the unique ID of the shortcut
|
Modifier | Constructor and Description |
---|---|
private |
Shortcut(String prefString) |
private |
Shortcut(String shortText,
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,
Integer modifier) |
private static int |
findNewOsxModifier(int requestedGroup) |
static Shortcut |
findShortcut(int requestedKey,
int modifier) |
int |
getAssignedKey() |
int |
getAssignedModifier() |
static KeyStroke |
getCopyKeyStroke()
Replies the platform specific key stroke for the 'Copy' command, i.e.
|
static KeyStroke |
getCutKeyStroke()
Replies the platform specific key stroke for the 'Cut' command, i.e.
|
private static int |
getGroupModifier(int group) |
KeyStroke |
getKeyStroke()
Use this to register the shortcut with Swing
|
String |
getKeyText()
Returns a human readable text for the shortcut.
|
String |
getLongText() |
static KeyStroke |
getPasteKeyStroke()
Replies the platform specific key stroke for the 'Paste' command, i.e.
|
String |
getShortText() |
boolean |
isAssignedDefault() |
boolean |
isAssignedUser() |
boolean |
isAutomatic() |
boolean |
isChangeable() |
boolean |
isEvent(KeyEvent e) |
private boolean |
isReset() |
private boolean |
isSame(int isKey,
int isModifier) |
static List<Shortcut> |
listAll()
Returns a list of all shortcuts.
|
private static Shortcut |
reassignShortcut(String shortText,
String longText,
int requestedKey,
Shortcut conflict,
int m,
int k,
int newmodifier) |
static Shortcut |
registerShortcut(String shortText,
String longText,
int requestedKey,
int requestedGroup)
Register a shortcut.
|
private static Shortcut |
registerShortcut(String shortText,
String longText,
int requestedKey,
int requestedGroup,
Integer modifier) |
static Shortcut |
registerSystemShortcut(String shortText,
String longText,
int key,
int modifier)
FOR PLATFORMHOOK USE ONLY.
|
private boolean |
save() |
private void |
saveDefault() |
static boolean |
savePrefs() |
void |
setAccelerator(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(JTextComponent component)
Sets the mnemonic key on a text component.
|
private void |
setLongText(String longText) |
void |
setMnemonic(AbstractButton button)
use this to set a buttons's mnemonic
|
void |
setMnemonic(JMenu menu)
use this to set a menu's mnemonic
|
String |
toString() |
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
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(String shortText, String longText, int requestedKey, int requestedGroup, int assignedKey, int assignedModifier, boolean assignedDefault, boolean assignedUser)
public String getShortText()
public String getLongText()
private void setLongText(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)
Sets the modifiers that are used.
assignedModifier
- assigned modifierpublic void setAssignedKey(int assignedKey)
Sets the key that actually is used.
assignedKey
- assigned keypublic void setAssignedUser(boolean assignedUser)
Sets whether the user has changed this shortcut.
assignedUser
- true
if the user has changed this shortcutpublic KeyStroke getKeyStroke()
private void saveDefault()
private boolean save()
private boolean isSame(int isKey, int isModifier)
public void setMnemonic(JMenu menu)
menu
- menupublic void setMnemonic(AbstractButton button)
button
- buttonpublic void setFocusAccelerator(JTextComponent component)
component
- componentpublic void setAccelerator(AbstractAction action)
action
- actionpublic String getKeyText()
public static Shortcut findShortcut(int requestedKey, int modifier)
public static List<Shortcut> listAll()
private static void doInit()
private static int getGroupModifier(int group)
private static int findModifier(int group, Integer modifier)
public static boolean savePrefs()
public static Shortcut registerSystemShortcut(String shortText, 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(String shortText, 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(String shortText, String longText, int requestedKey, int requestedGroup, Integer modifier)
private static int findNewOsxModifier(int requestedGroup)
private static Shortcut reassignShortcut(String shortText, String longText, int requestedKey, Shortcut conflict, int m, int k, int newmodifier)
public static KeyStroke getCopyKeyStroke()
public static KeyStroke getPasteKeyStroke()
public static KeyStroke getCutKeyStroke()