org.pvv.bcd.instrument.JTree
Class InfoBankTreeAction
java.lang.Object
|
+--javax.swing.AbstractAction
|
+--org.pvv.bcd.instrument.JTree.InfoBankTreeAction
- All Implemented Interfaces:
- javax.swing.Action, java.awt.event.ActionListener, java.lang.Cloneable, java.util.EventListener, java.beans.PropertyChangeListener, java.io.Serializable
- public class InfoBankTreeAction
- extends javax.swing.AbstractAction
- implements java.beans.PropertyChangeListener
A specialized action-wrapper class that handles both the state imposed by the
tree and the state imposed from the outside. That is, even if you call
setEnabled(true)
on an action, it
may not return true from isEnabled()
.
For instance, if the action is a "Copy", the instrumenter will not allow
it to be enabled unless there is an active selection in the tree.
Two states are taken into account to achieve this. One is the
user_state
. The other is the tree_state
.
The user state is set by calling setEnabled()
on the InfoBankTreeAction
. The
tree state depends on the state of the instrumented tree and is supplied
by the Action
object passed to
the constructor. isEnabled()
in this class effectively returns
(user_state && tree_state)
.
- See Also:
- Serialized Form
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 |
InfoBankTreeAction(java.lang.String title,
javax.swing.Action act)
Creates the action. |
Method Summary |
void |
actionPerformed(java.awt.event.ActionEvent ev)
Forwards actionPerformed() to my wrapped action. |
boolean |
isEnabled()
Returns true only if both I and the wrapped action are both
enabled. |
void |
propertyChange(java.beans.PropertyChangeEvent ev)
Catches the "enabled" property change in the wrapped action object.
|
Methods inherited from class javax.swing.AbstractAction |
addPropertyChangeListener, clone, firePropertyChange, getKeys, getValue, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
InfoBankTreeAction
public InfoBankTreeAction(java.lang.String title,
javax.swing.Action act)
- Creates the action. Adds myself as property change listener to the
given action object so I can react to enablement changes.
- Parameters:
title
- Title, passed to super.act
- Action object to instrument with dual-state functionality.
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent ev)
- Catches the "enabled" property change in the wrapped action object.
Fires an "enabled" property change based upon the new joint state of
this action.
- Specified by:
propertyChange
in interface java.beans.PropertyChangeListener
- Parameters:
ev
- Event to react to.
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent ev)
- Forwards actionPerformed() to my wrapped action.
- Overrides:
actionPerformed
in class javax.swing.AbstractAction
- Parameters:
ev
- Event to forward
isEnabled
public boolean isEnabled()
- Returns true only if both I and the wrapped action are both
enabled.
- Overrides:
isEnabled
in class javax.swing.AbstractAction
- Returns:
- Enabled status of this action