DESY ACOP Beans Home

com.cosylab.gui.components.util
Class ActionList

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by com.cosylab.gui.components.util.ActionList
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

public class ActionList
extends javax.swing.AbstractAction

An action which holds a list of other Action objects. Convenient for containment of functionally similar actions.

With asotiation with Action can be used for creation of menus. Set putValue(MENU_CONTEXT,MENU_CONTEXT_RADIO) to produce group of radio menu items.

Action will use separator menu item, where null actionitemisplaced or Action has SEPARATOR boolean attribute.

Version:
$id$
Author:
Miha Kadunc
See Also:
Serialized Form

Field Summary
static java.lang.String ACTIONS
          DOCUMENT ME!
static java.lang.String MENU_CONTEXT
          Key name for a String value indicating if this list is to be presented in menu with buttons or radio buttons.
static java.lang.String MENU_CONTEXT_BUTTON
          DOCUMENT ME!
static java.lang.String MENU_CONTEXT_RADIO
          DOCUMENT ME!
static java.lang.String SEPARATOR
          Key name for a Boolean value indicating that the added action should be represented in the GUI as a separator.
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
ActionList()
          Creates a new ActionList object.
ActionList(java.lang.String name)
          Creates a new ActionList object.
ActionList(java.lang.String name, javax.swing.Icon icon)
          Creates a new ActionList object.
ActionList(java.lang.String name, javax.swing.Icon icon, javax.swing.Action[] actions)
          Creates a new ActionList object.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addAction(javax.swing.Action action)
          Adds Action to end of the list.
 void addAction(int index, javax.swing.Action action)
           
 void addAll(ActionList action)
          Adds all actions from ActionList to end of the this list in specified order.
 void clear()
          Removes all actions from this list.
 boolean contains(javax.swing.Action action)
          Checks if this list contains the given action.
 boolean containsActionWithName(java.lang.String name)
          Checks if the list containes action with the given name.
 int firstIndexOfActionWithName(java.lang.String name)
          Returns the index of the first action with the given name.
 javax.swing.Action getAction(int index)
          Returns Action under provided index.
 javax.swing.Action getAction(java.lang.String ID)
          Returns Action which command ID corresponds to the provided parameter.
 int indexOf(javax.swing.Action action)
           
 java.util.Iterator iterator()
          Returns iterator over contained actions.
 void removeAction(javax.swing.Action action)
           
 javax.swing.Action removeAction(int index)
           
 int size()
          Returns the size of this list (number of actions in the list).
 javax.swing.Action[] toArray()
          Returns all contained actions in an array.
 
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

SEPARATOR

public static final java.lang.String SEPARATOR
Key name for a Boolean value indicating that the added action should be represented in the GUI as a separator.

See Also:
Constant Field Values

MENU_CONTEXT

public static final java.lang.String MENU_CONTEXT
Key name for a String value indicating if this list is to be presented in menu with buttons or radio buttons.

See Also:
Action.getValue(java.lang.String), Constant Field Values

MENU_CONTEXT_BUTTON

public static final java.lang.String MENU_CONTEXT_BUTTON
DOCUMENT ME!

See Also:
Constant Field Values

MENU_CONTEXT_RADIO

public static final java.lang.String MENU_CONTEXT_RADIO
DOCUMENT ME!

See Also:
Constant Field Values

ACTIONS

public static java.lang.String ACTIONS
DOCUMENT ME!

Constructor Detail

ActionList

public ActionList()
Creates a new ActionList object.


ActionList

public ActionList(java.lang.String name)
Creates a new ActionList object.

Parameters:
name -

ActionList

public ActionList(java.lang.String name,
                  javax.swing.Icon icon)
Creates a new ActionList object.

Parameters:
name -
icon -

ActionList

public ActionList(java.lang.String name,
                  javax.swing.Icon icon,
                  javax.swing.Action[] actions)
Creates a new ActionList object.

Parameters:
name -
icon -
actions -
Method Detail

addAction

public void addAction(javax.swing.Action action)
Adds Action to end of the list.

Parameters:
action - Action to be added

contains

public boolean contains(javax.swing.Action action)
Checks if this list contains the given action.

Parameters:
action -
Returns:
true if action exists in the list

containsActionWithName

public boolean containsActionWithName(java.lang.String name)
Checks if the list containes action with the given name.

Parameters:
name - name of the action
Returns:
true if action is present in the list

firstIndexOfActionWithName

public int firstIndexOfActionWithName(java.lang.String name)
Returns the index of the first action with the given name.

Parameters:
name - name of the action
Returns:
index of the action in the list

addAll

public void addAll(ActionList action)
Adds all actions from ActionList to end of the this list in specified order.

Parameters:
action - actions to be added

addAction

public void addAction(int index,
                      javax.swing.Action action)

getAction

public javax.swing.Action getAction(int index)
Returns Action under provided index.

Parameters:
index - the index of requested action
Returns:
the action

getAction

public javax.swing.Action getAction(java.lang.String ID)
Returns Action which command ID corresponds to the provided parameter.

Parameters:
ID - the command key string of action
Returns:
Action which command ID corresponds to the provided parameter
See Also:
Action.ACTION_COMMAND_KEY

indexOf

public int indexOf(javax.swing.Action action)

removeAction

public void removeAction(javax.swing.Action action)

removeAction

public javax.swing.Action removeAction(int index)

size

public int size()
Returns the size of this list (number of actions in the list).

Returns:
the size

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)

toArray

public javax.swing.Action[] toArray()
Returns all contained actions in an array.

Returns:
returns all contained actions in an array

iterator

public java.util.Iterator iterator()
Returns iterator over contained actions.

Returns:
iterator over contained actions

clear

public void clear()
Removes all actions from this list.



Copyright © 2010. All Rights Reserved.