com.algosome.common.util
Class ActionDelegate

java.lang.Object
  extended by com.algosome.common.util.ActionDelegate
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class ActionDelegate
extends java.lang.Object
implements java.awt.event.ActionListener

Delegates actions to the appropriate listeners. This class also keeps internally a ChangeManager so that when action are performed they are added to the manager so they can be undone.

Author:
Greg Cope

Constructor Summary
ActionDelegate()
          Creates a new ActionDelegate.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Implementation of the ActionListener interface.
 void addAction(java.lang.String key, java.awt.event.ActionListener listener)
          Adds an action to this object.
 java.util.Collection<java.lang.String> getActionCommands()
          Retrieves
 boolean hasAction(java.lang.String actionCommand)
          Determines if the parameter action command has an action
 boolean removeAction(java.lang.String key, java.awt.event.ActionListener listener)
          Removes the parameter action specified by the string key.
 void removeAllActionsFor(java.lang.String actionCommand)
          Removes all actions for the parameter action command
 void setRecorder(Recorder recorder)
          Sets a recorder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionDelegate

public ActionDelegate()
Creates a new ActionDelegate.

Method Detail

setRecorder

public void setRecorder(Recorder recorder)
Sets a recorder. This allows any called actions to be added to the recorder (if recording is set) and run at a later time in an automated way.

Parameters:
recorder -

getActionCommands

public java.util.Collection<java.lang.String> getActionCommands()
Retrieves

Returns:

addAction

public void addAction(java.lang.String key,
                      java.awt.event.ActionListener listener)
Adds an action to this object.

Parameters:
key -
listener -

removeAction

public boolean removeAction(java.lang.String key,
                            java.awt.event.ActionListener listener)
Removes the parameter action specified by the string key.

Parameters:
key - The key which defines the action
listener - The listener to remove.
Returns:
true if the listener was removed, false otherwise. False would indicate the parameter listener (as defined by hashCode/equals) was never registered prior to calling this function.

removeAllActionsFor

public void removeAllActionsFor(java.lang.String actionCommand)
Removes all actions for the parameter action command

Parameters:
key -

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Implementation of the ActionListener interface.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

hasAction

public boolean hasAction(java.lang.String actionCommand)
Determines if the parameter action command has an action

Parameters:
actionCommand -
Returns: