org.fife.ui.app
Class ActionRegistry

java.lang.Object
  extended by org.fife.ui.app.ActionRegistry

public class ActionRegistry
extends java.lang.Object

A mapping of keys to actions. Instances of AbstractGUIApplication use this class to keep track of their actions, and to simply loading and saving their customized shortcuts.

Version:
1.0
Author:
Robert Futrell

Constructor Summary
ActionRegistry()
           
 
Method Summary
 void addAction(java.lang.String key, javax.swing.Action action)
          Adds an action to this action registry.
 javax.swing.Action getAction(java.lang.String key)
          Returns an action by its key.
 java.util.SortedSet<java.lang.String> getActionKeys()
          Returns the list of keys of all actions known to this registry.
 javax.swing.Action[] getActions()
          Returns all actions as an array.
 void loadShortcuts(java.io.File file)
          Loads shortcuts for the actions from a file.
 void saveShortcuts(java.io.File file)
          Saves the shortcuts of all actions in this registry to a properties file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionRegistry

public ActionRegistry()
Method Detail

addAction

public void addAction(java.lang.String key,
                      javax.swing.Action action)
Adds an action to this action registry.

Parameters:
key - The key with which to fetch the action via getAction.
action - The action to add.
See Also:
getAction(String)

getAction

public javax.swing.Action getAction(java.lang.String key)
Returns an action by its key.

Returns:
The action, or null if no action exists for the specified key.
See Also:
addAction(String, Action), getActions()

getActionKeys

public java.util.SortedSet<java.lang.String> getActionKeys()
Returns the list of keys of all actions known to this registry.

Returns:
The list of all action keys.

getActions

public javax.swing.Action[] getActions()
Returns all actions as an array.

Returns:
The actions. An empty array is returned if the action map has not yet been initialized.
See Also:
getAction(String)

loadShortcuts

public void loadShortcuts(java.io.File file)
                   throws java.io.IOException
Loads shortcuts for the actions from a file. The file is expected to be a standard Java properties file; its keys correspond to the action keys in this registry, and its values correspond go the KeyStrokes to use for action accelerators.

If any property key doesn't have a corresponding action in this registry, it is ignored. If any property value isn't a valid KeyStroke, it is ignored.

Parameters:
file - The properties file to load.
Throws:
java.io.IOException - If an IO error occurs reading the file.
See Also:
saveShortcuts(File)

saveShortcuts

public void saveShortcuts(java.io.File file)
                   throws java.io.IOException
Saves the shortcuts of all actions in this registry to a properties file. Property keys are the action keys, property values are the KeyStrokes for the shortcuts for each action. Actions with no shortcut will have an empty string value for their property.

Parameters:
file - The file to save to.
Throws:
java.io.IOException - If an IO error occurs writing the file.
See Also:
loadShortcuts(File)