com.sas.actionprovider
Class BaseAction

com.sas.actionprovider.BaseAction
All Implemented Interfaces:
ActionStatusKeysInterface, SupplementalPropertyKeysInterface, BaseEntityInterface, BaseEntityValueInterface, EntityKeyInterface, java.awt.event.ActionListener, java.lang.Cloneable, java.rmi.Remote, java.util.EventListener, javax.swing.Action
Direct Known Subclasses:
HttpAction, SwingAction

public abstract class BaseAction
implements com.sas.swing.util.Action, ActionStatusKeysInterface, SupplementalPropertyKeysInterface

The BaseAction class is the base class for all Actions acquired via the Action Provider Framework (APF).

A basic understanding of the ActionProvider Framework, of which this class is a part, is recommended before attempting to use this class.


Actions are objects that encapsulate everything needed to:


Typically, a Command object associated with the Action contains the logic for actually performing the operation.

When multiple Actions of the same actionType ( e.g. a DRILL_DOWN_ACTION in an OLAPTableView ) appear in different areas of a Component, they all share the same Command instance. This is possible because the APF can apply certain Action attributes to the command during the command execution phase. Often these attributes are specific area-dependent values such as a row and/or column index.

Action attributes that are applied to the command are COMMAND-type attributes that are designated as such via a property of the AttributeDescriptorInterface that is associated with the attribute.

There are 5 properties of the AttributeDescriptorInterface that are pertinent in the APF:

  1. COMMAND: When true, these are Action attributes that the APF will apply to the command during the Action's execution phase.
  2. DYNAMIC: When true, the values of these Action attributes are generated by the APF support class during the Action acquisition phase.
  3. CUSTOM: When true, this type of attribute does not have a name that is explicitly defined or known by the APF support class like conventional DYNAMIC attributes but is one for which a value can be generated given some support class specific rule. For example, a table support class may expect that attributes of this type have a name corresponding to a column name and may then set the attribute's value to the data value for that column.
  4. Http Only: visible When true, and the attribute is also either a COMMAND attribute or an EXTERNAL attribute, the attributeName/attributeValue become a key/value pair on the query string of the url generated for the Action. Otherwise, the pair is stored on the HttpActionProvider.
  5. Http Only: EXTERNAL When true and visible is also true, the APF will include the attributeName and attributeValue on the request but will not apply the attribute to the command during the Action's execution phase().

The visible property is a standard, not supplemental, property and is accessed differently than the others:

action.getAttributeDescriptor("someAttributeName").setVisible(false);
boolean visible = action.getAttributeDescriptor("someAttributeName").isVisible();

Refer to the individually documented fields of the supplemental properties for examples demonstrating their accessibility methods. The fields also document the default values for these properties which may vary according to the type of attribute.

  1. Class-Based: Attributes defined by the Action class.
  2. Instance-Based: Attributes that are not defined by the Action class. Instead, they are attributes that are added dynamically to the Action instance.


Visit the AppDev Studio Developer's Site to access step-by-step examples, white papers and additional usage information at http://support.sas.com/rnd/appdev/.

Note: A snapshot of the AppDev Studio Developers Site is installed on your local Web server when you install AppDev Studio. To access the site from webAF, select Help -> Developer Site .

Since:
3.0
See Also:
DynamicAttributeCommandInterface, BaseCommand, BaseActionProvider.getActions(com.sas.actionprovider.ActionSupportFilter), putValue(java.lang.String, java.lang.Object), getAttributeDescriptor(java.lang.String), AttributeDescriptorInterface

Field Summary
 
Fields inherited from interface com.sas.swing.util.Action
ALIGNMENT_CENTER, ALIGNMENT_LEADING, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, ALIGNMENT_TRAILING, ALTERNATE_TEXT, COMMAND_CLASS, DISABLED_IMAGE_KEY, GROUP_NAME, IMAGE_KEY, LABEL, LARGE_DISABLED_ICON, LARGE_DISABLED_ICON_NAME, LARGE_ICON, LARGE_ICON_NAME, LONG_DISABLED_DESCRIPTION, LONG_NAME, MNEMONIC_INDEX, ROLLOVER_ICON_NAME, ROLLOVER_IMAGE_KEY, SHORT_DISABLED_DESCRIPTION, SMALL_DISABLED_ICON, SMALL_DISABLED_ICON_NAME, SMALL_ICON_NAME, STYLE_MAP, TARGET, TEXT_ALIGNMENT, TYPE, TYPE_BOOLEAN, TYPE_NORMAL, URL
 
Fields inherited from interface com.sas.actionprovider.ActionStatusKeysInterface
AREA_DISABLED, DISABLED, ENABLED, IS_CURRENT_STATE_DISABLED, MODEL_MEMBER_DISABLED, MODEL_STATE_DISABLED, MODEL_TYPE_DISABLED, UNSUPPORTED, VIEWER_DISABLED
 
Fields inherited from interface com.sas.actionprovider.SupplementalPropertyKeysInterface
COMMAND, CUSTOM, DYNAMIC, ENCODE, EXTERNAL
 
Constructor Summary
BaseAction()
          Default constructor
BaseAction(DynamicAttributeCommandInterface command)
          Constructor that takes an instance of a command.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Performs the operation associated with this Action.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a listener for this classes property changes.
protected  void applyCommandAttributes(DynamicAttributeCommandInterface command)
          Applies all dynamic attributes on the Action to the command.
 java.lang.Object clone()
          Create a new BaseAction object using this Object's attributes.
protected  void executeCommand(DynamicAttributeCommandInterface command)
          Call the command's execute() method.
protected  void fireEvent(DynamicAttributeCommandInterface command)
          If the command implements the ContentsChangedInterface and the command's isContentsChanged() method returns true, then this method tells the SwingActionProvider to fire a ActionProviderEvent to its listeners.
 ActionStrategyInterface getActionStrategy()
          Returns the strategy object for this Action.
 java.lang.String getActionType()
          Returns the actionType key that uniquely identifies this type of action.
 AttributeDescriptorInterface getAttributeDescriptor(java.lang.String attributeName)
          Returns the AttributeDescriptorInterface associated with the named attribute.
 AttributeDescriptorInterface[] getAttributeDescriptors()
          Returns an array containing an AttributeDescriptorInterface for each attribute of this Action.
 DynamicAttributeCommandInterface getCommand()
          Returns this Action's command instance.
 int getReturnStatus()
          Returns this Action's returnStatus attribute which determines if and possibly why this action should be returned to a requesting viewer when it is in a disabled state.
 java.lang.Object getValue(java.lang.String attributeName)
          Get the value of the specified attribute.
 boolean isCustom()
          Returns the boolean indicating whether this Action represents a non-default actionType or a replacement action for a default actionType.
 void performAction()
          Performs the operation associated with this Action.
 void putValue(java.lang.String attributeName, java.lang.Object attributeValue)
          Set the value of the specified key attribute.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a listener of this classes property changes.
 void setActionStrategy(ActionStrategyInterface actionStrategy)
          Sets the strategy object for this Action.
 void setActionType(java.lang.String actionType)
          Sets the actionType key that uniquely identifies this type of action.
protected  boolean setAttribute(java.lang.String attributeName, java.util.Map propertyDescriptors, java.lang.Object[] args)
          Set an attribute and its value.
 void setCommand(DynamicAttributeCommandInterface command)
          Sets the Action's command instance.
 void setCustom(boolean custom)
          Sets the boolean indicating whether this Action represents a non-default actionType or a replacement action for a default actionType.
 void setReturnStatus(int returnStatus)
          Sets this Action's returnStatus attribute if this action should be returned to a requesting viewer when it is in a disabled state.
 
Methods inherited from class com.sas.entities.BaseEntity
containsAttributeNamed, equals, equals, getAttribute, getAttribute, getAttributeCount, getAttributes, getEntityKey, getPropertyDescriptors, getStringAttribute, listAttributeNames, removeAllAttributes, sameEntity, setAttribute, setAttributes, setEntityKey, toString
 

Constructor Detail

BaseAction

public BaseAction()
Default constructor


BaseAction

public BaseAction(DynamicAttributeCommandInterface command)

Constructor that takes an instance of a command.

Parameters:
command - The command that contains the logic to execute this action.
Method Detail

getCommand

public DynamicAttributeCommandInterface getCommand()
Returns this Action's command instance.

The command is the object that gets executed when a user performs an Action.

Returns:
an Action's command instance.
See Also:
setCommand(com.sas.commands.DynamicAttributeCommandInterface)

setCommand

public void setCommand(DynamicAttributeCommandInterface command)
Sets the Action's command instance.

The command is the object that gets executed when a user performs an Action.

Parameters:
command - Action's command instance.
See Also:
getCommand()

getReturnStatus

public int getReturnStatus()
Returns this Action's returnStatus attribute which determines if and possibly why this action should be returned to a requesting viewer when it is in a disabled state.

By default, this value is ActionStatusKeysInterface.ENABLED which means that the Action will be returned only when it is in an enabled state.

Returns:
the viewer that requested this action.
See Also:
BaseActionProviderSupport.getActionStatus(com.sas.actionprovider.BaseAction, com.sas.actionprovider.ActionSupportFilter), setReturnStatus(int)

setReturnStatus

public void setReturnStatus(int returnStatus)
Sets this Action's returnStatus attribute if this action should be returned to a requesting viewer when it is in a disabled state.

If the returnStatus has a matching bit for every bit on the status determined by the support classes getActionsStatus() method, then the Action will be returned in a disabled state. Otherwise, the Action will not be returned.

For example, if the Action's status includes both MODEL_MEMBER_DISABLED and IS_CURRENT_STATE_DISABLED then the Action's returnStatus would need to have both of those values set to force the support class to return the Action.

By default, this value is ActionStatusKeysInterface.ENABLED which means that the Action will be returned only when it is in an enabled state.

Other valid values for this attribute:

Parameters:
viewer - The viewer that requested this action.
See Also:
BaseActionProviderSupport.getActionStatus(com.sas.actionprovider.BaseAction, com.sas.actionprovider.ActionSupportFilter), getReturnStatus()

getActionType

public java.lang.String getActionType()

Returns the actionType key that uniquely identifies this type of action.

Returns:
a key representing the actionType.
See Also:
setActionType(java.lang.String)

setActionType

public void setActionType(java.lang.String actionType)

Sets the actionType key that uniquely identifies this type of action.

On default Actions, the value of this attribute is set by the APF support class that creates the Action.

On custom Actions, the value may be any that does not conflict with an actionType defined on the APF support class.

Parameters:
actionType - an key representing the actionType.
See Also:
getActionType()

isCustom

public boolean isCustom()

Returns the boolean indicating whether this Action represents a non-default actionType or a replacement action for a default actionType.

Returns:
the boolean indicating whether this Action represents a non-default actionType or a replacement action for a default actionType.
See Also:
setCustom(boolean)

setCustom

public void setCustom(boolean custom)

Sets the boolean indicating whether this Action represents a non-default actionType or a replacement action for a default actionType.

Parameters:
custom - The Action's custom setting.
See Also:
isCustom()

getValue

public java.lang.Object getValue(java.lang.String attributeName)

Get the value of the specified attribute.

Specified by:
getValue in interface javax.swing.Action
Parameters:
attributeName - the action attribute's name.
Returns:
The value object for the action's attribute as specified by the attributeName argument.
See Also:
putValue(java.lang.String, java.lang.Object)

putValue

public void putValue(java.lang.String attributeName,
                     java.lang.Object attributeValue)

Set the value of the specified key attribute.

Specified by:
putValue in interface javax.swing.Action
Parameters:
attributeName - the attribute's name.
attributeValue - the value to be set for the attribute.
Throws:
java.lang.IllegalArgumentException - when an assignment to an Action's attribute fails.
See Also:
getValue(java.lang.String)

setAttribute

protected boolean setAttribute(java.lang.String attributeName,
                               java.util.Map propertyDescriptors,
                               java.lang.Object[] args)
                        throws AttributeSetException
Set an attribute and its value.

Overrides:
setAttribute in class BaseEntity
Parameters:
attributeName - the name of the attribute
propertyDescriptors - a map containing the Java properties associated with the entity. This map is used to determine whether the attribute is associated with a java property. If so, then the write method associated with the property is used to set the attribute value.
value - the value to associate with the attribute Attribute values may be null.
Throws:
AttributeSetException

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

Adds a listener for this classes property changes.

Specified by:
addPropertyChangeListener in interface javax.swing.Action
Parameters:
listener - the listener.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

Removes a listener of this classes property changes.

Specified by:
removePropertyChangeListener in interface javax.swing.Action
Parameters:
listener - the listener.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Performs the operation associated with this Action.

Swing Only:

The following steps occur during this method:

This method required by the ActionListener interface.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - The event which indicates that a component-defined action occured. This high-level event is generated by a component (such as a Button) when the component-specific action occurs (such as being pressed). This parameter is not referenced in this method's implementation.

performAction

public void performAction()
Performs the operation associated with this Action.

Swing Only:

The following steps occur during this method:


applyCommandAttributes

protected void applyCommandAttributes(DynamicAttributeCommandInterface command)

Applies all dynamic attributes on the Action to the command.

Parameters:
command - The command instance to which this Action's dynamic attributes should be applied.

executeCommand

protected void executeCommand(DynamicAttributeCommandInterface command)

Call the command's execute() method.

Parameters:
command - The command whose execute() method is to be called

getActionStrategy

public ActionStrategyInterface getActionStrategy()
Returns the strategy object for this Action.

See Also:
setActionStrategy(com.sas.actionprovider.strategies.ActionStrategyInterface)

setActionStrategy

public void setActionStrategy(ActionStrategyInterface actionStrategy)
Sets the strategy object for this Action.

See Also:
getActionStrategy()

fireEvent

protected void fireEvent(DynamicAttributeCommandInterface command)

If the command implements the ContentsChangedInterface and the command's isContentsChanged() method returns true, then this method tells the SwingActionProvider to fire a ActionProviderEvent to its listeners.

Parameters:
command - The command whose execution may require an Event to be fired.

getAttributeDescriptor

public AttributeDescriptorInterface getAttributeDescriptor(java.lang.String attributeName)
                                                    throws java.util.NoSuchElementException
Returns the AttributeDescriptorInterface associated with the named attribute.

Parameters:
attributeName - The name of the attribute.
Returns:
the AttributeDescriptorInterface associated with the named attribute.
Throws:
java.util.NoSuchElementException

getAttributeDescriptors

public AttributeDescriptorInterface[] getAttributeDescriptors()
Returns an array containing an AttributeDescriptorInterface for each attribute of this Action.

Returns:
an array containing an AttributeDescriptorInterface for each attribute of this Action.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Create a new BaseAction object using this Object's attributes.

Overrides:
clone in class BaseEntity
Returns:
new BaseAction that will have the same attributes as this Object.
Throws:
java.lang.CloneNotSupportedException



Copyright © 2009 SAS Institute Inc. All Rights Reserved.