Changeset 101 in tmcsimulator-scriptbuilder for trunk/src/event/editor/frame/Editor.java
- Timestamp:
- 08/30/2017 10:05:35 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/event/editor/frame/Editor.java (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/event/editor/frame/Editor.java
r97 r101 8 8 import java.util.*; 9 9 import java.awt.event.*; 10 import java.text.SimpleDateFormat; 10 11 import scriptbuilder.gui.IncidentEditorFrame; 12 import scriptbuilder.gui.panels.IncidentTimelinePanel; 13 import scriptbuilder.structures.ScriptEvent; 11 14 import scriptbuilder.structures.ScriptIncident; 15 import scriptbuilder.structures.TimeSlice; 12 16 import scriptbuilder.structures.events.*; 13 17 … … 16 20 17 21 IncidentEditorFrame topFrame = null; 22 23 ScriptIncident incident = null; 24 25 TimeSlice slice = null; 18 26 19 27 private PropertyModel model = new PropertyModel(); … … 23 31 // return model; 24 32 // } 25 public void addProperty(Properties property, I_ScriptEvent se) 26 { 27 model.addProperty(property, se); 33 public void addEvent(Properties property, I_ScriptEvent se) 34 { 35 model.addEventPanel(property, se); 36 } 37 38 public void setSlice(TimeSlice ts) 39 { 40 slice = ts; 41 42 if (slice != null) 43 44 { 45 for (I_ScriptEvent se : slice.events) 46 { 47 48 this.addEvent(IncidentTimelinePanel.eventTypeToPropertyMap.get(se.getScriptEventType()), se); 49 50 } 51 System.out.println("Current time = " + slice.getTime() + " seconds"); 52 SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss"); 53 df.setTimeZone(TimeZone.getTimeZone("GMT")); 54 String eventTime = df.format(new Date(slice.getTime() * 1000)); 55 System.out.println("[" + eventTime + "]"); 56 txtEventStart.setText(eventTime); 57 } 58 28 59 } 29 60 … … 37 68 if (src.isSelected()) 38 69 { 39 model.add Property(property, new CCTVEvent());70 model.addEventPanel(property, new CCTVEvent()); 40 71 } 41 72 else … … 51 82 { 52 83 JMenuItem src = (JMenuItem) evt.getSource(); 53 model.add Property(Properties.valueOf(src.getText().replaceAll(" ", "")), new CCTVEvent());84 model.addEventPanel(Properties.valueOf(src.getText().replaceAll(" ", "")), new CCTVEvent()); 54 85 } 55 86 }; … … 62 93 topFrame = frame; 63 94 initComponents(); 95 96 incident = frame.getIncident(); 64 97 65 98 model.addObserver(this); … … 91 124 } 92 125 } 126 127 String eventTime = ""; 128 129 txtEventStart.setText(eventTime); 130 131 txtEventStart.addKeyListener(new KeyListener() 132 { 133 134 @Override 135 public void keyTyped(KeyEvent e) 136 { 137 } 138 139 @Override 140 public void keyPressed(KeyEvent e) 141 { 142 if (e.getKeyCode() == KeyEvent.VK_ENTER) 143 { 144 updateEventTime(); 145 } 146 } 147 148 @Override 149 public void keyReleased(KeyEvent e) 150 { 151 } 152 }); 93 153 } 94 154 … … 106 166 jTabbedPane1 = new javax.swing.JTabbedPane(); 107 167 jPanel2 = new javax.swing.JPanel(); 168 txtEventStart = new javax.swing.JTextField(); 108 169 btnRemoveCurrentEvent = new javax.swing.JButton(); 109 170 jMenuBar1 = new javax.swing.JMenuBar(); … … 143 204 setTitle("Event Editor"); 144 205 145 btnRemoveCurrentEvent.setText("Remove This Event");146 btnRemoveCurrentEvent.addActionListener(new java.awt.event.ActionListener()147 {148 public void actionPerformed(java.awt.event.ActionEvent evt)149 {150 btnRemoveCurrentEventActionPerformed(evt);151 }152 });153 154 206 org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); 155 207 jPanel2.setLayout(jPanel2Layout); 156 208 jPanel2Layout.setHorizontalGroup( 157 209 jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 158 .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup() 159 .addContainerGap(701, Short.MAX_VALUE) 160 .add(btnRemoveCurrentEvent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 226, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 161 .addContainerGap()) 210 .add(0, 613, Short.MAX_VALUE) 162 211 ); 163 212 jPanel2Layout.setVerticalGroup( 164 213 jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 165 .add( btnRemoveCurrentEvent)214 .add(0, 34, Short.MAX_VALUE) 166 215 ); 216 217 txtEventStart.setText("00:00:00"); 218 219 btnRemoveCurrentEvent.setText("Remove This Event"); 220 btnRemoveCurrentEvent.addActionListener(new java.awt.event.ActionListener() 221 { 222 public void actionPerformed(java.awt.event.ActionEvent evt) 223 { 224 btnRemoveCurrentEventActionPerformed(evt); 225 } 226 }); 167 227 168 228 jMenu1.setText("Evaluations"); … … 347 407 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 348 408 .add(org.jdesktop.layout.GroupLayout.TRAILING, jTabbedPane1) 349 .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 409 .add(layout.createSequentialGroup() 410 .addContainerGap() 411 .add(txtEventStart, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 412 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 413 .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 414 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 415 .add(btnRemoveCurrentEvent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 226, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 416 .addContainerGap()) 350 417 ); 351 418 layout.setVerticalGroup( … … 353 420 .add(layout.createSequentialGroup() 354 421 .addContainerGap() 355 .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 53 9, Short.MAX_VALUE)422 .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 534, Short.MAX_VALUE) 356 423 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 357 .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 424 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 425 .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 426 .add(txtEventStart, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 427 .add(btnRemoveCurrentEvent))) 358 428 ); 359 429 … … 386 456 387 457 }//GEN-LAST:event_btnRemoveCurrentEventActionPerformed 458 459 private void updateEventTime() 460 { 461 String[] tokens = txtEventStart.getText().split(":"); 462 463 int hrs = Integer.parseInt(tokens[0]); 464 int mins = Integer.parseInt(tokens[1]); 465 int secs = Integer.parseInt(tokens[2]); 466 467 int time = (3600 * hrs) + (60 * mins) + secs; 468 469 int index = jTabbedPane1.getSelectedIndex(); 470 471 if (index >= 0 && jTabbedPane1.getTabComponentAt(index) != null) 472 { 473 JPanel removable = (JPanel) jTabbedPane1 474 .getSelectedComponent(); 475 I_ScriptEvent ise = this.model.eventMap.get(removable); 476 if (time != slice.getTime()) 477 { 478 System.out.println("New time = " + time); 479 this.model.properties.removeProperty(removable); 480 incident.addNewEvent(ise, time); 481 SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss"); 482 df.setTimeZone(TimeZone.getTimeZone("GMT")); 483 String eventTime = df.format(new Date(slice.getTime() * 1000)); 484 txtEventStart.setText(eventTime); 485 } 486 } 487 } 388 488 389 489 /** … … 427 527 private javax.swing.JPanel jPanel2; 428 528 private javax.swing.JTabbedPane jTabbedPane1; 529 private javax.swing.JTextField txtEventStart; 429 530 // End of variables declaration//GEN-END:variables 430 531
Note: See TracChangeset
for help on using the changeset viewer.
