Changeset 145 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder


Ignore:
Timestamp:
11/04/2019 08:14:32 AM (6 years ago)
Author:
sdanthin
Message:

Move from Git to Svn (LARGE COMMIT)

Location:
trunk/src/scriptbuilder
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scriptbuilder/gui/IncidentEditorFrame.java

    r135 r145  
    264264        cctvButton.addKeyListener(new TimelineKeyListener()); 
    265265        chpRadioButton.addKeyListener(new TimelineKeyListener()); 
     266        //todo: change paramics button to Traffic Modeler 
    266267        paramicsButton.addKeyListener(new TimelineKeyListener()); 
    267268        towButton.addKeyListener(new TimelineKeyListener()); 
     
    340341    public void update(Observable o, Object arg) 
    341342    { 
     343        System.out.println("the type of update is: " + arg.getClass()); 
    342344        //Three possibilities: This is a general script update, or it's one of 
    343345        //two different focus updates 
     
    366368        else if (arg instanceof SliceChangedEvent) 
    367369        { 
     370            System.out.println("you got the hover over a timeslice"); 
    368371            TimeSlice slice = ((SliceChangedEvent) arg).slice; 
    369372 
     
    17161719     * @param evt the mouse event 
    17171720     */ 
     1721    //todo: make the zoom slider more dynamic: when it is at completely zoomed out, show the entire timeline? 
    17181722    private void zoomInIconMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_zoomInIconMouseClicked 
    1719         zoomSlider.setValue(zoomSlider.getValue() >= 21 ? 21 : zoomSlider.getValue() + 1); 
     1723        //zoomSlider.setValue(zoomSlider.getValue() >= 21 ? 21 : zoomSlider.getValue() + 1); 
     1724        zoomSlider.setValue(zoomSlider.getValue() + 1); 
     1725 
    17201726    }//GEN-LAST:event_zoomInIconMouseClicked 
    17211727 
  • trunk/src/scriptbuilder/gui/ScriptBuilderFrame.form

    r129 r145  
    1313            <Property name="text" type="java.lang.String" value="Delete Incident..."/> 
    1414          </Properties> 
     15          <Events> 
     16            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="popupDeleteIncidentActionPerformed"/> 
     17          </Events> 
    1518        </MenuItem> 
    1619      </SubComponents> 
     
    241244        <DimensionLayout dim="0"> 
    242245          <Group type="103" groupAlignment="0" attributes="0"> 
    243               <Group type="102" alignment="1" attributes="0"> 
    244                   <EmptySpace max="-2" attributes="0"/> 
    245                   <Group type="103" groupAlignment="1" attributes="0"> 
     246              <Group type="102" attributes="0"> 
     247                  <EmptySpace max="-2" attributes="0"/> 
     248                  <Group type="103" groupAlignment="0" attributes="0"> 
    246249                      <Component id="incidentPropertiesScrollPane" alignment="0" pref="322" max="32767" attributes="0"/> 
    247                       <Component id="labelIncidentDescription" alignment="0" min="-2" max="-2" attributes="0"/> 
    248250                      <Group type="102" alignment="0" attributes="0"> 
    249251                          <Group type="103" groupAlignment="0" attributes="0"> 
     
    252254                              <Component id="labelIncidentColor" alignment="0" min="-2" max="-2" attributes="0"/> 
    253255                          </Group> 
    254                           <EmptySpace type="separate" max="-2" attributes="0"/> 
     256                          <EmptySpace min="-2" pref="66" max="-2" attributes="0"/> 
    255257                          <Group type="103" groupAlignment="0" attributes="0"> 
    256                               <Component id="addIncidentName" pref="218" max="32767" attributes="0"/> 
    257                               <Component id="addIncidentNumber" alignment="0" pref="218" max="32767" attributes="0"/> 
     258                              <Component id="addIncidentName" pref="199" max="32767" attributes="0"/> 
     259                              <Component id="addIncidentNumber" alignment="0" pref="199" max="32767" attributes="0"/> 
    258260                              <Group type="102" alignment="1" attributes="0"> 
    259                                   <Component id="incidentColorField" pref="119" max="32767" attributes="0"/> 
     261                                  <Component id="incidentColorField" pref="97" max="32767" attributes="0"/> 
    260262                                  <EmptySpace max="-2" attributes="0"/> 
    261263                                  <Component id="btnChooseColor" min="-2" pref="93" max="-2" attributes="0"/> 
     
    283285                          </Group> 
    284286                      </Group> 
     287                      <Group type="102" alignment="0" attributes="0"> 
     288                          <Component id="jLabel2" min="-2" max="-2" attributes="0"/> 
     289                          <EmptySpace min="-2" pref="93" max="-2" attributes="0"/> 
     290                          <Component id="addIncidentType" max="32767" attributes="0"/> 
     291                      </Group> 
     292                      <Group type="102" attributes="0"> 
     293                          <Component id="labelIncidentDescription" min="-2" max="-2" attributes="0"/> 
     294                          <EmptySpace min="0" pref="0" max="32767" attributes="0"/> 
     295                      </Group> 
     296                      <Group type="102" alignment="0" attributes="0"> 
     297                          <Component id="jLabel1" min="-2" max="-2" attributes="0"/> 
     298                          <EmptySpace min="-2" pref="69" max="-2" attributes="0"/> 
     299                          <Component id="addIncidentLocation" max="32767" attributes="0"/> 
     300                      </Group> 
    285301                  </Group> 
    286302                  <EmptySpace max="-2" attributes="0"/> 
     
    308324                  </Group> 
    309325                  <EmptySpace max="-2" attributes="0"/> 
     326                  <Group type="103" groupAlignment="3" attributes="0"> 
     327                      <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> 
     328                      <Component id="addIncidentLocation" alignment="3" min="-2" max="-2" attributes="0"/> 
     329                  </Group> 
     330                  <EmptySpace max="-2" attributes="0"/> 
     331                  <Group type="103" groupAlignment="3" attributes="0"> 
     332                      <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> 
     333                      <Component id="addIncidentType" alignment="3" min="-2" max="-2" attributes="0"/> 
     334                  </Group> 
     335                  <EmptySpace max="-2" attributes="0"/> 
    310336                  <Component id="labelIncidentDescription" min="-2" max="-2" attributes="0"/> 
    311337                  <EmptySpace max="-2" attributes="0"/> 
    312                   <Component id="incidentPropertiesScrollPane" pref="118" max="32767" attributes="0"/> 
     338                  <Component id="incidentPropertiesScrollPane" pref="130" max="32767" attributes="0"/> 
    313339                  <EmptySpace max="-2" attributes="0"/> 
    314340                  <Group type="103" groupAlignment="3" attributes="0"> 
     
    397423        </Component> 
    398424        <Component class="javax.swing.JTextField" name="addIncidentName"> 
     425          <Events> 
     426            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addIncidentNameActionPerformed"/> 
     427          </Events> 
    399428        </Component> 
    400429        <Component class="javax.swing.JLabel" name="labelIncidentLength"> 
     
    437466            <Property name="toolTipText" type="java.lang.String" value=""/> 
    438467          </Properties> 
     468        </Component> 
     469        <Component class="javax.swing.JLabel" name="jLabel1"> 
     470          <Properties> 
     471            <Property name="text" type="java.lang.String" value="Incident Location:"/> 
     472          </Properties> 
     473        </Component> 
     474        <Component class="javax.swing.JTextField" name="addIncidentLocation"> 
     475          <Events> 
     476            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addIncidentLocationActionPerformed"/> 
     477          </Events> 
     478        </Component> 
     479        <Component class="javax.swing.JLabel" name="jLabel2"> 
     480          <Properties> 
     481            <Property name="text" type="java.lang.String" value="Incident Type:"/> 
     482          </Properties> 
     483        </Component> 
     484        <Component class="javax.swing.JTextField" name="addIncidentType"> 
    439485        </Component> 
    440486      </SubComponents> 
     
    641687    </Component> 
    642688    <Menu class="javax.swing.JMenuBar" name="scriptBuilderMenuBar"> 
     689      <Events> 
     690        <EventHandler event="ancestorAdded" listener="javax.swing.event.AncestorListener" parameters="javax.swing.event.AncestorEvent" handler="scriptBuilderMenuBarAncestorAdded"/> 
     691      </Events> 
    643692      <SubComponents> 
    644693        <Menu class="javax.swing.JMenu" name="fileMenu"> 
     
    794843              </Events> 
    795844            </MenuItem> 
     845            <MenuItem class="javax.swing.JMenuItem" name="deleteIncident1"> 
     846              <Properties> 
     847                <Property name="text" type="java.lang.String" value="Edit Incident..."/> 
     848              </Properties> 
     849              <Events> 
     850                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="incidentDetailsActionPerformed"/> 
     851              </Events> 
     852            </MenuItem> 
    796853            <MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator4"> 
    797854            </MenuItem> 
     
    825882              <Events> 
    826883                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="generateNoiseOptionActionPerformed"/> 
     884              </Events> 
     885            </MenuItem> 
     886          </SubComponents> 
     887        </Menu> 
     888        <Menu class="javax.swing.JMenu" name="helpMenu1"> 
     889          <Properties> 
     890            <Property name="text" type="java.lang.String" value="Unit"/> 
     891            <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> 
     892              <Insets value="[0, 10, 0, 10]"/> 
     893            </Property> 
     894          </Properties> 
     895          <SubComponents> 
     896            <MenuItem class="javax.swing.JMenuItem" name="loadUnits"> 
     897              <Properties> 
     898                <Property name="text" type="java.lang.String" value="Load Units..."/> 
     899              </Properties> 
     900              <Events> 
     901                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="loadUnitsActionPerformed"/> 
    827902              </Events> 
    828903            </MenuItem> 
     
    862937  </NonVisualComponents> 
    863938  <Properties> 
    864     <Property name="defaultCloseOperation" type="int" value="3"/> 
     939    <Property name="defaultCloseOperation" type="int" value="0"/> 
    865940    <Property name="title" type="java.lang.String" value="Script Builder"/> 
    866941    <Property name="bounds" type="java.awt.Rectangle" editor="org.netbeans.beaninfo.editors.RectangleEditor"> 
  • trunk/src/scriptbuilder/gui/ScriptBuilderFrame.java

    r139 r145  
    1313import java.awt.event.KeyEvent; 
    1414import java.awt.event.KeyListener; 
     15import java.awt.event.WindowAdapter; 
     16import java.awt.event.WindowEvent; 
    1517import java.io.File; 
    1618import java.io.IOException; 
     19import java.io.FileNotFoundException; 
    1720import java.net.URI; 
    1821import java.util.Observable; 
     
    3841import scriptbuilder.structures.TimeSlice; 
    3942import scriptbuilder.structures.events.I_ScriptEvent; 
     43import scriptbuilder.structures.CadData; 
    4044 
    4145/** 
     
    152156        script.addObserver(this); 
    153157        initComponents(); 
     158        addCustomListeners(); 
     159        //add to listener helper method 
     160         
     161         
     162         
    154163        //We don't currently want the button to be present in this window 
    155164        btnAddTime.setVisible(false); 
     
    162171         */ 
    163172        // Set listener for scroll pane 
    164         String t = "Script Builder: "; 
    165         if (script.saveFile == null) 
    166         { 
    167             t += "untitled1.xml"; 
    168         } 
    169         else 
    170         { 
    171             t += script.saveFile.getName(); 
    172         } 
    173         this.setTitle(t); 
     173         
     174         
    174175        AdjustmentListener listener = new MyAdjustmentListener(); 
    175176        timelinesScrollPane.getHorizontalScrollBar().addAdjustmentListener(listener); 
     
    177178        repaint(); 
    178179 
     180    } 
     181     
     182    /** 
     183     * Put all custom non-generated listeners in this method 
     184     */ 
     185    private void addCustomListeners(){ 
     186         
     187        String fileName = "units.xml"; 
     188        File unitFile = new File(fileName); 
     189        script.loadUnitsFromFile(unitFile); 
     190        //listener for window closing 
     191        this.addWindowListener(new WindowAdapter(){ 
     192            @Override 
     193            public void windowClosing(WindowEvent e) 
     194            { 
     195                //System.out.println("Window is closing!" + saved); 
     196 
     197                if(!script.saved){ 
     198                    //System.out.println("window was not saved!"); 
     199                    Object[] options = {"Yes","No","Cancel"}; 
     200                    int result = JOptionPane.showOptionDialog(null,"Would you like to save changes before exiting?", 
     201                            "Exit", 
     202                            JOptionPane.YES_NO_CANCEL_OPTION, 
     203                            JOptionPane.QUESTION_MESSAGE, 
     204                            null, 
     205                            options, 
     206                            options[2]); 
     207                    switch (result){ 
     208                        //should save script then close 
     209                        case 0: 
     210                            fileSaveActionPerformed(null); 
     211                            //System.exit(0); 
     212                            break; 
     213                        // should just exit 
     214                        case 1: 
     215                            System.exit(0); 
     216                            break; 
     217                        // should do nothing 
     218                        case 2: 
     219                            break; 
     220                        default: 
     221                            break; 
     222                    } 
     223                     
     224                     
     225                     
     226                }else{ 
     227                    //should close current window since it is saved already 
     228                    System.exit(0); 
     229                } 
     230            } 
     231        }); 
    179232    } 
    180233 
     
    192245    public void update(Observable o, Object arg) 
    193246    { 
    194         //Three major update types: whole script, and 2 event updates 
     247        checkNeedsSave(); 
    195248        if (arg instanceof SimulationScript) 
    196249        { 
     250             
    197251            script = (SimulationScript) arg; 
    198252 
     
    236290             * model.addElement(i); } gotoIncident.setModel(model);* 
    237291             */ 
     292             
    238293            this.setPreferredSize(this.getSize()); 
    239294            pack(); 
     295             
    240296        } 
    241297        //Mouse has changed focus to a different timeslice 
     
    249305                model.addElement(e); 
    250306            } 
     307             
     308             
     309             
    251310        } 
    252311        //Mouse has changed focus to a different incident timeline panel  
     
    256315 
    257316            //gotoIncident.setSelectedItem(i); 
     317             
    258318        } 
    259319 
     
    267327        //scale the zoom slider such that the most zoomed-out point allows the 
    268328        //entire script to be visible at once 
     329         
     330        //todo: interpret these two calls and make them so that they are more accurate to fit the entire window at once 
    269331        zoomSlider.setMinimum(((timelineTickPanel.getVisibleRect().width - 20) 
    270332                * ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION) 
    271333                / Math.max(script.absoluteLength(), ScriptBuilderGuiConstants.TICK_TIMELINE_SMALLEST_LENGTH)); 
    272334        zoomSlider.setMaximum(zoomSlider.getMinimum() + 20); 
    273         String t = "Script Builder: "; 
    274         if (script.saveFile == null) 
    275         { 
    276             t += "untitled1.xml"; 
    277         } 
    278         else 
    279         { 
    280             t += script.saveFile.getName(); 
    281         } 
    282         this.setTitle(t); 
     335         
    283336        repaint(); 
    284337    } 
     
    291344    @SuppressWarnings("unchecked") 
    292345    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 
    293     private void initComponents() 
    294     { 
     346    private void initComponents() { 
    295347 
    296348        incidentPopupMenu = new javax.swing.JPopupMenu(); 
     
    333385        incidentColorField = new javax.swing.JTextField(); 
    334386        txtIncidentLength = new javax.swing.JLabel(); 
     387        jLabel1 = new javax.swing.JLabel(); 
     388        addIncidentLocation = new javax.swing.JTextField(); 
     389        jLabel2 = new javax.swing.JLabel(); 
     390        addIncidentType = new javax.swing.JTextField(); 
    335391        addNoiseFrame = new javax.swing.JFrame(); 
    336392        labelRadioChatter = new javax.swing.JLabel(); 
     
    396452        newIncident = new javax.swing.JMenuItem(); 
    397453        deleteIncident = new javax.swing.JMenuItem(); 
     454        deleteIncident1 = new javax.swing.JMenuItem(); 
    398455        jSeparator4 = new javax.swing.JPopupMenu.Separator(); 
    399456        saveIncident = new javax.swing.JMenuItem(); 
     
    401458        generateNoiseMenu = new javax.swing.JMenu(); 
    402459        generateNoiseOption = new javax.swing.JMenuItem(); 
     460        helpMenu1 = new javax.swing.JMenu(); 
     461        loadUnits = new javax.swing.JMenuItem(); 
    403462        helpMenu = new javax.swing.JMenu(); 
    404463        helpTutorial = new javax.swing.JMenuItem(); 
     
    406465 
    407466        popupDeleteIncident.setText("Delete Incident..."); 
     467        popupDeleteIncident.addActionListener(new java.awt.event.ActionListener() { 
     468            public void actionPerformed(java.awt.event.ActionEvent evt) { 
     469                popupDeleteIncidentActionPerformed(evt); 
     470            } 
     471        }); 
    408472        incidentPopupMenu.add(popupDeleteIncident); 
    409473 
    410474        cadEvent.setText("CAD Event"); 
    411         cadEvent.addMouseListener(new java.awt.event.MouseAdapter() 
    412         { 
    413             public void mousePressed(java.awt.event.MouseEvent evt) 
    414             { 
     475        cadEvent.addMouseListener(new java.awt.event.MouseAdapter() { 
     476            public void mousePressed(java.awt.event.MouseEvent evt) { 
    415477                cadEventMousePressed(evt); 
    416478            } 
    417             public void mouseReleased(java.awt.event.MouseEvent evt) 
    418             { 
     479            public void mouseReleased(java.awt.event.MouseEvent evt) { 
    419480                cadEventMouseReleased(evt); 
    420481            } 
    421482        }); 
    422         cadEvent.addActionListener(new java.awt.event.ActionListener() 
    423         { 
    424             public void actionPerformed(java.awt.event.ActionEvent evt) 
    425             { 
     483        cadEvent.addActionListener(new java.awt.event.ActionListener() { 
     484            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    426485                cadEventActionPerformed(evt); 
    427486            } 
     
    433492 
    434493        radioEvent.setText("Radio Event"); 
    435         radioEvent.addMouseListener(new java.awt.event.MouseAdapter() 
    436         { 
    437             public void mousePressed(java.awt.event.MouseEvent evt) 
    438             { 
     494        radioEvent.addMouseListener(new java.awt.event.MouseAdapter() { 
     495            public void mousePressed(java.awt.event.MouseEvent evt) { 
    439496                radioEventMousePressed(evt); 
    440497            } 
     
    490547 
    491548        okButton.setText("OK"); 
    492         okButton.addActionListener(new java.awt.event.ActionListener() 
    493         { 
    494             public void actionPerformed(java.awt.event.ActionEvent evt) 
    495             { 
     549        okButton.addActionListener(new java.awt.event.ActionListener() { 
     550            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    496551                okButtonActionPerformed(evt); 
    497552            } 
     
    499554 
    500555        cancelButton.setText("Cancel"); 
    501         cancelButton.addActionListener(new java.awt.event.ActionListener() 
    502         { 
    503             public void actionPerformed(java.awt.event.ActionEvent evt) 
    504             { 
     556        cancelButton.addActionListener(new java.awt.event.ActionListener() { 
     557            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    505558                cancelButtonActionPerformed(evt); 
    506559            } 
     
    545598 
    546599        editEventList.setText("Edit..."); 
    547         editEventList.addActionListener(new java.awt.event.ActionListener() 
    548         { 
    549             public void actionPerformed(java.awt.event.ActionEvent evt) 
    550             { 
     600        editEventList.addActionListener(new java.awt.event.ActionListener() { 
     601            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    551602                editEventListActionPerformed(evt); 
    552603            } 
     
    578629 
    579630        incidentOkButton.setText("OK"); 
    580         incidentOkButton.addActionListener(new java.awt.event.ActionListener() 
    581         { 
    582             public void actionPerformed(java.awt.event.ActionEvent evt) 
    583             { 
     631        incidentOkButton.addActionListener(new java.awt.event.ActionListener() { 
     632            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    584633                incidentOkButtonActionPerformed(evt); 
    585634            } 
     
    587636 
    588637        incidentCancelButton.setText("Cancel"); 
    589         incidentCancelButton.addActionListener(new java.awt.event.ActionListener() 
    590         { 
    591             public void actionPerformed(java.awt.event.ActionEvent evt) 
    592             { 
     638        incidentCancelButton.addActionListener(new java.awt.event.ActionListener() { 
     639            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    593640                incidentCancelButtonActionPerformed(evt); 
    594641            } 
    595642        }); 
    596643 
    597         addIncidentNumber.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(101), Integer.valueOf(101), null, Integer.valueOf(1))); 
     644        addIncidentNumber.setModel(new javax.swing.SpinnerNumberModel(101, 101, null, 1)); 
     645 
     646        addIncidentName.addActionListener(new java.awt.event.ActionListener() { 
     647            public void actionPerformed(java.awt.event.ActionEvent evt) { 
     648                addIncidentNameActionPerformed(evt); 
     649            } 
     650        }); 
    598651 
    599652        labelIncidentLength.setText("Incident Length in Minutes: "); 
     
    601654        labelIncidentStart.setText("Incident Start Time in Minutes:"); 
    602655 
    603         addIncidentStart.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1))); 
     656        addIncidentStart.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1)); 
    604657 
    605658        btnChooseColor.setText("Choose..."); 
    606         btnChooseColor.addActionListener(new java.awt.event.ActionListener() 
    607         { 
    608             public void actionPerformed(java.awt.event.ActionEvent evt) 
    609             { 
     659        btnChooseColor.addActionListener(new java.awt.event.ActionListener() { 
     660            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    610661                btnChooseColorActionPerformed(evt); 
    611662            } 
     
    618669        txtIncidentLength.setText("0"); 
    619670        txtIncidentLength.setToolTipText(""); 
     671 
     672        jLabel1.setText("Incident Location:"); 
     673 
     674        addIncidentLocation.addActionListener(new java.awt.event.ActionListener() { 
     675            public void actionPerformed(java.awt.event.ActionEvent evt) { 
     676                addIncidentLocationActionPerformed(evt); 
     677            } 
     678        }); 
     679 
     680        jLabel2.setText("Incident Type:"); 
    620681 
    621682        javax.swing.GroupLayout incidentFrameLayout = new javax.swing.GroupLayout(incidentFrame.getContentPane()); 
     
    623684        incidentFrameLayout.setHorizontalGroup( 
    624685            incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
    625             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, incidentFrameLayout.createSequentialGroup() 
     686            .addGroup(incidentFrameLayout.createSequentialGroup() 
    626687                .addContainerGap() 
    627                 .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 
    628                     .addComponent(incidentPropertiesScrollPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE) 
    629                     .addComponent(labelIncidentDescription, javax.swing.GroupLayout.Alignment.LEADING) 
    630                     .addGroup(javax.swing.GroupLayout.Alignment.LEADING, incidentFrameLayout.createSequentialGroup() 
     688                .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
     689                    .addComponent(incidentPropertiesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE) 
     690                    .addGroup(incidentFrameLayout.createSequentialGroup() 
    631691                        .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
    632692                            .addComponent(labelIncidentNumber) 
    633693                            .addComponent(labelIncidentName) 
    634694                            .addComponent(labelIncidentColor)) 
    635                         .addGap(18, 18, 18) 
     695                        .addGap(66, 66, 66) 
    636696                        .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
    637                             .addComponent(addIncidentName, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE) 
    638                             .addComponent(addIncidentNumber, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE) 
     697                            .addComponent(addIncidentName, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE) 
     698                            .addComponent(addIncidentNumber, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE) 
    639699                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, incidentFrameLayout.createSequentialGroup() 
    640                                 .addComponent(incidentColorField, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE) 
     700                                .addComponent(incidentColorField, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE) 
    641701                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
    642702                                .addComponent(btnChooseColor, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)))) 
    643                     .addGroup(javax.swing.GroupLayout.Alignment.LEADING, incidentFrameLayout.createSequentialGroup() 
     703                    .addGroup(incidentFrameLayout.createSequentialGroup() 
    644704                        .addComponent(incidentCancelButton) 
    645705                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 188, Short.MAX_VALUE) 
    646706                        .addComponent(incidentOkButton, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)) 
    647                     .addGroup(javax.swing.GroupLayout.Alignment.LEADING, incidentFrameLayout.createSequentialGroup() 
     707                    .addGroup(incidentFrameLayout.createSequentialGroup() 
    648708                        .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
    649709                            .addComponent(labelIncidentStart) 
     
    655715                                .addComponent(txtIncidentLength, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 
    656716                                .addGap(22, 22, 22)) 
    657                             .addComponent(addIncidentStart, javax.swing.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE)))) 
     717                            .addComponent(addIncidentStart, javax.swing.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE))) 
     718                    .addGroup(incidentFrameLayout.createSequentialGroup() 
     719                        .addComponent(jLabel2) 
     720                        .addGap(93, 93, 93) 
     721                        .addComponent(addIncidentType)) 
     722                    .addGroup(incidentFrameLayout.createSequentialGroup() 
     723                        .addComponent(labelIncidentDescription) 
     724                        .addGap(0, 0, Short.MAX_VALUE)) 
     725                    .addGroup(incidentFrameLayout.createSequentialGroup() 
     726                        .addComponent(jLabel1) 
     727                        .addGap(69, 69, 69) 
     728                        .addComponent(addIncidentLocation))) 
    658729                .addContainerGap()) 
    659730        ); 
     
    675746                    .addComponent(incidentColorField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 
    676747                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
     748                .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 
     749                    .addComponent(jLabel1) 
     750                    .addComponent(addIncidentLocation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 
     751                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
     752                .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 
     753                    .addComponent(jLabel2) 
     754                    .addComponent(addIncidentType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 
     755                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
    677756                .addComponent(labelIncidentDescription) 
    678757                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
    679                 .addComponent(incidentPropertiesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE) 
     758                .addComponent(incidentPropertiesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE) 
    680759                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
    681760                .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 
     
    726805 
    727806        btnCancelNoise.setText("Cancel"); 
    728         btnCancelNoise.addActionListener(new java.awt.event.ActionListener() 
    729         { 
    730             public void actionPerformed(java.awt.event.ActionEvent evt) 
    731             { 
     807        btnCancelNoise.addActionListener(new java.awt.event.ActionListener() { 
     808            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    732809                btnCancelNoiseActionPerformed(evt); 
    733810            } 
     
    735812 
    736813        btnGenerateNoise.setText("Generate"); 
    737         btnGenerateNoise.addActionListener(new java.awt.event.ActionListener() 
    738         { 
    739             public void actionPerformed(java.awt.event.ActionEvent evt) 
    740             { 
     814        btnGenerateNoise.addActionListener(new java.awt.event.ActionListener() { 
     815            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    741816                btnGenerateNoiseActionPerformed(evt); 
    742817            } 
     
    817892        ); 
    818893 
    819         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 
     894        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); 
    820895        setTitle("Script Builder"); 
    821896        setBounds(new java.awt.Rectangle(0, 23, 800, 700)); 
     
    11871262        zoomSlider.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); 
    11881263        zoomSlider.setFocusable(false); 
    1189         zoomSlider.addChangeListener(new javax.swing.event.ChangeListener() 
    1190         { 
    1191             public void stateChanged(javax.swing.event.ChangeEvent evt) 
    1192             { 
     1264        zoomSlider.addChangeListener(new javax.swing.event.ChangeListener() { 
     1265            public void stateChanged(javax.swing.event.ChangeEvent evt) { 
    11931266                zoomSliderStateChanged(evt); 
    11941267            } 
     
    11971270        zoomInIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ZoomIn.png"))); // NOI18N 
    11981271        zoomInIcon.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); 
    1199         zoomInIcon.addMouseListener(new java.awt.event.MouseAdapter() 
    1200         { 
    1201             public void mouseClicked(java.awt.event.MouseEvent evt) 
    1202             { 
     1272        zoomInIcon.addMouseListener(new java.awt.event.MouseAdapter() { 
     1273            public void mouseClicked(java.awt.event.MouseEvent evt) { 
    12031274                zoomInIconMouseClicked(evt); 
    12041275            } 
     
    12071278        zoomOutIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ZoomOut.png"))); // NOI18N 
    12081279        zoomOutIcon.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); 
    1209         zoomOutIcon.addMouseListener(new java.awt.event.MouseAdapter() 
    1210         { 
    1211             public void mouseClicked(java.awt.event.MouseEvent evt) 
    1212             { 
     1280        zoomOutIcon.addMouseListener(new java.awt.event.MouseAdapter() { 
     1281            public void mouseClicked(java.awt.event.MouseEvent evt) { 
    12131282                zoomOutIconMouseClicked(evt); 
    12141283            } 
     
    12331302 
    12341303        btnAddTime.setText("+15:00"); 
    1235         btnAddTime.addActionListener(new java.awt.event.ActionListener() 
    1236         { 
    1237             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1238             { 
     1304        btnAddTime.addActionListener(new java.awt.event.ActionListener() { 
     1305            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    12391306                btnAddTimeActionPerformed(evt); 
     1307            } 
     1308        }); 
     1309 
     1310        scriptBuilderMenuBar.addAncestorListener(new javax.swing.event.AncestorListener() { 
     1311            public void ancestorMoved(javax.swing.event.AncestorEvent evt) { 
     1312            } 
     1313            public void ancestorAdded(javax.swing.event.AncestorEvent evt) { 
     1314                scriptBuilderMenuBarAncestorAdded(evt); 
     1315            } 
     1316            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { 
    12401317            } 
    12411318        }); 
     
    12431320        fileMenu.setText("File"); 
    12441321        fileMenu.setMargin(new java.awt.Insets(0, 10, 0, 10)); 
    1245         fileMenu.addActionListener(new java.awt.event.ActionListener() 
    1246         { 
    1247             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1248             { 
     1322        fileMenu.addActionListener(new java.awt.event.ActionListener() { 
     1323            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    12491324                fileMenuActionPerformed(evt); 
    12501325            } 
     
    12531328        fileNew.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); 
    12541329        fileNew.setText("New"); 
    1255         fileNew.addActionListener(new java.awt.event.ActionListener() 
    1256         { 
    1257             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1258             { 
     1330        fileNew.addActionListener(new java.awt.event.ActionListener() { 
     1331            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    12591332                fileNewActionPerformed(evt); 
    12601333            } 
     
    12651338        fileOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); 
    12661339        fileOpen.setText("Open..."); 
    1267         fileOpen.addActionListener(new java.awt.event.ActionListener() 
    1268         { 
    1269             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1270             { 
     1340        fileOpen.addActionListener(new java.awt.event.ActionListener() { 
     1341            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    12711342                fileOpenActionPerformed(evt); 
    12721343            } 
     
    12771348        fileSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); 
    12781349        fileSave.setText("Save"); 
    1279         fileSave.addActionListener(new java.awt.event.ActionListener() 
    1280         { 
    1281             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1282             { 
     1350        fileSave.addActionListener(new java.awt.event.ActionListener() { 
     1351            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    12831352                fileSaveActionPerformed(evt); 
    12841353            } 
     
    12881357        fileSaveAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); 
    12891358        fileSaveAs.setText("Save as..."); 
    1290         fileSaveAs.addActionListener(new java.awt.event.ActionListener() 
    1291         { 
    1292             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1293             { 
     1359        fileSaveAs.addActionListener(new java.awt.event.ActionListener() { 
     1360            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    12941361                fileSaveAsActionPerformed(evt); 
    12951362            } 
     
    13041371        generateNotebooks.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK)); 
    13051372        generateNotebooks.setText("Generate Notebooks..."); 
    1306         generateNotebooks.addActionListener(new java.awt.event.ActionListener() 
    1307         { 
    1308             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1309             { 
     1373        generateNotebooks.addActionListener(new java.awt.event.ActionListener() { 
     1374            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    13101375                generateNotebooksActionPerformed(evt); 
    13111376            } 
     
    13151380        generateWebNotebook.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK)); 
    13161381        generateWebNotebook.setText("Generate Web Notebook..."); 
    1317         generateWebNotebook.addActionListener(new java.awt.event.ActionListener() 
    1318         { 
    1319             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1320             { 
     1382        generateWebNotebook.addActionListener(new java.awt.event.ActionListener() { 
     1383            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    13211384                generateWebNotebookActionPerformed(evt); 
    13221385            } 
     
    13261389        generateScorecards.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK)); 
    13271390        generateScorecards.setText("Generate Scorecards..."); 
    1328         generateScorecards.addActionListener(new java.awt.event.ActionListener() 
    1329         { 
    1330             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1331             { 
     1391        generateScorecards.addActionListener(new java.awt.event.ActionListener() { 
     1392            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    13321393                generateScorecardsActionPerformed(evt); 
    13331394            } 
     
    13371398        generateOrganizationChart.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK)); 
    13381399        generateOrganizationChart.setText("Generate D14 TMC Org Chart..."); 
    1339         generateOrganizationChart.addActionListener(new java.awt.event.ActionListener() 
    1340         { 
    1341             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1342             { 
     1400        generateOrganizationChart.addActionListener(new java.awt.event.ActionListener() { 
     1401            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    13431402                generateOrganizationChartActionPerformed(evt); 
    13441403            } 
     
    13491408        generateProjectRequirements.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK)); 
    13501409        generateProjectRequirements.setText("Generate Project Worklist..."); 
    1351         generateProjectRequirements.addActionListener(new java.awt.event.ActionListener() 
    1352         { 
    1353             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1354             { 
     1410        generateProjectRequirements.addActionListener(new java.awt.event.ActionListener() { 
     1411            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    13551412                generateProjectRequirementsActionPerformed(evt); 
    13561413            } 
     
    13641421 
    13651422        newIncident.setText("New Incident..."); 
    1366         newIncident.addActionListener(new java.awt.event.ActionListener() 
    1367         { 
    1368             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1369             { 
     1423        newIncident.addActionListener(new java.awt.event.ActionListener() { 
     1424            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    13701425                newIncidentActionPerformed(evt); 
    13711426            } 
     
    13741429 
    13751430        deleteIncident.setText("Delete Incident"); 
    1376         deleteIncident.addActionListener(new java.awt.event.ActionListener() 
    1377         { 
    1378             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1379             { 
     1431        deleteIncident.addActionListener(new java.awt.event.ActionListener() { 
     1432            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    13801433                deleteIncidentActionPerformed(evt); 
    13811434            } 
    13821435        }); 
    13831436        incidentMenu.add(deleteIncident); 
     1437 
     1438        deleteIncident1.setText("Edit Incident..."); 
     1439        deleteIncident1.addActionListener(new java.awt.event.ActionListener() { 
     1440            public void actionPerformed(java.awt.event.ActionEvent evt) { 
     1441                incidentDetailsActionPerformed(evt); 
     1442            } 
     1443        }); 
     1444        incidentMenu.add(deleteIncident1); 
    13841445        incidentMenu.add(jSeparator4); 
    13851446 
    13861447        saveIncident.setText("Save Incident..."); 
    1387         saveIncident.addActionListener(new java.awt.event.ActionListener() 
    1388         { 
    1389             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1390             { 
     1448        saveIncident.addActionListener(new java.awt.event.ActionListener() { 
     1449            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    13911450                saveIncidentActionPerformed(evt); 
    13921451            } 
     
    13951454 
    13961455        loadIncident.setText("Load Incident..."); 
    1397         loadIncident.addActionListener(new java.awt.event.ActionListener() 
    1398         { 
    1399             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1400             { 
     1456        loadIncident.addActionListener(new java.awt.event.ActionListener() { 
     1457            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    14011458                loadIncidentActionPerformed(evt); 
    14021459            } 
     
    14091466 
    14101467        generateNoiseOption.setText("Generate Noise..."); 
    1411         generateNoiseOption.addActionListener(new java.awt.event.ActionListener() 
    1412         { 
    1413             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1414             { 
     1468        generateNoiseOption.addActionListener(new java.awt.event.ActionListener() { 
     1469            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    14151470                generateNoiseOptionActionPerformed(evt); 
    14161471            } 
     
    14191474 
    14201475        scriptBuilderMenuBar.add(generateNoiseMenu); 
     1476 
     1477        helpMenu1.setText("Unit"); 
     1478        helpMenu1.setMargin(new java.awt.Insets(0, 10, 0, 10)); 
     1479 
     1480        loadUnits.setText("Load Units..."); 
     1481        loadUnits.addActionListener(new java.awt.event.ActionListener() { 
     1482            public void actionPerformed(java.awt.event.ActionEvent evt) { 
     1483                loadUnitsActionPerformed(evt); 
     1484            } 
     1485        }); 
     1486        helpMenu1.add(loadUnits); 
     1487 
     1488        scriptBuilderMenuBar.add(helpMenu1); 
    14211489 
    14221490        helpMenu.setText("Help"); 
     
    14251493        helpTutorial.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0)); 
    14261494        helpTutorial.setText("Tutorial..."); 
    1427         helpTutorial.addActionListener(new java.awt.event.ActionListener() 
    1428         { 
    1429             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1430             { 
     1495        helpTutorial.addActionListener(new java.awt.event.ActionListener() { 
     1496            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    14311497                helpTutorialActionPerformed(evt); 
    14321498            } 
     
    14351501 
    14361502        helpAbout.setText("About..."); 
    1437         helpAbout.addActionListener(new java.awt.event.ActionListener() 
    1438         { 
    1439             public void actionPerformed(java.awt.event.ActionEvent evt) 
    1440             { 
     1503        helpAbout.addActionListener(new java.awt.event.ActionListener() { 
     1504            public void actionPerformed(java.awt.event.ActionEvent evt) { 
    14411505                helpAboutActionPerformed(evt); 
    14421506            } 
     
    15741638            SimulationScript.incidentColors[indx] = selectedColor; 
    15751639            // Add the new incident to the list 
     1640            //todo: need to add new data to the ScriptIncident Object here 
    15761641            script.incidents.add(indx, 
    15771642                    new ScriptIncident(SimulationScript.incidentColors[indx], 
    15781643                            (Integer) addIncidentNumber.getValue(), addIncidentName.getText(), addIncidentDescription.getText(), 
    1579                             script)); 
     1644                            script,0)); 
     1645             
    15801646            script.incidents.get(indx).setOffset((Integer) addIncidentStart.getValue() * 60); 
     1647            script.incidents.get(indx).insertCadData((Integer) addIncidentStart.getValue(), new CadData(addIncidentType.getText(),addIncidentLocation.getText())); 
    15811648            script.numberOfIncidents++; 
     1649             
    15821650            IncidentEditorFrame editor = new IncidentEditorFrame(script.incidents.get(indx), this); 
    15831651 
     
    15941662            //change offset of incident 
    15951663            script.incidents.get(oldIncidentIndex).setOffset(((int) addIncidentStart.getValue()) * 60); 
     1664             
     1665            script.incidents.get(oldIncidentIndex).insertCadData((int) addIncidentStart.getValue() * 60, new CadData(addIncidentType.getText(),addIncidentLocation.getText())); 
    15961666            //update incident number, if it was changed 
    15971667            if ((int) addIncidentNumber.getValue() == script.incidents.get(oldIncidentIndex).number 
     
    16131683        repaint(); 
    16141684    }//GEN-LAST:event_incidentOkButtonActionPerformed 
    1615  
    1616     /** 
     1685    /** 
     1686     * Calling this will check to see if the model has been updated.  
     1687     * @param save indicated whether or not the file needs to be saved 
     1688     */ 
     1689    private void checkNeedsSave(){ 
     1690         
     1691        if(!script.saved){ 
     1692            changeFrameTitle("*"); 
     1693        }else{ 
     1694            changeFrameTitle(""); 
     1695        } 
     1696    } 
     1697    /** 
     1698     *  
     1699     * @param ext changes title by putting ext after current title.  
     1700     */ 
     1701    private void changeFrameTitle(String ext){ 
     1702        String t = "Script Builder: "; 
     1703        if (script.saveFile == null) 
     1704        { 
     1705            t += "untitled1.xml"; 
     1706        } 
     1707        else 
     1708        { 
     1709            t += script.saveFile.getName(); 
     1710        } 
     1711        t+= ext; 
     1712        this.setTitle(t); 
     1713    } 
     1714    /** 
     1715     *  
    16171716     * Determine if the given incident number is already present in the script. 
    16181717     * 
     
    16531752 
    16541753        addIncidentName.setText(""); 
    1655  
    16561754        int newLogNum = 100; 
    16571755        boolean found = false; 
     
    16821780        selectedColor = Color.BLACK; 
    16831781        addIncidentDescription.setText(""); 
     1782        addIncidentLocation.setText(""); 
     1783        addIncidentType.setText(""); 
    16841784 
    16851785        incidentFrame.setVisible(true); 
     
    17111811            script.saveFile = fc.getSelectedFile(); 
    17121812        } 
     1813         
    17131814        this.update(script, script); 
    17141815        //zoom out all the way so that the whole imported script is visible 
     
    17361837            } 
    17371838            script.saveFile = new File("" + fName + untitledCount + ".xml"); 
     1839             
    17381840        } 
    17391841 
     
    17551857            script.saveScriptToFile(new File(filename)); 
    17561858            script.saveFile = new File(filename); 
     1859             
    17571860        } 
    17581861        else 
     
    17631866            } 
    17641867        } 
     1868         
    17651869        this.update(script, 0); 
    17661870    }//GEN-LAST:event_fileSaveAsActionPerformed 
     
    17821886        else 
    17831887        { 
     1888             
    17841889            script.saveScriptToFile(script.saveFile); 
    17851890        } 
     1891        //TODO: TEST TO MAKE SURE THIS DOES NOT CREATE BADDIES 
     1892        this.update(script, 0); 
    17861893    }//GEN-LAST:event_fileSaveActionPerformed 
    17871894 
     
    18091916        addIncidentName.setText(i.name); 
    18101917        addIncidentNumber.setValue(i.number); 
     1918        addIncidentLocation.setText(i.getCadData(i.offset).Header_FullLoc); 
     1919        addIncidentType.setText(i.getCadData(i.offset).Header_Type); 
    18111920        addIncidentStart.setValue(i.offset / 60); 
    18121921        txtIncidentLength.setText("" + (i.length / 60)); 
     
    21062215    {//GEN-HEADEREND:event_fileNewActionPerformed 
    21072216        script = new SimulationScript(); 
     2217        String fileName = "units.xml"; 
     2218        File f = new File(fileName); 
     2219        script.loadUnitsFromFile(f); 
    21082220        script.update(); 
    21092221        this.update(null, script); 
     
    21572269                    script.incidents.add(null); 
    21582270                    script.numberOfIncidents--; 
     2271                     
    21592272                } 
    21602273            } 
    21612274        } 
     2275        //since delete is the only method in this class that actually edits the data model, needs .update() 
     2276        script.update(); 
    21622277        //Refresh 
    21632278        this.update(script, script); 
     2279         
     2280         
    21642281        repaint(); 
    21652282    }//GEN-LAST:event_deleteIncidentActionPerformed 
     
    22202337// TODO add your handling code here: 
    22212338    }//GEN-LAST:event_helpTutorialActionPerformed 
     2339 
     2340    private void addIncidentLocationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addIncidentLocationActionPerformed 
     2341        // TODO add your handling code here: 
     2342    }//GEN-LAST:event_addIncidentLocationActionPerformed 
     2343 
     2344    private void addIncidentNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addIncidentNameActionPerformed 
     2345        // TODO add your handling code here: 
     2346    }//GEN-LAST:event_addIncidentNameActionPerformed 
     2347 
     2348    private void incidentDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_incidentDetailsActionPerformed 
     2349        // TODO add your handling code here: 
     2350        Object[] incidentList = script.incidents.toArray(); 
     2351        ScriptIncident i = (ScriptIncident) JOptionPane.showInputDialog( 
     2352                this, 
     2353                "Select Incident:", 
     2354                "Edit Incident", 
     2355                JOptionPane.PLAIN_MESSAGE, 
     2356                null, 
     2357                incidentList, 
     2358                script.incidents.get(0)); 
     2359 
     2360        // If a valid incident was selected 
     2361        if (i != null) 
     2362        { 
     2363            editingIncident = true; 
     2364            oldIncidentIndex = script.incidents.indexOf(i); 
     2365 
     2366            addIncidentName.setText(i.name); 
     2367            addIncidentNumber.setValue(i.number); 
     2368             
     2369            addIncidentLocation.setText(i.getCadData(i.offset).Header_FullLoc); 
     2370            addIncidentType.setText(i.getCadData(i.offset).Header_Type); 
     2371            addIncidentStart.setValue(i.offset / 60); 
     2372            //addIncidentLength.setValue(i.length / 60); 
     2373            incidentColorField.setBackground(i.color); 
     2374            selectedColor = i.color; 
     2375            addIncidentDescription.setText(i.description); 
     2376 
     2377            incidentFrame.setVisible(true); 
     2378        } 
     2379    }//GEN-LAST:event_incidentDetailsActionPerformed 
     2380 
     2381    private void popupDeleteIncidentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_popupDeleteIncidentActionPerformed 
     2382        // TODO add your handling code here: 
     2383    }//GEN-LAST:event_popupDeleteIncidentActionPerformed 
     2384 
     2385    private void loadUnitsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadUnitsActionPerformed 
     2386        // TODO: needs to have testing performed 
     2387        JFileChooser fc = new JFileChooser(); 
     2388 
     2389        //Search for .xml files 
     2390        fc.setFileFilter(new ExtensionFileFilter("Simulation Script XML (.xml)", 
     2391                new String[] 
     2392                { 
     2393                    "xml" 
     2394                })); 
     2395        if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) 
     2396        { 
     2397            //load script with values from the selected file 
     2398            script.loadUnitsFromFile(fc.getSelectedFile()); 
     2399        } 
     2400    }//GEN-LAST:event_loadUnitsActionPerformed 
     2401 
     2402    private void scriptBuilderMenuBarAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_scriptBuilderMenuBarAncestorAdded 
     2403        //loads in the initial unit file 
     2404//        String fileName = "units.xml"; 
     2405//         
     2406//        File f = new File(fileName); 
     2407//         
     2408//        script.loadUnitsFromFile(f); 
     2409    }//GEN-LAST:event_scriptBuilderMenuBarAncestorAdded 
    22222410 
    22232411    /** 
     
    22922480    private javax.swing.JSlider TMCALSlider; 
    22932481    private javax.swing.JTextArea addIncidentDescription; 
     2482    private javax.swing.JTextField addIncidentLocation; 
    22942483    private javax.swing.JTextField addIncidentName; 
    22952484    private javax.swing.JSpinner addIncidentNumber; 
    22962485    private javax.swing.JSpinner addIncidentStart; 
     2486    private javax.swing.JTextField addIncidentType; 
    22972487    private javax.swing.JFrame addNoiseFrame; 
    22982488    private javax.swing.JSlider backgroundNoiseSlider; 
     
    23062496    private javax.swing.JMenuItem deleteEventList; 
    23072497    private javax.swing.JMenuItem deleteIncident; 
     2498    private javax.swing.JMenuItem deleteIncident1; 
    23082499    private javax.swing.JMenuItem editEventList; 
    23092500    private javax.swing.JPopupMenu eventListPopupMenu; 
     
    23242515    private javax.swing.JMenuItem helpAbout; 
    23252516    private javax.swing.JMenu helpMenu; 
     2517    private javax.swing.JMenu helpMenu1; 
    23262518    private javax.swing.JMenuItem helpTutorial; 
    23272519    private javax.swing.JButton incidentCancelButton; 
     
    23532545    private scriptbuilder.gui.panels.IncidentTimelinePanel incidentTimelinePanel8; 
    23542546    private scriptbuilder.gui.panels.IncidentTimelinePanel incidentTimelinePanel9; 
     2547    private javax.swing.JLabel jLabel1; 
     2548    private javax.swing.JLabel jLabel2; 
    23552549    private javax.swing.JMenuItem jMenuItem2; 
    23562550    private javax.swing.JMenuItem jMenuItem4; 
     
    23792573    private javax.swing.JSlider laneClosuresSlider; 
    23802574    private javax.swing.JMenuItem loadIncident; 
     2575    private javax.swing.JMenuItem loadUnits; 
    23812576    private javax.swing.JSlider minorEventsSlider; 
    23822577    private javax.swing.JMenuItem newIncident; 
  • trunk/src/scriptbuilder/gui/ScriptBuilderGuiConstants.java

    r32 r145  
    1616{ 
    1717    public static int       PIXEL_WIDTH_PER_HORIZONTAL_TICK = 24; 
    18     public static final int HORIZONTAL_TICK_RESOLUTION = 60, 
     18    public static final int HORIZONTAL_TICK_RESOLUTION = 20,//changes how wide each tick in the timeline panel is. can add every X seconds 
    1919                            TIMELINE_TOP_MARGIN = 25, 
    2020                            MAX_NUMBER_OF_SCRIPT_EVENT_ICON = 10, 
  • trunk/src/scriptbuilder/gui/application.properties

    r144 r145  
    1 #Tue, 09 Jan 2018 11:31:37 -0800 
     1#Thu, 31 Oct 2019 16:04:24 -0700 
    22 
    3 Application.revision=143 
     3Application.revision=144 
    44 
    5 Application.buildnumber=38 
     5Application.buildnumber=43 
    66 
    77Incidents.directory=Incidents 
  • trunk/src/scriptbuilder/gui/drawers/CursorDrawer.java

    r1 r145  
    8181                + (seconds / 60 % 60 > 9 ? seconds / 60 % 60 
    8282                : "0" + seconds / 60 % 60) 
    83                 + ":00", 
     83                + ":" + (seconds % 60)/10  + "0", 
    8484                x - ScriptBuilderGuiConstants.CURSOR_TIMESTAMP_TEXT_CENTER, 
    8585                ScriptBuilderGuiConstants.CURSOR_TIMESTAMP_TEXT_TOP_MARGIN); 
  • trunk/src/scriptbuilder/gui/drawers/TimeSliceDrawer.java

    r76 r145  
    7272            return; 
    7373        } 
    74  
     74        //System.out.println("new slice"); 
    7575        // Draw the slice event icon to show that there are events here 
    7676        g2d.drawImage(getSliceEventImage(), slice.getX() 
  • trunk/src/scriptbuilder/gui/panels/IncidentTimelinePanel.java

    r133 r145  
    202202         * Determine if the mouse click happened within a valid timeSlice on 
    203203         * this incident; if so, activate the Editor window for that timeSlice. 
    204          * 
    205          * @param e the mouse event 
     204         *todo: fix bug where the event editor window appears even when a event type is not selected. 
     205         * @param clickEvent the mouse event 
    206206         */ 
    207207        @Override 
    208         public void mouseClicked(MouseEvent e) 
    209         { 
    210             Editor ed = null; 
    211             ScriptBuilderFrame f = null; 
    212             IncidentEditorFrame g = null; 
     208        public void mouseClicked(MouseEvent clickEvent) 
     209        { 
     210            Editor editor = null; 
     211            ScriptBuilderFrame scriptBuilderFrameCurrent = null; 
     212            IncidentEditorFrame incidentEditFrameCurrent = null; 
    213213            if (getTopLevelAncestor() instanceof ScriptBuilderFrame) 
    214214            { 
    215                 f = (ScriptBuilderFrame) getTopLevelAncestor(); 
     215                scriptBuilderFrameCurrent = (ScriptBuilderFrame) getTopLevelAncestor(); 
    216216 
    217217            } 
    218218            else if (getTopLevelAncestor() instanceof IncidentEditorFrame) 
    219219            { 
    220                 g = (IncidentEditorFrame) getTopLevelAncestor(); 
    221                 ed = new Editor(g); 
    222             } 
    223  
    224             x = cursorTime = e.getX(); 
    225             y = e.getY(); 
    226  
    227             if (e.getX() % ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK 
     220                incidentEditFrameCurrent = (IncidentEditorFrame) getTopLevelAncestor(); 
     221                editor = new Editor(incidentEditFrameCurrent); 
     222            } 
     223 
     224            x = cursorTime = clickEvent.getX(); 
     225            y = clickEvent.getY(); 
     226            //System.out.println(cursorTime); 
     227            //logic that follows is used to "snap" the cursor location to the lines displayed on the timeline panel 
     228            if (clickEvent.getX() % ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK 
    228229                    > ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK / 2) 
    229230            { 
    230231                cursorTime += ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK 
    231                         - e.getX() 
     232                        - clickEvent.getX() 
    232233                        % ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK; 
    233234            } 
    234235            else 
    235236            { 
    236                 cursorTime -= e.getX() 
     237                cursorTime -= clickEvent.getX() 
    237238                        % ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK; 
    238239            } 
    239240 
    240241            int newSlice = (cursorTime / ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK); 
     242             
    241243            newSlice *= ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION; 
    242244            /** 
     
    248250            } 
    249251 
    250             if (ed != null) 
    251             { 
    252                 ed.setSlice(incident.slices.get(newSlice)); 
    253             } 
     252             
    254253 
    255254            /** 
    256              * Add a new icon if left mouse button was clicked * 
     255             * Add a new icon if left mouse button was clicked  
    257256             */ 
    258             if (e.getButton() == MouseEvent.BUTTON1) 
    259             { 
    260  
     257            if (clickEvent.getButton() == MouseEvent.BUTTON1) 
     258            { 
     259                 
    261260                if (getTopLevelAncestor() instanceof IncidentEditorFrame) 
    262261                { 
    263                     if (incident.slices.size() == 0 && newSlice != 0) 
     262                     
     263                    if (incidentEditFrameCurrent.currentEventType != null) 
    264264                    { 
    265                         JOptionPane.showMessageDialog(g, "This is the first event in the incident.\n" 
    266                                 + "Therefore, it will be automatically positioned at time 00:00:00,\n" 
    267                                 + "relative to the start of the incident.", "Event will be moved", JOptionPane.INFORMATION_MESSAGE); 
    268                         newSlice = 0; 
    269                     } 
    270                     if (g.currentEventType != null) 
    271                     { 
    272                         I_ScriptEvent s = ScriptEvent.factoryByType(g.currentEventType); 
    273                         if (ed != null) 
     265                        if ((incident.slices.size() == 0 && newSlice != 0)||(incident.slices.get(0).events.isEmpty())) 
    274266                        { 
    275                             ed.addEvent(eventTypeToPropertyMap.get(g.currentEventType), s); 
     267                             
     268                            JOptionPane.showMessageDialog(incidentEditFrameCurrent, "This is the first event in the incident.\n" 
     269                                    + "Therefore, it will be automatically positioned at time 00:00:00,\n" 
     270                                    + "relative to the start of the incident.", "Event will be moved", JOptionPane.INFORMATION_MESSAGE); 
     271                            newSlice = 0; 
    276272                        } 
    277                         if (incident.slices.get(newSlice) == null) 
     273                        //add the time of addition to be passed through to the event itself somewhere in here? Stored in newSlice 
     274                        I_ScriptEvent newScriptEvent = ScriptEvent.factoryByType(incidentEditFrameCurrent.currentEventType); 
     275//                        if (editor != null) 
     276//                        { 
     277//                            //this is not necessary if we just load the slices after we create a new one in the window, creates some extra dummy slice for no reason. 
     278//                            //this adds a new event to the existing editor window 
     279//                            editor.addEvent(eventTypeToPropertyMap.get(incidentEditFrameCurrent.currentEventType), newScriptEvent); 
     280//                        } 
     281                        if (incident.slices.get(newSlice) == null || incident.slices.get(newSlice).events.isEmpty()) 
    278282                        { 
    279                             incident.addNewEvent(s, newSlice); 
     283                            //if there is no slice at the newSlice time, then create a new event with a new slice at that time 
     284                             
     285                            incident.addNewEvent(newScriptEvent, newSlice); 
     286                            //find out where the new slice is added and then make it 
     287                            //possible to  
     288                            //editor.setSlice(incident.getSlices().get(newSlice)); 
    280289                        } 
    281290                        else 
    282291                        { 
    283                             incident.slices.get(newSlice).addEvent(s); 
     292                            //if there is already a slice there, just add the event to the  
     293                            incident.slices.get(newSlice).addEvent(newScriptEvent); 
    284294                        } 
    285                         g.update(null, g.getIncident()); 
     295                        incidentEditFrameCurrent.update(null, incidentEditFrameCurrent.getIncident()); 
    286296                    } 
    287297                } 
    288298            } 
    289299 
     300            if (editor != null) 
     301            { 
     302                editor.setSlice(incident.slices.get(newSlice)); 
     303            } 
    290304            if (incident.slices.get(newSlice) != null 
    291305                    && getTopLevelAncestor() instanceof IncidentEditorFrame) 
    292306            { 
    293                 ed.setVisible(true); 
     307                editor.setVisible(true); 
    294308            } 
    295309        } 
     
    498512        if (focused) 
    499513        { 
     514            //System.out.println("Cursor Time: " + cursorTime); 
    500515            CursorDrawer.DrawCursor(g2d, cursorTime, false); 
    501516            if (this.getTopLevelAncestor() instanceof ScriptBuilderFrame) 
  • trunk/src/scriptbuilder/structures/CadData.java

    r143 r145  
    1515        locInfo = new ArrayList<Location_Info>(); 
    1616    } 
     17     
     18    /** 
     19     * Constructor to add type and location, where TruncLoc is the first 5 letters of the fullloc. 
     20     * @param Header_Type 
     21     * @param Header_FullLoc  
     22     */ 
     23    public CadData(String Header_Type, String Header_FullLoc) 
     24    { 
     25        this.Header_Type = Header_Type; 
     26        this.Header_FullLoc = Header_FullLoc; 
     27//        if(Header_FullLoc.length()>10) 
     28//        { 
     29//            this.Header_TruncLoc = Header_FullLoc.substring(0,9); 
     30//        } 
     31        this.Header_TruncLoc = Header_FullLoc; 
     32        locInfo = new ArrayList<Location_Info>(); 
     33    } 
    1734 
    1835    public TimeSlice tSlice; 
    1936 
    20     public String Header_Type = "DEFAULT"; 
     37    public String Header_Type = ""; 
    2138 
    2239    public String Header_Beat = ""; 
    2340 
    24     public String Header_TruncLoc = "Default Location (short)"; 
    25  
    26     public String Header_FullLoc = "Default Location (long)"; 
     41    public String Header_TruncLoc = ""; 
     42 
     43    public String Header_FullLoc = ""; 
    2744 
    2845    public String Master_Inc_Num = ""; 
     
    134151        } 
    135152 
    136         if (hasHeaderInfo() || true) //checking to see if header info is always necessary 
    137         { 
     153        if (hasHeaderInfo()) //checking to see if header info is always necessary 
     154        { 
     155            //todo: make this logic trigger only once per incident 
    138156            output += XMLWriter.openTag(ELEMENT.HEADER_INFO.tag); 
    139157 
  • trunk/src/scriptbuilder/structures/ELEMENT.java

    r138 r145  
    3535    LOCATION_INFO, 
    3636    NEW_UNIT, 
     37    //todo: change this paramics to traffic modeler 
    3738    PARAMICS,//EVENT 
    3839    RADIO_EVALUATION, 
  • trunk/src/scriptbuilder/structures/MyScriptHandler.java

    r138 r145  
    304304 
    305305        docPosition.push(ELEMENT.byName(qName)); 
    306  
     306         
    307307        try 
    308308        { 
     
    612612     * SAX Handler method. Executes at the close of each XML element. 
    613613     */ 
     614    //todo: interpret this function better so that what is loaded from the XML file is easier to know. 
    614615    @Override 
    615616    public void endElement(String uri, String localName, String qName) 
     
    670671            { 
    671672                cad.Header_Type = pcData.remove(currentElement); 
     673//                //change where the data is loaded in here 
     674//                currInc.insertCadData((int) currentEventTime, cad); 
    672675            } 
    673676            else if (currentElement == ELEMENT.Beat && docPosition.peek() == ELEMENT.HEADER_INFO) 
  • trunk/src/scriptbuilder/structures/ScriptEvent.java

    r107 r145  
    8383    public int length; 
    8484     
    85     private TimeSlice slice; 
     85    public TimeSlice slice; 
    8686 
    8787    /** 
  • trunk/src/scriptbuilder/structures/ScriptIncident.java

    r131 r145  
    4646     */ 
    4747    public String description; 
    48  
     48     
    4949    /** 
    5050     * Length, in seconds, of the incident. 
     
    7272    public int eventCount = 0; 
    7373 
    74     SimulationScript script; 
     74    public SimulationScript script; 
    7575 
    7676    /** 
     
    135135        this.setOffset(offset); 
    136136    } 
     137     
     138//    /** 
     139//     * Constructor with type and location parameters. 
     140//     * @param color 
     141//     * @param number 
     142//     * @param name 
     143//     * @param description 
     144//     * @param script 
     145//     * @param offset 
     146//     * @param type 
     147//     * @param location  
     148//     */ 
     149//    public ScriptIncident(Color color, int number, String name, 
     150//            String description, SimulationScript script, 
     151//            int offset, String type, String location) 
     152//    { 
     153//        this.color = color; 
     154//        this.number = number; 
     155//        this.name = name; 
     156//        this.description = description; 
     157//        this.script = script; 
     158//        slices = new TreeMap<Integer, TimeSlice>(); 
     159//        this.setOffset(offset); 
     160//        this.location = location; 
     161//        this.type = type; 
     162//        insertCadData(offset, new CadData(type,location)); 
     163//    } 
    137164 
    138165    /** 
     
    293320    } 
    294321 
    295     void insertCadData(long currentEventTime, CadData cad) 
     322    public void insertCadData(long currentEventTime, CadData cad) 
    296323    { 
    297324        int time = (int) currentEventTime; 
     
    305332        slice = slices.get(time); 
    306333        slice.cadData = cad; 
     334    } 
     335     
     336    public CadData getCadData(long currentEventTime) 
     337    { 
     338        int time = (int) currentEventTime; 
     339        TimeSlice slice; 
     340         
     341        slice = slices.get(time); 
     342        return slice.cadData; 
    307343    } 
    308344 
  • trunk/src/scriptbuilder/structures/SimulationScript.java

    r131 r145  
    2121 * 
    2222 * @author Bryan McGuffin <bmcguffi@calpoly.edu> 
     23 * @author Sebastien Danthinne <sdanthin@calpoly.edu> 
    2324 * @version 2017/06/22 
    2425 */ 
     
    6162     * The units which participate in Unit events. 
    6263     */ 
    63     public List<Unit> units; 
     64    public List<Unit> units;  
    6465 
    6566    //Somewhere in the code, something assumes that the list of incidents 
    6667    //contains exactly 10 items. Until I can find and un-break that, this will do. 
     68    //todo: this incident fill count error 
    6769    private final int INCIDENT_FILL_COUNT = 10; 
    6870 
     
    7678     */ 
    7779    private MyScriptHandler sh; 
     80     
     81    public boolean saved; 
    7882 
    7983    //TODO: Pretty much everything in this constructor is dummy data. 
     
    8993        units = new ArrayList<Unit>(); 
    9094        numberOfIncidents = 0; 
     95        saved = true; 
    9196 
    9297        //Backfill with null incidents 
     
    96101        } 
    97102    } 
    98  
     103     
     104    /** 
     105     * checks and sees if this object has the unit passed. 
     106     * @param unitID 
     107     * @return does this SimulationScript have unitnum? 
     108     */ 
     109    public boolean hasUnit(String unitID){ 
     110        boolean indicator = false; 
     111        if(units.size()!=0){ 
     112            for(Unit u : units){ 
     113               if(unitID.equals(u.UnitNum)){ 
     114                   indicator = true; 
     115               } 
     116            } 
     117        } 
     118             
     119        return indicator; 
     120    } 
     121    /** 
     122     * creates a dummy unit that only has unit number 
     123     * @param unitNum  
     124     */ 
     125    public void addDummyUnit(String unitNum){ 
     126        Unit dummy = new Unit(); 
     127        dummy.UnitNum = unitNum; 
     128        units.add(dummy); 
     129    } 
    99130    /** 
    100131     * Update the script's observers. 
    101      * 
     132     *  
    102133     */ 
    103134    public void update() 
    104135    { 
    105136        // The script has changed, notify observers 
     137        //use to rewrite the save indicator 
     138        //System.out.println("Script changed"); 
    106139        setChanged(); 
    107140        notifyObservers(this); 
    108     } 
     141        saved = false; 
     142         
     143         
     144    } 
     145     
    109146 
    110147    /** 
     
    154191        { 
    155192            System.out.println("ERROR LOADING SCRIPT"); 
     193            ex.printStackTrace(); 
     194        } 
     195        System.out.println("H"); 
     196        for(Unit testUnit : units){ 
     197            System.out.println(testUnit.toXML()); 
     198        } 
     199        this.update(); 
     200    } 
     201     
     202    /** 
     203     * Load in an existing list of units from an XML file. 
     204     * @param f the file containing the units 
     205     */ 
     206    public void loadUnitsFromFile(File f){ 
     207        try 
     208        { 
     209            SAXParserFactory.newInstance().newSAXParser().parse(f, sh); 
     210            units.addAll(sh.getUnits()); 
     211        } 
     212        catch (Exception ex) 
     213        { 
     214            System.out.println("ERROR LOADING UNITS"); 
    156215            ex.printStackTrace(); 
    157216        } 
     
    197256            ex.printStackTrace(); 
    198257        } 
     258        saved = true; 
    199259    } 
    200260 
  • trunk/src/scriptbuilder/structures/TimeSlice.java

    r142 r145  
    5656    } 
    5757 
     58     
     59    public ScriptIncident getIncident(){ 
     60        return thisIncident; 
     61    } 
    5862    /** 
    5963     * Add a new script event to this time slice. Sort events by event type. 
     
    7781    public int getX() 
    7882    { 
     83//        System.out.println("position: " + seconds / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION 
     84//                * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK); 
    7985        return seconds / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION 
    8086                * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK; 
     
    210216    public String toXML() 
    211217    { 
     218        //eventsCopy2 is used to clear out eventsCopy with one element contained 
    212219        ArrayList<I_ScriptEvent> eventsCopy = new ArrayList<I_ScriptEvent>(); 
    213220        ArrayList<I_ScriptEvent> eventsCopy2 = new ArrayList<I_ScriptEvent>(); 
  • trunk/src/scriptbuilder/structures/events/UnitEvent.java

    r76 r145  
    2222    /** 
    2323     * Constructor. 
     24     * //TODO: when created, add a unit to the main units list that is contained within SimulationScript 
    2425     */ 
    2526    public UnitEvent() 
    2627    { 
     28         
    2729        super(ScriptEventType.UNIT_EVENT); 
     30         
    2831    } 
    2932 
  • trunk/src/scriptbuilder/structures/units/Unit.java

    r46 r145  
    102102        Unit_Status = ""; 
    103103    } 
     104     
     105    public boolean equals(Unit u){ 
     106        return UnitNum.equals(u.UnitNum); 
     107    } 
     108    public boolean equals(String num){ 
     109        return UnitNum.equals(num); 
     110    } 
    104111 
    105112    @Override 
Note: See TracChangeset for help on using the changeset viewer.