org.ejtools.adwt.action
Class CommandAction

java.lang.Object
  |
  +--java.beans.beancontext.BeanContextChildSupport
        |
        +--java.beans.beancontext.BeanContextSupport
              |
              +--java.beans.beancontext.BeanContextServicesSupport
                    |
                    +--org.ejtools.beans.beancontext.CustomBeanContextServicesSupport
                          |
                          +--org.ejtools.adwt.action.CommandAction
All Implemented Interfaces:
javax.swing.Action, java.awt.event.ActionListener, java.beans.beancontext.BeanContext, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextServiceRevokedListener, java.beans.beancontext.BeanContextServices, java.beans.beancontext.BeanContextServicesListener, java.util.Collection, java.beans.DesignMode, java.util.EventListener, java.beans.PropertyChangeListener, java.io.Serializable, org.ejtools.util.state.Storable, java.beans.VetoableChangeListener, java.beans.Visibility
Direct Known Subclasses:
AboutAction, CascadeAction, CloseAction, CloseAllAction, CopyAction, CutAction, DeleteAction, DeselectAllAction, ExitAction, ExportAction, FileHistoryAction, FileHistoryActionTop, HelpOnLineAction, ImportAction, InternalFrameAction, NewAction, OpenAction, OpenWorkspaceAction, PasteAction, PrintAction, RefreshAction, SaveAction, SaveAsAction, SaveAsWorkspaceAction, SaveWorkspaceAction, SelectAllAction, ShowConsoleAction, TileAction, TOTDAction

public class CommandAction
extends org.ejtools.beans.beancontext.CustomBeanContextServicesSupport
implements javax.swing.Action

BeanContext that wraps an Action and delegates to a Command object.

It supports the Command pattern by delegating the ActionEvent event to the execute method of the Command object.

It automatically handles the negotiation in ToolBar and MenuBar if these services are present.

It supports the following properties :

Version:
$Revision: 1.8 $
Author:
Laurent Etiemble
See Also:
Command, Serialized Form

Field Summary
protected  javax.swing.AbstractAction action
          The wrapped action
protected  Command command
          The command to execute
static java.lang.String ICON
          Constant for ICON property
static java.lang.String MENU
          Constant for MENU property
static java.lang.String MENU_ITEM
          Constant for MENU_ITEM property
static java.lang.String MENU_LAYOUT
          Constant for MENU_LAYOUT property
protected  java.util.ResourceBundle resource
          Resource Bundle
static java.lang.String TOOLBAR
          Constant for TOOLBAR property
static java.lang.String TOOLTIP
          Constant for TOOLTIP property
 
Fields inherited from class java.beans.beancontext.BeanContextServicesSupport
bcsListeners, proxy, serializable, services
 
Fields inherited from class java.beans.beancontext.BeanContextSupport
bcmListeners, children, designTime, locale, okToUseGui
 
Fields inherited from class java.beans.beancontext.BeanContextChildSupport
beanContext, beanContextChildPeer, pcSupport, rejectedSetBCOnce, vcSupport
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Fields inherited from interface java.beans.beancontext.BeanContext
globalHierarchyLock
 
Fields inherited from interface java.beans.DesignMode
PROPERTYNAME
 
Constructor Summary
protected CommandAction(Command command, java.util.ResourceBundle res, java.lang.String name)
          Constructor used to fully define the CommandAction.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          This method is called whenever the action is acted upon.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a PropertyChangeListener.
protected  Command getCommand()
          Returns the wrapped command object
 java.lang.String getMenu()
          Returns the menu property
 javax.swing.JMenuItem getMenuItem()
          Getter for the menuItem attribute
 int getMenuLayout()
          Returns the menu layout property
 java.util.ResourceBundle getResourceBundle()
          Returns the Resource Bundle used by this object
 boolean getToolBar()
          Returns the toolbar presence property
 java.lang.Object getValue(java.lang.String key)
          Gets the value attribute of the CommandAction object
protected  void initializeBeanContextResources()
          Called when the CommandAction is put in a BeanContext
 boolean isEnabled()
          Gets the enabled attribute of the CommandAction object
 void putValue(java.lang.String key, java.lang.Object value)
          Description of the Method
protected  void register(java.beans.beancontext.BeanContextServices context)
          Description of the Method
protected  void releaseBeanContextResources()
          Called when the CommandAction is removed from a BeanContext
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a PropertyChangeListener.
 void serviceAvailable(java.beans.beancontext.BeanContextServiceAvailableEvent bcsae)
          Triggered when a service is made available.
 void serviceRevoked(java.beans.beancontext.BeanContextServiceRevokedEvent bcsre)
          Triggered when a service is revoked.
protected  void setCommand(Command newValue)
          This method sets the action's command object.
 void setEnabled(boolean b)
          Enables the Action.
 void setIcon(java.lang.String icon)
          Sets the icon attribute of the CommandAction object
 void setMenu(java.lang.String menu)
          Constructor for the setMenu object
 void setMenuLayout(int menuLayout)
          Sets the menuLayout attribute of the CommandAction object
protected  void setResourceBundle(java.util.ResourceBundle newValue)
          Setter for the resourceBundle attribute
 void setSmallIcon(java.lang.String icon)
          Constructor for the setIcon object
 void setToolBar(boolean inToolBar)
          Sets the toolBar attribute of the CommandAction object
protected  void unregister(java.beans.beancontext.BeanContextServices context)
          Description of the Method
 
Methods inherited from class org.ejtools.beans.beancontext.CustomBeanContextServicesSupport
accept, clear, getService
 
Methods inherited from class java.beans.beancontext.BeanContextServicesSupport
addBeanContextServicesListener, addService, addService, bcsPreDeserializationHook, bcsPreSerializationHook, childJustRemovedHook, createBCSChild, createBCSSServiceProvider, fireServiceAdded, fireServiceAdded, fireServiceRevoked, fireServiceRevoked, getBeanContextServicesPeer, getChildBeanContextServicesListener, getCurrentServiceClasses, getCurrentServiceSelectors, hasService, initialize, releaseService, removeBeanContextServicesListener, revokeService
 
Methods inherited from class java.beans.beancontext.BeanContextSupport
add, addAll, addBeanContextMembershipListener, avoidingGui, bcsChildren, childDeserializedHook, childJustAddedHook, classEquals, contains, containsAll, containsKey, copyChildren, deserialize, dontUseGui, fireChildrenAdded, fireChildrenRemoved, getBeanContextPeer, getChildBeanContextChild, getChildBeanContextMembershipListener, getChildPropertyChangeListener, getChildSerializable, getChildVetoableChangeListener, getChildVisibility, getLocale, getResource, getResourceAsStream, instantiateChild, isDesignTime, isEmpty, isSerializing, iterator, needsGui, okToUseGui, propertyChange, readChildren, remove, remove, removeAll, removeBeanContextMembershipListener, retainAll, serialize, setDesignTime, setLocale, size, toArray, toArray, validatePendingAdd, validatePendingRemove, vetoableChange, writeChildren
 
Methods inherited from class java.beans.beancontext.BeanContextChildSupport
addPropertyChangeListener, addVetoableChangeListener, firePropertyChange, fireVetoableChange, getBeanContext, getBeanContextChildPeer, isDelegated, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext, validatePendingSetBeanContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.beans.beancontext.BeanContext
addBeanContextMembershipListener, getResource, getResourceAsStream, instantiateChild, removeBeanContextMembershipListener
 
Methods inherited from interface java.beans.beancontext.BeanContextChild
addPropertyChangeListener, addVetoableChangeListener, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext
 
Methods inherited from interface java.util.Collection
add, addAll, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.beans.DesignMode
isDesignTime, setDesignTime
 
Methods inherited from interface java.beans.Visibility
avoidingGui, dontUseGui, needsGui, okToUseGui
 

Field Detail

action

protected javax.swing.AbstractAction action
The wrapped action


command

protected Command command
The command to execute


resource

protected java.util.ResourceBundle resource
Resource Bundle


ICON

public static final java.lang.String ICON
Constant for ICON property

See Also:
Constant Field Values

MENU

public static final java.lang.String MENU
Constant for MENU property

See Also:
Constant Field Values

MENU_ITEM

public static final java.lang.String MENU_ITEM
Constant for MENU_ITEM property

See Also:
Constant Field Values

MENU_LAYOUT

public static final java.lang.String MENU_LAYOUT
Constant for MENU_LAYOUT property

See Also:
Constant Field Values

TOOLBAR

public static final java.lang.String TOOLBAR
Constant for TOOLBAR property

See Also:
Constant Field Values

TOOLTIP

public static final java.lang.String TOOLTIP
Constant for TOOLTIP property

See Also:
Constant Field Values
Constructor Detail

CommandAction

protected CommandAction(Command command,
                        java.util.ResourceBundle res,
                        java.lang.String name)
Constructor used to fully define the CommandAction.

Parameters:
command - The command object to delegate the ActionEvent to
res - The Resource Bundle used for resolving the name and other properties
name - The name of the CommandAction. Must be a key found in the Resource Bundle
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
This method is called whenever the action is acted upon. The call will be delegated to the wrapped action.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - The action event

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener. The call will be delegated to the wrapped action.

Specified by:
addPropertyChangeListener in interface javax.swing.Action
Parameters:
listener - The listener to be added

getMenuItem

public javax.swing.JMenuItem getMenuItem()
Getter for the menuItem attribute

Returns:
The value

getValue

public java.lang.Object getValue(java.lang.String key)
Gets the value attribute of the CommandAction object

Specified by:
getValue in interface javax.swing.Action
Parameters:
key - Description of Parameter
Returns:
The value value

isEnabled

public boolean isEnabled()
Gets the enabled attribute of the CommandAction object

Specified by:
isEnabled in interface javax.swing.Action
Returns:
The enabled value

putValue

public void putValue(java.lang.String key,
                     java.lang.Object value)
Description of the Method

Specified by:
putValue in interface javax.swing.Action
Parameters:
key - Description of Parameter
value - Description of Parameter

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener. The call will be delegated to the wrapped action.

Specified by:
removePropertyChangeListener in interface javax.swing.Action
Parameters:
listener - The listener to remove

serviceAvailable

public void serviceAvailable(java.beans.beancontext.BeanContextServiceAvailableEvent bcsae)
Triggered when a service is made available.

Specified by:
serviceAvailable in interface java.beans.beancontext.BeanContextServicesListener
Overrides:
serviceAvailable in class java.beans.beancontext.BeanContextServicesSupport
Parameters:
bcsae - The availability event

serviceRevoked

public void serviceRevoked(java.beans.beancontext.BeanContextServiceRevokedEvent bcsre)
Triggered when a service is revoked.

Specified by:
serviceRevoked in interface java.beans.beancontext.BeanContextServiceRevokedListener
Overrides:
serviceRevoked in class java.beans.beancontext.BeanContextServicesSupport
Parameters:
bcsre - The revocation event

setEnabled

public void setEnabled(boolean b)
Enables the Action. The call will be delegated to the wrapped action.

Specified by:
setEnabled in interface javax.swing.Action
Parameters:
b - If true, the action will be enable

initializeBeanContextResources

protected void initializeBeanContextResources()
Called when the CommandAction is put in a BeanContext

Overrides:
initializeBeanContextResources in class java.beans.beancontext.BeanContextServicesSupport

register

protected void register(java.beans.beancontext.BeanContextServices context)
Description of the Method

Parameters:
context - Description of Parameter

releaseBeanContextResources

protected void releaseBeanContextResources()
Called when the CommandAction is removed from a BeanContext

Overrides:
releaseBeanContextResources in class java.beans.beancontext.BeanContextServicesSupport

unregister

protected void unregister(java.beans.beancontext.BeanContextServices context)
Description of the Method

Parameters:
context - Description of Parameter

getMenu

public final java.lang.String getMenu()
Returns the menu property

Returns:
The menu property

getMenuLayout

public final int getMenuLayout()
Returns the menu layout property

Returns:
The menu layout property

getResourceBundle

public final java.util.ResourceBundle getResourceBundle()
Returns the Resource Bundle used by this object

Returns:
The Resource Bundle

getToolBar

public final boolean getToolBar()
Returns the toolbar presence property

Returns:
The toolbar presence property

setIcon

public final void setIcon(java.lang.String icon)
Sets the icon attribute of the CommandAction object

Parameters:
icon - The new icon value

setMenu

public final void setMenu(java.lang.String menu)
Constructor for the setMenu object

Parameters:
menu - Description of Parameter

setMenuLayout

public final void setMenuLayout(int menuLayout)
Sets the menuLayout attribute of the CommandAction object

Parameters:
menuLayout - The new menuLayout value

setSmallIcon

public final void setSmallIcon(java.lang.String icon)
Constructor for the setIcon object

Parameters:
icon - Description of Parameter

setToolBar

public final void setToolBar(boolean inToolBar)
Sets the toolBar attribute of the CommandAction object

Parameters:
inToolBar - The new toolBar value

getCommand

protected final Command getCommand()
Returns the wrapped command object

Returns:
The command object

setCommand

protected final void setCommand(Command newValue)
This method sets the action's command object.

Parameters:
newValue - the command for this action to act upon

setResourceBundle

protected final void setResourceBundle(java.util.ResourceBundle newValue)
Setter for the resourceBundle attribute

Parameters:
newValue - The new value for resourceBundle attribute


Copyright © 2002-2003 EJTools Org.. All Rights Reserved.