eTextReader.actions
Class BaseAction
java.lang.Object
javax.swing.AbstractAction
eTextReader.actions.BaseAction
- All Implemented Interfaces:
- java.awt.event.ActionListener, java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
- Direct Known Subclasses:
- BrowserAction, CurrentAnnotationAction, DeleteHighlightAction, NotationListingAction
public abstract class BaseAction
- extends javax.swing.AbstractAction
- implements java.beans.PropertyChangeListener
This class serves as a base class for all the actions associated with the eTextReader. It has three
main purposes:
- to provide a constructor that helps set up the icon associated with the action
- to enforce the singleton access of action objects derived from this class
- to provide management of the accelerator keystroke associated with the action
- Author:
- mcfall
- See Also:
- Serialized Form
Nested Class Summary |
(package private) static class |
BaseAction.Key
This class is used as a key to find a specific type of action associated with a specific object |
Field Summary |
(package private) static java.util.HashMap<BaseAction.Key,javax.swing.Action> |
instances
Maintains a set of references to actions associated with a specific component |
Fields inherited from class javax.swing.AbstractAction |
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON |
Constructor Summary |
protected |
BaseAction()
Constructs a BaseAction instance with no icon associated with the action |
protected |
BaseAction(java.lang.String fileName)
Constructs a BaseAction instance with the specified icon |
Methods inherited from class javax.swing.AbstractAction |
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.awt.event.ActionListener |
actionPerformed |
instances
static java.util.HashMap<BaseAction.Key,javax.swing.Action> instances
- Maintains a set of references to actions associated with a specific component
BaseAction
protected BaseAction()
- Constructs a BaseAction instance with no icon associated with the action
BaseAction
protected BaseAction(java.lang.String fileName)
- Constructs a BaseAction instance with the specified icon
- Parameters:
fileName
- the path to an icon file; currently the file
must reside in the directory returned by ContentPane.getHomeDir()
getInstance
public static javax.swing.Action getInstance(java.lang.Object object,
java.lang.Class actionClass)
- Retrieve an action associated with a specified object of a specific type. If an action
with the desired type has already been created for that specified object, it is returned;
otherwise, a new action is created and returned. The object is created via Java's reflection
methods, since we don't know the object's type at compile time
- Parameters:
object
- the object that action is associated withactionClass
- the class of the desired action
- Returns:
- An action of the desired class associated with the specified object
- Throws:
java.lang.Exception
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- Specified by:
propertyChange
in interface java.beans.PropertyChangeListener
updateAcceleratorFromPreferences
private void updateAcceleratorFromPreferences()
getAcceleratorKeyStrokeFromPreferences
protected javax.swing.KeyStroke getAcceleratorKeyStrokeFromPreferences()
- Returns the KeyStroke associated with this action from the user's
application preferences. The default implementation here returns null.
Any action that wants to associate an accelerator with its action that
will be maintained by the ApplicationPreferences class should override
this method to load the KeyStroke from the user's application preferences
- Returns: