org.progeeks.util.swing
Class ActionList

java.lang.Object
  extended by org.progeeks.util.DefaultObservableList
      extended by org.progeeks.util.swing.ActionList
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.EventListener, java.util.List, javax.swing.Action, ObservableList, ViewContextAware
Direct Known Subclasses:
ActionListGroup, CheckBoxActionGroup, LookAndFeelActions

public class ActionList
extends DefaultObservableList
implements javax.swing.Action, ViewContextAware, java.lang.Cloneable

A list of actions that itself implements the Action interface. This allows additional information to be associated with the list such as name, description, enabled, etc.

Version:
$Revision: 1.14 $
Author:
Paul Speed
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
ActionList()
           
ActionList(java.lang.String name)
           
ActionList(java.lang.String name, javax.swing.Icon icon)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Called when this action is activated.
 void add(int index, java.lang.Object element)
           
 boolean add(java.lang.Object o)
           
 java.lang.Object clone()
          Creates a copy of this action list.
protected  java.lang.Object deepClone(java.util.Map references)
           
 boolean equals(java.lang.Object obj)
           
 javax.swing.Action findAction(java.lang.String field, java.lang.Object value)
          Finds an action with the specified field/value pair.
 javax.swing.Action getAction(java.lang.String name)
          Returns the action or action list associated with the specified action name.
 boolean getDeepClone()
          Returns true if cloning this list would also clone any of its cloneable children.
 java.lang.Object getValue(java.lang.String key)
          Gets one of this object's properties using the associated key.
 ViewContext getViewContext()
          Returns the view context for this object.
 int hashCode()
           
protected  void initializeClone(ActionList clone)
          Called by either clone method to do custom clone initialization.
 boolean isEnabled()
          Returns the enabled state of the Action.
 void putValue(java.lang.String key, java.lang.Object value)
          Sets one of this object's properties using the associated key.
 java.lang.Object remove(int index)
           
 boolean remove(java.lang.Object o)
           
 java.lang.Object set(int index, java.lang.Object element)
           
 void setDeepClone(boolean flag)
          Set to true if cloning this list should also clone any of its cloneable children.
 void setEnabled(boolean b)
          Sets the enabled state of the Action.
 void setViewContext(ViewContext context)
          Sets the view context for this action list and any of its children that are also context-aware.
 java.lang.String toString()
           
 
Methods inherited from class org.progeeks.util.DefaultObservableList
addAll, addAll, addPropertyChangeListener, clear, contains, containsAll, fireElementsInserted, fireElementsModified, fireElementsRemoved, firePropertyChangeEvent, get, getPropertyName, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, removeAll, removePropertyChangeListener, retainAll, setList, size, subList, toArray, toArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.swing.Action
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

ActionList

public ActionList()

ActionList

public ActionList(java.lang.String name)

ActionList

public ActionList(java.lang.String name,
                  javax.swing.Icon icon)
Method Detail

equals

public boolean equals(java.lang.Object obj)
Specified by:
equals in interface java.util.Collection
Specified by:
equals in interface java.util.List
Overrides:
equals in class DefaultObservableList

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection
Specified by:
hashCode in interface java.util.List
Overrides:
hashCode in class DefaultObservableList

setViewContext

public void setViewContext(ViewContext context)
Sets the view context for this action list and any of its children that are also context-aware.

Specified by:
setViewContext in interface ViewContextAware

getViewContext

public ViewContext getViewContext()
Returns the view context for this object.

Specified by:
getViewContext in interface ViewContextAware

setDeepClone

public void setDeepClone(boolean flag)
Set to true if cloning this list should also clone any of its cloneable children.


getDeepClone

public boolean getDeepClone()
Returns true if cloning this list would also clone any of its cloneable children.


initializeClone

protected void initializeClone(ActionList clone)
Called by either clone method to do custom clone initialization. This is to avoid having to override both clone and deepClone to support proper cloning. Default implementation does nothing. Remember, any this.foo type of references are refering to the original object and clone.foo is refering to the clone version. Seems obvious but it is easy to forget. Note: this will always be called at the end of clone() or deepClone() so any nested actions will have already been cloned.


clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a copy of this action list. If the deepClone flag is currently true then any cloneable contained actions are also cloned.

Overrides:
clone in class DefaultObservableList
Throws:
java.lang.CloneNotSupportedException

deepClone

protected java.lang.Object deepClone(java.util.Map references)
                              throws java.lang.CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException

getAction

public javax.swing.Action getAction(java.lang.String name)
Returns the action or action list associated with the specified action name.


getValue

public java.lang.Object getValue(java.lang.String key)
Gets one of this object's properties using the associated key.

Specified by:
getValue in interface javax.swing.Action

putValue

public void putValue(java.lang.String key,
                     java.lang.Object value)
Sets one of this object's properties using the associated key. If the value has changed, a PropertyChangeEvent is sent to listeners.

Specified by:
putValue in interface javax.swing.Action

setEnabled

public void setEnabled(boolean b)
Sets the enabled state of the Action. When enabled, any component associated with this object is active and able to fire this object's actionPerformed method. If the value has changed, a PropertyChangeEvent is sent to listeners.

Specified by:
setEnabled in interface javax.swing.Action

findAction

public javax.swing.Action findAction(java.lang.String field,
                                     java.lang.Object value)
Finds an action with the specified field/value pair. Nested lists will also be searched.


isEnabled

public boolean isEnabled()
Returns the enabled state of the Action. When enabled, any component associated with this object is active and able to fire this object's actionPerformed method.

Specified by:
isEnabled in interface javax.swing.Action

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Called when this action is activated. Default implementation does nothing.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.List
Overrides:
add in class DefaultObservableList

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.List
Overrides:
remove in class DefaultObservableList

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Specified by:
set in interface java.util.List
Overrides:
set in class DefaultObservableList

add

public void add(int index,
                java.lang.Object element)
Specified by:
add in interface java.util.List
Overrides:
add in class DefaultObservableList

remove

public java.lang.Object remove(int index)
Specified by:
remove in interface java.util.List
Overrides:
remove in class DefaultObservableList

toString

public java.lang.String toString()
Overrides:
toString in class DefaultObservableList


Copyright © 2002-2003 Paul Speed. All Rights Reserved.