Warning: Can't use blame annotator:
svn blame failed on trunk/src/tmcsim/simulationmanager/actions/StartSimulationAction.java: ("Can't find a temporary directory: Internal error", 20014)

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

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

Initial Import of project files

RevLine 
1package tmcsim.simulationmanager.actions;
2
3import java.awt.event.ActionEvent;
4
5import javax.swing.AbstractAction;
6import javax.swing.JOptionPane;
7
8import tmcsim.common.ScriptException;
9import tmcsim.common.SimulationException;
10import tmcsim.simulationmanager.SimulationManagerView;
11
12/**
13 * StartSimulationAction is an AbstractAction that is used for starting
14 * the simulation. When the action is performed, the action checks
15 * whether the a connection has been made to Paramics.  If not, the user
16 * is prompted whether they want to continue without a connection to Paramics.
17 * If not, the action returns.  If there is a connection, or the user wishes to
18 * continue without, the action calls the SimulationManagerModel to start the
19 * simulation.
20 * @author Matthew Cechini
21 */
22@SuppressWarnings("serial")
23public class StartSimulationAction extends AbstractAction {
24   
25    /** Reference to the SimulationManagerView object. */
26    private SimulationManagerView theSimManagerView = null;
27   
28    /**
29     * Constructor.
30     * @param View class object for the Simulation Manager.
31     */
32    public StartSimulationAction(SimulationManagerView view) {
33        super("Start");
34       
35        theSimManagerView = view;
36    }
37   
38    public void actionPerformed(ActionEvent evt) {
39        Runnable startRunnable = new Runnable(){       
40            public void run() {             
41                if(!theSimManagerView.isConnectedToParamics()) {
42                    if (JOptionPane.showConfirmDialog(null, "Connection has not been " +
43                            "made to the Paramics Traffic Modeler.  Do you wish " +
44                            "to continue?", "Paramics Connection", 
45                            JOptionPane.YES_NO_OPTION, 
46                            JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
47                                return;
48                            }
49                }
50               
51                try { 
52                    theSimManagerView.getModel().startSimulation();
53                }
54                catch (ScriptException se) {
55                    theSimManagerView.ScriptExceptionHandler(se);
56                }
57                catch (SimulationException se) {
58                    theSimManagerView.SimulationExceptionHandler(se);
59                }
60            }       
61        };     
62
63        Thread theThread = new Thread(startRunnable);
64        theThread.start();
65    }
66
67}
Note: See TracBrowser for help on using the repository browser.