edu.neu.ccs.gui
Class ActionSequence

java.lang.Object
  extended byjavax.swing.AbstractAction
      extended byedu.neu.ccs.gui.ActionSequence
All Implemented Interfaces:
Action, ActionListener, Cloneable, EventListener, Serializable

public class ActionSequence
extends AbstractAction
implements Serializable

An ordered collection of ActionListener objects similar to a List; the sequence itself is an instance of AbstractAction; the actionPerformed method of the sequence executes the actionPerformed method of each listener in its list in order of entry into the list.

Prior to version 2.3.3, this class required that its contents satisfy the stronger interface Action. To avoid the inconvenience of this restriction, certain parameter and return types were changed to require only the weaker interface ActionListener.

Since:
1.0
Version:
2.3.3
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.AbstractAction
 
Field Summary
protected  List actions
          The underlying list used for storage of action listeners.
 
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
ActionSequence()
          Constructs a sequence using the default underlying linear data structure.
ActionSequence(List l)
          Constructs a sequence using the given underlying linear data structure.
 
Method Summary
 void actionPerformed(ActionEvent evt)
          If this sequence is enabled then performs the enabled actions within the sequence in order; otherwise does nothing.
 boolean add(ActionListener a)
          Appends the given action listener to the end of this sequence.
 void add(int index, ActionListener a)
          Inserts the given action listener at the given index in this sequence.
 void clear()
          Removes all of the action listeners from this sequence.
 boolean contains(ActionListener a)
          Returns true if the given action listener is contained in this sequence, or false if it is not.
 boolean containsAll(Collection c)
          Returns true if this sequence contains all of the elements of the specified collection.
 boolean equals(Object object)
          Returns true if the given object is an ActionSequence and is equal to this sequence, and false if it is not.
 ActionListener get(int index)
          Returns the action listener at the given index in this sequence.
 int hashCode()
          Returns a hash code value for this sequence.
 int indexOf(ActionListener a)
          Returns the index in this sequence of the first occurence of the given action listener, or -1 if this sequence does not contain this action listener.
 boolean isEmpty()
          Returns true if this sequence is empty, and false if it is not.
 Iterator iterator()
          Returns an iterator over the action listeners in this sequence in proper order.
 int lastIndexOf(ActionListener a)
          Returns the index in this sequence of the last occurrence of the given action listener, or -1 if this list does not contain this action listener.
 ListIterator listIterator()
          Returns a list iterator over the action listeners in this sequence in order.
 ListIterator listIterator(int index)
          Returns a list iterator over the action listeners in this sequence in order, starting at the given index.
 boolean remove(ActionListener a)
          Removes the first occurrence of the given action listener in this sequence, and returns true, or returns false if this sequence does not contain the action listener.
 ActionListener remove(int index)
          Removes the action listener at the given index of the sequence.
 ActionListener set(int index, ActionListener a)
          Replaces the action listener at the given index in this sequence with the given action listener.
 int size()
          Returns the number of action listeners in this sequence.
 ActionSequence subList(int fromIndex, int toIndex)
          Returns an ActionSequence containing the action listeners in this sequence from the given starting index, inclusive, to the given ending index, exclusive.
 ActionListener[] toArray()
          Returns an array containing the action listeners in this sequence in order.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

actions

protected List actions
The underlying list used for storage of action listeners.

Constructor Detail

ActionSequence

public ActionSequence()
Constructs a sequence using the default underlying linear data structure.

See Also:
ActionSequence(List)

ActionSequence

public ActionSequence(List l)
Constructs a sequence using the given underlying linear data structure. If the given structure is null, the default structure is used.

Parameters:
l - the data structure to be used
See Also:
ActionSequence()
Method Detail

actionPerformed

public final void actionPerformed(ActionEvent evt)

If this sequence is enabled then performs the enabled actions within the sequence in order; otherwise does nothing.

As of 2.3.3, this sequence may contain objects that implement only the ActionListener interface in which case there is no notion of enabled. Therefore, if the sequence is enabled as a whole, those objects will perform their actions. However, to maintain backward compatibility, if an object in the sequence implements Action, then that object will only perform its action if it is individually enabled as well.

Specified by:
actionPerformed in interface ActionListener
Parameters:
evt - the action event

add

public void add(int index,
                ActionListener a)
Inserts the given action listener at the given index in this sequence.

See Also:
add(ActionListener)

add

public boolean add(ActionListener a)
Appends the given action listener to the end of this sequence.

Returns:
whether or not the action was successfully appended
See Also:
add(int, ActionListener)

clear

public void clear()
Removes all of the action listeners from this sequence.


contains

public boolean contains(ActionListener a)
Returns true if the given action listener is contained in this sequence, or false if it is not.

See Also:
containsAll(Collection)

containsAll

public boolean containsAll(Collection c)
Returns true if this sequence contains all of the elements of the specified collection.

See Also:
contains(ActionListener)

equals

public boolean equals(Object object)

Returns true if the given object is an ActionSequence and is equal to this sequence, and false if it is not.


get

public ActionListener get(int index)
Returns the action listener at the given index in this sequence.


hashCode

public int hashCode()
Returns a hash code value for this sequence.


indexOf

public int indexOf(ActionListener a)
Returns the index in this sequence of the first occurence of the given action listener, or -1 if this sequence does not contain this action listener.

See Also:
lastIndexOf(ActionListener)

isEmpty

public boolean isEmpty()
Returns true if this sequence is empty, and false if it is not.

See Also:
size()

iterator

public Iterator iterator()
Returns an iterator over the action listeners in this sequence in proper order.

See Also:
listIterator(), listIterator(int)

lastIndexOf

public int lastIndexOf(ActionListener a)
Returns the index in this sequence of the last occurrence of the given action listener, or -1 if this list does not contain this action listener.

See Also:
indexOf(ActionListener)

listIterator

public ListIterator listIterator()
Returns a list iterator over the action listeners in this sequence in order.

See Also:
listIterator(int), iterator()

listIterator

public ListIterator listIterator(int index)
Returns a list iterator over the action listeners in this sequence in order, starting at the given index.

See Also:
listIterator(), iterator()

remove

public ActionListener remove(int index)
Removes the action listener at the given index of the sequence.

Returns:
the action listener that was removed
See Also:
remove(ActionListener)

remove

public boolean remove(ActionListener a)
Removes the first occurrence of the given action listener in this sequence, and returns true, or returns false if this sequence does not contain the action listener.

See Also:
remove(int)

set

public ActionListener set(int index,
                          ActionListener a)
Replaces the action listener at the given index in this sequence with the given action listener.

Returns:
the action listener that was replaced

size

public int size()
Returns the number of action listeners in this sequence.

See Also:
isEmpty()

subList

public ActionSequence subList(int fromIndex,
                              int toIndex)
Returns an ActionSequence containing the action listeners in this sequence from the given starting index, inclusive, to the given ending index, exclusive.

See Also:
listIterator(int)

toArray

public ActionListener[] toArray()
Returns an array containing the action listeners in this sequence in order.

See Also:
iterator(), listIterator()