source: tmcsimulator/trunk/src/tmcsim/simulationmanager/actions/PauseSimulationAction.java @ 2

Revision 2, 1.3 KB checked in by jdalbey, 10 years ago (diff)

Initial Import of project files

Line 
1package tmcsim.simulationmanager.actions;
2
3import java.awt.event.ActionEvent;
4
5import javax.swing.AbstractAction;
6
7import tmcsim.common.SimulationException;
8import tmcsim.simulationmanager.SimulationManagerView;
9
10/**
11 * PauseSimulationAction is an AbstractAction that is used for pausing
12 * the simulation. When the action is performed, the action
13 * calls the SimulationManagerModel to pause the simulation.
14 */
15@SuppressWarnings("serial")
16public class PauseSimulationAction extends AbstractAction {
17   
18    /** Reference to the SimulationManagerView object. */
19    private SimulationManagerView theSimManagerView = null;
20
21    /**
22     * Constructor.
23     * @param view View class object for the Simulation Manager.
24     */
25    public PauseSimulationAction(SimulationManagerView view) {
26        super("Pause");
27       
28        theSimManagerView = view;
29    }
30
31    public void actionPerformed(ActionEvent evt) {
32        Runnable pauseRunnable = new Runnable(){       
33            public void run() { 
34                try {
35                    theSimManagerView.getModel().pauseSimulation();
36                }
37                catch(SimulationException se) {
38                    theSimManagerView.SimulationExceptionHandler(se);
39                }
40            }
41        };
42
43        Thread theThread = new Thread(pauseRunnable);
44        theThread.start();
45    }
46
47}
Note: See TracBrowser for help on using the repository browser.