com.pentec.util
Class AAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by com.pentec.util.AAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

public class AAction
extends javax.swing.AbstractAction

This class implements the Action and ActionListener interfaces and supports actions from a drop down menu bar, pop-up menus, arbitrary hot keys, or tool buttons. This class also provides a static method for generating action listeners with calls to specified methods with full support of the ADAPT history tracking feature, and a static method for executing a command string (such as from a macro definition).

Author:
Pender Technology
See Also:
Serialized Form

Field Summary
private  java.lang.Object[] aoParam
          An array of objects to pass to the method as parameters
private  DataFrame mainFrame
          The ADAPT data frame to which this action belongs
private  java.lang.reflect.Method method
          The method to call from the installed action listener
 
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
AAction(DataFrame aframe, java.lang.String $Method, java.lang.String $Menu, javax.swing.KeyStroke hotKey)
          Constructor for generating actions that will invoke a method on an ADAPT data frame.
AAction(DataFrame dataFrame, java.lang.String $Class, java.lang.String $Method, java.lang.String $Menu, java.lang.String $Param, java.lang.Object oParam)
          Constructor for generating actions that call a static method with one parameter.
AAction(DataFrame dataFrame, java.lang.String $Class, java.lang.String $Method, java.lang.String $Menu, java.lang.String $Param1, java.lang.Object oParam1, java.lang.String $Param2, java.lang.Object oParam2)
          Constructor for generating actions that call a static method with two parameters.
AAction(DataFrame dataFrame, java.lang.String $Class, java.lang.String $Method, java.lang.String $Menu, java.lang.String $Param1, java.lang.Object oParam1, java.lang.String $Param2, java.lang.Object oParam2, java.lang.String $Param3, java.lang.Object oParam3)
          Constructor for generating actions that call a static method with three parameters.
AAction(java.lang.String $Class, java.lang.String $Method, java.lang.String $Menu, javax.swing.KeyStroke hotKey, java.lang.String $Param, java.lang.Object oParam)
          Constructor for generating actions that call a static method with one parameter.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Invoke a method with a saved context and optional parameters
static void addActionListener(javax.swing.JMenuItem jmi, AdaptWindow adaptWindow, java.lang.String $Class, java.lang.String $Method, java.lang.String $Context, java.lang.Class cParamType, java.lang.Object oParam)
          This method creates and installs action listeners for menu commands, and works for methods with 0 or 1 parameter.
static void addActionListener(javax.swing.JMenuItem jmi, DataFrame aframe, java.lang.String $Class, java.lang.String $Method, java.lang.String $Context, java.lang.Class cParamType, java.lang.Object oParam)
          This method creates and installs action listeners for menu commands, and works for methods with 0 or 1 parameter.
private static java.awt.event.ActionListener getActionListener(AdaptWindow adaptWindow, java.lang.String $Class, java.lang.String $Method, java.lang.String $Context, java.lang.Class cParamType, java.lang.Object oParam)
          This method creates an action listener for menu commands, and works for methods with 0 or 1 parameter.
private static java.awt.event.ActionListener getActionListener(DataFrame dataFrame, java.lang.String $Class, java.lang.String $Method, java.lang.String $Context, java.lang.Class cParamType, java.lang.Object oParam)
          This method creates an action listener for menu commands, and works for methods with 0 or 1 parameter.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aoParam

private java.lang.Object[] aoParam
An array of objects to pass to the method as parameters


mainFrame

private DataFrame mainFrame
The ADAPT data frame to which this action belongs


method

private java.lang.reflect.Method method
The method to call from the installed action listener

Constructor Detail

AAction

public AAction(DataFrame aframe,
               java.lang.String $Method,
               java.lang.String $Menu,
               javax.swing.KeyStroke hotKey)
Constructor for generating actions that will invoke a method on an ADAPT data frame. The method to call must be a public method of com.pentec.adapt.DataFrame with no input parameters.

Parameters:
aframe - the ADAPT data frame to use for loading the context
$Method - the name of the method to call
$Menu - a description of the action for use in drop down menus
hotKey - the accelerator key to associate with the action

AAction

public AAction(DataFrame dataFrame,
               java.lang.String $Class,
               java.lang.String $Method,
               java.lang.String $Menu,
               java.lang.String $Param,
               java.lang.Object oParam)
Constructor for generating actions that call a static method with one parameter.

Parameters:
dataFrame - the ADAPT data frame to which this action belongs
$Class - fully qualified class name for the class containing the target method
$Method - the name of the method to call
$Menu - a description of the action
$Param - fully qualified class name for the parameter object
oParam - the parameter to pass to the method when it is invoked

AAction

public AAction(DataFrame dataFrame,
               java.lang.String $Class,
               java.lang.String $Method,
               java.lang.String $Menu,
               java.lang.String $Param1,
               java.lang.Object oParam1,
               java.lang.String $Param2,
               java.lang.Object oParam2)
Constructor for generating actions that call a static method with two parameters.

Parameters:
dataFrame - the ADAPT data frame to which this action belongs
$Class - fully qualified class name for the class containing the target method
$Method - the name of the method to call
$Menu - a description of the action
$Param1 - fully qualified class name for the first parameter
oParam1 - the first parameter
$Param2 - fully qualified class name for the second parameter
oParam2 - the second parameter

AAction

public AAction(DataFrame dataFrame,
               java.lang.String $Class,
               java.lang.String $Method,
               java.lang.String $Menu,
               java.lang.String $Param1,
               java.lang.Object oParam1,
               java.lang.String $Param2,
               java.lang.Object oParam2,
               java.lang.String $Param3,
               java.lang.Object oParam3)
Constructor for generating actions that call a static method with three parameters.

Parameters:
dataFrame - the ADAPT data frame to which this action belongs
$Class - fully qualified class name for the class containing the target method
$Method - the name of the method to call
$Menu - a description of the action
$Param1 - fully qualified class name for the first parameter
oParam1 - the first parameter
$Param2 - fully qualified class name for the second parameter
oParam2 - the second parameter
$Param3 - fully qualified class name for the third parameter
oParam3 - the third parameter

AAction

public AAction(java.lang.String $Class,
               java.lang.String $Method,
               java.lang.String $Menu,
               javax.swing.KeyStroke hotKey,
               java.lang.String $Param,
               java.lang.Object oParam)
Constructor for generating actions that call a static method with one parameter.

Parameters:
$Class - fully qualified class name for the class containing the target method
$Method - the name of the method to call
$Menu - a description of the action for use in drop down menus
hotKey - the accelerator key to associate with the action
$Param - fully qualified class name for the parameter object
oParam - the parameter to pass to the method when it is invoked
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Invoke a method with a saved context and optional parameters


addActionListener

public static void addActionListener(javax.swing.JMenuItem jmi,
                                     AdaptWindow adaptWindow,
                                     java.lang.String $Class,
                                     java.lang.String $Method,
                                     java.lang.String $Context,
                                     java.lang.Class cParamType,
                                     java.lang.Object oParam)
This method creates and installs action listeners for menu commands, and works for methods with 0 or 1 parameter. If the requested Class.method cannot be found, the menu item is disabled. For example, the method com.pentec.adapt.afile.AFile.fileOpen is defined like this:
      public void fileOpen(String $)
      
To create an action listener that calls fileOpen, you would use the following code:
      JMenuItem jmi = new JMenuItem("Menu Item");
      AAction.addActionListener(
        jmi,aframe,"com.pentec.adapt.afile.AFile","fileOpen","afile",String.class,"filename"));
      

Parameters:
jmi - the menu item to attach the action to
adaptWindow - the ADAPT window on which this function is to operate
$Class - the class in which the method is located
$Method - the method to install as the action listener
$Context - the context from which to call the method
cParamType - the class type of the method parameter
oParam - the method parameter

addActionListener

public static void addActionListener(javax.swing.JMenuItem jmi,
                                     DataFrame aframe,
                                     java.lang.String $Class,
                                     java.lang.String $Method,
                                     java.lang.String $Context,
                                     java.lang.Class cParamType,
                                     java.lang.Object oParam)
This method creates and installs action listeners for menu commands, and works for methods with 0 or 1 parameter. If the requested Class.method cannot be found, the menu item is disabled. For example, the method com.pentec.adapt.afile.AFile.fileOpen is defined like this:
      public void fileOpen(String $)
      
To create an action listener that calls fileOpen, you would use the following code:
      JMenuItem jmi = new JMenuItem("Menu Item");
      AAction.addActionListener(
        jmi,aframe,"com.pentec.adapt.afile.AFile","fileOpen","afile",String.class,"filename"));
      

Parameters:
jmi - the menu item to attach the action to
aframe - the ADAPT data frame on which this function is to operate
$Class - the class in which the method is located
$Method - the method to install as the action listener
$Context - the context from which to call the method
cParamType - the class type of the method parameter
oParam - the method parameter

getActionListener

private static java.awt.event.ActionListener getActionListener(AdaptWindow adaptWindow,
                                                               java.lang.String $Class,
                                                               java.lang.String $Method,
                                                               java.lang.String $Context,
                                                               java.lang.Class cParamType,
                                                               java.lang.Object oParam)
This method creates an action listener for menu commands, and works for methods with 0 or 1 parameter. If the requested Class.method cannot be found, null is returned.

Parameters:
adaptWindow - the ADAPT window on which this function is to operate
$Class - the class in which the method is located
$Method - the method to install as the action listener
$Context - the context from which to call the method
cParamType - the class type of the method parameter
oParam - the method parameter

getActionListener

private static java.awt.event.ActionListener getActionListener(DataFrame dataFrame,
                                                               java.lang.String $Class,
                                                               java.lang.String $Method,
                                                               java.lang.String $Context,
                                                               java.lang.Class cParamType,
                                                               java.lang.Object oParam)
This method creates an action listener for menu commands, and works for methods with 0 or 1 parameter. If the requested Class.method cannot be found, null is returned.

Parameters:
dataFrame - the ADAPT data frame on which this function is to operate
$Class - the class in which the method is located
$Method - the method to install as the action listener
$Context - the context from which to call the method
cParamType - the class type of the method parameter
oParam - the method parameter