com.borland.primetime.actions
Class DelegateAction

java.lang.Object
  |
  +--javax.swing.AbstractAction
        |
        +--com.borland.primetime.actions.UpdateAction
              |
              +--com.borland.primetime.actions.DelegateAction

public class DelegateAction
extends UpdateAction

A DelegateAction is a type of UpdateAction acts as a delegate for any number of other Actions. When a DelegateAction is invoked, it searches for a Component that implements the DelegateHandler interface starting at the current focused component on the same Window as the passed source (the source must be an instance of java.awt.Component), and works its way up the parent hierarchy until it finds one that handles this DelegateAction. All calls to the DelegateAction are forwarded through a target action via a DelegateHandler in this way.

A an example subclass of DelegateAction would be an Edit-Cut type of Action - one that needs to 're-target' depending on the part of the window that is currently active.

Typically, subclasses of DelegateAction override NONE of the DelegateAction methods - but merely act as a 'marker' for Actions to target to at runtime.

See Also:
Action, DelegateHandler, Serialized Form

Field Summary
protected  javax.swing.Action action
          The transient storage for the currently associated target action.
 
Fields inherited from class com.borland.primetime.actions.UpdateAction
ACCELERATOR, EMPTY_ARRAY, HELP_TOPIC, LARGE_ICON, MNEMONIC
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Constructor Summary
DelegateAction()
          Constructs an DelegateAction will all default properties.
DelegateAction(java.lang.String shortText)
          Constructs an DelegateAction will the specified short text.
DelegateAction(java.lang.String shortText, char mnemonic)
          Constructs an DelegateAction will the specified short text and mnemonic.
DelegateAction(java.lang.String shortText, char mnemonic, java.lang.String longText)
          Constructs an DelegateAction will the specified short text, mnemonic, and long text.
DelegateAction(java.lang.String shortText, char mnemonic, java.lang.String longText, javax.swing.Icon smallIcon)
          Constructs an DelegateAction will the specified short text, mnemonic, long text, and small icon.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          The default implementation of actionPerformed is to first find a target action, then update it (if it is an UpdateableAction), and finally to call its actionPerformed if it is enabled.
protected  void findAction(java.lang.Object source)
          The findAction method takes the passed source object and calls findFocusOwner(Object source) to find the current focused component in the source's context.
protected  java.awt.Component findFocusOwner(java.lang.Object source)
          The findFocusOwner method takes the passed source object (assuming it is an instance of java.awt.Component), and walks up its parent hierarchy until it finds a java.awt.Window.
 java.lang.Object getValue(java.lang.String key)
          The javax.swing.Action.getValue(String key) method is overridden to delegate to the current 'target' action.
 boolean isEnabled()
          The javax.swing.Action.isEnabled() method is overridden to delegate to the current 'target' action.
 void update(java.lang.Object source)
          The default implementation of update is to first find a target action, then update it (if it is an UpdateableAction), and finally to reflect the enabled state of the target action.
 
Methods inherited from class com.borland.primetime.actions.UpdateAction
getHelpTopic, getLargeIcon, getLongText, getMnemonic, getShortText, getSmallIcon, setHelpTopic, setLargeIcon, setLongText, setMnemonic, setShortText, setSmallIcon
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

action

protected javax.swing.Action action
The transient storage for the currently associated target action.
Constructor Detail

DelegateAction

public DelegateAction()
Constructs an DelegateAction will all default properties.

DelegateAction

public DelegateAction(java.lang.String shortText)
Constructs an DelegateAction will the specified short text.
Parameters:
shortText - The short text for the action

DelegateAction

public DelegateAction(java.lang.String shortText,
                      char mnemonic)
Constructs an DelegateAction will the specified short text and mnemonic.
Parameters:
shortText - The short text for the action
mnemonic - The mnemonic character for the action

DelegateAction

public DelegateAction(java.lang.String shortText,
                      char mnemonic,
                      java.lang.String longText)
Constructs an DelegateAction will the specified short text, mnemonic, and long text.
Parameters:
shortText - The short text for the action
mnemonic - The mnemonic character for the action
longText - The long text for the action

DelegateAction

public DelegateAction(java.lang.String shortText,
                      char mnemonic,
                      java.lang.String longText,
                      javax.swing.Icon smallIcon)
Constructs an DelegateAction will the specified short text, mnemonic, long text, and small icon.
Parameters:
shortText - The short text for the action
mnemonic - The mnemonic character for the action
longText - The long text for the action
smallIcon - The small icon for the action (16x16)
Method Detail

getValue

public java.lang.Object getValue(java.lang.String key)
The javax.swing.Action.getValue(String key) method is overridden to delegate to the current 'target' action.
Overrides:
getValue in class javax.swing.AbstractAction

isEnabled

public boolean isEnabled()
The javax.swing.Action.isEnabled() method is overridden to delegate to the current 'target' action.
Overrides:
isEnabled in class javax.swing.AbstractAction

update

public void update(java.lang.Object source)
The default implementation of update is to first find a target action, then update it (if it is an UpdateableAction), and finally to reflect the enabled state of the target action.
Overrides:
update in class UpdateAction
Tags copied from class: UpdateAction
Parameters:
source - The source of the action that is about to be displayed as UI.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
The default implementation of actionPerformed is to first find a target action, then update it (if it is an UpdateableAction), and finally to call its actionPerformed if it is enabled.
Overrides:
actionPerformed in class javax.swing.AbstractAction

findAction

protected void findAction(java.lang.Object source)
The findAction method takes the passed source object and calls findFocusOwner(Object source) to find the current focused component in the source's context. It then walks up the parent hierarchy starting at the focused component until it finds an instance of DelegateHandler. It queries the DelegateHandler (calls the getAction(DelegateAction) method) to see if the DelegateHandler has an associated action for this DelegateAction. If an action is returned from the DelegateHandler, it is returned from this method. If no action is returned from the DelegateHandler, the walk up the parent hierarchy continues until one is found that does handle the DelegateAction, or until the top of the hierarchy is reached. If none is found, null is returned.
Parameters:
source - The source context object

findFocusOwner

protected java.awt.Component findFocusOwner(java.lang.Object source)
The findFocusOwner method takes the passed source object (assuming it is an instance of java.awt.Component), and walks up its parent hierarchy until it finds a java.awt.Window. It then returns the focus owner from the Window.
Parameters:
source - The source context object