haifa.shopsim.UI
Class AlgorithmSelectionAction

java.lang.Object
  |
  +--javax.swing.AbstractAction
        |
        +--haifa.shopsim.UI.AlgorithmSelectionAction
All Implemented Interfaces:
javax.swing.Action, java.awt.event.ActionListener, java.lang.Cloneable, java.util.EventListener, java.io.Serializable

abstract class AlgorithmSelectionAction
extends javax.swing.AbstractAction

This class implements an action that occurs when a new algorithm is selected. The action first stops the simulation if it is running. It then removes the simulation and gc's what it can. A new algorithm is then created.

The class is abstract in the sense of the allocateAlgorithm method. It is best if this class be extended by an anonymous inner class within listeners such that the allocateAlgorithm method is extended and allocates the proper algorithm.

This design prevents allocating all of the available algorithms at start up.

Version:
1.1
See Also:
Serialized Form

Inner classes inherited from class javax.swing.AbstractAction
javax.swing.AbstractAction.ArrayTable
 
Field Summary
private  int index
           
(package private)  MainGUI mainGUI
           
private  ShopAlgorithm shopAlgorithm
          A reference to the shopAlgorithm which this class handles.
 
Fields inherited from class javax.swing.AbstractAction
arrayTable, 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
(package private) AlgorithmSelectionAction(MainGUI mainGUI_, java.lang.String algName, int index_)
          The constructor uses an algorithm name.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
          Does what is specified at the class explanation above.
abstract  GUIAlgorithm allocateAlgorithm()
          This method is to be overriden by implementations such that it allocates the desired algorithm and returns a reference.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getValue, isEnabled, putValue, readObject, removePropertyChangeListener, setEnabled, writeObject
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

mainGUI

MainGUI mainGUI

shopAlgorithm

private ShopAlgorithm shopAlgorithm
A reference to the shopAlgorithm which this class handles.

index

private int index
Constructor Detail

AlgorithmSelectionAction

AlgorithmSelectionAction(MainGUI mainGUI_,
                         java.lang.String algName,
                         int index_)
The constructor uses an algorithm name.
Method Detail

allocateAlgorithm

public abstract GUIAlgorithm allocateAlgorithm()
This method is to be overriden by implementations such that it allocates the desired algorithm and returns a reference.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
Does what is specified at the class explanation above.
Overrides:
actionPerformed in class javax.swing.AbstractAction