source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/gui/ScriptOverviewWindow.java @ 144

Revision 144, 78.1 KB checked in by jdalbey, 7 years ago (diff)

multi-file commit: Add color attribute, Add ScriptOverviewWindow?

Line 
1package scriptbuilder.gui;
2
3import java.awt.Adjustable;
4import java.awt.Color;
5import java.awt.event.AdjustmentEvent;
6import java.awt.event.AdjustmentListener;
7import java.awt.event.KeyEvent;
8import java.awt.event.KeyListener;
9import java.io.File;
10import java.io.IOException;
11import java.util.Observable;
12import java.util.Observer;
13import java.util.Properties;
14import java.util.Random;
15import java.util.logging.Level;
16import java.util.logging.Logger;
17import javax.swing.DefaultListModel;
18import javax.swing.JFileChooser;
19import javax.swing.JOptionPane;
20import javax.swing.UIManager;
21import javax.swing.UnsupportedLookAndFeelException;
22import scriptbuilder.gui.drawers.RangeSlider;
23import scriptbuilder.structures.ScriptEvent;
24import scriptbuilder.structures.ScriptEvent.ScriptEventType;
25import scriptbuilder.structures.ScriptIncident;
26import scriptbuilder.structures.ScriptIncident.IncidentFocusedEvent;
27import scriptbuilder.structures.ScriptIncident.SliceChangedEvent;
28import scriptbuilder.structures.SimulationScript;
29import scriptbuilder.structures.TimeSlice;
30import scriptbuilder.structures.events.I_ScriptEvent;
31
32/**
33 * Overview window shows high level view of all incidents in the script.
34 *
35 * @author Greg Eddington
36 * @author Bryan McGuffin
37 * @author jdalbey
38 */
39public class ScriptOverviewWindow extends javax.swing.JFrame implements Observer
40{
41
42    /**
43     * The script model.
44     */
45    private SimulationScript script;
46    /**
47     * The current type of selected event.
48     */
49    public ScriptEventType currentEventType;
50    /**
51     * True if we are currently editing an incident.
52     */
53    private boolean editingIncident;
54    /**
55     * Index of the previous incident.
56     */
57    private int oldIncidentIndex;
58
59    /**
60     * Get the script currently in use.
61     *
62     * @return the script model object
63     */
64    public SimulationScript getScript()
65    {
66        return script;
67    }
68
69    /**
70     * Listener for the scroll pane.
71     */
72    class MyAdjustmentListener implements AdjustmentListener
73    {
74
75        /**
76         * If the incident timeline is scrolled horizontally, the timestamp
77         * panel is updated to reflect it.
78         *
79         * @param evt the adjustment event
80         */
81        @Override
82        public void adjustmentValueChanged(AdjustmentEvent evt)
83        {
84            if (evt.getAdjustable().getOrientation() == Adjustable.HORIZONTAL)
85            {
86                timeStampScrollPane.getHorizontalScrollBar()
87                        .setValue(timelinesScrollPane.getHorizontalScrollBar().getValue());
88            }
89            else
90            {
91                // Event from vertical scrollbar
92            }
93
94            repaint();
95        }
96    }
97
98    /**
99     * Listener for key presses. Used for hotkeys for different event types.
100     */
101    private class TimelineKeyListener implements KeyListener
102    {
103
104        /**
105         * If a hotkey is pressed, select that type of event.
106         *
107         * @param e the key event
108         */
109        @Override
110        public void keyPressed(KeyEvent e)
111        {
112            repaint();
113        }
114
115        /**
116         * Take no action upon key release.
117         *
118         * @param e the key event
119         */
120        @Override
121        public void keyReleased(KeyEvent e)
122        {
123        }
124
125        /**
126         * Take no action upon key release.
127         *
128         * @param e the key event
129         */
130        @Override
131        public void keyTyped(KeyEvent e)
132        {
133        }
134    }
135
136    /**
137     * Constructor. Prep new script model, initialize the GUI, and add listeners
138     * for all buttons.
139     */
140    public ScriptOverviewWindow()
141    {
142        script = new SimulationScript();
143        script.addObserver(this);
144        initComponents();
145        this.update(null, script);
146
147        // Hack to refresh the zoom
148        /*
149         zoomSlider.setValue(zoomSlider.getValue() - 1);
150         zoomSlider.setValue(zoomSlider.getValue() + 1);
151         */
152        // Set listener for scroll pane
153        AdjustmentListener listener = new MyAdjustmentListener();
154        timelinesScrollPane.getHorizontalScrollBar().addAdjustmentListener(listener);
155        timelinesScrollPane.getVerticalScrollBar().addAdjustmentListener(listener);
156    }
157
158    /**
159     * Update the GUI to reflect the model. If the script changed, update all
160     * the incident panels. If a timeslice changed, add any new events to the
161     * model. If an incident gained focus, update the incident info screen to
162     * display its details.
163     *
164     * @param o The observed object
165     * @param arg Either the script model or an incident event, depending on who
166     * called this update
167     */
168    @Override
169    public void update(Observable o, Object arg)
170    {
171        if (arg instanceof SimulationScript)
172        {
173            script = (SimulationScript) arg;
174
175            if (script.incidents.size() != 10)
176            {
177                return;
178            }
179
180            timelineTickPanel.update(script);
181            timeStampPanel.update(script);
182
183            incidentTimelinePanel1.timelinePanelUpdate(script.incidents.get(0));
184
185
186            incidentNumberPanel1.update(script.incidents.get(0));
187
188
189            /**
190             * DefaultComboBoxModel model = new DefaultComboBoxModel(); for
191             * (ScriptIncident i : script.incidents) { if (i != null)
192             * model.addElement(i); } gotoIncident.setModel(model);*
193             */
194            this.setPreferredSize(this.getSize());
195            pack();
196        }
197        else if (arg instanceof SliceChangedEvent)
198        {
199            TimeSlice slice = ((SliceChangedEvent) arg).slice;
200
201            DefaultListModel model = new DefaultListModel();
202            for (I_ScriptEvent e : slice.events)
203            {
204                model.addElement(e);
205            }
206        }
207        else if (arg instanceof IncidentFocusedEvent)
208        {
209            ScriptIncident i = ((IncidentFocusedEvent) arg).incident;
210
211            //gotoIncident.setSelectedItem(i);
212        }
213
214        zoomSlider.setMinimum(((timelineTickPanel.getVisibleRect().width - 20)
215                * ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION)
216                / Math.max(script.absoluteLength(), ScriptBuilderGuiConstants.TICK_TIMELINE_SMALLEST_LENGTH));
217        zoomSlider.setMaximum(zoomSlider.getMinimum() + 20);
218    }
219
220    /**
221     * This method is called from within the constructor to initialize the form.
222     * WARNING: Do NOT modify this code. The content of this method is always
223     * regenerated by the Form Editor.
224     */
225    @SuppressWarnings("unchecked")
226    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
227    private void initComponents() {
228
229        incidentPopupMenu = new javax.swing.JPopupMenu();
230        popupDeleteIncident = new javax.swing.JMenuItem();
231        eventPopupMenu = new javax.swing.JPopupMenu();
232        cadEvent = new javax.swing.JMenuItem();
233        jMenuItem2 = new javax.swing.JMenuItem();
234        radioEvent = new javax.swing.JMenuItem();
235        jMenuItem4 = new javax.swing.JMenuItem();
236        jMenuItem5 = new javax.swing.JMenuItem();
237        jMenuItem6 = new javax.swing.JMenuItem();
238        cadEventFrame = new javax.swing.JFrame();
239        jLabel5 = new javax.swing.JLabel();
240        radioEventFrame = new javax.swing.JFrame();
241        radioTypeLabel = new javax.swing.JLabel();
242        jLabel7 = new javax.swing.JLabel();
243        radioTypeComboBox = new javax.swing.JComboBox();
244        radioMessageScrollPane = new javax.swing.JScrollPane();
245        radioMessage = new javax.swing.JTextArea();
246        okButton = new javax.swing.JButton();
247        cancelButton = new javax.swing.JButton();
248        eventListPopupMenu = new javax.swing.JPopupMenu();
249        editEventList = new javax.swing.JMenuItem();
250        deleteEventList = new javax.swing.JMenuItem();
251        incidentFrame = new javax.swing.JFrame();
252        jLabel6 = new javax.swing.JLabel();
253        jLabel8 = new javax.swing.JLabel();
254        jLabel9 = new javax.swing.JLabel();
255        jLabel10 = new javax.swing.JLabel();
256        jScrollPane1 = new javax.swing.JScrollPane();
257        addIncidentDescription = new javax.swing.JTextArea();
258        incidentOkButton = new javax.swing.JButton();
259        incidentCancelButton = new javax.swing.JButton();
260        addIncidentNumber = new javax.swing.JSpinner();
261        addIncidentName = new javax.swing.JTextField();
262        jLabel11 = new javax.swing.JLabel();
263        addIncidentLength = new javax.swing.JSpinner();
264        jLabel12 = new javax.swing.JLabel();
265        addIncidentStart = new javax.swing.JSpinner();
266        jButton3 = new javax.swing.JButton();
267        incidentColorField = new javax.swing.JTextField();
268        addNoiseFrame = new javax.swing.JFrame();
269        jLabel13 = new javax.swing.JLabel();
270        jSlider1 = new javax.swing.JSlider();
271        jSlider2 = new javax.swing.JSlider();
272        jLabel14 = new javax.swing.JLabel();
273        jSlider3 = new javax.swing.JSlider();
274        jLabel15 = new javax.swing.JLabel();
275        jTextArea1 = new javax.swing.JTextArea();
276        jSlider4 = new javax.swing.JSlider();
277        jLabel16 = new javax.swing.JLabel();
278        jSlider5 = new javax.swing.JSlider();
279        jLabel17 = new javax.swing.JLabel();
280        jButton1 = new javax.swing.JButton();
281        jButton2 = new javax.swing.JButton();
282        jLabel20 = new javax.swing.JLabel();
283        jLabel21 = new javax.swing.JLabel();
284        incidentColorChooser = new javax.swing.JColorChooser();
285        timelinesScrollPane = new javax.swing.JScrollPane();
286        timelineTickPanel = new scriptbuilder.gui.panels.TimelineTickPanel();
287        incidentTimelinePanel1 = new scriptbuilder.gui.panels.IncidentTimelinePanel();
288        incidentNumberPanel1 = new scriptbuilder.gui.panels.IncidentNumberPanel();
289        zoomSlider = new javax.swing.JSlider();
290        zoomInIcon = new javax.swing.JLabel();
291        zoomOutIcon = new javax.swing.JLabel();
292        timeStampScrollPane = new javax.swing.JScrollPane();
293        timeStampPanel = new scriptbuilder.gui.panels.TimeStampPanel();
294        scriptBuilderMenuBar = new javax.swing.JMenuBar();
295        fileMenu = new javax.swing.JMenu();
296        fileNew = new javax.swing.JMenuItem();
297        jSeparator1 = new javax.swing.JPopupMenu.Separator();
298        fileOpen = new javax.swing.JMenuItem();
299        jSeparator2 = new javax.swing.JPopupMenu.Separator();
300        fileSave = new javax.swing.JMenuItem();
301        fileSaveAs = new javax.swing.JMenuItem();
302        generateMenu = new javax.swing.JMenu();
303        generateNotebooks = new javax.swing.JMenuItem();
304        jMenuItem3 = new javax.swing.JMenuItem();
305        generateScorecards = new javax.swing.JMenuItem();
306        generateOrganizationChart = new javax.swing.JMenuItem();
307        jSeparator3 = new javax.swing.JPopupMenu.Separator();
308        generateProjectRequirements = new javax.swing.JMenuItem();
309        incidentMenu = new javax.swing.JMenu();
310        newIncident = new javax.swing.JMenuItem();
311        editIncident = new javax.swing.JMenuItem();
312        incidentDetails = new javax.swing.JMenuItem();
313        jSeparator4 = new javax.swing.JPopupMenu.Separator();
314        saveIncident = new javax.swing.JMenuItem();
315        loadIncident = new javax.swing.JMenuItem();
316        generateNoiseMenu = new javax.swing.JMenu();
317        generateNoiseOption = new javax.swing.JMenuItem();
318        helpMenu = new javax.swing.JMenu();
319        helpTutorial = new javax.swing.JMenuItem();
320        helpAbout = new javax.swing.JMenuItem();
321
322        popupDeleteIncident.setText("Delete Incident...");
323        incidentPopupMenu.add(popupDeleteIncident);
324
325        cadEvent.setText("CAD Event");
326        cadEvent.addMouseListener(new java.awt.event.MouseAdapter() {
327            public void mousePressed(java.awt.event.MouseEvent evt) {
328                cadEventMousePressed(evt);
329            }
330            public void mouseReleased(java.awt.event.MouseEvent evt) {
331                cadEventMouseReleased(evt);
332            }
333        });
334        eventPopupMenu.add(cadEvent);
335
336        jMenuItem2.setText("Paramics Event");
337        eventPopupMenu.add(jMenuItem2);
338
339        radioEvent.setText("Radio Event");
340        radioEvent.addMouseListener(new java.awt.event.MouseAdapter() {
341            public void mousePressed(java.awt.event.MouseEvent evt) {
342                radioEventMousePressed(evt);
343            }
344        });
345        eventPopupMenu.add(radioEvent);
346
347        jMenuItem4.setText("Telephone Event");
348        eventPopupMenu.add(jMenuItem4);
349
350        jMenuItem5.setText("Video Event");
351        eventPopupMenu.add(jMenuItem5);
352
353        jMenuItem6.setText("Evaluation Event");
354        eventPopupMenu.add(jMenuItem6);
355
356        cadEventFrame.setMinimumSize(new java.awt.Dimension(400, 300));
357
358        jLabel5.setText("CAD Entry");
359
360        javax.swing.GroupLayout cadEventFrameLayout = new javax.swing.GroupLayout(cadEventFrame.getContentPane());
361        cadEventFrame.getContentPane().setLayout(cadEventFrameLayout);
362        cadEventFrameLayout.setHorizontalGroup(
363            cadEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
364            .addGroup(cadEventFrameLayout.createSequentialGroup()
365                .addContainerGap()
366                .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
367                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
368        );
369        cadEventFrameLayout.setVerticalGroup(
370            cadEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
371            .addGroup(cadEventFrameLayout.createSequentialGroup()
372                .addContainerGap()
373                .addComponent(jLabel5)
374                .addContainerGap(1357, Short.MAX_VALUE))
375        );
376
377        radioEventFrame.setTitle("Add Radio Event");
378        radioEventFrame.setMinimumSize(new java.awt.Dimension(400, 300));
379
380        radioTypeLabel.setText("Radio Type:");
381
382        jLabel7.setText("Radio Message:");
383
384        radioTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "TMT", "Maintanence" }));
385
386        radioMessageScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
387
388        radioMessage.setColumns(20);
389        radioMessage.setLineWrap(true);
390        radioMessage.setRows(5);
391        radioMessage.setWrapStyleWord(true);
392        radioMessageScrollPane.setViewportView(radioMessage);
393
394        okButton.setText("OK");
395        okButton.addActionListener(new java.awt.event.ActionListener() {
396            public void actionPerformed(java.awt.event.ActionEvent evt) {
397                okButtonActionPerformed(evt);
398            }
399        });
400
401        cancelButton.setText("Cancel");
402        cancelButton.addActionListener(new java.awt.event.ActionListener() {
403            public void actionPerformed(java.awt.event.ActionEvent evt) {
404                cancelButtonActionPerformed(evt);
405            }
406        });
407
408        javax.swing.GroupLayout radioEventFrameLayout = new javax.swing.GroupLayout(radioEventFrame.getContentPane());
409        radioEventFrame.getContentPane().setLayout(radioEventFrameLayout);
410        radioEventFrameLayout.setHorizontalGroup(
411            radioEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
412            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, radioEventFrameLayout.createSequentialGroup()
413                .addContainerGap()
414                .addGroup(radioEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
415                    .addComponent(radioMessageScrollPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
416                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, radioEventFrameLayout.createSequentialGroup()
417                        .addComponent(radioTypeLabel)
418                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
419                        .addComponent(radioTypeComboBox, 0, 312, Short.MAX_VALUE))
420                    .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING)
421                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, radioEventFrameLayout.createSequentialGroup()
422                        .addComponent(cancelButton)
423                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 246, Short.MAX_VALUE)
424                        .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)))
425                .addContainerGap())
426        );
427        radioEventFrameLayout.setVerticalGroup(
428            radioEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
429            .addGroup(radioEventFrameLayout.createSequentialGroup()
430                .addContainerGap()
431                .addGroup(radioEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
432                    .addComponent(radioTypeLabel)
433                    .addComponent(radioTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
434                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
435                .addComponent(jLabel7)
436                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
437                .addComponent(radioMessageScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE)
438                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
439                .addGroup(radioEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
440                    .addComponent(okButton)
441                    .addComponent(cancelButton))
442                .addContainerGap())
443        );
444
445        editEventList.setText("Edit...");
446        editEventList.addActionListener(new java.awt.event.ActionListener() {
447            public void actionPerformed(java.awt.event.ActionEvent evt) {
448                editEventListActionPerformed(evt);
449            }
450        });
451        eventListPopupMenu.add(editEventList);
452
453        deleteEventList.setText("Delete...");
454        eventListPopupMenu.add(deleteEventList);
455
456        incidentFrame.setTitle("Incident");
457        incidentFrame.setMinimumSize(new java.awt.Dimension(400, 400));
458
459        jLabel6.setText("Incident Number: ");
460
461        jLabel8.setText("Incident Name:");
462
463        jLabel9.setText("Incident Color: ");
464
465        jLabel10.setText("Incident Description:");
466
467        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
468        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
469
470        addIncidentDescription.setColumns(20);
471        addIncidentDescription.setLineWrap(true);
472        addIncidentDescription.setRows(5);
473        addIncidentDescription.setWrapStyleWord(true);
474        jScrollPane1.setViewportView(addIncidentDescription);
475
476        incidentOkButton.setText("OK");
477        incidentOkButton.addActionListener(new java.awt.event.ActionListener() {
478            public void actionPerformed(java.awt.event.ActionEvent evt) {
479                incidentOkButtonActionPerformed(evt);
480            }
481        });
482
483        incidentCancelButton.setText("Cancel");
484        incidentCancelButton.addActionListener(new java.awt.event.ActionListener() {
485            public void actionPerformed(java.awt.event.ActionEvent evt) {
486                incidentCancelButtonActionPerformed(evt);
487            }
488        });
489
490        addIncidentNumber.setModel(new javax.swing.SpinnerNumberModel(101, 101, null, 1));
491
492        jLabel11.setText("Incident Length in Minutes: ");
493
494        addIncidentLength.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
495
496        jLabel12.setText("Incident Start Time in Minutes:");
497
498        addIncidentStart.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
499
500        jButton3.setText("Choose...");
501        jButton3.addActionListener(new java.awt.event.ActionListener() {
502            public void actionPerformed(java.awt.event.ActionEvent evt) {
503                jButton3ActionPerformed(evt);
504            }
505        });
506
507        incidentColorField.setEditable(false);
508        incidentColorField.setBackground(new java.awt.Color(0, 0, 0));
509
510        javax.swing.GroupLayout incidentFrameLayout = new javax.swing.GroupLayout(incidentFrame.getContentPane());
511        incidentFrame.getContentPane().setLayout(incidentFrameLayout);
512        incidentFrameLayout.setHorizontalGroup(
513            incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
514            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, incidentFrameLayout.createSequentialGroup()
515                .addContainerGap()
516                .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
517                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)
518                    .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.LEADING)
519                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, incidentFrameLayout.createSequentialGroup()
520                        .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
521                            .addComponent(jLabel6)
522                            .addComponent(jLabel8)
523                            .addComponent(jLabel9))
524                        .addGap(18, 18, 18)
525                        .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
526                            .addComponent(addIncidentName, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE)
527                            .addComponent(addIncidentNumber, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE)
528                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, incidentFrameLayout.createSequentialGroup()
529                                .addComponent(incidentColorField, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
530                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
531                                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))))
532                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, incidentFrameLayout.createSequentialGroup()
533                        .addComponent(incidentCancelButton)
534                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 188, Short.MAX_VALUE)
535                        .addComponent(incidentOkButton, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))
536                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, incidentFrameLayout.createSequentialGroup()
537                        .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
538                            .addComponent(jLabel12)
539                            .addComponent(jLabel11))
540                        .addGap(18, 18, 18)
541                        .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
542                            .addComponent(addIncidentStart, javax.swing.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE)
543                            .addComponent(addIncidentLength, javax.swing.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE))))
544                .addContainerGap())
545        );
546        incidentFrameLayout.setVerticalGroup(
547            incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
548            .addGroup(incidentFrameLayout.createSequentialGroup()
549                .addContainerGap()
550                .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
551                    .addComponent(jLabel6)
552                    .addComponent(addIncidentNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
553                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
554                .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
555                    .addComponent(jLabel8)
556                    .addComponent(addIncidentName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
557                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
558                .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
559                    .addComponent(jLabel9)
560                    .addComponent(jButton3)
561                    .addComponent(incidentColorField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
562                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
563                .addComponent(jLabel10)
564                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
565                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
566                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
567                .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
568                    .addComponent(addIncidentStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
569                    .addComponent(jLabel12))
570                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
571                .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
572                    .addComponent(addIncidentLength, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
573                    .addComponent(jLabel11))
574                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
575                .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
576                    .addComponent(incidentCancelButton)
577                    .addComponent(incidentOkButton))
578                .addContainerGap())
579        );
580
581        addNoiseFrame.setTitle("Generate Noise");
582        addNoiseFrame.setMinimumSize(new java.awt.Dimension(395, 315));
583        addNoiseFrame.setResizable(false);
584
585        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
586        jLabel13.setText("Radio Chatter: ");
587
588        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
589        jLabel14.setText("Lane Closures:");
590
591        jLabel15.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
592        jLabel15.setText("TMCAL Logs:");
593
594        jTextArea1.setEditable(false);
595        jTextArea1.setColumns(20);
596        jTextArea1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
597        jTextArea1.setLineWrap(true);
598        jTextArea1.setRows(5);
599        jTextArea1.setText("Noise events will be randomly generated for the simulation with frequencies based on the control selections made below");
600        jTextArea1.setWrapStyleWord(true);
601        jTextArea1.setAutoscrolls(false);
602        jTextArea1.setBorder(null);
603        jTextArea1.setDisabledTextColor(new java.awt.Color(0, 0, 0));
604        jTextArea1.setFocusable(false);
605        jTextArea1.setOpaque(false);
606
607        jLabel16.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
608        jLabel16.setText("Background Noise: ");
609
610        jLabel17.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
611        jLabel17.setText("Minor Events:");
612
613        jButton1.setText("Cancel");
614        jButton1.addActionListener(new java.awt.event.ActionListener() {
615            public void actionPerformed(java.awt.event.ActionEvent evt) {
616                jButton1ActionPerformed(evt);
617            }
618        });
619
620        jButton2.setText("Generate");
621        jButton2.addActionListener(new java.awt.event.ActionListener() {
622            public void actionPerformed(java.awt.event.ActionEvent evt) {
623                jButton2ActionPerformed(evt);
624            }
625        });
626
627        jLabel20.setText("Least Frequent");
628
629        jLabel21.setText("Most Frequent");
630
631        javax.swing.GroupLayout addNoiseFrameLayout = new javax.swing.GroupLayout(addNoiseFrame.getContentPane());
632        addNoiseFrame.getContentPane().setLayout(addNoiseFrameLayout);
633        addNoiseFrameLayout.setHorizontalGroup(
634            addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
635            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, addNoiseFrameLayout.createSequentialGroup()
636                .addContainerGap(21, Short.MAX_VALUE)
637                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
638                    .addComponent(jTextArea1, javax.swing.GroupLayout.Alignment.LEADING)
639                    .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
640                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, addNoiseFrameLayout.createSequentialGroup()
641                            .addComponent(jButton1)
642                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
643                            .addComponent(jButton2))
644                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, addNoiseFrameLayout.createSequentialGroup()
645                            .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
646                                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
647                                    .addComponent(jLabel16)
648                                    .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
649                                    .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
650                                    .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
651                                .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
652                            .addGap(4, 4, 4)
653                            .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
654                                .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
655                                .addComponent(jSlider2, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
656                                .addComponent(jSlider3, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
657                                .addComponent(jSlider5, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
658                                .addComponent(jSlider4, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
659                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, addNoiseFrameLayout.createSequentialGroup()
660                                    .addComponent(jLabel20)
661                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
662                                    .addComponent(jLabel21))))))
663                .addGap(20, 20, 20))
664        );
665        addNoiseFrameLayout.setVerticalGroup(
666            addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
667            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, addNoiseFrameLayout.createSequentialGroup()
668                .addContainerGap()
669                .addComponent(jTextArea1, javax.swing.GroupLayout.DEFAULT_SIZE, 39, Short.MAX_VALUE)
670                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
671                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
672                    .addComponent(jLabel21)
673                    .addComponent(jLabel20))
674                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
675                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
676                    .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
677                    .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
678                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
679                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
680                    .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
681                    .addComponent(jSlider2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
682                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
683                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
684                    .addComponent(jLabel15)
685                    .addComponent(jSlider3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
686                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
687                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
688                    .addComponent(jSlider4, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
689                    .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
690                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
691                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
692                    .addComponent(jSlider5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
693                    .addComponent(jLabel17))
694                .addGap(18, 18, 18)
695                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
696                    .addComponent(jButton1)
697                    .addComponent(jButton2))
698                .addContainerGap())
699        );
700
701        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
702        setTitle("Script Builder");
703        setBounds(new java.awt.Rectangle(0, 23, 800, 700));
704        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
705        setMinimumSize(new java.awt.Dimension(800, 700));
706
707        timelinesScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
708        timelinesScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
709        timelinesScrollPane.setFocusCycleRoot(true);
710        timelinesScrollPane.setFocusTraversalPolicyProvider(true);
711        timelinesScrollPane.setPreferredSize(new java.awt.Dimension(72000, 1341));
712        timelinesScrollPane.setWheelScrollingEnabled(false);
713
714        timelineTickPanel.setMaximumSize(new java.awt.Dimension(7200, 32767));
715        timelineTickPanel.setMinimumSize(new java.awt.Dimension(7200, 0));
716        timelineTickPanel.setPreferredSize(new java.awt.Dimension(7200, 1317));
717
718        incidentTimelinePanel1.setMaximumSize(new java.awt.Dimension(32767, 100));
719        incidentTimelinePanel1.setOpaque(false);
720        incidentTimelinePanel1.setPreferredSize(new java.awt.Dimension(691, 100));
721
722        javax.swing.GroupLayout incidentTimelinePanel1Layout = new javax.swing.GroupLayout(incidentTimelinePanel1);
723        incidentTimelinePanel1.setLayout(incidentTimelinePanel1Layout);
724        incidentTimelinePanel1Layout.setHorizontalGroup(
725            incidentTimelinePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
726            .addGap(0, 691, Short.MAX_VALUE)
727        );
728        incidentTimelinePanel1Layout.setVerticalGroup(
729            incidentTimelinePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
730            .addGap(0, 100, Short.MAX_VALUE)
731        );
732
733        incidentNumberPanel1.setOpaque(false);
734
735        javax.swing.GroupLayout incidentNumberPanel1Layout = new javax.swing.GroupLayout(incidentNumberPanel1);
736        incidentNumberPanel1.setLayout(incidentNumberPanel1Layout);
737        incidentNumberPanel1Layout.setHorizontalGroup(
738            incidentNumberPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
739            .addGap(0, 0, Short.MAX_VALUE)
740        );
741        incidentNumberPanel1Layout.setVerticalGroup(
742            incidentNumberPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
743            .addGap(0, 0, Short.MAX_VALUE)
744        );
745
746        javax.swing.GroupLayout timelineTickPanelLayout = new javax.swing.GroupLayout(timelineTickPanel);
747        timelineTickPanel.setLayout(timelineTickPanelLayout);
748        timelineTickPanelLayout.setHorizontalGroup(
749            timelineTickPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
750            .addGroup(timelineTickPanelLayout.createSequentialGroup()
751                .addContainerGap()
752                .addComponent(incidentNumberPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
753                .addGap(10, 10, 10)
754                .addComponent(incidentTimelinePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
755                .addContainerGap(6487, Short.MAX_VALUE))
756        );
757        timelineTickPanelLayout.setVerticalGroup(
758            timelineTickPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
759            .addGroup(timelineTickPanelLayout.createSequentialGroup()
760                .addContainerGap()
761                .addGroup(timelineTickPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
762                    .addComponent(incidentNumberPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
763                    .addComponent(incidentTimelinePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
764                .addContainerGap(1205, Short.MAX_VALUE))
765        );
766
767        timelinesScrollPane.setViewportView(timelineTickPanel);
768
769        zoomSlider.setMaximum(22);
770        zoomSlider.setMinimum(4);
771        zoomSlider.setValue(4);
772        zoomSlider.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
773        zoomSlider.setFocusable(false);
774        zoomSlider.addChangeListener(new javax.swing.event.ChangeListener() {
775            public void stateChanged(javax.swing.event.ChangeEvent evt) {
776                zoomSliderStateChanged(evt);
777            }
778        });
779
780        zoomInIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ZoomIn.png"))); // NOI18N
781        zoomInIcon.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
782        zoomInIcon.addMouseListener(new java.awt.event.MouseAdapter() {
783            public void mouseClicked(java.awt.event.MouseEvent evt) {
784                zoomInIconMouseClicked(evt);
785            }
786        });
787
788        zoomOutIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ZoomOut.png"))); // NOI18N
789        zoomOutIcon.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
790        zoomOutIcon.addMouseListener(new java.awt.event.MouseAdapter() {
791            public void mouseClicked(java.awt.event.MouseEvent evt) {
792                zoomOutIconMouseClicked(evt);
793            }
794        });
795
796        timeStampScrollPane.setBorder(null);
797        timeStampScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
798        timeStampScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
799
800        javax.swing.GroupLayout timeStampPanelLayout = new javax.swing.GroupLayout(timeStampPanel);
801        timeStampPanel.setLayout(timeStampPanelLayout);
802        timeStampPanelLayout.setHorizontalGroup(
803            timeStampPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
804            .addGap(0, 0, Short.MAX_VALUE)
805        );
806        timeStampPanelLayout.setVerticalGroup(
807            timeStampPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
808            .addGap(0, 0, Short.MAX_VALUE)
809        );
810
811        timeStampScrollPane.setViewportView(timeStampPanel);
812
813        fileMenu.setText("File");
814        fileMenu.setMargin(new java.awt.Insets(0, 10, 0, 10));
815        fileMenu.addActionListener(new java.awt.event.ActionListener() {
816            public void actionPerformed(java.awt.event.ActionEvent evt) {
817                fileMenuActionPerformed(evt);
818            }
819        });
820
821        fileNew.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
822        fileNew.setText("New");
823        fileNew.addActionListener(new java.awt.event.ActionListener() {
824            public void actionPerformed(java.awt.event.ActionEvent evt) {
825                fileNewActionPerformed(evt);
826            }
827        });
828        fileMenu.add(fileNew);
829        fileMenu.add(jSeparator1);
830
831        fileOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
832        fileOpen.setText("Open...");
833        fileOpen.addActionListener(new java.awt.event.ActionListener() {
834            public void actionPerformed(java.awt.event.ActionEvent evt) {
835                fileOpenActionPerformed(evt);
836            }
837        });
838        fileMenu.add(fileOpen);
839        fileMenu.add(jSeparator2);
840
841        fileSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
842        fileSave.setText("Save");
843        fileSave.addActionListener(new java.awt.event.ActionListener() {
844            public void actionPerformed(java.awt.event.ActionEvent evt) {
845                fileSaveActionPerformed(evt);
846            }
847        });
848        fileMenu.add(fileSave);
849
850        fileSaveAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
851        fileSaveAs.setText("Save as...");
852        fileSaveAs.addActionListener(new java.awt.event.ActionListener() {
853            public void actionPerformed(java.awt.event.ActionEvent evt) {
854                fileSaveAsActionPerformed(evt);
855            }
856        });
857        fileMenu.add(fileSaveAs);
858
859        scriptBuilderMenuBar.add(fileMenu);
860
861        generateMenu.setLabel("Generate");
862        generateMenu.setMargin(new java.awt.Insets(0, 10, 0, 10));
863
864        generateNotebooks.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
865        generateNotebooks.setText("Generate Notebooks...");
866        generateNotebooks.addActionListener(new java.awt.event.ActionListener() {
867            public void actionPerformed(java.awt.event.ActionEvent evt) {
868                generateNotebooksActionPerformed(evt);
869            }
870        });
871        generateMenu.add(generateNotebooks);
872
873        jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
874        jMenuItem3.setText("Generate Web Notebook...");
875        generateMenu.add(jMenuItem3);
876
877        generateScorecards.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
878        generateScorecards.setText("Generate Scorecards...");
879        generateScorecards.addActionListener(new java.awt.event.ActionListener() {
880            public void actionPerformed(java.awt.event.ActionEvent evt) {
881                generateScorecardsActionPerformed(evt);
882            }
883        });
884        generateMenu.add(generateScorecards);
885
886        generateOrganizationChart.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
887        generateOrganizationChart.setText("Generate D14 TMC Org Chart...");
888        generateOrganizationChart.addActionListener(new java.awt.event.ActionListener() {
889            public void actionPerformed(java.awt.event.ActionEvent evt) {
890                generateOrganizationChartActionPerformed(evt);
891            }
892        });
893        generateMenu.add(generateOrganizationChart);
894        generateMenu.add(jSeparator3);
895
896        generateProjectRequirements.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
897        generateProjectRequirements.setText("Generate Project Worklist...");
898        generateProjectRequirements.addActionListener(new java.awt.event.ActionListener() {
899            public void actionPerformed(java.awt.event.ActionEvent evt) {
900                generateProjectRequirementsActionPerformed(evt);
901            }
902        });
903        generateMenu.add(generateProjectRequirements);
904
905        scriptBuilderMenuBar.add(generateMenu);
906
907        incidentMenu.setText("Incidents");
908        incidentMenu.setMargin(new java.awt.Insets(0, 10, 0, 10));
909
910        newIncident.setText("New Incident...");
911        newIncident.addActionListener(new java.awt.event.ActionListener() {
912            public void actionPerformed(java.awt.event.ActionEvent evt) {
913                newIncidentActionPerformed(evt);
914            }
915        });
916        incidentMenu.add(newIncident);
917
918        editIncident.setText("Edit Incident...");
919        editIncident.addActionListener(new java.awt.event.ActionListener() {
920            public void actionPerformed(java.awt.event.ActionEvent evt) {
921                editIncidentActionPerformed(evt);
922            }
923        });
924        incidentMenu.add(editIncident);
925
926        incidentDetails.setText("Incident Details...");
927        incidentDetails.addActionListener(new java.awt.event.ActionListener() {
928            public void actionPerformed(java.awt.event.ActionEvent evt) {
929                incidentDetailsActionPerformed(evt);
930            }
931        });
932        incidentMenu.add(incidentDetails);
933        incidentMenu.add(jSeparator4);
934
935        saveIncident.setText("Save Incident...");
936        saveIncident.addActionListener(new java.awt.event.ActionListener() {
937            public void actionPerformed(java.awt.event.ActionEvent evt) {
938                saveIncidentActionPerformed(evt);
939            }
940        });
941        incidentMenu.add(saveIncident);
942
943        loadIncident.setText("Load Incident...");
944        loadIncident.addActionListener(new java.awt.event.ActionListener() {
945            public void actionPerformed(java.awt.event.ActionEvent evt) {
946                loadIncidentActionPerformed(evt);
947            }
948        });
949        incidentMenu.add(loadIncident);
950
951        scriptBuilderMenuBar.add(incidentMenu);
952
953        generateNoiseMenu.setText("Noise");
954
955        generateNoiseOption.setText("Generate Noise...");
956        generateNoiseOption.addActionListener(new java.awt.event.ActionListener() {
957            public void actionPerformed(java.awt.event.ActionEvent evt) {
958                generateNoiseOptionActionPerformed(evt);
959            }
960        });
961        generateNoiseMenu.add(generateNoiseOption);
962
963        scriptBuilderMenuBar.add(generateNoiseMenu);
964
965        helpMenu.setText("Help");
966        helpMenu.setMargin(new java.awt.Insets(0, 10, 0, 10));
967
968        helpTutorial.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
969        helpTutorial.setText("Tutorial...");
970        helpMenu.add(helpTutorial);
971
972        helpAbout.setText("About...");
973        helpAbout.addActionListener(new java.awt.event.ActionListener() {
974            public void actionPerformed(java.awt.event.ActionEvent evt) {
975                helpAboutActionPerformed(evt);
976            }
977        });
978        helpMenu.add(helpAbout);
979
980        scriptBuilderMenuBar.add(helpMenu);
981
982        setJMenuBar(scriptBuilderMenuBar);
983
984        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
985        getContentPane().setLayout(layout);
986        layout.setHorizontalGroup(
987            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
988            .addGroup(layout.createSequentialGroup()
989                .addContainerGap()
990                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
991                    .addComponent(timelinesScrollPane, 0, 0, Short.MAX_VALUE)
992                    .addComponent(timeStampScrollPane)
993                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
994                        .addGap(0, 597, Short.MAX_VALUE)
995                        .addComponent(zoomOutIcon)
996                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
997                        .addComponent(zoomSlider, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
998                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
999                        .addComponent(zoomInIcon)
1000                        .addGap(136, 136, 136)))
1001                .addContainerGap())
1002        );
1003        layout.setVerticalGroup(
1004            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
1005            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
1006                .addContainerGap()
1007                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
1008                    .addComponent(zoomOutIcon)
1009                    .addComponent(zoomSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
1010                    .addComponent(zoomInIcon))
1011                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1012                .addComponent(timeStampScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
1013                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
1014                .addComponent(timelinesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1289, Short.MAX_VALUE)
1015                .addContainerGap())
1016        );
1017
1018        pack();
1019    }// </editor-fold>//GEN-END:initComponents
1020
1021    /**
1022     * Scale the timeline width based on zoom slider position.
1023     *
1024     * @param evt the state change event
1025     */
1026    private void zoomSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_zoomSliderStateChanged
1027        ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK = zoomSlider.getValue();
1028        this.update(script, script);
1029        pack();
1030        repaint();
1031    }//GEN-LAST:event_zoomSliderStateChanged
1032
1033    private void cadEventMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cadEventMousePressed
1034    }//GEN-LAST:event_cadEventMousePressed
1035
1036    private void radioEventMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_radioEventMousePressed
1037    }//GEN-LAST:event_radioEventMousePressed
1038
1039    private void cadEventMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cadEventMouseReleased
1040    }//GEN-LAST:event_cadEventMouseReleased
1041
1042    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
1043    }//GEN-LAST:event_okButtonActionPerformed
1044
1045    /**
1046     * If cancel button is pressed, close radio event editor
1047     *
1048     * @param evt the button press event
1049     */
1050    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
1051        radioMessage.setText("");
1052        radioTypeComboBox.setSelectedIndex(0);
1053        radioEventFrame.setVisible(false);
1054    }//GEN-LAST:event_cancelButtonActionPerformed
1055
1056    private void editEventListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editEventListActionPerformed
1057    }//GEN-LAST:event_editEventListActionPerformed
1058
1059    /**
1060     * Executed when the "OK" button is pressed on the Incident editor. If
1061     * incident is new, and is valid, adds it to the model and updates. If
1062     * editing existing incident, verifies changes are valid and applies them.
1063     * Then closes editor window.
1064     *
1065     * @param evt the button press event
1066     */
1067    private void incidentOkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_incidentOkButtonActionPerformed
1068        if (!editingIncident)
1069        {
1070            boolean found = false;
1071            int indx = 0;
1072            // ALERT: Wacky logic follows
1073            // Examine all the incidents contained in this script
1074            for (ScriptIncident inci : script.incidents)
1075            {
1076                // If this spot in the list of incidents hasn't been assigned yet
1077                if (inci == null)
1078                {
1079                    found = true;
1080                    break;
1081                }
1082                ++indx;
1083                // Does the new incident number match an existing one?
1084                if (inci.number == (Integer) addIncidentNumber.getValue())
1085                {
1086                    JOptionPane.showMessageDialog(this, "Incident number already in use.",
1087                            "Unable to Create Incident", JOptionPane.ERROR_MESSAGE);
1088                    incidentFrame.setVisible(true);
1089                    return;
1090                }
1091            }
1092            // We examined all incidents and there wasn't an empty slot
1093            if (!found)
1094            {
1095                JOptionPane.showMessageDialog(this, "Script already has the max number of incidents.",
1096                        "Unable to Create Incident", JOptionPane.ERROR_MESSAGE);
1097                incidentFrame.setVisible(true);
1098                // ALERT: exit from middle of method
1099                return;
1100            }
1101
1102            // We found a spot for the new incident
1103            script.incidents.remove(indx); // remove the null incident placeholder
1104            SimulationScript.incidentColors[indx] = selectedColor;
1105            // Add the new incident to the list
1106            script.incidents.add(indx,
1107                    new ScriptIncident(SimulationScript.incidentColors[indx],
1108                            (Integer) addIncidentNumber.getValue(), addIncidentName.getText(), addIncidentDescription.getText(),
1109                            script));
1110            script.incidents.get(indx).length = (Integer) addIncidentLength.getValue() * 60;
1111            script.incidents.get(indx).setOffset((Integer) addIncidentStart.getValue() * 60);
1112            script.numberOfIncidents++;
1113        }
1114        else
1115        {
1116            ScriptIncident backup = script.incidents.get(oldIncidentIndex);
1117            script.incidents.remove(oldIncidentIndex);
1118            script.incidents.add(oldIncidentIndex, null);
1119
1120            for (ScriptIncident i : script.incidents)
1121            {
1122                if (i != null && i.number == (Integer) addIncidentNumber.getValue())
1123                {
1124                    script.incidents.remove(oldIncidentIndex);
1125                    script.incidents.add(oldIncidentIndex, backup);
1126                    JOptionPane.showMessageDialog(this, "Incident number already in use.",
1127                            "Unable to Create Incident", JOptionPane.ERROR_MESSAGE);
1128                    incidentFrame.setVisible(true);
1129                    return;
1130                }
1131            }
1132
1133            script.incidents.remove(oldIncidentIndex);
1134            SimulationScript.incidentColors[oldIncidentIndex] = selectedColor;
1135            script.incidents.add(oldIncidentIndex,
1136                    new ScriptIncident(SimulationScript.incidentColors[oldIncidentIndex],
1137                            (Integer) addIncidentNumber.getValue(), addIncidentName.getText(), addIncidentDescription.getText(),
1138                            script));
1139            script.incidents.get(oldIncidentIndex).length = (Integer) addIncidentLength.getValue() * 60;
1140            script.incidents.get(oldIncidentIndex).slices = backup.slices;
1141            script.incidents.get(oldIncidentIndex).offset = backup.offset;
1142            script.incidents.get(oldIncidentIndex).setOffset((Integer) addIncidentStart.getValue() * 60);
1143            script.numberOfIncidents++;
1144        }
1145
1146        incidentFrame.setVisible(false);
1147        update(script, script);
1148        repaint();
1149    }//GEN-LAST:event_incidentOkButtonActionPerformed
1150
1151    /**
1152     * Closes editor window upon click of cancel button.
1153     *
1154     * @param evt the button press event
1155     */
1156    private void incidentCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_incidentCancelButtonActionPerformed
1157        incidentFrame.setVisible(false);
1158    }//GEN-LAST:event_incidentCancelButtonActionPerformed
1159
1160    /**
1161     * Opens incident editor window and preps for addition of new incident, upon
1162     * click of "New Incident" menu option.
1163     *
1164     * @param evt the button press event
1165     */
1166    private void newIncidentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newIncidentActionPerformed
1167        editingIncident = false;
1168
1169        addIncidentName.setText("");
1170        addIncidentNumber.setValue(101);
1171        addIncidentStart.setValue(0);
1172        addIncidentLength.setValue(0);
1173        incidentColorField.setBackground(Color.BLACK);
1174        selectedColor = Color.BLACK;
1175        addIncidentDescription.setText("");
1176
1177        incidentFrame.setVisible(true);
1178    }//GEN-LAST:event_newIncidentActionPerformed
1179
1180    private void fileMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileMenuActionPerformed
1181    }//GEN-LAST:event_fileMenuActionPerformed
1182
1183    /**
1184     * Upon click of "Open file" menu option, opens a window to load a new .sim
1185     * file.
1186     *
1187     * @param evt the button press event
1188     */
1189    private void fileOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileOpenActionPerformed
1190        JFileChooser fc = new JFileChooser();
1191
1192        fc.setFileFilter(new ExtensionFileFilter("Simulation Script XML (.xml)",
1193                new String[]
1194                {
1195                    "xml"
1196                }));
1197        if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
1198        {
1199            script = new SimulationScript();
1200            System.out.println(fc.getSelectedFile().getName());
1201            script.loadScriptFromFile(fc.getSelectedFile());
1202            script.saveFile = fc.getSelectedFile();
1203        }
1204        update(script, script);
1205        zoomSlider.setValue(zoomSlider.getMinimum());
1206        repaint();
1207    }//GEN-LAST:event_fileOpenActionPerformed
1208
1209    /**
1210     * Upon click of "Save as" menu option, opens a window to choose a .sim file
1211     * to save this as.
1212     *
1213     * @param evt the button press event
1214     */
1215    private void fileSaveAsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileSaveAsActionPerformed
1216        JFileChooser fc = new JFileChooser();
1217
1218        fc.setFileFilter(new ExtensionFileFilter("Simulation Script XML (.xml)",
1219                new String[]
1220                {
1221                    "xml"
1222                }));
1223
1224        if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION)
1225        {
1226            script.saveScriptToFile(fc.getSelectedFile());
1227            script.saveFile = fc.getSelectedFile();
1228        }
1229    }//GEN-LAST:event_fileSaveAsActionPerformed
1230
1231    /**
1232     * Upon click of "Save" menu option, opens a window to choose a .sim file to
1233     * save this as.
1234     *
1235     * @param evt the button press event
1236     */
1237    private void fileSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileSaveActionPerformed
1238        if (script.saveFile == null)
1239        {
1240            fileSaveAsActionPerformed(evt);
1241        }
1242        else
1243        {
1244            script.saveScriptToFile(script.saveFile);
1245        }
1246    }//GEN-LAST:event_fileSaveActionPerformed
1247
1248    /**
1249     * Upon click of "Edit incident" menu option, brings up a dropdown menu of
1250     * all existing incidents. Once an incident is selected, opens incident
1251     * editor window with that event's details loaded.
1252     *
1253     * @param evt the button press event
1254     */
1255    private void incidentDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_incidentDetailsActionPerformed
1256        Object[] incidentList = script.incidents.toArray();
1257        ScriptIncident i = (ScriptIncident) JOptionPane.showInputDialog(
1258                this,
1259                "Select Incident:",
1260                "Edit Incident",
1261                JOptionPane.PLAIN_MESSAGE,
1262                null,
1263                incidentList,
1264                script.incidents.get(0));
1265
1266        // If a valid incident was selected
1267        if (i != null)
1268        {
1269            editingIncident = true;
1270            oldIncidentIndex = script.incidents.indexOf(i);
1271
1272            addIncidentName.setText(i.name);
1273            addIncidentNumber.setValue(i.number);
1274            addIncidentStart.setValue(i.offset / 60);
1275            addIncidentLength.setValue(i.length / 60);
1276            incidentColorField.setBackground(i.color);
1277            selectedColor = i.color;
1278            addIncidentDescription.setText(i.description);
1279
1280            incidentFrame.setVisible(true);
1281        }
1282    }//GEN-LAST:event_incidentDetailsActionPerformed
1283
1284    /**
1285     * Brings up the noise generation screen upon click of the "Generate Noise"
1286     * menu option.
1287     *
1288     * @param evt the button press event
1289     */
1290    private void generateNoiseOptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateNoiseOptionActionPerformed
1291        addNoiseFrame.setVisible(true);
1292    }//GEN-LAST:event_generateNoiseOptionActionPerformed
1293
1294    /**
1295     * Hides the noise generation screen upon click of the "Cancel" button.
1296     *
1297     * @param evt the button press event
1298     */
1299    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
1300        addNoiseFrame.setVisible(false);
1301    }//GEN-LAST:event_jButton1ActionPerformed
1302
1303    /**
1304     * Generates random noise upon click of the "OK" button, then hides the
1305     * noise generation screen.
1306     *
1307     * @param evt the button press event
1308     */
1309    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
1310        Random rng = new Random();
1311        ScriptEventType[] eventTypes = ScriptEventType.values();
1312
1313        /* For prototyping purpose, ignore the sliders and average their values */
1314        int total = jSlider1.getValue() + jSlider2.getValue() + jSlider3.getValue() + jSlider5.getValue() + jSlider4.getValue();
1315        total /= 5;
1316
1317        for (int i = 0; i < script.incidents.get(9).slices.size(); i++)
1318        {
1319            script.incidents.get(9).slices.get(i).events.clear();
1320        }
1321
1322        for (int i = 0; i < total; i++)
1323        {
1324            int n = rng.nextInt();
1325            int s = rng.nextInt();
1326            int e = rng.nextInt();
1327            if (n < 0)
1328            {
1329                n *= -1;
1330            }
1331            if (s < 0)
1332            {
1333                s *= -1;
1334            }
1335            if (e < 0)
1336            {
1337                e *= -1;
1338            }
1339
1340            script.incidents.get(9).slices.get(s % (script.incidents.get(9).slices.size())).addEvent(ScriptEvent.factoryByType(eventTypes[e % eventTypes.length]));
1341        }
1342
1343        addNoiseFrame.setVisible(false);
1344
1345        update(script, script);
1346}//GEN-LAST:event_jButton2ActionPerformed
1347
1348    /**
1349     * Allow the user to pick an incident from a dropdown, then save it to an
1350     * XML file.
1351     *
1352     * @param evt the button press event
1353     */
1354    private void saveIncidentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveIncidentActionPerformed
1355        Object[] incidentList = script.incidents.toArray();
1356        String input = "";
1357        ScriptIncident inc = null;
1358        Object result = JOptionPane.showInputDialog(
1359                this,
1360                "Select Incident:",
1361                "Save Incident",
1362                JOptionPane.PLAIN_MESSAGE,
1363                null,
1364                incidentList,
1365                script.incidents.get(0));
1366
1367        System.out.println("RESULT = " + result.toString());
1368
1369        input = result.toString();
1370
1371        System.out.println("INPUT = " + input);
1372
1373        int i = 0;
1374        for (ScriptIncident incident : script.incidents)
1375        {
1376            if (incident == null)
1377            {
1378                continue;
1379            }
1380            System.out.println((++i) + ": " + incident.toString());
1381            if (incident.toString().equals(input))
1382            {
1383                inc = incident;
1384            }
1385        }
1386
1387        if (inc == null)
1388        {
1389            System.out.println("DIDN'T FIND ANYTHING");
1390            return;
1391        }
1392
1393        JFileChooser fc = new JFileChooser();
1394        fc.setFileFilter(new ExtensionFileFilter("Script Incident (.xml)", new String[]
1395        {
1396            "xml"
1397        }));
1398        if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION)
1399        {
1400            inc.saveIncidentToFile(fc.getSelectedFile());
1401        }
1402    }//GEN-LAST:event_saveIncidentActionPerformed
1403
1404    private void loadIncidentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadIncidentActionPerformed
1405    //    new IncidentPaletteFrame(script, this).setVisible(true);
1406        JOptionPane.showMessageDialog(this, "Incident Palette will appear here", "Message", JOptionPane.INFORMATION_MESSAGE);
1407        zoomSlider.setValue(zoomSlider.getMinimum());
1408    }//GEN-LAST:event_loadIncidentActionPerformed
1409
1410    private void generateProjectRequirementsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateProjectRequirementsActionPerformed
1411        JFileChooser fc = new JFileChooser();
1412        fc.setFileFilter(new ExtensionFileFilter("Portable Document Format (.pdf)", new String[]
1413        {
1414            "pdf"
1415        }));
1416        fc.setSelectedFile(new File("Requirements.pdf"));
1417        fc.showSaveDialog(this);
1418    }//GEN-LAST:event_generateProjectRequirementsActionPerformed
1419
1420    private void generateNotebooksActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateNotebooksActionPerformed
1421        JFileChooser fc = new JFileChooser();
1422        fc.setFileFilter(new ExtensionFileFilter("Portable Document Format (.pdf)", new String[]
1423        {
1424            "pdf"
1425        }));
1426        fc.setSelectedFile(new File("Notebooks.pdf"));
1427        fc.showSaveDialog(this);
1428    }//GEN-LAST:event_generateNotebooksActionPerformed
1429
1430    private void generateScorecardsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateScorecardsActionPerformed
1431        JFileChooser fc = new JFileChooser();
1432        fc.setFileFilter(new ExtensionFileFilter("Portable Document Format (.pdf)", new String[]
1433        {
1434            "pdf"
1435        }));
1436        fc.setSelectedFile(new File("Scorecards.pdf"));
1437        fc.showSaveDialog(this);
1438    }//GEN-LAST:event_generateScorecardsActionPerformed
1439
1440    private void generateOrganizationChartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateOrganizationChartActionPerformed
1441        JFileChooser fc = new JFileChooser();
1442        fc.setFileFilter(new ExtensionFileFilter("Portable Document Format (.pdf)", new String[]
1443        {
1444            "pdf"
1445        }));
1446        fc.setSelectedFile(new File("OrganizationChart.pdf"));
1447        fc.showSaveDialog(this);
1448    }//GEN-LAST:event_generateOrganizationChartActionPerformed
1449
1450    /**
1451     * Increases zoom level upon click of the "Zoom in" icon.
1452     *
1453     * @param evt the mouse event
1454     */
1455    private void zoomInIconMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_zoomInIconMouseClicked
1456        zoomSlider.setValue(zoomSlider.getValue() >= 21 ? 21 : zoomSlider.getValue() + 1);
1457    }//GEN-LAST:event_zoomInIconMouseClicked
1458
1459    /**
1460     * Decreases zoom level upon click of the "Zoom out" icon.
1461     *
1462     * @param evt the mouse event
1463     */
1464    private void zoomOutIconMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_zoomOutIconMouseClicked
1465        zoomSlider.setValue(zoomSlider.getValue() <= 5 ? 5 : zoomSlider.getValue() - 1);
1466    }//GEN-LAST:event_zoomOutIconMouseClicked
1467    private Color selectedColor = Color.BLACK;
1468
1469    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
1470        Color newColor = incidentColorChooser.showDialog(this, "Incident Color", incidentColorField.getBackground());
1471        if (newColor != null)
1472        {
1473            selectedColor = newColor;
1474            incidentColorField.setBackground(newColor);
1475        }
1476    }//GEN-LAST:event_jButton3ActionPerformed
1477
1478    /* Help > About simply displays the current SVN revision number so
1479     * the user can determine which version of the source code was used to
1480     * build the executable she is running.
1481     */
1482    private void helpAboutActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_helpAboutActionPerformed
1483    {//GEN-HEADEREND:event_helpAboutActionPerformed
1484        JOptionPane.showMessageDialog(rootPane, "Revision: " + getAppVersion(), "About", JOptionPane.INFORMATION_MESSAGE);
1485    }//GEN-LAST:event_helpAboutActionPerformed
1486
1487    private void fileNewActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_fileNewActionPerformed
1488    {//GEN-HEADEREND:event_fileNewActionPerformed
1489        script = new SimulationScript();
1490        script.update();
1491        update(null, script);
1492        repaint();
1493    }//GEN-LAST:event_fileNewActionPerformed
1494
1495    private void editIncidentActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_editIncidentActionPerformed
1496    {//GEN-HEADEREND:event_editIncidentActionPerformed
1497        Object[] incidentList = script.incidents.toArray();
1498        String input = "";
1499        ScriptIncident inc = null;
1500        Object result = JOptionPane.showInputDialog(
1501                this,
1502                "Select Incident:",
1503                "Save Incident",
1504                JOptionPane.PLAIN_MESSAGE,
1505                null,
1506                incidentList,
1507                script.incidents.get(0));
1508
1509        if (result != null)
1510        {
1511            System.out.println("RESULT = " + result.toString());
1512
1513            input = result.toString();
1514
1515            System.out.println("INPUT = " + input);
1516
1517            int i = 0;
1518            for (ScriptIncident incident : script.incidents)
1519            {
1520                if (incident == null)
1521                {
1522                    continue;
1523                }
1524                System.out.println((++i) + ": " + incident.toString());
1525                if (incident.toString().equals(input))
1526                {
1527                    inc = incident;
1528                }
1529            }
1530
1531            if (inc != null)
1532            {
1533                IncidentEditorFrame editor = new IncidentEditorFrame(inc, null);
1534                script.addObserver(editor);
1535                editor.setVisible(true);
1536            }
1537        }
1538        update(script, script);
1539    }//GEN-LAST:event_editIncidentActionPerformed
1540
1541    /**
1542     * Read the version number from the application properties. The file
1543     * 'application.properties' is generated by build.xml.
1544     *
1545     * @return a version string obtained from application.properties file, or
1546     * "Version: unknown" if an IOerror prevents us from reading the file.
1547     */
1548    private String getAppVersion()
1549    {
1550        String propfilename = "/scriptbuilder/gui/application.properties";
1551        String propKey = "Application.revision";
1552        String version = "unknown";
1553        // Load the application properties (created by build.xml)
1554        try
1555        {
1556            Properties props = new Properties();
1557            props.load(this.getClass().getResourceAsStream(propfilename));
1558            version = (String) props.get(propKey);
1559        }
1560        catch (IOException ex)
1561        {
1562            Logger.getLogger("scriptbuilder.gui").log(Level.SEVERE,
1563                    "ScriptBuilderFrame.getAppVersion()."
1564                    + " IOError reading " + propfilename);
1565        }
1566        catch (NullPointerException npe)
1567        {
1568            Logger.getLogger("scriptbuilder.gui").log(Level.SEVERE,
1569                    "ScriptBuilderFrame.getAppVersion().load."
1570                    + " Missing file: " + propfilename);
1571        }
1572        return version;
1573    }
1574
1575    /**
1576     * Runs the script builder.
1577     *
1578     * @param args the command line arguments
1579     */
1580    public static void main(String args[])
1581    {
1582        try
1583        {
1584            UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
1585        }
1586        catch (ClassNotFoundException ex)
1587        {
1588        }
1589        catch (InstantiationException ex)
1590        {
1591        }
1592        catch (IllegalAccessException ex)
1593        {
1594        }
1595        catch (UnsupportedLookAndFeelException ex)
1596        {
1597        }
1598
1599        try
1600        {
1601            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
1602        }
1603        catch (ClassNotFoundException ex)
1604        {
1605        }
1606        catch (InstantiationException ex)
1607        {
1608        }
1609        catch (IllegalAccessException ex)
1610        {
1611        }
1612        catch (UnsupportedLookAndFeelException ex)
1613        {
1614        }
1615
1616        java.awt.EventQueue.invokeLater(new Runnable()
1617                {
1618                    public void run()
1619                    {
1620                        new ScriptOverviewWindow().setVisible(true);
1621                    }
1622                });
1623    }
1624    // Variables declaration - do not modify//GEN-BEGIN:variables
1625    private javax.swing.JTextArea addIncidentDescription;
1626    private javax.swing.JSpinner addIncidentLength;
1627    private javax.swing.JTextField addIncidentName;
1628    private javax.swing.JSpinner addIncidentNumber;
1629    private javax.swing.JSpinner addIncidentStart;
1630    private javax.swing.JFrame addNoiseFrame;
1631    private javax.swing.JMenuItem cadEvent;
1632    private javax.swing.JFrame cadEventFrame;
1633    private javax.swing.JButton cancelButton;
1634    private javax.swing.JMenuItem deleteEventList;
1635    private javax.swing.JMenuItem editEventList;
1636    private javax.swing.JMenuItem editIncident;
1637    private javax.swing.JPopupMenu eventListPopupMenu;
1638    private javax.swing.JPopupMenu eventPopupMenu;
1639    private javax.swing.JMenu fileMenu;
1640    private javax.swing.JMenuItem fileNew;
1641    private javax.swing.JMenuItem fileOpen;
1642    private javax.swing.JMenuItem fileSave;
1643    private javax.swing.JMenuItem fileSaveAs;
1644    private javax.swing.JMenu generateMenu;
1645    private javax.swing.JMenu generateNoiseMenu;
1646    private javax.swing.JMenuItem generateNoiseOption;
1647    private javax.swing.JMenuItem generateNotebooks;
1648    private javax.swing.JMenuItem generateOrganizationChart;
1649    private javax.swing.JMenuItem generateProjectRequirements;
1650    private javax.swing.JMenuItem generateScorecards;
1651    private javax.swing.JMenuItem helpAbout;
1652    private javax.swing.JMenu helpMenu;
1653    private javax.swing.JMenuItem helpTutorial;
1654    private javax.swing.JButton incidentCancelButton;
1655    private javax.swing.JColorChooser incidentColorChooser;
1656    private javax.swing.JTextField incidentColorField;
1657    private javax.swing.JMenuItem incidentDetails;
1658    private javax.swing.JFrame incidentFrame;
1659    private javax.swing.JMenu incidentMenu;
1660    private scriptbuilder.gui.panels.IncidentNumberPanel incidentNumberPanel1;
1661    private javax.swing.JButton incidentOkButton;
1662    private javax.swing.JPopupMenu incidentPopupMenu;
1663    private scriptbuilder.gui.panels.IncidentTimelinePanel incidentTimelinePanel1;
1664    private javax.swing.JButton jButton1;
1665    private javax.swing.JButton jButton2;
1666    private javax.swing.JButton jButton3;
1667    private javax.swing.JLabel jLabel10;
1668    private javax.swing.JLabel jLabel11;
1669    private javax.swing.JLabel jLabel12;
1670    private javax.swing.JLabel jLabel13;
1671    private javax.swing.JLabel jLabel14;
1672    private javax.swing.JLabel jLabel15;
1673    private javax.swing.JLabel jLabel16;
1674    private javax.swing.JLabel jLabel17;
1675    private javax.swing.JLabel jLabel20;
1676    private javax.swing.JLabel jLabel21;
1677    private javax.swing.JLabel jLabel5;
1678    private javax.swing.JLabel jLabel6;
1679    private javax.swing.JLabel jLabel7;
1680    private javax.swing.JLabel jLabel8;
1681    private javax.swing.JLabel jLabel9;
1682    private javax.swing.JMenuItem jMenuItem2;
1683    private javax.swing.JMenuItem jMenuItem3;
1684    private javax.swing.JMenuItem jMenuItem4;
1685    private javax.swing.JMenuItem jMenuItem5;
1686    private javax.swing.JMenuItem jMenuItem6;
1687    private javax.swing.JScrollPane jScrollPane1;
1688    private javax.swing.JPopupMenu.Separator jSeparator1;
1689    private javax.swing.JPopupMenu.Separator jSeparator2;
1690    private javax.swing.JPopupMenu.Separator jSeparator3;
1691    private javax.swing.JPopupMenu.Separator jSeparator4;
1692    private javax.swing.JSlider jSlider1;
1693    private javax.swing.JSlider jSlider2;
1694    private javax.swing.JSlider jSlider3;
1695    private javax.swing.JSlider jSlider4;
1696    private javax.swing.JSlider jSlider5;
1697    private javax.swing.JTextArea jTextArea1;
1698    private javax.swing.JMenuItem loadIncident;
1699    private javax.swing.JMenuItem newIncident;
1700    private javax.swing.JButton okButton;
1701    private javax.swing.JMenuItem popupDeleteIncident;
1702    private javax.swing.JMenuItem radioEvent;
1703    private javax.swing.JFrame radioEventFrame;
1704    private javax.swing.JTextArea radioMessage;
1705    private javax.swing.JScrollPane radioMessageScrollPane;
1706    private javax.swing.JComboBox radioTypeComboBox;
1707    private javax.swing.JLabel radioTypeLabel;
1708    private javax.swing.JMenuItem saveIncident;
1709    private javax.swing.JMenuBar scriptBuilderMenuBar;
1710    private scriptbuilder.gui.panels.TimeStampPanel timeStampPanel;
1711    private javax.swing.JScrollPane timeStampScrollPane;
1712    private scriptbuilder.gui.panels.TimelineTickPanel timelineTickPanel;
1713    private javax.swing.JScrollPane timelinesScrollPane;
1714    private javax.swing.JLabel zoomInIcon;
1715    private javax.swing.JLabel zoomOutIcon;
1716    private javax.swing.JSlider zoomSlider;
1717    // End of variables declaration//GEN-END:variables
1718}
Note: See TracBrowser for help on using the repository browser.