Changeset 255 in tmcsimulator for trunk/src/atmsdriver/trafficeventseditor


Ignore:
Timestamp:
02/10/2019 11:46:05 AM (7 years ago)
Author:
jdalbey
Message:

TrafficEventsEditor? - modified to use JD's custom TimeSelectionDialog? for choosing new time frames.

File:
1 edited

Legend:

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

    r253 r255  
    1 /* 
    2  * To change this license header, choose License Headers in Project Properties. 
    3  * To change this template file, choose Tools | Templates 
    4  * and open the template in the editor. 
    5  */ 
    61package atmsdriver.trafficeventseditor; 
    72 
     
    105import atmsdriver.model.LoopDetector.DOTCOLOR; 
    116import atmsdriver.model.Station; 
     7import timeselector.*; 
    128import java.io.File; 
    139import java.util.ArrayList; 
     
    2016import javax.swing.DefaultListSelectionModel; 
    2117import javax.swing.JComboBox; 
     18import javax.swing.JDialog; 
    2219import javax.swing.JFileChooser; 
     20import javax.swing.JFrame; 
    2321import javax.swing.JList; 
    2422import javax.swing.JOptionPane; 
     23import javax.swing.JPanel; 
    2524import javax.swing.JTable; 
    2625import javax.swing.JTextField; 
     
    995994    private void addNewTimeFrameButtonClicked(java.awt.event.ActionEvent evt)//GEN-FIRST:event_addNewTimeFrameButtonClicked 
    996995    {//GEN-HEADEREND:event_addNewTimeFrameButtonClicked 
    997         // String name = JOptionPane.showInputDialog(this, "Enter a time frame (HH:MM:SS)"); 
    998         String[] hourChoices = getTimeChoices(); 
    999         String[] minChoices = getTimeChoices(); 
    1000         String[] secChoices = {"00", "30"}; 
    1001          
    1002         JComboBox hourCombo = new JComboBox(hourChoices); 
    1003         JComboBox minCombo = new JComboBox(minChoices); 
    1004         JComboBox secCombo = new JComboBox(secChoices); 
    1005          
    1006         Object[] message = { 
    1007             "Hour:", hourCombo, 
    1008             "Minute:", minCombo, 
    1009             "Second:", secCombo 
    1010         }; 
    1011         int option = JOptionPane.showConfirmDialog(this, message, "Enter a time frame:", JOptionPane.OK_CANCEL_OPTION); 
    1012         if(option == JOptionPane.OK_OPTION) 
    1013         { 
    1014             String h = hourCombo.getSelectedItem().toString(); 
    1015             String m = minCombo.getSelectedItem().toString(); 
    1016             String s = secCombo.getSelectedItem().toString(); 
    1017             String cum = h + ":" + m + ":" + s; 
    1018             timeFrames.addTimeFrame(cum); 
    1019         } 
    1020         /*if(name != null) 
    1021         { 
    1022             timeFrames.addTimeFrame(name); 
    1023         }*/ 
     996        // Obtain the time of the previous time frame 
     997        int size = timeFrames.frames.size(); 
     998        if (timeFrames.frames.size() > 0) 
     999        { 
     1000            String prevTime = timeFrames.frames.get(size-1).toString(); 
     1001        } 
     1002        // Show a dialog for the user to select a time in HH:MM:SS 
     1003        // TODO: this could be enhanced so it appears with previous time 
     1004        TimeSelectionDialog dialog = new TimeSelectionDialog((JFrame)this, true); 
     1005        dialog.setLocation(200,400); 
     1006        dialog.setVisible(true); 
     1007        // Add the new time frame 
     1008        timeFrames.addTimeFrame(dialog.getSelectedTime()); 
     1009        dialog.dispose(); 
     1010             
    10241011    }//GEN-LAST:event_addNewTimeFrameButtonClicked 
    10251012 
Note: See TracChangeset for help on using the changeset viewer.