org.yasl.arch.impl.action
Class YASLGUIAbstractAction

java.lang.Object
  extended byjavax.swing.AbstractAction
      extended byorg.yasl.arch.impl.action.YASLGUIAbstractAction
All Implemented Interfaces:
Action, ActionListener, Cloneable, EventListener, Serializable
Direct Known Subclasses:
YASLSwingAbstractAction

public abstract class YASLGUIAbstractAction
extends AbstractAction

Base YASL action for GUI applications.

Implements the actionPerformed method from the Action interface as a Runnable wrapper that is started by a call to SwingUtilities.invokeLater.

Extending classes implement their code in the performAction method.

See Also:
Runnable, Serialized Form

Field Summary
static String COMMAND_SYNCHRONOUS_CALL
          A command string that signals the call to the action's method should be synchronous instead of the default asynchronous call.
 
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
YASLGUIAbstractAction(String name, boolean initialState, ImageIcon imageIcon, YASLGUIApplication yaslApp)
          Sets the NAME and SHORT_DESCRIPTION properties to the value of the name param.
YASLGUIAbstractAction(String name, boolean initialState, YASLGUIApplication yaslApp)
          Sets the NAME and SHORT_DESCRIPTION properties to the value of the name param.
YASLGUIAbstractAction(String name, String shortName, boolean initialState, ImageIcon imageIcon, YASLGUIApplication yaslApp)
          Sets the NAME, SHORT_DESCRIPTION, and SMALL_ICON properties.
YASLGUIAbstractAction(String name, String shortName, boolean initialState, YASLGUIApplication yaslApp)
          Sets the NAME and SHORT_DESCRIPTION properties.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Creates a Runnable object that wraps a call to performAction.
 boolean getInitialState()
          Returns the initial state.
 String getName()
          Returns the NAME property.
protected  YASLApplication getYASLApplication()
          Returns the application object as a YASLApplication instance.
protected  YASLGUIApplication getYASLGUIApplication()
          Returns the application object as a YASLGUIApplication instance.
protected abstract  void performAction(ActionEvent e)
          Abstract method that is called from the actionPerformed method.
 void setName(String name)
          Sets the NAME and SHORT_DESCRIPTION properties to the param value.
 void setName(String name, String shortName)
          Sets the NAME and SHORT_DESCRIPTION properties to the respective param values.
 void setToInitialState()
          Resets the action to its initial state.
 
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
 

Field Detail

COMMAND_SYNCHRONOUS_CALL

public static final String COMMAND_SYNCHRONOUS_CALL
A command string that signals the call to the action's method should be synchronous instead of the default asynchronous call.

See Also:
Constant Field Values
Constructor Detail

YASLGUIAbstractAction

public YASLGUIAbstractAction(String name,
                             boolean initialState,
                             YASLGUIApplication yaslApp)
Sets the NAME and SHORT_DESCRIPTION properties to the value of the name param. Stores a reference to the YASLGUIApplication instance and sets the action to the passed initialState.

Parameters:
name - String
initialState - boolean
yaslApp - YASLGUIApplication

YASLGUIAbstractAction

public YASLGUIAbstractAction(String name,
                             boolean initialState,
                             ImageIcon imageIcon,
                             YASLGUIApplication yaslApp)
Sets the NAME and SHORT_DESCRIPTION properties to the value of the name param. Also sets the SMALL_ICON property. Stores a reference to the YASLGUIApplication instance and sets the action to the passed initialState.

Parameters:
name - String
initialState - boolean
imageIcon - ImageIcon
yaslApp - YASLGUIApplication

YASLGUIAbstractAction

public YASLGUIAbstractAction(String name,
                             String shortName,
                             boolean initialState,
                             YASLGUIApplication yaslApp)
Sets the NAME and SHORT_DESCRIPTION properties. Stores a reference to the YASLGUIApplication instance and sets the action to the passed initialState.

Parameters:
name - String
shortName - String
initialState - boolean
yaslApp - YASLGUIApplication

YASLGUIAbstractAction

public YASLGUIAbstractAction(String name,
                             String shortName,
                             boolean initialState,
                             ImageIcon imageIcon,
                             YASLGUIApplication yaslApp)
Sets the NAME, SHORT_DESCRIPTION, and SMALL_ICON properties. Stores a reference to the YASLGUIApplication instance and sets the action to the passed initialState.

Parameters:
name - String
shortName - String
initialState - boolean
imageIcon - ImageIcon
yaslApp - YASLGUIApplication
Method Detail

setName

public void setName(String name)
Sets the NAME and SHORT_DESCRIPTION properties to the param value.

Parameters:
name - String

setName

public void setName(String name,
                    String shortName)
Sets the NAME and SHORT_DESCRIPTION properties to the respective param values.

Parameters:
name - String
shortName - String

getName

public String getName()
Returns the NAME property.

Returns:
String

setToInitialState

public void setToInitialState()
Resets the action to its initial state.


getInitialState

public boolean getInitialState()
Returns the initial state.

Returns:
boolean

performAction

protected abstract void performAction(ActionEvent e)
                               throws Exception
Abstract method that is called from the actionPerformed method. Extending classes must implement their action specific code in this method.

Parameters:
e - ActionEvent
Throws:
Exception

getYASLApplication

protected YASLApplication getYASLApplication()
Returns the application object as a YASLApplication instance.

Returns:
YASLApplication

getYASLGUIApplication

protected YASLGUIApplication getYASLGUIApplication()
Returns the application object as a YASLGUIApplication instance.

Returns:
YASLGUIApplication

actionPerformed

public final void actionPerformed(ActionEvent e)
Creates a Runnable object that wraps a call to performAction. The runnable object is started with a call to SwingUtilities.invokeLater.

Parameters:
e - ActionEvent
See Also:
Runnable