Changeset 101 in tmcsimulator-scriptbuilder
- Timestamp:
- 08/30/2017 10:05:35 AM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
-
event/editor/frame/Editor.form (modified) (3 diffs)
-
event/editor/frame/Editor.java (modified) (13 diffs)
-
event/editor/frame/PropertyModel.java (modified) (4 diffs)
-
scriptbuilder/gui/panels/IncidentTimelinePanel.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/event/editor/frame/Editor.form
r93 r101 287 287 <Group type="103" groupAlignment="0" attributes="0"> 288 288 <Component id="jTabbedPane1" alignment="1" max="32767" attributes="0"/> 289 <Component id="jPanel2" alignment="0" max="32767" attributes="0"/> 289 <Group type="102" alignment="0" attributes="0"> 290 <EmptySpace max="-2" attributes="0"/> 291 <Component id="txtEventStart" min="-2" max="-2" attributes="0"/> 292 <EmptySpace max="-2" attributes="0"/> 293 <Component id="jPanel2" max="32767" attributes="0"/> 294 <EmptySpace max="-2" attributes="0"/> 295 <Component id="btnRemoveCurrentEvent" min="-2" pref="226" max="-2" attributes="0"/> 296 <EmptySpace max="-2" attributes="0"/> 297 </Group> 290 298 </Group> 291 299 </DimensionLayout> … … 294 302 <Group type="102" alignment="0" attributes="0"> 295 303 <EmptySpace max="-2" attributes="0"/> 296 <Component id="jTabbedPane1" pref="539" max="32767" attributes="0"/> 297 <EmptySpace max="-2" attributes="0"/> 298 <Component id="jPanel2" min="-2" max="-2" attributes="0"/> 304 <Component id="jTabbedPane1" pref="534" max="32767" attributes="0"/> 305 <EmptySpace max="-2" attributes="0"/> 306 <Group type="103" groupAlignment="0" attributes="0"> 307 <Component id="jPanel2" min="-2" max="-2" attributes="0"/> 308 <Component id="txtEventStart" min="-2" max="-2" attributes="0"/> 309 <Component id="btnRemoveCurrentEvent" min="-2" max="-2" attributes="0"/> 310 </Group> 299 311 </Group> 300 312 </Group> … … 311 323 <DimensionLayout dim="0"> 312 324 <Group type="103" groupAlignment="0" attributes="0"> 313 <Group type="102" alignment="1" attributes="0"> 314 <EmptySpace pref="701" max="32767" attributes="0"/> 315 <Component id="btnRemoveCurrentEvent" min="-2" pref="226" max="-2" attributes="0"/> 316 <EmptySpace max="-2" attributes="0"/> 317 </Group> 325 <EmptySpace min="0" pref="613" max="32767" attributes="0"/> 318 326 </Group> 319 327 </DimensionLayout> 320 328 <DimensionLayout dim="1"> 321 329 <Group type="103" groupAlignment="0" attributes="0"> 322 < Component id="btnRemoveCurrentEvent" min="-2" max="-2" attributes="0"/>330 <EmptySpace min="0" pref="34" max="32767" attributes="0"/> 323 331 </Group> 324 332 </DimensionLayout> 325 333 </Layout> 326 <SubComponents>327 <Component class="javax.swing.JButton" name="btnRemoveCurrentEvent">328 <Properties>329 <Property name="text" type="java.lang.String" value="Remove This Event"/>330 </Properties>331 <Events>332 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnRemoveCurrentEventActionPerformed"/>333 </Events>334 </Component>335 </SubComponents>336 334 </Container> 335 <Component class="javax.swing.JTextField" name="txtEventStart"> 336 <Properties> 337 <Property name="text" type="java.lang.String" value="00:00:00"/> 338 </Properties> 339 </Component> 340 <Component class="javax.swing.JButton" name="btnRemoveCurrentEvent"> 341 <Properties> 342 <Property name="text" type="java.lang.String" value="Remove This Event"/> 343 </Properties> 344 <Events> 345 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnRemoveCurrentEventActionPerformed"/> 346 </Events> 347 </Component> 337 348 </SubComponents> 338 349 </Form> -
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 -
trunk/src/event/editor/frame/PropertyModel.java
r94 r101 18 18 import java.awt.event.ActionListener; 19 19 import java.util.EnumMap; 20 import java.util.HashMap; 20 21 import java.util.Observable; 21 22 import java.util.Observer; 23 import java.util.TreeMap; 22 24 import javax.swing.JPanel; 23 25 import scriptbuilder.structures.events.I_ScriptEvent; … … 34 36 private EnumMap<Properties, Class> classMap 35 37 = new EnumMap<Properties, Class>(Properties.class); 38 39 public HashMap<JPanel, I_ScriptEvent> eventMap = new HashMap<JPanel, I_ScriptEvent>(); 36 40 37 41 public PropertyModel() … … 60 64 } 61 65 62 public void add Property(Properties property, I_ScriptEvent se)66 public void addEventPanel(Properties property, I_ScriptEvent se) 63 67 { 64 68 try … … 69 73 if (panel instanceof I_ScriptEventEditorPanel) 70 74 { 75 eventMap.put(panel, se); 71 76 ((I_ScriptEventEditorPanel) panel).getEventObject(se); 72 77 } -
trunk/src/scriptbuilder/gui/panels/IncidentTimelinePanel.java
r98 r101 80 80 * event types. Values: Properties objects for those events. 81 81 */ 82 Map<ScriptEventType, Properties> eventTypeToPropertyMap;82 public static Map<ScriptEventType, Properties> eventTypeToPropertyMap; 83 83 84 84 /** … … 225 225 } 226 226 227 if (incident.slices.get(newSlice) != null) 228 229 { 230 for (I_ScriptEvent se : incident.slices.get(newSlice).events) 231 { 232 if (ed != null) 233 { 234 ed.addProperty(eventTypeToPropertyMap.get(se.getScriptEventType()), se); 235 } 236 } 237 } 227 if (ed != null) 228 { 229 ed.setSlice(incident.slices.get(newSlice)); 230 } 231 238 232 239 233 /** … … 250 244 if (ed != null) 251 245 { 252 ed.add Property(eventTypeToPropertyMap.get(g.currentEventType), s);246 ed.addEvent(eventTypeToPropertyMap.get(g.currentEventType), s); 253 247 } 254 248 if (incident.slices.get(newSlice) == null)
Note: See TracChangeset
for help on using the changeset viewer.
