ehsbe CommonsTM
Version 1.1.0rc3

com.ehsbe.commons.action
Class AbstractActionExt

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by com.ehsbe.commons.action.AbstractActionExt
All Implemented Interfaces:
ActionListener, ItemListener, Serializable, Cloneable, EventListener, Action
Direct Known Subclasses:
ManagedAction

public abstract class AbstractActionExt
extends AbstractAction
implements ItemListener

Extends the concept of the Action to include toggle or group states.

See Also:
Serialized Form

Field Summary
static String GROUP
          The key for the button group
static String IS_STATE
          The key for the flag which indicates that this is a state type.
static String LARGE_ICON_P_KEY
          The key for the large pressed icon
static String SELECT_PROPERTY_NAME
          the property name to be used, when a selection property change gets fired.
static String SMALL_ICON_P_KEY
          The key for the small pressed icon
 
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
AbstractActionExt(String name)
          Create a action with the given name.
AbstractActionExt(String name, Icon icon)
          Create a action with the given name and icon.
AbstractActionExt(String name, String command)
          Constructs an Action with the label and command
AbstractActionExt(String name, String command, Icon icon)
          Constructs an action with the given name, icon and command key.
 
Method Summary
 AbstractActionExt clone()
          
 void dispose()
          Will perform cleanup on the object.
 KeyStroke getAccelerator()
          Returns the key stroke which represents an accelerator for the action.
 String getActionCommand()
          Returns the action command.
 String getGroup()
          Get the id of the group, to which this action belongs to.
 Icon getLargeIcon()
          Returns a large icon which represents the action.
 Icon getLargePressedIcon()
          Returns a large pressed icon which represents the action.
 String getLongDescription()
          Returns a long desciption of the action.
 int getMnemonic()
          Return the mnemonic key code for the action.
 String getName()
          Returns the name of the action.
 String getShortDescription()
          Returns a short desciption of the action.
 Icon getSmallIcon()
          Returns a small icon which represents the action.
 Icon getSmallPressedIcon()
          Returns a small pressed icon which represents the action.
 boolean isSelected()
          Check the selection state of this action.
 boolean isStateAction()
          Indicates if this action has states.
 void setAccelerator(KeyStroke key)
          Sets the key stroke which represents an accelerator for the action.
 void setActionCommand(String key)
          Sets the action command key.
 void setGroup(String group)
          Sets the group identity of the state action.
 void setLargeIcon(Icon icon)
          Sets the large icon which represents the action.
 void setLargePressedIcon(Icon icon)
          Sets the large pressed icon which represents the action.
 void setLongDescription(String desc)
          Sets the long desciption of the action.
 void setMnemonic(int mnemonic)
          Sets the mnemonic key code for the action.
 void setMnemonic(String mnemonic)
          Set the mnemonic for this action.
 void setName(String name)
          Sets the name of the action.
 void setSelected(boolean newValue)
          Changes the state of the action If this property has been changed, a property change event with the name selected gets fired.
 void setShortDescription(String desc)
          Sets the short desciption of the action.
 void setSmallIcon(Icon icon)
          Sets the small icon which represents the action.
 void setSmallPressedIcon(Icon icon)
          Sets the small pressed icon which represents the action.
 void setStateAction()
          Set the state property to true.
 void setStateAction(boolean state)
          Set the state property.
 String toString()
          
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.event.ItemListener
itemStateChanged
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 

Field Detail

LARGE_ICON_P_KEY

public static final String LARGE_ICON_P_KEY
The key for the large pressed icon

See Also:
Constant Field Values

SMALL_ICON_P_KEY

public static final String SMALL_ICON_P_KEY
The key for the small pressed icon

See Also:
Constant Field Values

GROUP

public static final String GROUP
The key for the button group

See Also:
Constant Field Values

IS_STATE

public static final String IS_STATE
The key for the flag which indicates that this is a state type.

See Also:
Constant Field Values

SELECT_PROPERTY_NAME

public static final String SELECT_PROPERTY_NAME
the property name to be used, when a selection property change gets fired.

See Also:
Constant Field Values
Constructor Detail

AbstractActionExt

public AbstractActionExt(String name)
Create a action with the given name.

Parameters:
name - action's name
See Also:
AbstractAction.AbstractAction(String)

AbstractActionExt

public AbstractActionExt(String name,
                         Icon icon)
Create a action with the given name and icon.

Parameters:
name - action's name
icon - small icon to set
See Also:
AbstractAction.AbstractAction(String, Icon)

AbstractActionExt

public AbstractActionExt(String name,
                         String command)
Constructs an Action with the label and command

Parameters:
name - name of the action usually used as a label
command - command key of the action

AbstractActionExt

public AbstractActionExt(String name,
                         String command,
                         Icon icon)
Constructs an action with the given name, icon and command key.

Parameters:
name - display name of the action
command - the value of the action command key
icon - icon to display
Method Detail

getShortDescription

public String getShortDescription()
Returns a short desciption of the action.

Returns:
the short description or null

setShortDescription

public void setShortDescription(String desc)
Sets the short desciption of the action. This will also set the long description value is it is null.

This is a convenience method for putValue with the Action.SHORT_DESCRIPTION key.

Parameters:
desc - the short description; can be null
See Also:
Action.SHORT_DESCRIPTION, Action.putValue(java.lang.String, java.lang.Object)

getLongDescription

public String getLongDescription()
Returns a long desciption of the action.

Returns:
the long description or null

setLongDescription

public void setLongDescription(String desc)
Sets the long desciption of the action. This will also set the value of the short description if that value is null.

This is a convenience method for putValue with the Action.LONG_DESCRIPTION key.

Parameters:
desc - the long description; can be null
See Also:
Action.LONG_DESCRIPTION, Action.putValue(java.lang.String, java.lang.Object)

getSmallIcon

public Icon getSmallIcon()
Returns a small icon which represents the action.

Returns:
the small icon or null

setSmallIcon

public void setSmallIcon(Icon icon)
Sets the small icon which represents the action.

This is a convenience method for putValue with the Action.SMALL_ICON key.

Parameters:
icon - the small icon; can be null
See Also:
Action.SMALL_ICON, Action.putValue(java.lang.String, java.lang.Object)

getSmallPressedIcon

public Icon getSmallPressedIcon()
Returns a small pressed icon which represents the action.

Returns:
the small icon or null

setSmallPressedIcon

public void setSmallPressedIcon(Icon icon)
Sets the small pressed icon which represents the action.

This is a convenience method for putValue with the SMALL_ICON_P_KEY key.

Parameters:
icon - the small icon; can be null
See Also:
Action.SMALL_ICON, Action.putValue(java.lang.String, java.lang.Object)

getLargeIcon

public Icon getLargeIcon()
Returns a large icon which represents the action.

Returns:
the large icon or null

setLargeIcon

public void setLargeIcon(Icon icon)
Sets the large icon which represents the action.

This is a convenience method for putValue with the LARGE_ICON key.

Parameters:
icon - the large icon; can be null
See Also:
Action.LARGE_ICON_KEY, Action.putValue(java.lang.String, java.lang.Object)

getLargePressedIcon

public Icon getLargePressedIcon()
Returns a large pressed icon which represents the action.

Returns:
the large pressed icon or null

setLargePressedIcon

public void setLargePressedIcon(Icon icon)
Sets the large pressed icon which represents the action.

This is a convenience method for putValue with the LARGE_ICON_P_KEY key.

Parameters:
icon - the large icon; can be null
See Also:
LARGE_ICON_P_KEY, Action.putValue(java.lang.String, java.lang.Object)

setName

public void setName(String name)
Sets the name of the action.

This is a convenience method for putValue with the Action.NAME key.

Parameters:
name - the name of the action; can be null
See Also:
Action.NAME, Action.putValue(java.lang.String, java.lang.Object)

getName

public String getName()
Returns the name of the action.

Returns:
the name of the action or null

setMnemonic

public void setMnemonic(String mnemonic)
Set the mnemonic for this action.

Parameters:
mnemonic - only the first character of this parameter will be used

setMnemonic

public void setMnemonic(int mnemonic)
Sets the mnemonic key code for the action.

This is a convenience method for putValue with the Action.MNEMONIC_KEY key.

This method does not validate the value. Please see AbstractButton.setMnemonic(int) for details concerning the value of the mnemonic.

Parameters:
mnemonic - an int key code mnemonic or 0
See Also:
AbstractButton.setMnemonic(int), Action.MNEMONIC_KEY, Action.putValue(java.lang.String, java.lang.Object)

getMnemonic

public int getMnemonic()
Return the mnemonic key code for the action.

Returns:
the mnemonic or 0

setActionCommand

public void setActionCommand(String key)
Sets the action command key. The action command key is used to identify the action.

This is a convenience method for putValue with the Action.ACTION_COMMAND_KEY key.

Parameters:
key - the action command
See Also:
Action.ACTION_COMMAND_KEY, Action.putValue(java.lang.String, java.lang.Object)

getActionCommand

public String getActionCommand()
Returns the action command.

Returns:
the action command or null

getAccelerator

public KeyStroke getAccelerator()
Returns the key stroke which represents an accelerator for the action.

Returns:
the key stroke or null

setAccelerator

public void setAccelerator(KeyStroke key)
Sets the key stroke which represents an accelerator for the action.

This is a convenience method for putValue with the Action.ACCELERATOR_KEY key.

Parameters:
key - the key stroke; can be null
See Also:
Action.ACCELERATOR_KEY, Action.putValue(java.lang.String, java.lang.Object)

setGroup

public void setGroup(String group)
Sets the group identity of the state action. This is used to identify the action as part of a button group.

Parameters:
group - groupId to set

getGroup

public String getGroup()
Get the id of the group, to which this action belongs to.

Returns:
null if this action belongs to no group, the group's id otherwise.

dispose

public void dispose()
Will perform cleanup on the object. Should be called when finished with the Action. This should be used if a new action is constructed from the properties of an old action. The old property change listeners should be removed.


isStateAction

public boolean isStateAction()
Indicates if this action has states. If this method returns true then the this will send ItemEvents to ItemListeners when the control constructed with this action in invoked.

Returns:
true if this can handle states

setStateAction

public void setStateAction()
Set the state property to true.


setStateAction

public void setStateAction(boolean state)
Set the state property.

Parameters:
state - if true then this action will fire ItemEvents

isSelected

public boolean isSelected()
Check the selection state of this action.

Returns:
true if the action is in the selected state

setSelected

public void setSelected(boolean newValue)
Changes the state of the action

If this property has been changed, a property change event with the name selected gets fired.

Parameters:
newValue - true to set the action as selected of the action.

toString

public String toString()

Overrides:
toString in class Object

clone

public AbstractActionExt clone()
                        throws CloneNotSupportedException

Overrides:
clone in class AbstractAction
Throws:
CloneNotSupportedException

ehsbe CommonsTM
Version 1.1.0rc3

Copyright ©2005-2009 EHSBE, Walther-Rathenau-Str. 58, 39104 Magdeburg, Sachsen-Anhalt, Germany. All Rights Reserved.