edu.neu.ccs.gui
Class ActionWrapper

java.lang.Object
  extended byedu.neu.ccs.gui.ActionWrapper
All Implemented Interfaces:
Action, ActionListener, EventListener
Direct Known Subclasses:
DialogAction, ThreadedAction

public abstract class ActionWrapper
extends Object
implements Action

Base class for encapsulating Action objects to provide extra functionality.

Since:
2.0
Version:
2.2

Field Summary
protected  Action action
          The action to encapsulate as a thread.
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
ActionWrapper()
          Constructs an empty wrapper.
ActionWrapper(Action action)
          Constructs a wrapper that encapsulates the given action.
 
Method Summary
abstract  void actionPerformed(ActionEvent event)
          Implement the actionPerformed method to decide how the encapsulated action will be used.
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 Action getAction()
          Returns the encapsulated action.
static Action getBaseAction(Action action)
          Returns the base action that remains after recursively stripping all action wrappers from the given action.
 String getName()
          Returns the name associated with the action, or an empty String if no name is defined.
 Object getValue(String key)
           
 boolean isEnabled()
           
 void putValue(String key, Object value)
           
 void removePropertyChangeListener(PropertyChangeListener listener)
           
 void setAction(Action action)
          Sets the encapsulated action to the given action.
 void setEnabled(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

action

protected Action action
The action to encapsulate as a thread.

Constructor Detail

ActionWrapper

public ActionWrapper()
Constructs an empty wrapper.

See Also:
ActionWrapper(Action)

ActionWrapper

public ActionWrapper(Action action)
Constructs a wrapper that encapsulates the given action.

Parameters:
action - the action to encapsulate
See Also:
ActionWrapper()
Method Detail

getValue

public Object getValue(String key)
Specified by:
getValue in interface Action

putValue

public void putValue(String key,
                     Object value)
Specified by:
putValue in interface Action

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface Action

setEnabled

public void setEnabled(boolean b)
Specified by:
setEnabled in interface Action

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Specified by:
addPropertyChangeListener in interface Action

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Specified by:
removePropertyChangeListener in interface Action

actionPerformed

public abstract void actionPerformed(ActionEvent event)
Implement the actionPerformed method to decide how the encapsulated action will be used.

Specified by:
actionPerformed in interface ActionListener
Parameters:
event - the event that invoked this action

getAction

public Action getAction()
Returns the encapsulated action.

See Also:
setAction(Action)

setAction

public void setAction(Action action)
Sets the encapsulated action to the given action.

Parameters:
action - the action to encapsulate
See Also:
getAction()

getName

public String getName()
Returns the name associated with the action, or an empty String if no name is defined.


getBaseAction

public static Action getBaseAction(Action action)
Returns the base action that remains after recursively stripping all action wrappers from the given action. If the given action is not wrapped, the given action is itself returned.