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

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

Revision 2, 2.8 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.SimulationException;
9import tmcsim.simulationmanager.SimulationManagerView;
10import tmcsim.simulationmanager.dialogs.GotoTimeIndexDialog;
11
12/**
13 * GotoTimeIndexAction is an AbstractAction that is used for moving the
14 * simulation to a new time mark.  When the action is performed, the action
15 * shows the GotoTimeIndexDialog to prompt the user for a new time mark.
16 * If the user chooses a new time, the action asks the user to confirm
17 * the Goto action and then calls the SimulationManagerModel to pause,
18 * reset, and then goto the new simulation time.  This is is done
19 * to ensure the current simulation is paused, to clear all current
20 * incident info from the view, and then to reset the simulation time.
21 * @author Matthew Cechini
22 */
23@SuppressWarnings("serial")
24public class GotoTimeIndexAction extends AbstractAction {
25   
26    /** Reference to the SimulationManagerView object. */
27    private SimulationManagerView theSimManagerView = null;
28   
29    /**
30     * Constructor.
31     * @param view View class object for the Simulation Manager.
32     */
33    public GotoTimeIndexAction(SimulationManagerView view) {
34        super("Goto");
35       
36        theSimManagerView = view;       
37    }
38   
39    public void actionPerformed(ActionEvent evt) {
40        Runnable gotoRunnable = new Runnable() {
41            public void run() {
42
43                try {                   
44                    GotoTimeIndexDialog gotoDialog = 
45                        new GotoTimeIndexDialog(null, theSimManagerView.getCurrentSimTime());
46                   
47                    if(gotoDialog.gotoApplied) {
48                       
49                        String gotoValue = gotoDialog.getGotoTime();
50                       
51                        if(JOptionPane.showConfirmDialog(null, 
52                                "Do you wish to reposition the simulation time to " + gotoValue,
53                                "Confirm Goto",
54                                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) 
55                        {       
56                            theSimManagerView.getModel().pauseSimulation();
57                            theSimManagerView.getModel().resetSimulation();                 
58                            theSimManagerView.getModel().gotoSimulationTime(
59                                    SimulationManagerView.stringTimeToLong(gotoValue));
60                        }
61                    }
62                }
63                catch (SimulationException se) {
64                    theSimManagerView.SimulationExceptionHandler(se);
65                }
66            }
67        };
68       
69        Thread theThread = new Thread(gotoRunnable);
70        theThread.start();
71    }
72
73}
Note: See TracBrowser for help on using the repository browser.