Changeset 253 in tmcsimulator for trunk/src


Ignore:
Timestamp:
02/10/2019 06:43:12 AM (7 years ago)
Author:
jdalbey
Message:

TrafficEventEditor?: Added file chooser to save button. TODO: Save the script to the selected file.

Location:
trunk/src/atmsdriver/trafficeventseditor
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/atmsdriver/trafficeventseditor/TrafficEventsEditor.form

    r247 r253  
    898898                  <EmptySpace pref="28" max="32767" attributes="0"/> 
    899899                  <Group type="103" groupAlignment="1" max="-2" attributes="0"> 
    900                       <Component id="jButton2" max="32767" attributes="0"/> 
     900                      <Component id="btnSave" max="32767" attributes="0"/> 
    901901                      <Component id="jButton1" max="32767" attributes="0"/> 
    902902                      <Component id="jButton3" alignment="0" max="32767" attributes="0"/> 
     
    912912                  <Component id="jButton1" min="-2" max="-2" attributes="0"/> 
    913913                  <EmptySpace max="-2" attributes="0"/> 
    914                   <Component id="jButton2" min="-2" max="-2" attributes="0"/> 
     914                  <Component id="btnSave" min="-2" max="-2" attributes="0"/> 
    915915                  <EmptySpace max="-2" attributes="0"/> 
    916916                  <Component id="jButton3" min="-2" max="-2" attributes="0"/> 
     
    926926          </Properties> 
    927927        </Component> 
    928         <Component class="javax.swing.JButton" name="jButton2"> 
     928        <Component class="javax.swing.JButton" name="btnSave"> 
    929929          <Properties> 
    930930            <Property name="text" type="java.lang.String" value="Save Script"/> 
    931931          </Properties> 
     932          <Events> 
     933            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSaveActionPerformed"/> 
     934          </Events> 
    932935        </Component> 
    933936        <Component class="javax.swing.JButton" name="jButton3"> 
  • trunk/src/atmsdriver/trafficeventseditor/TrafficEventsEditor.java

    r247 r253  
    1010import atmsdriver.model.LoopDetector.DOTCOLOR; 
    1111import atmsdriver.model.Station; 
     12import java.io.File; 
    1213import java.util.ArrayList; 
    1314import java.util.Enumeration; 
     
    1920import javax.swing.DefaultListSelectionModel; 
    2021import javax.swing.JComboBox; 
     22import javax.swing.JFileChooser; 
    2123import javax.swing.JList; 
    2224import javax.swing.JOptionPane; 
     
    398400        jPanel14 = new javax.swing.JPanel(); 
    399401        jButton1 = new javax.swing.JButton(); 
    400         jButton2 = new javax.swing.JButton(); 
     402        btnSave = new javax.swing.JButton(); 
    401403        jButton3 = new javax.swing.JButton(); 
    402404 
     
    895897        jButton1.setText("Load Script"); 
    896898 
    897         jButton2.setText("Save Script"); 
     899        btnSave.setText("Save Script"); 
     900        btnSave.addActionListener(new java.awt.event.ActionListener() 
     901        { 
     902            public void actionPerformed(java.awt.event.ActionEvent evt) 
     903            { 
     904                btnSaveActionPerformed(evt); 
     905            } 
     906        }); 
    898907 
    899908        jButton3.setText("Save Script As"); 
     
    906915                .addContainerGap(28, Short.MAX_VALUE) 
    907916                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) 
    908                     .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 
     917                    .addComponent(btnSave, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 
    909918                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 
    910919                    .addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 
     
    917926                .addComponent(jButton1) 
    918927                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
    919                 .addComponent(jButton2) 
     928                .addComponent(btnSave) 
    920929                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
    921930                .addComponent(jButton3) 
     
    10401049        timeFrames.cumulativePreviewHighways(); 
    10411050    }//GEN-LAST:event_CumulativeHighwaysPreviewButtonActionPerformed 
     1051 
     1052     /** 
     1053     * Shows the dialog for choosing a file to save the script data to. 
     1054     * @author jdalbey 
     1055     */ 
     1056    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnSaveActionPerformed 
     1057    {//GEN-HEADEREND:event_btnSaveActionPerformed 
     1058        boolean saved = false; 
     1059        JFileChooser chooser = new JFileChooser("."); 
     1060        int choice = chooser.showSaveDialog(chooser); 
     1061        if (choice == JFileChooser.APPROVE_OPTION) 
     1062        { 
     1063            File selectedFile = chooser.getSelectedFile(); 
     1064            //TODO: Save the script to the selected file 
     1065            JOptionPane.showMessageDialog(null, "Saving Not Implemented Yet"); 
     1066        } 
     1067//        return choice == JFileChooser.APPROVE_OPTION && saved; 
     1068    }//GEN-LAST:event_btnSaveActionPerformed 
    10421069 
    10431070    private DOTCOLOR getDotColorFromText(String text) 
     
    11421169    private javax.swing.JTable TrafficLaneEventsTable; 
    11431170    private javax.swing.JRadioButton YellowButton; 
     1171    private javax.swing.JButton btnSave; 
    11441172    private javax.swing.ButtonGroup colorRadioButtons; 
    11451173    private javax.swing.JButton jButton1; 
    1146     private javax.swing.JButton jButton2; 
    11471174    private javax.swing.JButton jButton3; 
    11481175    private javax.swing.JLabel jLabel1; 
Note: See TracChangeset for help on using the changeset viewer.