net.sourceforge.jsxe
Class ActionManager

java.lang.Object
  extended bynet.sourceforge.jsxe.ActionManager

public class ActionManager
extends Object

The ActionManager handles key bindings within jsXe. Key bindings can be set editor wide via the shortcuts option pane in the global options dialog.

While most actions are editor wide, some are editor wide but the implementations are view specific. These include Cut/Copy/Paste/Find which are common among different views thought their implementation will be provided by the view. These actions will be named using the format viewname.actionname (ex. treeview.cut). these special actions will have a single key binding associated with them but when invoked will activate view specific code provided by the plugin.

Since:
jsXe 0.5 pre1
Version:
$Id$
Author:
Ian Lewis (IanLewis@member.fsf.org)

Nested Class Summary
static class ActionManager.Wrapper
          The Wrapper class wraps LocalizedActions so they can be invoked through Swing via the ActionListener interface.
 
Field Summary
static String COPY_SUFFIX
           
static String CUT_SUFFIX
           
static String FIND_SUFFIX
           
static String PASTE_SUFFIX
           
 
Method Summary
static void addActionSet(ActionSet set)
          Adds a set of actions to the jsXe's pool of action sets.
static void addKeyBinding(String keyBinding, LocalizedAction action)
          Adds a key binding to this input handler.
static void addKeyBinding(String keyBinding, String action)
          Adds a key binding to jsXe.
static Action getAction(String name)
          Gets a true action for the LocalizedAction with the given name.
static ArrayList getActionSets()
          Gets all action sets that have been registered with jsXe
static LocalizedAction getLocalizedAction(String name)
          Gets the LocalizedAction set with the given name
static void handleKey(KeyEvent event)
          Handles a key event.
static void initKeyBindings()
          Initialized the key bindings for jsXe.
static void invokeAction(String name, ActionEvent evt)
          Invokes the action with the given name.
static boolean isDocViewSpecific(String actionName)
          Returns whether the action with the given name is document view specific.
static void removeAllKeyBindings()
          Removes all key bindings.
static void removeKeyBinding(String keyBinding)
          Removes a key binding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CUT_SUFFIX

public static final String CUT_SUFFIX
See Also:
Constant Field Values

COPY_SUFFIX

public static final String COPY_SUFFIX
See Also:
Constant Field Values

PASTE_SUFFIX

public static final String PASTE_SUFFIX
See Also:
Constant Field Values

FIND_SUFFIX

public static final String FIND_SUFFIX
See Also:
Constant Field Values
Method Detail

addActionSet

public static void addActionSet(ActionSet set)
Adds a set of actions to the jsXe's pool of action sets. This allows action sets from installed plugins to be added and retrieved via jsXe's pool of actions.

Parameters:
set - the action set to add

getLocalizedAction

public static LocalizedAction getLocalizedAction(String name)
Gets the LocalizedAction set with the given name

Returns:
the action set that matches the name, or null if none match.

getAction

public static Action getAction(String name)
Gets a true action for the LocalizedAction with the given name. This can be used in menus and toobars etc.

Parameters:
name - the name of the action.

getActionSets

public static ArrayList getActionSets()
Gets all action sets that have been registered with jsXe

Returns:
an ArrayList of ActionSet objects

invokeAction

public static void invokeAction(String name,
                                ActionEvent evt)
Invokes the action with the given name.

Parameters:
name - the internal name of the action

initKeyBindings

public static void initKeyBindings()
Initialized the key bindings for jsXe. This method is called at startup after plugins are loaded. Subsequent calls will do nothing.


addKeyBinding

public static void addKeyBinding(String keyBinding,
                                 String action)
Adds a key binding to jsXe.

Parameters:
keyBinding - The key binding
action - The action name

addKeyBinding

public static void addKeyBinding(String keyBinding,
                                 LocalizedAction action)
Adds a key binding to this input handler.

Parameters:
keyBinding - The key binding. It should be of the form described in KeyEventTranslator
action - The action

removeKeyBinding

public static void removeKeyBinding(String keyBinding)
Removes a key binding.

Parameters:
keyBinding - The key binding

removeAllKeyBindings

public static void removeAllKeyBindings()
Removes all key bindings.


handleKey

public static void handleKey(KeyEvent event)
Handles a key event. If the event matches any key bindings the associated action is invoked.


isDocViewSpecific

public static boolean isDocViewSpecific(String actionName)
Returns whether the action with the given name is document view specific.