com.borland.primetime.actions
Class ActionGroup

java.lang.Object
  |
  +--javax.swing.AbstractAction
        |
        +--com.borland.primetime.actions.UpdateAction
              |
              +--com.borland.primetime.actions.ActionGroup

public class ActionGroup
extends UpdateAction

An ActionGroup is a type of UpdateAction that is actually a group of nested Action objects (potentially including nested ActionGroups). ActionGroups are used to define groups of Actions - that might appear as a set of items between separators on a menu, as a pop-up menu, or as a button cluster on a toolbar.

ActionGroups are used to build an Action hierarchy that can be mapped directly on a hierarchical UI - like a menu. Subclasses of ActionGroup do not need to override any methods. They are typically known groups that appear in different parts of the UI. An example ActionGroup is the list of Wizards.

See Also:
Action, Serialized Form

Field Summary
protected  java.util.ArrayList aList
          The storage for the group of Actions.
static java.lang.String DEFAULT_ACTION
          The attribute key for the DEFAULT_ACTION (Integer) property.
static java.lang.String LIST
          The attribute key for the LIST (pseudo) property.
static java.lang.String POPUP
          The storage attribute key for the POPUP (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
ActionGroup()
          Constructs an ActionGroup with all default settings.
ActionGroup(java.lang.String shortText)
          Constructs an ActionGroup with the specified shortText.
ActionGroup(java.lang.String shortText, char mnemonic)
          Constructs an ActionGroup with the specified shortText and mnemonic.
ActionGroup(java.lang.String shortText, char mnemonic, boolean popup)
          Constructs an ActionGroup with the specified shortText, mnemonic, and popup setting.
ActionGroup(java.lang.String shortText, char mnemonic, java.lang.String longText)
          Constructs an ActionGroup with the specified shortText, mnemonic, and longText.
ActionGroup(java.lang.String shortText, char mnemonic, java.lang.String longText, javax.swing.Icon smallIcon)
          Constructs an ActionGroup with the specified shortText, mnemonic, longText, and smallIcon.
ActionGroup(java.lang.String shortText, char mnemonic, java.lang.String longText, javax.swing.Icon smallIcon, boolean popup)
          Constructs an ActionGroup with the specified shortText, mnemonic, longText, smallIcon, and popup setting.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          The default implementation of actionPerformed(ActionEvent e) does nothing for an ActionGroup.
 void add(javax.swing.Action a)
          Adds a Action to the end of this ActionGroup.
 void add(int index, javax.swing.Action a)
          Adds a Action into this ActionGroup at the specified index.
 javax.swing.Action getAction(int index)
          Returns the Action object at the specified index.
 int getActionCount()
          Returns the number of Actions in this ActionGroup.
 javax.swing.Action[] getActions()
          Returns an array of Action objects in this ActionGroup.
 int getDefaultAction()
          Returns the default action index.
 boolean isPopup()
          Returns the popup property setting.
 void remove(javax.swing.Action a)
          Removes the specified Action from this ActionGroup.
 void removeAll()
          Removes all Actions from this ActionGroup.
 void setDefaultAction(int defaultAction)
          Sets the default action index.
 void setPopup(boolean popup)
          Sets the popup property.
 void update(java.lang.Object source)
           The default implementation of update is as follows: If the ActionGroup's popup property is set to true, nothing happens.
 
Methods inherited from class com.borland.primetime.actions.UpdateAction
getHelpTopic, getLargeIcon, getLongText, getMnemonic, getShortText, getSmallIcon, setHelpTopic, setLargeIcon, setLongText, setMnemonic, setShortText, setSmallIcon
 
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

POPUP

public static final java.lang.String POPUP
The storage attribute key for the POPUP (Boolean) property. When the POPUP property is set to 'Boolean.TRUE', the ActionGroup is displayed as a popup menu or toolbar, etc. If it is set to anything else (including null), the ActionGroup is displayed as a 'cluster'.

LIST

public static final java.lang.String LIST
The attribute key for the LIST (pseudo) property. When actions are added or removed from the ActionGroup, a PropertyChangeEvent fires for the LIST property - with both the oldValue and newValue as null.

DEFAULT_ACTION

public static final java.lang.String DEFAULT_ACTION
The attribute key for the DEFAULT_ACTION (Integer) property.

aList

protected java.util.ArrayList aList
The storage for the group of Actions.
Constructor Detail

ActionGroup

public ActionGroup()
Constructs an ActionGroup with all default settings.

ActionGroup

public ActionGroup(java.lang.String shortText)
Constructs an ActionGroup with the specified shortText.
Parameters:
shortText - The short text for the ActionGroup

ActionGroup

public ActionGroup(java.lang.String shortText,
                   char mnemonic)
Constructs an ActionGroup with the specified shortText and mnemonic.
Parameters:
shortText - The short text for the ActionGroup
mnemonic - The mnemonic for the ActionGroup

ActionGroup

public ActionGroup(java.lang.String shortText,
                   char mnemonic,
                   boolean popup)
Constructs an ActionGroup with the specified shortText, mnemonic, and popup setting.
Parameters:
shortText - The short text for the ActionGroup
mnemonic - The mnemonic for the ActionGroup
popup - The popup setting for the ActionGroup

ActionGroup

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

ActionGroup

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

ActionGroup

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

setDefaultAction

public void setDefaultAction(int defaultAction)
Sets the default action index.
Parameters:
defaultAction - The default action index for this ActionGroup

getDefaultAction

public int getDefaultAction()
Returns the default action index.
Returns:
The default action index for this ActionGroup

setPopup

public void setPopup(boolean popup)
Sets the popup property. The popup property controls wether the ActionGroup will be represented in a menu as a group of actions between separators or as a pop-up menu. By default, ActionGroups are flat - the popup property is set to false.
Parameters:
popup - The popup setting for the ActionGroup (default: false)

isPopup

public boolean isPopup()
Returns the popup property setting.
Returns:
The popup setting for the ActionGroup

getActionCount

public int getActionCount()
Returns the number of Actions in this ActionGroup.
Returns:
An int representing the count of Actions in this ActionGroup.

getAction

public javax.swing.Action getAction(int index)
Returns the Action object at the specified index.
Returns:
The Action at the specified index.

getActions

public javax.swing.Action[] getActions()
Returns an array of Action objects in this ActionGroup. The returned array may contain nested ActionGroups, which, in turn, may contain more nested ActionGroups as well as Actions.
Returns:
The array of Actions in this ActionGroup.

add

public void add(javax.swing.Action a)
Adds a Action to the end of this ActionGroup.
Parameters:
a - The Action object to add to the end of this ActionGroup.

add

public void add(int index,
                javax.swing.Action a)
Adds a Action into this ActionGroup at the specified index.
Parameters:
index - The int location to insert the Action object.
a - The Action object to insert into this ActionGroup.

remove

public void remove(javax.swing.Action a)
Removes the specified Action from this ActionGroup.
Parameters:
a - The Action object to remove from this ActionGroup.

removeAll

public void removeAll()
Removes all Actions from this ActionGroup.

update

public void update(java.lang.Object source)

The default implementation of update is as follows: If the ActionGroup's popup property is set to true, nothing happens. If the popup property is false (a flat ActionGroup), the nested Actions are scanned, and the update method is called on each one (that is a UpdateAction).

A subclass may wish to also respond to the update call and enable or disable the popup itself. Be sure to call super.update(...) when overriding, so that nested Actions are appropriately notified as well.

Overrides:
update in class UpdateAction
Tags copied from class: UpdateAction
Parameters:
source - The source of the action that is about to be displayed as UI.

actionPerformed

public final void actionPerformed(java.awt.event.ActionEvent e)
The default implementation of actionPerformed(ActionEvent e) does nothing for an ActionGroup. Subclasses cannot override this, as this method will never be called on an ActionGroup.
Overrides:
actionPerformed in class javax.swing.AbstractAction