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

Revision 47, 51.4 KB checked in by jdalbey, 10 years ago (diff)

Merge 305 modifications into trunk.

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