com.borland.primetime.actions
Class StateAction

java.lang.Object
  |
  +--javax.swing.AbstractAction
        |
        +--com.borland.primetime.actions.UpdateAction
              |
              +--com.borland.primetime.actions.StateAction
Direct Known Subclasses:
BrowserStateAction

public abstract class StateAction
extends UpdateAction

A StateAction is a type of UpdateAction that encapsulates a single state property.

A StateAction functions as a regular UpdateAction (or Swing Action object) - it stores the shortText, longText, icon, and enabled state for a single boolean state. The difference is that a StateAction represents a boolean state - as opposed to the UpdateAction (or Action) that represents an arbitrary action.

Subclasses of StateAction need only override the two abstract methods: public void setState(Object source, boolean state) and public boolean getState(Object source) . They can optionally override the public method: public void update(Object source) to initialize the StateAction object immediately before it is represented as UI somewhere in the environment.

The Grouped property is added to allow a StateAction to appear as grouped in UI - like the use of a radio button or toggle button instead of a checkbox.

See Also:
Action, Serialized Form

Field Summary
static java.lang.String GROUPED
          The storage attribute key for the GROUPED (Boolean) property.
 
Fields inherited from class com.borland.primetime.actions.UpdateAction
ACCELERATOR, EMPTY_ARRAY, HELP_TOPIC, LARGE_ICON, MNEMONIC
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Constructor Summary
StateAction()
          Constructs a StateAction will all default properties.
StateAction(java.lang.String shortText)
          Constructs a StateAction will the specified shortText.
StateAction(java.lang.String shortText, char mnemonic)
          Constructs a StateAction will the specified shortText and mnemonic.
StateAction(java.lang.String shortText, char mnemonic, java.lang.String longText)
          Constructs a StateAction will the specified shortText, mnemonic, and longText.
StateAction(java.lang.String shortText, char mnemonic, java.lang.String longText, javax.swing.Icon smallIcon)
          Constructs a StateAction will the specified shortText, mnemonic, longText, and smallIcon.
StateAction(java.lang.String shortText, char mnemonic, java.lang.String longText, javax.swing.Icon smallIcon, boolean grouped)
          Constructs a StateAction will the specified shortText, mnemonic, longText, smallIcon, and grouped setting.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          The StateAction class implements the actionPerformed(ActionEvent e) method as a toggle.
abstract  boolean getState(java.lang.Object source)
          Subclasses should implement this method by returning the appropriate boolean based on the passed source context.
 boolean isGrouped()
          Returns the grouped property setting.
 void setGrouped(boolean grouped)
          Sets the grouped property.
abstract  void setState(java.lang.Object source, boolean state)
          Subclasses should implement this method by setting the appropriate boolean state using the passed source context.
 
Methods inherited from class com.borland.primetime.actions.UpdateAction
getHelpTopic, getLargeIcon, getLongText, getMnemonic, getShortText, getSmallIcon, setHelpTopic, setLargeIcon, setLongText, setMnemonic, setShortText, setSmallIcon, update
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROUPED

public static final java.lang.String GROUPED
The storage attribute key for the GROUPED (Boolean) property. When the GROUPED property is set to 'Boolean.TRUE', the StateAction is displayed as a grouped state - with a radio button rather than a checkbox.
Constructor Detail

StateAction

public StateAction()
Constructs a StateAction will all default properties.

StateAction

public StateAction(java.lang.String shortText)
Constructs a StateAction will the specified shortText.
Parameters:
shortText - The short text for the StateAction

StateAction

public StateAction(java.lang.String shortText,
                   char mnemonic)
Constructs a StateAction will the specified shortText and mnemonic.
Parameters:
shortText - The short text for the StateAction
mnemonic - The mnemonic for the StateAction

StateAction

public StateAction(java.lang.String shortText,
                   char mnemonic,
                   java.lang.String longText)
Constructs a StateAction will the specified shortText, mnemonic, and longText.
Parameters:
shortText - The short text for the StateAction
mnemonic - The mnemonic for the StateAction
longText - The long text for the StateAction

StateAction

public StateAction(java.lang.String shortText,
                   char mnemonic,
                   java.lang.String longText,
                   javax.swing.Icon smallIcon)
Constructs a StateAction will the specified shortText, mnemonic, longText, and smallIcon.
Parameters:
shortText - The short text for the StateAction
mnemonic - The mnemonic for the StateAction
longText - The long text for the StateAction
smallIcon - The small icon for the StateAction

StateAction

public StateAction(java.lang.String shortText,
                   char mnemonic,
                   java.lang.String longText,
                   javax.swing.Icon smallIcon,
                   boolean grouped)
Constructs a StateAction will the specified shortText, mnemonic, longText, smallIcon, and grouped setting.
Parameters:
shortText - The short text for the StateAction
mnemonic - The mnemonic for the StateAction
longText - The long text for the StateAction
smallIcon - The small icon for the StateAction
grouped - The grouped setting for the StateAction
Method Detail

setGrouped

public void setGrouped(boolean grouped)
Sets the grouped property. When the grouped property is set to true, the StateAction is displayed as a grouped state - with a radio button rather than a checkbox.
Parameters:
grouped - The grouped state

isGrouped

public boolean isGrouped()
Returns the grouped property setting.
Returns:
The grouped state

actionPerformed

public final void actionPerformed(java.awt.event.ActionEvent e)
The StateAction class implements the actionPerformed(ActionEvent e) method as a toggle. This behavior cannot be overriden.
Overrides:
actionPerformed in class javax.swing.AbstractAction

setState

public abstract void setState(java.lang.Object source,
                              boolean state)
Subclasses should implement this method by setting the appropriate boolean state using the passed source context.

getState

public abstract boolean getState(java.lang.Object source)
Subclasses should implement this method by returning the appropriate boolean based on the passed source context.