edu.udo.cs.yale.gui
Class ConditionalAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by edu.udo.cs.yale.gui.ConditionalAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
Direct Known Subclasses:
MainFrame.ResumeAction, MainFrame.RunAction, MainFrame.StopAction, MainFrame.ValidateExperiment, OperatorTree.CopyAction, OperatorTree.CutAction, OperatorTree.DeleteOperatorAction, OperatorTree.InfoOperatorAction, OperatorTree.NewBuildingBlockAction, OperatorTree.NewOperatorAction, OperatorTree.PasteAction, OperatorTree.RenameOperatorAction, OperatorTree.SaveBuildingBlockAction, TreePanel.MoveDownAction, TreePanel.MoveUpAction, XMLEditor.SearchAction

public abstract class ConditionalAction
extends javax.swing.AbstractAction

An action that must be enabled/disabled depending on certain conditions. These conditions can be mandatrory, disallowed, or irrelevant. All ConditionalActions created are added to a collection and there status is automatically checked if the condition premises might have changed.

Version:
$Id: ConditionalAction.java,v 2.10 2006/03/27 13:21:58 ingomierswa Exp $
Author:
Ingo Mierswa, Simon Fischer
See Also:
Serialized Form

Field Summary
private static java.util.List<ConditionalAction> ALL_ACTIONS
           
static int CLIPBOARD_FILLED
           
private  int[] conditions
           
static int DISALLOWED
           
static int DONT_CARE
           
static int EXPERIMENT_RUNNING
           
static int MANDATORY
           
static int NUMBER_OF_CONDITIONS
           
static int OPERATOR_CHAIN_SELECTED
           
static int OPERATOR_SELECTED
           
static int ROOT_SELECTED
           
static int SIBLINGS_EXIST
           
static int XML_VIEW
           
 
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
ConditionalAction(java.lang.String name)
           
ConditionalAction(java.lang.String name, javax.swing.Icon icon)
           
 
Method Summary
 void setCondition(int index, int condition)
           
private  void update(boolean[] state)
          Updates an action given the set of states that can be true or false.
static void updateAll(boolean[] states)
          Updates all actions.
 
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
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 

Field Detail

ALL_ACTIONS

private static final java.util.List<ConditionalAction> ALL_ACTIONS

DISALLOWED

public static final int DISALLOWED
See Also:
Constant Field Values

DONT_CARE

public static final int DONT_CARE
See Also:
Constant Field Values

MANDATORY

public static final int MANDATORY
See Also:
Constant Field Values

OPERATOR_SELECTED

public static final int OPERATOR_SELECTED
See Also:
Constant Field Values

OPERATOR_CHAIN_SELECTED

public static final int OPERATOR_CHAIN_SELECTED
See Also:
Constant Field Values

ROOT_SELECTED

public static final int ROOT_SELECTED
See Also:
Constant Field Values

SIBLINGS_EXIST

public static final int SIBLINGS_EXIST
See Also:
Constant Field Values

CLIPBOARD_FILLED

public static final int CLIPBOARD_FILLED
See Also:
Constant Field Values

EXPERIMENT_RUNNING

public static final int EXPERIMENT_RUNNING
See Also:
Constant Field Values

XML_VIEW

public static final int XML_VIEW
See Also:
Constant Field Values

NUMBER_OF_CONDITIONS

public static final int NUMBER_OF_CONDITIONS
See Also:
Constant Field Values

conditions

private int[] conditions
Constructor Detail

ConditionalAction

public ConditionalAction(java.lang.String name)

ConditionalAction

public ConditionalAction(java.lang.String name,
                         javax.swing.Icon icon)
Method Detail

setCondition

public void setCondition(int index,
                         int condition)
Parameters:
index - one out of OPERATOR_SELECTED, OPERATOR_CHAIN_SELECTED, ROOT_SELECTED, CLIPBOARD_FILLED, and EXPERIMENT_RUNNING
condition - one out of DISALLOWED, DONT_CARE, and MANDATORY

updateAll

public static void updateAll(boolean[] states)
Updates all actions.


update

private void update(boolean[] state)
Updates an action given the set of states that can be true or false. States refer to OPERATOR_SELECTED... An action is enabled iff for all states the condition is DONT_CARE or MANDATORY and state is true or DISALLOWED and state is false.



Copyright © 2001-2006