com.fullspan.pwkeep.gui
Class PwkAction
java.lang.Object
javax.swing.AbstractAction
com.fullspan.pwkeep.gui.PwkAction
- All Implemented Interfaces:
- java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
public class PwkAction
- extends javax.swing.AbstractAction
This class represents an action that can be performed in the user interface.
As explained in
Sun's Java Tutorial, actions are convenient when you have
multiple user interface elements (for example, both a toolbar button
and a menu item) that perform the same operation.
Two common techniques for handling user interface events are:
- have a separate class (often an anonymous inner class) to handle each
operation
- have a single class/method with a list of if conditions
This class uses a different technique: it is a generic class that uses
uses a naming convention for its attributes and event dispatching.
The following attributes are retrieved from the
messages.properties file:
- menu text
- short description
- icon [optional]
- mnemonic [optional]
For example, the entries in messages.properties for the
FileSave action are:
action.FileSave.menutext=Save
action.FileSave.shortdesc=Save the current file
action.FileSave.icon=file-save.gif
action.FileSave.mnemonic=S
- Version:
- $Revision: 1.3 $, $Date: 2004/01/18 07:21:04 $
- Author:
- Mitch Stuart, $Author: mitch $
- See Also:
IPwkActionHandler,
PwkActionMgr,
Serialized Form
| Fields inherited from class javax.swing.AbstractAction |
changeSupport, enabled |
| Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON |
|
Constructor Summary |
PwkAction(java.lang.String name)
Creates a new action with the given name, whose enabled state does
not depend on the current selection. |
PwkAction(java.lang.String name,
int selectionMask)
Creates a new action with the given name and selection mask. |
| 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 |
PwkAction
public PwkAction(java.lang.String name,
int selectionMask)
- Creates a new action with the given name and selection mask. The
selection mask determines when the action is in the enabled vs.
disabled state. When the current selection in the user interface
is one of the selections in the specified selection mask, then this
action is enabled, otherwise it is disabled. The selection mask
should contain one or more of the
PwkSelectionMgr.SELECTION_* values.
- Parameters:
name - the name of the actionselectionMask - the selection mask indicating which selections
are valid for this action to be in the enabled state- See Also:
PwkSelectionMgr
PwkAction
public PwkAction(java.lang.String name)
- Creates a new action with the given name, whose enabled state does
not depend on the current selection. Equivalent to calling
PwkAction(name, PwkSelectionMgr.SELECTION_DONT_CARE).
- Parameters:
name - the name of the action, for example FileSave- See Also:
PwkAction(String, int)
setActionDispatcher
public static void setActionDispatcher(IPwkActionDispatcher actionDispatcher)
- Register an action dispatcher that will be invoked whenever an
action is performed. This method should be called once before
any actions are performed.
getName
public java.lang.String getName()
- Returns:
- the name of this action
getSelectionMask
public int getSelectionMask()
- Returns:
- the selection mask of this action
- See Also:
PwkAction(String, int)
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Dispatches this action by invoking the action dispatcher
registered with
setActionDispatcher. If no dispatcher
has been registered, this method does not do anything.
- See Also:
ActionListener.actionPerformed(ActionEvent)