edu.neu.ccs.gui
Class DialogAction

java.lang.Object
  extended byedu.neu.ccs.gui.ActionWrapper
      extended byedu.neu.ccs.gui.DialogAction
All Implemented Interfaces:
Action, ActionListener, ConsoleAware, EventListener

public class DialogAction
extends ActionWrapper
implements ConsoleAware

Encapsulates an Action that will be performed for a GeneralDialog.

Since:
2.0
Version:
2.2

Field Summary
static Object AUTO_CLOSE
          The choice to auto close the dialog after the action.
protected  GeneralDialog dialog
          The dialog to act on.
protected  Object finish
          The last action to perform.
static Object KEEP_OPEN
          The choice to keep the dialog open after the action.
static Object SET_CANCEL
          The choice to both close the dialog and mark the dialog as cancelled.
 
Fields inherited from class edu.neu.ccs.gui.ActionWrapper
action
 
Fields inherited from interface edu.neu.ccs.console.ConsoleAware
console
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
DialogAction(GeneralDialog dialog, Action action, Object finish)
          Constructs a DialogAction object using a GeneralDialog object, an action that must be performed for that dialog, and an object that determines what will happen to the dialog when the action is done.
DialogAction(GeneralDialog dialog, Object[] actionData)
          Constructs a DialogAction object using a GeneralDialog object and an action data array to set the action and finish.
DialogAction(GeneralDialog dialog, String name, Icon icon, Object finish)
          Constructs a DialogAction object using a GeneralDialog object, a name and icon to define a trivial action, and an object that determines what will happen to the dialog when the action is done.
DialogAction(GeneralDialog dialog, String name, Object finish)
          Constructs a DialogAction object using a GeneralDialog object, a name to define a trivial action, and an object that determines what will happen to the dialog when the action is done.
 
Method Summary
 void actionPerformed(ActionEvent event)
          Invokes the actionPerformed method of the encapsulated action and then performs the action specified as the finish action.
 Object getFinish()
          Returns the choice of what to do to the dialog when the action is done.
static DialogAction makeDialogAction(GeneralDialog dialog, Object[] actionData)
           
static DialogAction[] makeDialogActions(GeneralDialog dialog, Object[][] actionData)
           
static Action makeTrivialAction(String name)
          Returns an action with the given name that does no work.
static Action makeTrivialAction(String name, Icon icon)
          Returns an action with the given name and icon that does no work.
 void setActionAndFinish(Object[] actionData)
           
 void setFinish(Object finish)
          Sets the choice of what to do to the dialog when the action is done to the given parameter.
 
Methods inherited from class edu.neu.ccs.gui.ActionWrapper
addPropertyChangeListener, getAction, getBaseAction, getName, getValue, isEnabled, putValue, removePropertyChangeListener, setAction, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEEP_OPEN

public static final Object KEEP_OPEN
The choice to keep the dialog open after the action.


AUTO_CLOSE

public static final Object AUTO_CLOSE
The choice to auto close the dialog after the action.


SET_CANCEL

public static final Object SET_CANCEL
The choice to both close the dialog and mark the dialog as cancelled.


dialog

protected GeneralDialog dialog
The dialog to act on.


finish

protected Object finish
The last action to perform.

Constructor Detail

DialogAction

public DialogAction(GeneralDialog dialog,
                    Action action,
                    Object finish)

Constructs a DialogAction object using a GeneralDialog object, an action that must be performed for that dialog, and an object that determines what will happen to the dialog when the action is done.

The finish parameter must be one of the following values:

If the parameter is not one of these values, the finish is set to DialogAction.AUTO_CLOSE.

A NullPointerException will be thrown if the GeneralDialog object is null.

Parameters:
dialog - the dialog to act on
action - the action to perform
finish - what to do to the dialog when the action is done
See Also:
DialogAction(GeneralDialog, String, Object), DialogAction(GeneralDialog, String, Icon, Object), DialogAction(GeneralDialog, Object[])

DialogAction

public DialogAction(GeneralDialog dialog,
                    String name,
                    Object finish)

Constructs a DialogAction object using a GeneralDialog object, a name to define a trivial action, and an object that determines what will happen to the dialog when the action is done.

The finish parameter must be one of the following values:

If the parameter is not one of these values, the finish is set to DialogAction.AUTO_CLOSE.

A NullPointerException will be thrown if the GeneralDialog object is null.

Parameters:
dialog - the dialog to act on
name - the name for a trivial action
finish - what to do to the dialog when the action is done
See Also:
DialogAction(GeneralDialog, Action, Object), DialogAction(GeneralDialog, String, Icon, Object), DialogAction(GeneralDialog, Object[])

DialogAction

public DialogAction(GeneralDialog dialog,
                    String name,
                    Icon icon,
                    Object finish)

Constructs a DialogAction object using a GeneralDialog object, a name and icon to define a trivial action, and an object that determines what will happen to the dialog when the action is done.

The finish parameter must be one of the following values:

If the parameter is not one of these values, the finish is set to DialogAction.AUTO_CLOSE.

A NullPointerException will be thrown if the GeneralDialog object is null.

Parameters:
dialog - the dialog to act on
name - the name for a trivial action
icon - the icon for a trivial action
finish - what to do to the dialog when the action is done
See Also:
DialogAction(GeneralDialog, Action, Object), DialogAction(GeneralDialog, String, Object), DialogAction(GeneralDialog, Object[])

DialogAction

public DialogAction(GeneralDialog dialog,
                    Object[] actionData)

Constructs a DialogAction object using a GeneralDialog object and an action data array to set the action and finish.

The parameter actionData is an Object[] array that specifies the action and finish in one of the following ways:

The option parameter must be one of the following values that will determine what is done to the dialog when the action is finished:

The default if the option is not specified is DialogAction.AUTO_CLOSE.

A NullPointerException will be thrown if the GeneralDialog object is null.

Parameters:
dialog - the dialog to act on
actionData - the array used to generate the dialog actions
See Also:
DialogAction(GeneralDialog, Action, Object), DialogAction(GeneralDialog, String, Object), DialogAction(GeneralDialog, String, Icon, Object)
Method Detail

actionPerformed

public void actionPerformed(ActionEvent event)
Invokes the actionPerformed method of the encapsulated action and then performs the action specified as the finish action.

Specified by:
actionPerformed in interface ActionListener
Specified by:
actionPerformed in class ActionWrapper
Parameters:
event - the event that invoked this action

getFinish

public Object getFinish()
Returns the choice of what to do to the dialog when the action is done.

See Also:
setFinish(Object), setActionAndFinish(Object[])

setFinish

public void setFinish(Object finish)

Sets the choice of what to do to the dialog when the action is done to the given parameter.

The finish parameter must be one of the following values:

If the finish parameter is not one of these values, this method does nothing.

Parameters:
finish - what to do to the dialog when the action is done
See Also:
getFinish(), setActionAndFinish(Object[])

setActionAndFinish

public void setActionAndFinish(Object[] actionData)

makeDialogAction

public static DialogAction makeDialogAction(GeneralDialog dialog,
                                            Object[] actionData)

makeDialogActions

public static DialogAction[] makeDialogActions(GeneralDialog dialog,
                                               Object[][] actionData)

makeTrivialAction

public static Action makeTrivialAction(String name)
Returns an action with the given name that does no work.

Parameters:
name - the name of the trivial action
See Also:
makeTrivialAction(String, Icon)

makeTrivialAction

public static Action makeTrivialAction(String name,
                                       Icon icon)
Returns an action with the given name and icon that does no work.

Parameters:
name - the name of the trivial action
icon - the icon of the trivial action
See Also:
makeTrivialAction(String)