org.openbp.jaspira.action.keys
Class KeyMgr

java.lang.Object
  extended by org.openbp.jaspira.action.keys.KeyMgr

public final class KeyMgr
extends java.lang.Object

The key manager is the central instance for handling keysequences. It transforms those sequences into key sequence events that are passed through the plugin hierarchy. In order to prevent unnecessesary events, it transforms only those sequences that have previously been registered with the manager. In order to make a toplevel component key aware, use the install method.

Author:
Stephan Moritz

Nested Class Summary
 class KeyMgr.KeyAction
          Updates the actualKey sequence of the manager, throws the event and restores the manager if no more combinations are possible.
 class KeyMgr.MultiActionMap
          Action Map that creates new Actions for pressed keys "on the fly".
 class KeyMgr.MultiInputMap
          Input Map that supports two different parent map.
 
Field Summary
static java.lang.String ESCAPE
          Escape key for input/action maps
 
Method Summary
 void addSequence(KeySequence sequence)
          Adds the given sequence to the list of recognized sequences.
 void addSequences(java.util.Iterator sequences)
          Adds the given sequences to the list of recognized sequences.
static KeyMgr getInstance()
          Returns the singleton instance of the key manager, creating it if necessary.
 void install(javax.swing.JComponent c)
          Installs the manager for the given JComponent.
static java.lang.String keyCodeToString(int keyCode)
          Converts the given key code to a string, as defined in the java\.awt\.event\.KeyEvent class.
 void removeSequence(KeySequence sequence)
          Removes the given sequences to the list of recognized sequences.
 void removeSequences(java.util.Iterator sequences)
          Removes the given sequencess to the list of recognized sequences.
 void resumeUpdate()
          Resumes updates of the clients of this key manager.
static int stringToKeyCode(java.lang.String keyName)
          Converts the given string to a keycode, as defined in the java\.awt\.event\.KeyEvent class.
 void suspendUpdate()
          Suspends updates of the clients of this key manager.
 void uninstall(javax.swing.JComponent c)
          Uninstalls the manager from the given JComponent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ESCAPE

public static final java.lang.String ESCAPE
Escape key for input/action maps

See Also:
Constant Field Values
Method Detail

stringToKeyCode

public static int stringToKeyCode(java.lang.String keyName)
Converts the given string to a keycode, as defined in the java\.awt\.event\.KeyEvent class. Note that the "VK_" must not be prepended to the string.

Parameters:
keyName - Key name to translate
Returns:
The key code or -1 if no such key exists

keyCodeToString

public static java.lang.String keyCodeToString(int keyCode)
Converts the given key code to a string, as defined in the java\.awt\.event\.KeyEvent class. Note that the "VK_" must not be prepended to the string.

Parameters:
keyCode - Key code to translate
Returns:
The key code or -1 if no such key exists

getInstance

public static KeyMgr getInstance()
Returns the singleton instance of the key manager, creating it if necessary.


install

public void install(javax.swing.JComponent c)
Installs the manager for the given JComponent. This should usually be the content pane of a toplevel container. Note that installing the manager to ANY component of a toplevel container activates the manager for the whole container. DO NOT call this method more than once for any component of the same tlc.

Parameters:
c - Component to install the manager to

uninstall

public void uninstall(javax.swing.JComponent c)
Uninstalls the manager from the given JComponent. Resets the input and action map of the container and removes the container from the manager's client list.

Parameters:
c - Component to uninstall the manager from

suspendUpdate

public void suspendUpdate()
Suspends updates of the clients of this key manager. This can be called before adding new key sequences to the manager.


resumeUpdate

public void resumeUpdate()
Resumes updates of the clients of this key manager. This must be called after adding new key sequences to the manager when the suspendUpdate() method has been called before.


addSequences

public void addSequences(java.util.Iterator sequences)
Adds the given sequences to the list of recognized sequences.

Parameters:
sequences - Iterator of KeySequence objects to add

removeSequences

public void removeSequences(java.util.Iterator sequences)
Removes the given sequencess to the list of recognized sequences.

Parameters:
sequences - Iterator of KeySequence objects to remove

addSequence

public void addSequence(KeySequence sequence)
Adds the given sequence to the list of recognized sequences.

Parameters:
sequence - Sequence to add

removeSequence

public void removeSequence(KeySequence sequence)
Removes the given sequences to the list of recognized sequences.

Parameters:
sequence - Sequence to remove


Copyright © 2011. All Rights Reserved.