|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.gui.KeyStrokeProvider
This abstract class defines and provides a single point of access to the
s used as shortcut keys for some commands.
Use KeyStroke in order to add
elements to the local addToMap(String, KeyStroke)Map.
Utility method can prove being
useful when one needs to add application specific shortcut key commands.
This class programmatically defines in its constructor Command Id/KeyStroke
associations for common commands. However it is possible to change the
KeyStroke associated to a common command through the properties files.
In order to do so, specific entries have to be added to the property files.
The current entry format is: dumpKeyStrokes()
Command Id + �.keystroke�.
Then the keystroke should be defined as follow:
Keycode + �|� + Modifiers KeyCode being one of the constants
starting with �VK_� defined in ,
without the �VK_� prefix.
Example: KeyEvent
W for VK_W
Valid modifiers are defined in .
They have to be separated using the following separator: KeyStrokeBuilder.VALID_MODIFIERS.
Example: KeyStrokeBuilder.MODIFIERS_SEPARATOR
Command.AddNodeAbove.keystroke=A|CTRL+SHIFT
Important: When subclassing this class, one should override
in order to be able to change programmatically defined keystrokes through
property files.
initSubclassKeyStrokesFromPropertyFile()
| Field Summary | |
static java.lang.String |
KEYCODE_VS_MODIFIERS_SEPARATOR
This is the separator used in keystrokes entry definitions for key codes and modifiers. |
static java.lang.String |
KEYSTROKE_DEFINITION_SUFFIX
ATTENTION: This is a reserved String that should not be used as part of an entry definition in property files apart for defining commands keystrokes. |
protected java.util.Map |
map
local map of Command Ids/KeyStrokes |
protected UIManager |
uiManager
This is the UIManager local instance |
| Constructor Summary | |
protected |
KeyStrokeProvider(UIManager uiManager)
This is the default constructor initilazing the internal
instance.
|
| Method Summary | |
protected void |
addToMap(java.lang.String commandId,
KeyStroke keystroke)
Simple wrapper allowing extra checks before adding elements to the local Map.
|
void |
dumpKeyStrokes()
Internal use only. |
java.util.Collection |
getCommandIds()
This method returns the set of command Ids for which the corresponding command has an associated keyStroke. |
KeyStroke |
getKeyStroke(java.lang.String commandId)
Returns the KeyStrokeassociated with the passed command Id.
|
protected abstract KeyStrokeBuilder |
getKeyStrokeBuilderInstance()
Returns the local instance of . |
protected abstract void |
initKeyStrokesFromPropertyFile()
This method tries to overwrite all the command Id/KeyStroke associations programmatically set up in the constructor with other associations potentially defined into the property files. |
protected void |
initSingleKeyStroke(java.lang.String commandId)
This method attempts to find in the UIManager a keystroke definition associated to the passed command. |
protected abstract void |
initSubclassKeyStrokesFromPropertyFile()
Subclasses of should implement
this method and call it at the end of their constructor in order to
allow the keystokes to be changed through property files.
|
void |
loadFromDescription(java.lang.String commandId,
java.lang.String keyStrokeDescription)
This method creates a KeyStroke instance from the passed keyStrokeDescription
parameter and associates it to the command with id commandId.
|
java.lang.String |
toString()
Simply calls toString() the local map of Command
Ids/KeyStrokes |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.util.Map map
protected UIManager uiManager
public static final java.lang.String KEYSTROKE_DEFINITION_SUFFIX
public static final java.lang.String KEYCODE_VS_MODIFIERS_SEPARATOR
| Constructor Detail |
protected KeyStrokeProvider(UIManager uiManager)
This is the default constructor initilazing the internal
instance.
UIManager
uiManager - this is the application UIManager| Method Detail |
protected abstract KeyStrokeBuilder getKeyStrokeBuilderInstance()
KeyStrokeBuilder.
KeyStrokeBuilder instance.
public void loadFromDescription(java.lang.String commandId,
java.lang.String keyStrokeDescription)
This method creates a KeyStroke instance from the passed keyStrokeDescription
parameter and associates it to the command with id commandId.
Note that if the provided id corresponds to a command for which a
keystroke has already been programmatically setup, the later one will be
overridden.
commandId - unique identifier for a command.keyStrokeDescription - this is the keystroke description which defines the keystroke
to be associated with the command with id commandId.
Please refere to this class comments for more information on
this description format.protected void initSingleKeyStroke(java.lang.String commandId)
This method attempts to find in the UIManager a keystroke definition
associated to the passed command. If it finds it, then a
instance is created and associated to the command with id 'commandId'.
Note that any other association between a keystroke and this particular
command will then be lost.
KeyStroke
commandId - this is a command unique identifier.loadFromDescription(String, String)protected abstract void initKeyStrokesFromPropertyFile()
This method tries to overwrite all the command Id/KeyStroke associations programmatically set up in the constructor with other associations potentially defined into the property files.
protected abstract void initSubclassKeyStrokesFromPropertyFile()
Subclasses of should implement
this method and call it at the end of their constructor in order to
allow the keystokes to be changed through property files.
Typically, for each keystroke programmatically defined in the constructor,
a call to KeyStrokeProvider should be made
in this method.
initSingleKeyStroke(String)
protected final void addToMap(java.lang.String commandId,
KeyStroke keystroke)
Simple wrapper allowing extra checks before adding elements to the local
Map.
commandId - this is a command unique identifier.keystroke - this is the KeyStroke associated with
the command with id commandId.public void dumpKeyStrokes()
Internal use only. Use this method in order to view the local Map's content. This can prove being useful when one wants to add custom shortcut key commands and be sure that they are not already used.
public java.lang.String toString()
toString() the local map of Command
Ids/KeyStrokes
Object.toString()public java.util.Collection getCommandIds()
This method returns the set of command Ids for which the corresponding command has an associated keyStroke.
public KeyStroke getKeyStroke(java.lang.String commandId)
Returns the KeyStrokeassociated with the passed command Id.
commandId - this is a unique identifier for a command.
KeyStrokeassociated with the passed command Id
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||