org.favabeans.base
Class MethodAction

java.lang.Object
  |
  +--javax.swing.AbstractAction
        |
        +--org.favabeans.base.MethodAction
All Implemented Interfaces:
Action, ActionFeature, ActionListener, Cloneable, EventListener, Faceted, Feature, Serializable

public class MethodAction
extends AbstractAction
implements Faceted, ActionFeature

A MethodAction, when performed, invokes a single public method of a specific object. It is a fairly low-level construct, and will generally only be presented to the end-user as a last resort or as part of some development tool.

Note: This implementation does not listen for changes in the underlying MethodDescriptor; this saves us some storage at the cost of some generality. It is very unlikely that this shortcut will lead to problems.

Note: In the current implementation, we do not have a "wizard" that pops up to allow the end-user to supply method arguments (we use null values) and we also have no way to communicate any return values of the method. This needs to be fixed soon.

See Also:
Serialized Form

Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
MethodAction(Object target, MethodDescriptor descriptor)
          Create a new MethodAction.
 
Method Summary
 void actionPerformed(ActionEvent e)
           
protected  Object doActionPerformed()
          Invoke the method which this object represents.
 MethodDescriptor getDescriptor()
          Obtain the Java reflection MethodDescriptor for the method which this MethodAction will execute upon #actionPerformed().
 Facet getFacet(Type type)
          Obtain a Facet of the requested Type for this object.
 Object getTarget()
          Obtain the target of this Feature.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.Action
addPropertyChangeListener, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 

Constructor Detail

MethodAction

public MethodAction(Object target,
                    MethodDescriptor descriptor)
Create a new MethodAction.
Parameters:
target - the object on which the method will be performed.
descriptor - the Java reflection MethodDescriptor for the method to be called.
Method Detail

getTarget

public Object getTarget()
Description copied from interface: Feature
Obtain the target of this Feature.
Specified by:
getTarget in interface Feature
Following copied from interface: org.favabeans.base.Feature
Returns:
the target.

getFacet

public Facet getFacet(Type type)
Description copied from interface: Faceted
Obtain a Facet of the requested Type for this object.
Specified by:
getFacet in interface Faceted
Following copied from interface: org.favabeans.base.Faceted
Parameters:
type - the Type of Facet requested for this object.
Returns:
a Facet, or null if none can be created as requested.

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class AbstractAction

getDescriptor

public MethodDescriptor getDescriptor()
Obtain the Java reflection MethodDescriptor for the method which this MethodAction will execute upon #actionPerformed().
Returns:
a MethodDescriptor.

doActionPerformed

protected Object doActionPerformed()
Invoke the method which this object represents. Note: We supply null for all method parameters for the moment. See class docs for other limitations.


Copyright © 2000-2001, Regents of the University of Minnesota. All Rights Reserved.