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

source: tmcsimulator/trunk/src/tmcsim/simulationmanager/SimulationManagerView.java @ 460

Revision 460, 51.1 KB checked in by jdalbey, 7 years ago (diff)

SimulationManagerView?.java: modify setScriptStatus() to fix ticket #172.

RevLine 
1 package tmcsim.simulationmanager;
2
3import java.awt.BorderLayout;
4import java.awt.Color;
5import java.awt.Dimension;
6import java.awt.Font;
7import java.awt.event.MouseEvent;
8import java.awt.event.MouseListener;
9import java.util.TreeMap;
10
11import javax.swing.BorderFactory;
12import javax.swing.Box;
13import javax.swing.BoxLayout;
14import javax.swing.JButton;
15import javax.swing.JComboBox;
16import javax.swing.JFrame;
17import javax.swing.JLabel;
18import javax.swing.JMenu;
19import javax.swing.JMenuBar;
20import javax.swing.JMenuItem;
21import javax.swing.JOptionPane;
22import javax.swing.JPanel;
23import javax.swing.JScrollPane;
24import javax.swing.JSpinner;
25import javax.swing.JTabbedPane;
26import javax.swing.JTable;
27import javax.swing.SpinnerNumberModel;
28import javax.swing.SwingUtilities;
29import javax.swing.border.CompoundBorder;
30import javax.swing.border.EtchedBorder;
31import javax.swing.border.TitledBorder;
32import javax.swing.event.TableModelEvent;
33import javax.swing.event.TableModelListener;
34
35import tmcsim.cadmodels.CMSDiversion;
36import tmcsim.cadmodels.CMSInfo;
37import tmcsim.client.cadclientgui.data.Incident;
38import tmcsim.client.cadclientgui.data.IncidentEvent;
39import tmcsim.common.RevisionNumber;
40import tmcsim.common.ScriptException;
41import tmcsim.common.SimulationException;
42import tmcsim.common.CADEnums.PARAMICS_STATUS;
43import tmcsim.common.CADEnums.SCRIPT_STATUS;
44import tmcsim.common.TimeUtils;
45import tmcsim.simulationmanager.actions.AddIncidentAction;
46import tmcsim.simulationmanager.actions.ApplyDiversionAction;
47import tmcsim.simulationmanager.actions.ConnectToParamicsAction;
48import tmcsim.simulationmanager.actions.DeleteIncidentAction;
49import tmcsim.simulationmanager.actions.ExitAction;
50import tmcsim.simulationmanager.actions.ExportAction;
51import tmcsim.simulationmanager.actions.GotoTimeIndexAction;
52import tmcsim.simulationmanager.actions.LoadParamicsNetworkAction;
53import tmcsim.simulationmanager.actions.LoadScriptAction;
54import tmcsim.simulationmanager.actions.PauseSimulationAction;
55import tmcsim.simulationmanager.actions.RescheduleIncidentAction;
56import tmcsim.simulationmanager.actions.ResetSimulationAction;
57import tmcsim.simulationmanager.actions.StartSimulationAction;
58import tmcsim.simulationmanager.actions.TriggerIncidentAction;
59import tmcsim.simulationmanager.model.AppliedDiversionTableModel;
60import tmcsim.simulationmanager.model.IncidentListTableModel;
61import tmcsim.simulationmanager.model.IncidentTimeCellRenderer;
62import tmcsim.simulationmanager.model.IncidentTimeSpinnerModel;
63import tmcsim.simulationmanager.model.AppliedDiversionTableModel.APPLIED_DIV_COLUMNS;
64import tmcsim.simulationmanager.model.IncidentListTableModel.INCIDENT_LIST_COLUMNS;
65
66/**
67 * This class is the view component to the SimlationManager.  User
68 * interaction with the SimulationManager is handled in this object. 
69 * The data contained within the SimlationManagerModel class is
70 * displayed in the JTables contained in this class.  The view class
71 * does not validate the user input.  Exception handling
72 * takes care of error in the user input.
73 *
74 * @author Matthew Cechini
75 * @version $Revision: 1.6 $ $Date: 2006/06/06 22:52:56 $
76 */
77@SuppressWarnings("serial")
78public class SimulationManagerView extends JFrame { 
79
80    /** Default Paramics network ID */
81    private static int DEFAULT_NETWORK_ID = 1;
82
83    /** Maximum Paramics network ID (100) */
84    private static int MAX_NETWORK_ID    = 100;
85
86    /** Default directory for script loading. */
87    public static String SCRIPT_DIR      = ".";
88
89    /** Reference to the simulation manager model. */
90    private SimulationManagerModel theSimManagerModel;
91       
92    /** The Table Model for the incident list table. */
93    private IncidentListTableModel incidentListTableModel;
94   
95    /** The Table Model for the applied diversions table. */   
96    private AppliedDiversionTableModel appliedDiversionTableModel;
97   
98    /**
99     * A map of DefaultTableModel objects associated with each incident
100     * in the simulation.  Key values are the log numberes of incidents. 
101     */
102    //private TreeMap<Integer, IncidentHistoryTableModel> incidentTableMap = null;
103    private TreeMap<Integer, IncidentHistoryPanel> incidentTableMap = null;
104   
105    /** The current simulation time. */
106    private long currentSimulationTime = 0;
107   
108    /**
109     * Flag to designate whether the simulation has started. Initialized to false.
110     * Becomes true when the user presses the start button.  Becomes false again
111     * when the simulation is "reset" or another script is loaded.
112     */
113    private boolean simulationStarted = false;
114   
115    /**
116     * Flag to designate whether a connection has been made to the remote
117     * Paramics Communicator.
118     */
119    private boolean connectedToParamics = false;
120   
121   
122    /**
123     * Constructor. This class sets the local reference to the simulation manager
124     * model to the parameter object.  It then initializes all of the swing
125     * components that are used in this user interface.
126     *
127     * @param newModel The reference to the SimulationManagerModel object
128     */
129    public SimulationManagerView(SimulationManagerModel newModel) {
130        super("Simulation Manager");
131       
132        theSimManagerModel   = newModel;   
133       
134        incidentTableMap = new TreeMap<Integer, IncidentHistoryPanel>();
135       
136        initComponents();
137
138    }
139 
140    /**
141     * Method gets the model object for the SimulationManagerView class.
142     * @return SimulationManagerModel object.
143     */
144    public SimulationManagerModel getModel() {
145        return theSimManagerModel;
146    }
147   
148    /**
149     * Method returns the boolean value designating whether a current
150     * connection has been made to the Paramics Communicator.
151     *
152     * @return True if connected, false if not.
153     */
154    public Boolean isConnectedToParamics() {
155        return connectedToParamics;
156    }
157   
158    /**
159     * Method returns the boolean value designating whether the
160     * simulation has started or not.
161     *
162     * @return True if started, false if not.
163     */
164    public Boolean isSimulationStarted() {
165        return simulationStarted;
166    }
167   
168    /**
169     * Method returns the value of the current simulation time.
170     *
171     * @return Current simulation time (in seconds).
172     */
173    public Long getCurrentSimTime() {
174        return currentSimulationTime;
175    }
176   
177    /**
178     * Creates a local JTable for the event history portion of the user interface
179     * with the table model passed in as a parameter.  The table has three columns.
180     * Addition and subtraction to this table are handled in the model clas.
181     *
182     * @param logNumber Log number for this incident.
183     */ 
184    public void addIncidentTab(final Integer logNumber) {
185        // Place this code on EDT to fix defect #154
186        SwingUtilities.invokeLater(new Runnable(){public void run(){
187            IncidentHistoryPanel newHistoryPanel = new IncidentHistoryPanel();
188
189            incidentTableMap.put(logNumber, newHistoryPanel);
190
191            eventHistoryPane.addTab(String.valueOf(logNumber), newHistoryPanel);
192        }});
193    }
194   
195    /**
196     * Remove the incident tab whose log number matches the parameter.
197     *
198     * @param logNumber Incident log number.
199     */
200    public void removeIncidentTab(Integer logNumber) {
201        for(int i = 0; i < eventHistoryPane.getTabCount(); i++) {
202            if(eventHistoryPane.getTitleAt(i).compareTo(String.valueOf(logNumber)) == 0) {
203                eventHistoryPane.remove(i);
204                break; 
205            }
206        }
207    }
208   
209    /**
210     * Remove all incident tabs from the event history pane.
211     */
212    public void resetIncidentTabs() {
213        eventHistoryPane.removeAll();
214    }
215   
216    /**
217     * Method is called to add a new incident to the IncidentManagement
218     * panel.  The incident object is added to the IncidentListTableModel.
219     *
220     * @param newIncident The incident object being added to the simulation.
221     */ 
222    public void addIncident(Incident newIncident) {
223        incidentListTableModel.addIncident(newIncident);
224    }   
225   
226    /**
227     * Method starts an incident found in the IncidentListTableModel.
228     * @param logNumber Incident log number.
229     */
230    public void startIncident(Integer logNumber) {
231        incidentListTableModel.startIncident(logNumber);       
232    }   
233   
234    /**
235     * Method removes an incident by removing it from the
236     * IncidentListTableModel.  If there are no more incidents
237     * in the simulation, reset the start, pause, and reset buttons
238     * to be disabled, and enable the load script button.
239     *
240     * @param logNumber Incident log number.
241     */
242    public void removeIncident(Integer logNumber) {
243        incidentListTableModel.removeIncident(logNumber);       
244       
245        //TODO check if simulation started??   
246        if(incidentListTableModel.getRowCount() == 0 && !simulationStarted) 
247        {
248            startButton.setEnabled(false);
249            pauseButton.setEnabled(false);
250            resetButton.setEnabled(false); 
251           
252            loadScriptButton.setEnabled(true);
253        }       
254    }
255   
256    /**
257     * Method resets the current list of Incidents by clearing the
258     * IncidentListTableModel.
259     */ 
260    public void resetIncidents() {
261        incidentListTableModel.clearModelData();
262    }
263   
264    /**
265     * Method adds a new Incident event to the IncidentHistoryTableModel
266     * that corresponds to the Incident log number.  If the IncidentEvent
267     * has been received from a terminal, the tab containing the
268     * incident's table will be colored red to notify the user.
269     *
270     * @param logNumber Incident log number.
271     * @param newEvent Incident event to add.
272     */
273    public void addIncidentEvent(Integer logNumber, IncidentEvent newEvent) {
274        //IncidentHistoryTableModel historyTableModel = incidentTableMap.get(logNumber);
275        IncidentHistoryPanel historyPanel = incidentTableMap.get(logNumber);
276       
277        //historyTableModel.addEvent(logNumber, newEvent);
278        historyPanel.updateIncidentHistory(newEvent);
279    }
280   
281    /**
282     * Method is called to add a new diversion to the Diversions panel. 
283     * The CMSInfo and CMSDiversion objects are added to the
284     * AppliedDiversionTableModel, which creates its needed view data.
285     *
286     * @param theCMSInfo The CMSInfo that the new diversion corresponds to.
287     * @param theDiversion A new diversion to be applied.
288     */
289    public void addDiversion(CMSInfo theCMSInfo, CMSDiversion theDiversion) {       
290        appliedDiversionTableModel.addDiversion(theCMSInfo, theDiversion);
291    }       
292
293    /**
294     * Method is called to remove an existing diversion from the Diversions panel. 
295     * The diversion information is removed from the AppliedDiversionTableModel,
296     * which removes the corresponding row.
297     *
298     * @param theCMSInfo The CMSInfo that the new diversion corresponds to.
299     * @param theDiversion A new diversion to be applied.
300     */
301    public void removeDiversion(CMSInfo theCMSInfo, CMSDiversion theDiversion) {
302        appliedDiversionTableModel.removeDiversion(theCMSInfo, theDiversion);
303
304    }
305   
306    /**
307     * Method resets the list of diversions by clearing the
308     * AppliedDiversionTableModel.
309     */
310    public void resetDiversions() {
311        appliedDiversionTableModel.clearModelData();
312    }
313   
314    /**
315     * Build the CMS ID combo box with the list of parameter ids.
316     *
317     * @param cmsIDArray Array of cms IDs
318     */
319    public void setCMS_IDList(Object[] cmsIDArray) {
320        for(int i = 0; i < cmsIDArray.length; i++) {
321            cmsIDComboBox.addItem(cmsIDArray[i]);   
322        }
323    }
324   
325    /**
326     * Method is called by the model everytime a second has passed during the simulation.
327     * The time in the parameter is shown in the simulationClockLabel.  The parameter
328     * is formatted HH:MM:SS.
329     *
330     * @param time The new time.
331     */
332    public void tick(long time) {
333        currentSimulationTime = time;
334       
335        String newTime = TimeUtils.longToTime(currentSimulationTime);
336       
337        simulationClockLabel.setText(newTime);
338        CADClientClockLabel.setText(newTime);
339    }
340   
341    /**
342     * Method updates the simulation control and 'load script' buttons' enabled status
343     * and the status text according to the parameter SCRIPT_STATUS.
344     * The following table describes each status and the actions taken. <br>
345     *
346     *<table cellpadding="2" cellspacing="2" border="1"
347     * style="text-align: left; width: 250px;">
348     *  <tbody>
349     *    <tr>
350     *      <th>Status<br></th>
351     *      <th>Actions Taken<br></th>
352     *    </tr>
353     *    <tr>
354     *      <td>NO_SCRIPT<br></td>
355     *      <td>Set the simulation status text to a black "No Script".  Then
356     *          disable all simulation buttons.  Enable the 'Load Script' button.<br></td>
357     *    </tr>
358     *    <tr>
359     *      <td>SCRIPT_STOPPED_NOT_STARTED<br></td>
360     *      <td>Set the simulation status text to a red "Not Started".  Then
361     *          enable the 'Start' and 'Reset' buttons, and disable the 'Pause'
362     *          button. Enable the 'Load Script' button.<br></td>
363     *    </tr>
364     *    <tr>
365     *      <td>SCRIPT_PAUSED_STARTED<br></td>
366     *      <td>Set the simulation status text to a red "Paused".  Then
367     *          enable the 'Start' and 'Reset' buttons, and disable the 'Pause'
368     *          button. Enable the 'Load Script' button. Set the simulationStarted
369     *          flag to true.<br></td>
370     *    </tr>
371     *    <tr>
372     *      <td>SCRIPT_RUNNING<br></td>
373     *      <td>Set the simulation status text to a green "Running".  Then
374     *          disable the 'Start' and 'Reset' buttons, and enable the 'Pause'
375     *          button. Disable the 'Load Script' button.  Set the simulationStarted
376     *          flag to true.<br></td>
377     *    </tr>
378     *    <tr>
379     *      <td>ATMS_SYNCHRONIZATION<br></td>
380     *      <td>Set the simulation status text to an orange "Synchronizing".  Then
381     *          disable all simulation buttons and the 'Load Script' button.<br></td>
382     *    </tr>
383     *  </tbody>
384     *</table>
385     *
386     * @param status Script status value.
387     */
388    public void setScriptStatus(SCRIPT_STATUS status) 
389    {
390        switch(status) {
391            case NO_SCRIPT:
392                simulationStatusText.setText("No Script");
393                simulationStatusText.setForeground(Color.BLACK);
394                   
395                startButton.setEnabled(false);
396                pauseButton.setEnabled(false);
397                resetButton.setEnabled(false);                                             
398                break;         
399               
400            case SCRIPT_STOPPED_NOT_STARTED:
401               
402                simulationStatusText.setText("Ready");
403                simulationStatusText.setForeground(Color.RED);
404                   
405                startButton.setEnabled(true);
406                startButton.setText("Start");
407                pauseButton.setEnabled(false);
408                resetButton.setEnabled(true);       
409               
410                loadScriptButton.setEnabled(true);
411               
412                //simulationClockLabel.setText("0:00:00");
413                //CADClientClockLabel.setText("0:00:00");               
414                break;         
415               
416            case SCRIPT_PAUSED_STARTED:
417                simulationStatusText.setText("Paused");
418                simulationStatusText.setForeground(Color.RED);
419                   
420                startButton.setEnabled(true);
421                startButton.setText("Resume");
422                pauseButton.setEnabled(false);
423                resetButton.setEnabled(true);               
424                simulationStarted = true;
425
426                loadScriptButton.setEnabled(true);
427                break;
428               
429            case SCRIPT_RUNNING:
430                simulationStatusText.setText("Running");
431                simulationStatusText.setForeground(Color.GREEN.darker());
432               
433                startButton.setEnabled(false);
434                pauseButton.setEnabled(true);
435                resetButton.setEnabled(false); 
436                simulationStarted = true;
437
438                loadScriptButton.setEnabled(false);
439                break;
440            case ATMS_SYNCHRONIZATION:
441                simulationStatusText.setText("Synchronizing");
442                simulationStatusText.setForeground(Color.ORANGE);
443               
444                startButton.setEnabled(false);
445                pauseButton.setEnabled(false);
446                resetButton.setEnabled(false); 
447                simulationStarted = false;
448
449                loadScriptButton.setEnabled(false);
450                break;
451        }       
452    }
453   
454
455    /**
456     * Method updates the paramics control buttons' enabled status
457     * and the paramics status text according to the parameter PARAMICS_STATUS.
458     * The following table describes each status and the actions taken. <br>
459     *
460     *<table cellpadding="2" cellspacing="2" border="1"
461     * style="text-align: left; width: 250px;">
462     *  <tbody>
463     *    <tr>
464     *      <th>Status<br></th>
465     *      <th>Actions Taken<br></th>
466     *    </tr>
467     *    <tr>
468     *      <td>UNREACHABLE<br></td>
469     *      <td>Show a message dialog to the user notifying them that a
470     *          connection to Paramics could not be made.  Reset the
471     *          connect button to be labled 'Connect to Paramics' and
472     *          set the status text to 'Unreachable'.  Enable the connect
473     *          button and disable the network load button.  Set the connected
474     *          to paramics flag to false.<br></td>
475     *    </tr>
476     *    <tr>
477     *      <td>DROPPED<br></td>
478     *      <td>Show a message dialog to the user notifying them that the
479     *          connection to Paramics has been dropped.  Reset the
480     *          connect button to be labled 'Connect to Paramics' and
481     *          set the status text to 'Dropped'.  <br></td>
482     *    </tr>
483     *    <tr>
484     *      <td>CONNECTING<br></td>
485     *      <td>Set the status text to 'Connecting'.  Disable the connect
486     *          button and network load button.  <br></td>         
487     *    </tr>
488     *    <tr>
489     *      <td>CONNECTED<br></td>
490     *      <td>Set the connect button to be labled 'Disconnect from Paramics'
491     *          and set the status text to 'Connected'.  Enable the disconnect
492     *          button and network load button.  Set the connected to paramics flag
493     *          to true.<br></td>
494     *    </tr>
495     *    <tr>
496     *      <td>DISCONNECTED<br></td>
497     *      <td>Set the connect button to be labled 'Connect to Paramics'
498     *          and set the status text to 'Disconnected'.  Enable the connect
499     *          button and disable the network load button.  Set the connected
500     *          to paramics flag to false.<br></td>
501     *    </tr>
502     *    <tr>
503     *      <td>SENDING_NETWORK_ID<br></td>
504     *      <td>Set the status text to 'Sending Network ID'.  Disable the
505     *          network load button.<br></td>     
506     *    </tr>
507     *    <tr>
508     *      <td>WARMING<br></td>
509     *      <td>Set the status text to 'Warming'.<br></td>
510     *    </tr>
511     *    <tr>
512     *      <td>LOADING<br></td>
513     *      <td>Set the status text to 'Loading'.<br></td>
514     *    </tr>
515     *    <tr>
516     *      <td>LOADED<br></td>
517     *      <td>Get the paramics network that has been been loaded from
518     *          the model.   Set the status text to 'Network # Loaded'.
519     *          Enable the connect button and disable the network
520     *          load button<br></td>
521     *    </tr>
522     *  </tbody>
523     *</table>
524     *
525     * @param status Paramics status value.
526     */
527    public void setParamicsStatus(PARAMICS_STATUS status) {
528       
529        switch(status) {
530       
531            case UNREACHABLE:           
532                JOptionPane.showMessageDialog(this, 
533                "Unable to connect to Paramics.", 
534                "Communication Error", JOptionPane.ERROR_MESSAGE);
535       
536                connectToParamicsButton.setText("Connect to Paramics");
537                paramicsStatusInfoLabel.setText("Unreachable");
538
539                connectToParamicsButton.setEnabled(true);
540                loadParamicsNetworkButton.setEnabled(false);
541                //networkIDSpinner.setEnabled(false);       
542                connectedToParamics = false;
543               
544            break;
545            case DROPPED:
546           
547                JOptionPane.showMessageDialog(this, 
548                "      Connection to Paramics has been dropped.\n" +
549                "Restart the Paramics Communicator and reconnect.", 
550                "Communication Error", JOptionPane.ERROR_MESSAGE);
551       
552                connectToParamicsButton.setText("Connect to Paramics");
553                paramicsStatusInfoLabel.setText("Dropped");
554               
555                loadParamicsNetworkButton.setEnabled(false);
556                //networkIDSpinner.setEnabled(false);       
557                connectedToParamics = false;
558            break;         
559            case CONNECTING:
560                paramicsStatusInfoLabel.setText("Connecting");
561               
562                connectToParamicsButton.setEnabled(false);
563                loadParamicsNetworkButton.setEnabled(false);
564                //networkIDSpinner.setEnabled(true);   
565            break;
566            case CONNECTED:
567                connectToParamicsButton.setText("Disconnect from Paramics");               
568                paramicsStatusInfoLabel.setText("Connected");
569               
570                connectToParamicsButton.setEnabled(true);
571                loadParamicsNetworkButton.setEnabled(true);
572                //networkIDSpinner.setEnabled(true);   
573                connectedToParamics = true;         
574                break;         
575               
576            case DISCONNECTED:
577                connectToParamicsButton.setText("Connect to Paramics");                             
578                paramicsStatusInfoLabel.setText("Disconnected");
579
580                connectToParamicsButton.setEnabled(true);
581                loadParamicsNetworkButton.setEnabled(false);
582                //networkIDSpinner.setEnabled(false);       
583                connectedToParamics = false;
584                       
585                break; 
586            case SENDING_NETWORK_ID:
587                paramicsStatusInfoLabel.setText("Sending Network ID");
588               
589                loadParamicsNetworkButton.setEnabled(false);
590            break;     
591            case WARMING:
592                paramicsStatusInfoLabel.setText("Warming Up");
593            break;
594            case LOADING:
595                paramicsStatusInfoLabel.setText("Loading Network");
596            break;     
597            case LOADED:           
598                String network = "";
599                try {                   
600                    int networkLoaded = theSimManagerModel.getParamicsNetworkLoaded();
601                   
602                    if(networkLoaded != -1)
603                        network = String.valueOf(networkLoaded);
604                }
605                catch (SimulationException se) {
606                    SimulationExceptionHandler(se);
607                }
608               
609                paramicsStatusInfoLabel.setText("Network " + network + " Loaded");
610
611                connectToParamicsButton.setEnabled(true);
612                loadParamicsNetworkButton.setEnabled(false);
613               
614            break;
615        }   
616    }
617
618    /**
619     * Method is used to convert a String containing a time in format H:MM:SS to a long
620     * value of the number of seconds represented.
621     *
622     * @param time String containing a time in format H:MM:SS
623     * @throws StringIndexOutOfBoundsException if parameter is not in format H:MM:SS
624     * @return long Number of seconds in parameter time 
625     */
626    public static long stringTimeToLong(String time) throws StringIndexOutOfBoundsException{
627        long seconds = 0;   
628       
629        seconds =  ((long) Character.digit(time.charAt(0), 10) * 3600 +
630                        Character.digit(time.charAt(2), 10) * 600 + 
631                        Character.digit(time.charAt(3), 10) * 60 + 
632                        Character.digit(time.charAt(5), 10) * 10 +
633                        Character.digit(time.charAt(6), 10));
634
635             
636        return seconds;
637    }
638   
639    /**
640     * This method is used to disply a message dialog with the received
641     * ScriptException's information.  The possible exceptions are found in the
642     * ScriptException class information.
643     *
644     * @param se The ScriptException to display
645     * @see ScriptException
646     */
647    public void ScriptExceptionHandler(ScriptException se) {
648        JOptionPane.showMessageDialog(this, se.getMessage(), "Script Error", JOptionPane.ERROR_MESSAGE);   
649    }
650
651/**
652     * This method is used to disply a message dialog with the received
653     * SimulationException's information.  The possible exceptions are found in the
654     * SimulationException class information.
655     *
656     * @param se The SimulationException to display
657     * @see SimulationException
658     */
659    public void SimulationExceptionHandler(SimulationException se) {
660        JOptionPane.showMessageDialog(this, se.getMessage(), "Simulation Error", JOptionPane.ERROR_MESSAGE);   
661    }
662   
663
664     
665    /**
666     * Initilize the GUI swing components.
667     */ 
668    private void initComponents() {
669
670        createMenuBar();
671        createTimeAndStatus();
672        createSimulationControl();
673        createParamicsControl();
674        createIncidentManagement();
675        createCMSTrafficDiversion();
676        createAdmin();
677        createEventHistory();   
678
679        addSimulationTab();     
680
681        setMinimumSize(new Dimension(1024, 768));
682        setMaximumSize(new Dimension(1600, 1200));
683        setPreferredSize(new Dimension(1024, 768)); 
684       
685        pack();
686    }
687   
688    /**
689     * Create the menu bar components.
690     */
691    private void createMenuBar() {
692
693        gotoMenuItem = new JMenuItem(new GotoTimeIndexAction(this));   
694        exportMenuItem = new JMenuItem(new ExportAction(this));
695        exitMenuItem = new JMenuItem(new ExitAction(this));
696       
697        fileMenu = new JMenu("File");
698        fileMenu.add(gotoMenuItem);
699        fileMenu.add(exportMenuItem);
700        fileMenu.add(exitMenuItem);
701       
702        simManagerMenuBar = new JMenuBar();
703        simManagerMenuBar.add(fileMenu);
704       
705        javax.swing.JMenu helpMenu = new javax.swing.JMenu("Help");
706        javax.swing.JMenuItem aboutItem = new javax.swing.JMenuItem("About");
707
708        aboutItem.addActionListener(new java.awt.event.ActionListener(){
709            public void actionPerformed(java.awt.event.ActionEvent evt)
710            {
711                String ver = RevisionNumber.getAppVersion();
712                JOptionPane.showMessageDialog(rootPane, "Version: " + ver, "About", JOptionPane.INFORMATION_MESSAGE);
713            }
714        });
715       
716        helpMenu.add(aboutItem);
717        simManagerMenuBar.add(helpMenu);
718       
719        setJMenuBar(simManagerMenuBar);
720    }
721   
722    /**
723     * Create the time and status boxes, buttons, and listeners.
724     */
725    private void createTimeAndStatus() {
726       
727        simulationTime       = new JPanel();
728        simulationClock      = new JPanel();
729        simulationStatus     = new JLabel("Simulation Status");
730        simulationStatusText = new JLabel("No Script");
731        simulationStatusText.setName("simulationStatusText");
732        simulationStatusText.setFont(new Font("Geneva", Font.BOLD, 14));
733       
734        simulationTime.setLayout(new BorderLayout());       
735        simulationClock.setPreferredSize(new Dimension(100, 60));
736       
737        startButton = new JButton(new StartSimulationAction(this));
738       
739        pauseButton  = new JButton(new PauseSimulationAction(this));
740        resetButton = new JButton(new ResetSimulationAction(this));
741        loadScriptButton = new JButton(new LoadScriptAction(this));
742        loadScriptButton.setAlignmentX(Box.CENTER_ALIGNMENT);
743       
744        startButton.setEnabled(false);
745        pauseButton.setEnabled(false);
746        resetButton.setEnabled(false);
747
748        simulationStatusBox     = new Box(BoxLayout.Y_AXIS);       
749        simulationTimeBox       = new Box(BoxLayout.Y_AXIS);
750        simulationClockBox      = new Box(BoxLayout.X_AXIS);
751        simulationTimeButtonBox = new Box(BoxLayout.X_AXIS);
752       
753        simulationTimeButtonBox.add(loadScriptButton);
754        simulationTimeButtonBox.add(startButton);
755        simulationTimeButtonBox.add(pauseButton);
756        simulationTimeButtonBox.add(resetButton);
757//        currentScript = new JLabel(" no script loaded");
758        //currentScript.setAlignmentX(Box.LEFT_ALIGNMENT);
759//        simulationTimeButtonBox.add (currentScript);
760       
761        simulationStatus.setAlignmentX(Box.CENTER_ALIGNMENT);
762        simulationStatusText.setAlignmentX(Box.CENTER_ALIGNMENT);
763       
764        TitledBorder title = BorderFactory.createTitledBorder(
765                BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Status");
766        title.setTitleJustification(TitledBorder.LEFT);
767        simulationStatusBox.setBorder(title);
768       
769        simulationStatusBox.setMaximumSize(new Dimension(140, 60));
770        simulationStatusBox.setAlignmentX(Box.CENTER_ALIGNMENT);                   
771       
772        simulationStatusBox.add(Box.createVerticalGlue());
773        simulationStatusBox.add(simulationStatusText);
774        simulationStatusBox.add(Box.createVerticalGlue());
775       
776        scriptBox = new Box(BoxLayout.Y_AXIS);
777        scriptBox.setAlignmentX(Box.CENTER_ALIGNMENT);
778       
779        scriptBox.add(simulationStatusBox);
780        scriptBox.add(Box.createVerticalStrut(5));
781       
782        simulationClockLabel = new JLabel("0:00:00");
783        simulationClockLabel.setFont(new Font("Geneva", Font.BOLD, 70));
784        simulationClockLabel.setForeground(Color.BLACK);
785        simulationClockLabel.setBackground(Color.BLACK);
786        simulationClockBox.setForeground(Color.BLACK);
787        simulationClockBox.setBackground(Color.BLACK);
788        simulationClockBox.add(simulationClockLabel);
789        simulationClockBox.setAlignmentX(Box.CENTER_ALIGNMENT); 
790        simulationTimeButtonBox.setAlignmentX(Box.CENTER_ALIGNMENT);
791        simulationTimeBox.add(simulationClockBox);
792        simulationTimeBox.add(simulationTimeButtonBox);
793
794        simulationTimeAndStatusBox = Box.createHorizontalBox();
795        simulationTimeAndStatusBox.setAlignmentX(Box.LEFT_ALIGNMENT);
796        simulationTimeAndStatusBox.setMaximumSize(new Dimension(640, 300));
797        simulationTimeAndStatusBox.setPreferredSize(new Dimension(640, 1600));
798        simulationTimeAndStatusBox.add(Box.createHorizontalStrut(5));
799        simulationTimeAndStatusBox.add(simulationTimeBox);
800        simulationTimeAndStatusBox.add(Box.createHorizontalStrut(20));
801        simulationTimeAndStatusBox.add(scriptBox);
802        simulationTimeAndStatusBox.add(Box.createHorizontalStrut(5));
803       
804        //*** Clock for CAD Tab ***//
805        CADClientClockLabel = new JLabel("0:00:00");
806        CADClientClockLabel.setFont(new Font("Geneva", Font.BOLD, 60));
807        CADClientClockLabel.setForeground(Color.BLACK);
808        CADClientClockLabel.setBackground(Color.BLACK);
809        CADClientClockLabel.setAlignmentX(Box.CENTER_ALIGNMENT);       
810       
811    }
812   
813   
814    /**
815     * Create Simulation Control Box
816     */
817    private void createSimulationControl() {
818       
819        simulationControlBox = new Box(BoxLayout.Y_AXIS);
820        simulationControlBox.add(simulationTimeAndStatusBox);
821               
822        CompoundBorder cBorder = BorderFactory.createCompoundBorder(
823            BorderFactory.createTitledBorder(
824                BorderFactory.createRaisedBevelBorder(), "Simulation Control"),
825                BorderFactory.createEmptyBorder(5,5,5,5));
826
827       
828        simulationControlBox.setBorder(cBorder);   
829    }
830   
831    /**
832     * Create ParamicsControl Box
833     */
834    private void createParamicsControl() {
835       
836        paramicsControlBox = new Box(BoxLayout.Y_AXIS);
837        paramicsControlBox.setAlignmentX(Box.LEFT_ALIGNMENT);
838        paramicsControlBox.setMaximumSize(new Dimension(650, 150));     
839        paramicsControlBox.setMinimumSize(new Dimension(250, 95)); 
840        paramicsControlBox.setPreferredSize(new Dimension(380, 95));
841       
842        paramicsStatusBox       = new Box(BoxLayout.X_AXIS);       
843        paramicsStatusLabel     = new JLabel("Status:");
844        paramicsStatusInfoLabel = new JLabel("Unknown");
845        paramicsStatusInfoLabel.setName("paramicsStatusInfoLabel");
846        paramicsStatusBox.add(paramicsStatusLabel);
847        paramicsStatusBox.add(Box.createHorizontalStrut(10));
848        paramicsStatusBox.add(paramicsStatusInfoLabel);
849        paramicsStatusBox.add(Box.createHorizontalGlue());
850       
851        networkIDSpinner = new JSpinner(
852            new SpinnerNumberModel(DEFAULT_NETWORK_ID, 1, MAX_NETWORK_ID, 1));
853        networkIDSpinner.setEnabled(false);     
854        networkIDSpinner.setMaximumSize(new Dimension(60, 30));
855       
856        connectToParamicsButton = new JButton(new ConnectToParamicsAction(this));
857
858        loadParamicsNetworkButton = new JButton(new LoadParamicsNetworkAction(this));
859        loadParamicsNetworkButton.setEnabled(false);
860        loadParamicsNetworkButton.getAction().putValue(
861                LoadParamicsNetworkAction.NETWORK_ID_SPINNER, networkIDSpinner);
862       
863
864        paramicsButtonBox = new Box(BoxLayout.X_AXIS);
865        paramicsButtonBox.add(Box.createHorizontalGlue());
866        paramicsButtonBox.add(connectToParamicsButton);
867        paramicsButtonBox.add(Box.createHorizontalGlue());
868        paramicsButtonBox.add(loadParamicsNetworkButton);
869        paramicsButtonBox.add(Box.createHorizontalStrut(10));
870        paramicsButtonBox.add(networkIDSpinner);
871        paramicsButtonBox.add(Box.createHorizontalGlue());
872
873        paramicsControlBox.add(Box.createVerticalStrut(5));
874        paramicsControlBox.add(paramicsStatusBox);
875        paramicsControlBox.add(Box.createVerticalStrut(5));
876        paramicsControlBox.add(paramicsButtonBox); 
877        paramicsControlBox.add(Box.createVerticalStrut(5));
878               
879        CompoundBorder cBorder = BorderFactory.createCompoundBorder(
880            BorderFactory.createTitledBorder(
881                BorderFactory.createRaisedBevelBorder(), "Paramics Control"),
882                BorderFactory.createEmptyBorder(5,5,5,5));
883
884       
885        paramicsControlBox.setBorder(cBorder);     
886   
887    }   
888   
889    /**
890     * Create the Incident Management portion of the Simulation
891     * Management Box
892     */       
893    private void createIncidentManagement() {
894   
895        createIncidentListTable();
896       
897        incidentTimeModel = new IncidentTimeSpinnerModel();
898        reschedSpinner = new JSpinner(incidentTimeModel);       
899        reschedSpinner.setEnabled(false);
900        reschedSpinner.setMaximumSize(new Dimension(70,20));
901               
902       
903        triggerButton     = new JButton(new TriggerIncidentAction(this));
904        triggerButton.getAction().putValue(
905                TriggerIncidentAction.INCIDENT_LIST_TABLE, incidentListTable);
906       
907        deleteIncButton   = new JButton(new DeleteIncidentAction(this));
908        deleteIncButton.getAction().putValue(
909                DeleteIncidentAction.INCIDENT_LIST_TABLE, incidentListTable);
910   
911        reschedButton     = new JButton(new RescheduleIncidentAction(this));
912        reschedButton.getAction().putValue(
913                RescheduleIncidentAction.INCIDENT_LIST_TABLE, incidentListTable);
914        reschedButton.getAction().putValue(
915                RescheduleIncidentAction.INCIDENT_TIME_MODEL, incidentTimeModel);
916       
917        addIncidentButton = new JButton(new AddIncidentAction(this));
918       
919        timeScheduledLabel  = new JLabel("Time Scheduled: ");   
920                   
921        triggerButton.setEnabled(false);
922        deleteIncButton.setEnabled(false);
923        reschedButton.setEnabled(false);
924
925        Box temp = new Box(BoxLayout.X_AXIS);
926        temp.setAlignmentX(Box.CENTER_ALIGNMENT);       
927        temp.add(timeScheduledLabel);
928        temp.add(Box.createHorizontalStrut(10));
929        temp.add(reschedSpinner);
930        temp.add(Box.createHorizontalStrut(20));
931        temp.add(reschedButton);       
932
933        incidentManagementReSchedBox = new Box(BoxLayout.Y_AXIS);
934        incidentManagementReSchedBox.setAlignmentX(Box.CENTER_ALIGNMENT);       
935        incidentManagementReSchedBox.add(temp);     
936               
937        Box temp2 = new Box(BoxLayout.X_AXIS);
938        temp2.setAlignmentX(Box.CENTER_ALIGNMENT);
939        temp2.add(triggerButton);
940        temp2.add(Box.createHorizontalStrut(20));
941        temp2.add(deleteIncButton);
942        temp2.add(Box.createHorizontalStrut(20));
943        temp2.add(addIncidentButton);                   
944
945        incidentManagementButtonsBox = new Box(BoxLayout.Y_AXIS);
946        incidentManagementButtonsBox.setAlignmentY(Box.CENTER_ALIGNMENT);
947        incidentManagementButtonsBox.add(temp2);
948       
949        incidentManagementActionBox = new Box(BoxLayout.Y_AXIS);
950        incidentManagementActionBox.setMaximumSize(new Dimension(500, 100));
951        incidentManagementActionBox.setAlignmentX(Box.LEFT_ALIGNMENT);
952        incidentManagementActionBox.add(incidentManagementReSchedBox);     
953        incidentManagementActionBox.add(Box.createVerticalStrut(10));       
954        incidentManagementActionBox.add(incidentManagementButtonsBox);     
955
956        incidentManagementBox = new Box(BoxLayout.Y_AXIS);
957        incidentManagementBox.setAlignmentX(Box.LEFT_ALIGNMENT);
958        incidentManagementBox.setMaximumSize(new Dimension(650, 500));     
959        incidentManagementBox.setMinimumSize(new Dimension(250, 240)); 
960        incidentManagementBox.setPreferredSize(new Dimension(380, 240));
961        incidentManagementBox.add(Box.createVerticalStrut(5));
962        incidentManagementBox.add(incidentListPane);       
963        incidentManagementBox.add(Box.createVerticalStrut(10));     
964        incidentManagementBox.add(incidentManagementActionBox);         
965        incidentManagementBox.add(Box.createVerticalStrut(5));
966       
967        CompoundBorder cBorder = BorderFactory.createCompoundBorder(
968            BorderFactory.createTitledBorder(
969                BorderFactory.createRaisedBevelBorder(), "Incident Management"),
970                BorderFactory.createEmptyBorder(5,5,5,5));
971
972       
973        incidentManagementBox.setBorder(cBorder);       
974   
975    }
976   
977    private void createIncidentListTable() {
978   
979        incidentListTableModel = new IncidentListTableModel();   
980        incidentListTableModel.addTableModelListener(new TableModelListener() {
981            public void tableChanged(TableModelEvent arg0) {
982
983                boolean incidentToTrigger = false;
984               
985                for(int i = 0; i < incidentListTableModel.getRowCount(); i++) {
986                   
987                    incidentToTrigger |= (((Long)incidentListTableModel.
988                            getValueAt(i, INCIDENT_LIST_COLUMNS.SCHEDULED_COL.colNum)) != -1); 
989                }                   
990
991                triggerButton.setEnabled(incidentToTrigger);
992                deleteIncButton.setEnabled(incidentToTrigger);
993                reschedButton.setEnabled(incidentToTrigger);
994                reschedSpinner.setEnabled(incidentToTrigger);           
995               
996            }
997        });
998           
999        incidentListTable = new JTable(incidentListTableModel);     
1000        incidentListTable.getTableHeader().setReorderingAllowed(false); 
1001        incidentListTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
1002        incidentListTable.setDragEnabled(false);     
1003               
1004        for(int c = 0; c < incidentListTable.getColumnCount(); c++) {
1005            incidentListTable.getColumnModel().getColumn(c).setMinWidth(
1006                    incidentListTableModel.getColumnMinWidth(c));
1007            incidentListTable.getColumnModel().getColumn(c).setMaxWidth(
1008                    incidentListTableModel.getColumnMaxWidth(c));
1009            incidentListTable.getColumnModel().getColumn(c).setPreferredWidth(
1010                    incidentListTableModel.getColumnPrefWidth(c));
1011            incidentListTable.getColumnModel().getColumn(c).setResizable(true);
1012           
1013            if(c == INCIDENT_LIST_COLUMNS.SCHEDULED_COL.colNum)
1014                incidentListTable.getColumnModel().getColumn(c).setCellRenderer(
1015                        new IncidentTimeCellRenderer());
1016               
1017        }
1018
1019        incidentListPane = new JScrollPane();
1020        incidentListPane.setAlignmentX(Box.LEFT_ALIGNMENT);
1021        incidentListPane.setMaximumSize(new Dimension(650, 400));       
1022        incidentListPane.setMinimumSize(new Dimension(200, 100));   
1023        incidentListPane.setPreferredSize(new Dimension(380, 100));
1024        incidentListPane.setViewportView(incidentListTable);
1025       
1026        incidentListTable.addMouseListener(new MouseListener() {
1027            public void mouseClicked(MouseEvent e) {}
1028            public void mouseEntered(MouseEvent e) {}           
1029            public void mouseExited(MouseEvent e) {}           
1030            public void mousePressed(MouseEvent e) {}           
1031            public void mouseReleased(MouseEvent e)  {
1032                long incTime = (Long)incidentListTable.getValueAt(incidentListTable.getSelectedRow(), 
1033                        INCIDENT_LIST_COLUMNS.SCHEDULED_COL.colNum);
1034                if(incTime != -1) {
1035                    incidentTimeModel.setValue(incTime);
1036                    triggerButton.setEnabled(true);
1037                    deleteIncButton.setEnabled(true);
1038                    reschedButton.setEnabled(true);
1039                    reschedSpinner.setEnabled(true);
1040                }
1041                else {
1042                    triggerButton.setEnabled(false);
1043                    deleteIncButton.setEnabled(false);
1044                    reschedButton.setEnabled(false);
1045                    reschedSpinner.setEnabled(false);       
1046                }
1047               
1048            }           
1049        });
1050    }
1051
1052    /**
1053     * Create the cms traffic diversion box.
1054     */   
1055    private void createCMSTrafficDiversion() {
1056   
1057        cmsTrafficDiversionBox = new Box(BoxLayout.Y_AXIS);
1058        cmsTrafficDiversionBox.setAlignmentX(Box.LEFT_ALIGNMENT);
1059        cmsTrafficDiversionBox.setMaximumSize(new Dimension(650, 350));     
1060        cmsTrafficDiversionBox.setMinimumSize(new Dimension(200, 145)); 
1061        cmsTrafficDiversionBox.setPreferredSize(new Dimension(380, 250));   
1062       
1063        CompoundBorder cBorder = BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(BorderFactory.createRaisedBevelBorder(), "CMS Diversion Management"),
1064                                                                    BorderFactory.createEmptyBorder(5,5,5,5));
1065
1066        cmsTrafficDiversionBox.setBorder(cBorder);                 
1067                       
1068        appliedDiversionTableModel = new AppliedDiversionTableModel();
1069        appliedDiversionTable = new JTable(appliedDiversionTableModel);
1070        appliedDiversionTable.getTableHeader().setReorderingAllowed(false);
1071        appliedDiversionTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
1072        appliedDiversionTable.setCellSelectionEnabled(false);
1073        appliedDiversionTable.setRowSelectionAllowed(true);
1074        appliedDiversionTable.addMouseListener(new MouseListener() {
1075            public void mouseClicked(MouseEvent evt)  {
1076                if(evt.getClickCount() >= 2) {
1077                    ((ApplyDiversionAction)divertButton.getAction()).showDiversionDialog(
1078                            (String)appliedDiversionTableModel.getValueAt(
1079                                    appliedDiversionTable.getSelectedRow(),
1080                                    APPLIED_DIV_COLUMNS.CMS_ID_COL.colNum));
1081                }
1082            };
1083            public void mouseEntered(MouseEvent arg0)  {};
1084            public void mouseExited(MouseEvent arg0)   {};
1085            public void mousePressed(MouseEvent arg0)  {};
1086            public void mouseReleased(MouseEvent arg0) {};         
1087        });
1088       
1089        for(int c = 0; c < appliedDiversionTable.getColumnCount(); c++) {
1090            appliedDiversionTable.getColumnModel().getColumn(c).setMinWidth(
1091                    appliedDiversionTableModel.getColumnMinWidth(c));
1092            appliedDiversionTable.getColumnModel().getColumn(c).setMaxWidth(
1093                    appliedDiversionTableModel.getColumnMaxWidth(c));
1094            appliedDiversionTable.getColumnModel().getColumn(c).setPreferredWidth(
1095                    appliedDiversionTableModel.getColumnPrefWidth(c));
1096            appliedDiversionTable.getColumnModel().getColumn(c).setResizable(false);
1097           
1098            if(c == APPLIED_DIV_COLUMNS.APPLIED_COL.colNum) {
1099                appliedDiversionTable.getColumnModel().getColumn(c).setCellRenderer(
1100                        new IncidentTimeCellRenderer());
1101            }       
1102        }       
1103
1104        appliedDiversionPane = new JScrollPane();
1105        appliedDiversionPane.setAlignmentX(Box.CENTER_ALIGNMENT);       
1106        appliedDiversionPane.setMaximumSize(new Dimension(650, 800));       
1107        appliedDiversionPane.setMinimumSize(new Dimension(200, 75));   
1108        appliedDiversionPane.setPreferredSize(new Dimension(380,100));             
1109        appliedDiversionPane.setViewportView(appliedDiversionTable);   
1110       
1111        cmsIDComboBox = new JComboBox();
1112        cmsIDComboBox.setMaximumSize(new Dimension(40, 25));
1113       
1114        divertButton = new JButton(new ApplyDiversionAction(this));
1115        divertButton.getAction().putValue(
1116                ApplyDiversionAction.CMS_ID_COMBO_BOX, cmsIDComboBox);
1117               
1118        appliedDiversionButtonBox = new Box(BoxLayout.X_AXIS);
1119        appliedDiversionButtonBox.setAlignmentX(Box.CENTER_ALIGNMENT);
1120        appliedDiversionButtonBox.setMaximumSize(new Dimension(1010, 40));
1121        appliedDiversionButtonBox.add(Box.createGlue());
1122        appliedDiversionButtonBox.add(new JLabel("CMS ID:  "));
1123        appliedDiversionButtonBox.add(cmsIDComboBox);
1124        appliedDiversionButtonBox.add(Box.createHorizontalStrut(15));
1125        appliedDiversionButtonBox.add(divertButton);   
1126        appliedDiversionButtonBox.add(Box.createGlue());
1127
1128        cmsTrafficDiversionBox.add(Box.createVerticalStrut(5));
1129        cmsTrafficDiversionBox.add(appliedDiversionPane);       
1130        cmsTrafficDiversionBox.add(Box.createVerticalStrut(5));
1131        cmsTrafficDiversionBox.add(appliedDiversionButtonBox);     
1132        cmsTrafficDiversionBox.add(Box.createVerticalStrut(5));             
1133   
1134    }
1135       
1136    /**
1137     * Create the main admin box.
1138     */           
1139    private void createAdmin() {       
1140       
1141        adminInteractionBox = new Box(BoxLayout.Y_AXIS);
1142        adminInteractionBox.setAlignmentX(Box.LEFT_ALIGNMENT); 
1143        adminInteractionBox.setMinimumSize(new Dimension(425, 740));   
1144        adminInteractionBox.setPreferredSize(new Dimension(425, 740)); 
1145        adminInteractionBox.setMaximumSize(new Dimension(625, 1975));       
1146       
1147        adminInteractionBox.add(Box.createVerticalStrut(10));       
1148        adminInteractionBox.add(simulationControlBox);
1149        adminInteractionBox.add(Box.createVerticalStrut(10));   
1150        adminInteractionBox.add(paramicsControlBox);
1151        adminInteractionBox.add(Box.createVerticalStrut(10));   
1152        adminInteractionBox.add(incidentManagementBox);
1153        adminInteractionBox.add(Box.createVerticalStrut(10));   
1154        adminInteractionBox.add(cmsTrafficDiversionBox);       
1155        adminInteractionBox.add(Box.createVerticalStrut(10));   
1156       
1157    }
1158
1159    /**
1160     * Create the event history box.
1161     */   
1162    private void createEventHistory() {
1163   
1164        eventHistoryPane = new JTabbedPane();
1165       
1166        eventHistoryBox = new Box(BoxLayout.Y_AXIS);
1167        eventHistoryBox.setAlignmentX(Box.CENTER_ALIGNMENT);
1168        eventHistoryBox.setMinimumSize(new Dimension(525, 700));   
1169        eventHistoryBox.setPreferredSize(new Dimension(525, 700));
1170        eventHistoryBox.setMaximumSize(new Dimension(925, 1975));   
1171       
1172        eventHistoryBox.add(eventHistoryPane);
1173        eventHistoryBox.add(Box.createVerticalStrut(10));   
1174       
1175        CompoundBorder cBorder = BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(BorderFactory.createRaisedBevelBorder(), "Event History"),
1176                                                                    BorderFactory.createEmptyBorder(5,5,5,5));
1177       
1178        eventHistoryBox.setBorder(cBorder);     
1179       
1180    }
1181   
1182
1183    /**
1184     * Create the administrator tab
1185     */           
1186    private void addSimulationTab() {
1187       
1188    simulationRightSideBox = new Box(BoxLayout.Y_AXIS);             
1189        simulationRightSideBox.add(Box.createVerticalStrut(10));
1190        simulationRightSideBox.add(eventHistoryBox);
1191        simulationRightSideBox.add(Box.createVerticalStrut(10));   
1192               
1193        simulationBox = new Box(BoxLayout.X_AXIS);     
1194        simulationBox.add(Box.createHorizontalStrut(20));
1195        simulationBox.add(adminInteractionBox);
1196        simulationBox.add(Box.createHorizontalStrut(20));   
1197        simulationBox.add(simulationRightSideBox);
1198        simulationBox.add(Box.createHorizontalStrut(20));
1199               
1200        getContentPane().add(simulationBox);
1201    }   
1202   
1203    private JTabbedPane eventHistoryPane;
1204   
1205    private JScrollPane incidentListPane; 
1206    private JScrollPane appliedDiversionPane;
1207
1208    private JTable incidentListTable;
1209    private JTable appliedDiversionTable;
1210   
1211    private JPanel simulationTime;
1212    private JPanel simulationClock;
1213           
1214    private JLabel paramicsStatusLabel;
1215    private JLabel paramicsStatusInfoLabel;
1216    private JLabel simulationStatus;
1217    private JLabel simulationClockLabel;
1218    private JLabel simulationStatusText;
1219    private JLabel timeScheduledLabel;
1220    private JLabel CADClientClockLabel;
1221    private JLabel currentScript;
1222    private Box adminInteractionBox;   
1223    private Box simulationRightSideBox;
1224    private Box simulationBox;         
1225    private Box appliedDiversionButtonBox; 
1226    private Box cmsTrafficDiversionBox;     
1227    private Box eventHistoryBox;   
1228    private Box incidentManagementActionBox;
1229    private Box incidentManagementBox; 
1230    private Box incidentManagementButtonsBox;
1231    private Box incidentManagementReSchedBox;
1232    private Box scriptBox;     
1233    private Box paramicsButtonBox;
1234    private Box paramicsControlBox; 
1235    private Box paramicsStatusBox;
1236    private Box simulationTimeAndStatusBox;
1237    private Box simulationStatusBox;       
1238    private Box simulationTimeBox;
1239    private Box simulationClockBox;
1240    private Box simulationControlBox;
1241    private Box simulationTimeButtonBox;
1242
1243    private IncidentTimeSpinnerModel incidentTimeModel;
1244    private JSpinner reschedSpinner;
1245    private JSpinner networkIDSpinner;
1246   
1247    private JButton addIncidentButton;         
1248    private JButton deleteIncButton;
1249    private JButton loadScriptButton;
1250    private JButton divertButton;
1251    private JButton reschedButton;
1252    private JButton resetButton;
1253    private JButton startButton;
1254    private JButton pauseButton;
1255    private JButton triggerButton; 
1256    private JButton connectToParamicsButton;
1257    private JButton loadParamicsNetworkButton;
1258   
1259    private JComboBox cmsIDComboBox;                   
1260       
1261    private JMenuBar simManagerMenuBar;
1262    private JMenu fileMenu;
1263    private JMenuItem gotoMenuItem;
1264    private JMenuItem exportMenuItem;
1265    private JMenuItem exitMenuItem;
1266   
1267}
1268
Note: See TracBrowser for help on using the repository browser.