| 1 | package event.editor.frame; |
|---|
| 2 | |
|---|
| 3 | import event.editor.I_ScriptEventEditorPanel; |
|---|
| 4 | import java.awt.BorderLayout; |
|---|
| 5 | import java.awt.Color; |
|---|
| 6 | import java.awt.FlowLayout; |
|---|
| 7 | import javax.swing.*; |
|---|
| 8 | import java.util.*; |
|---|
| 9 | import java.awt.event.*; |
|---|
| 10 | import java.text.SimpleDateFormat; |
|---|
| 11 | import scriptbuilder.gui.IncidentEditorFrame; |
|---|
| 12 | import scriptbuilder.gui.ScriptBuilderFrame; |
|---|
| 13 | import scriptbuilder.gui.panels.IncidentTimelinePanel; |
|---|
| 14 | import scriptbuilder.structures.ScriptEvent; |
|---|
| 15 | import scriptbuilder.structures.ScriptIncident; |
|---|
| 16 | import scriptbuilder.structures.TimeSlice; |
|---|
| 17 | import scriptbuilder.structures.events.*; |
|---|
| 18 | |
|---|
| 19 | public class Editor extends javax.swing.JFrame implements Observer |
|---|
| 20 | { |
|---|
| 21 | |
|---|
| 22 | IncidentEditorFrame topFrame = null; |
|---|
| 23 | |
|---|
| 24 | ScriptIncident incident = null; |
|---|
| 25 | |
|---|
| 26 | TimeSlice slice = null; |
|---|
| 27 | |
|---|
| 28 | private PropertyModel model = new PropertyModel(); |
|---|
| 29 | |
|---|
| 30 | // public PropertyModel getPropertyModel() |
|---|
| 31 | // { |
|---|
| 32 | // return model; |
|---|
| 33 | // } |
|---|
| 34 | public void addEvent(Properties property, I_ScriptEvent se) |
|---|
| 35 | { |
|---|
| 36 | model.addEventPanel(property, se); |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | public void setSlice(TimeSlice ts) |
|---|
| 40 | { |
|---|
| 41 | slice = ts; |
|---|
| 42 | |
|---|
| 43 | if (slice != null) |
|---|
| 44 | |
|---|
| 45 | { |
|---|
| 46 | for (I_ScriptEvent se : slice.events) |
|---|
| 47 | { |
|---|
| 48 | |
|---|
| 49 | this.addEvent(IncidentTimelinePanel.eventTypeToPropertyMap.get(se.getScriptEventType()), se); |
|---|
| 50 | |
|---|
| 51 | } |
|---|
| 52 | System.out.println("Current time = " + slice.getTime() + " seconds"); |
|---|
| 53 | SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss"); |
|---|
| 54 | df.setTimeZone(TimeZone.getTimeZone("GMT")); |
|---|
| 55 | String eventTime = df.format(new Date(slice.getTime() * 1000)); |
|---|
| 56 | System.out.println("[" + eventTime + "]"); |
|---|
| 57 | txtEventStart.setText(eventTime); |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | private ActionListener optionalChangeListener = new ActionListener() |
|---|
| 63 | { |
|---|
| 64 | public void actionPerformed(ActionEvent evt) |
|---|
| 65 | { |
|---|
| 66 | JCheckBoxMenuItem src = (JCheckBoxMenuItem) evt.getSource(); |
|---|
| 67 | Properties property = Properties.valueOf(src.getText().replaceAll(" ", "")); |
|---|
| 68 | |
|---|
| 69 | if (src.isSelected()) |
|---|
| 70 | { |
|---|
| 71 | model.addEventPanel(property, new CCTVEvent()); |
|---|
| 72 | } |
|---|
| 73 | else |
|---|
| 74 | { |
|---|
| 75 | model.removeProperty(property); |
|---|
| 76 | } |
|---|
| 77 | } |
|---|
| 78 | }; |
|---|
| 79 | |
|---|
| 80 | private ActionListener multipleChangeListener = new ActionListener() |
|---|
| 81 | { |
|---|
| 82 | public void actionPerformed(ActionEvent evt) |
|---|
| 83 | { |
|---|
| 84 | JMenuItem src = (JMenuItem) evt.getSource(); |
|---|
| 85 | model.addEventPanel(Properties.valueOf(src.getText().replaceAll(" ", "")), new CCTVEvent()); |
|---|
| 86 | } |
|---|
| 87 | }; |
|---|
| 88 | |
|---|
| 89 | /** |
|---|
| 90 | * Blank constructor for a new editor. |
|---|
| 91 | */ |
|---|
| 92 | public Editor(IncidentEditorFrame frame) |
|---|
| 93 | { |
|---|
| 94 | topFrame = frame; |
|---|
| 95 | initComponents(); |
|---|
| 96 | |
|---|
| 97 | incident = frame.getIncident(); |
|---|
| 98 | |
|---|
| 99 | model.addObserver(this); |
|---|
| 100 | |
|---|
| 101 | // For each menu |
|---|
| 102 | for (int menuCtr = 0; menuCtr < editorMenuBar.getMenuCount(); menuCtr++) |
|---|
| 103 | { |
|---|
| 104 | // for each menu item |
|---|
| 105 | for (java.awt.Component comp : editorMenuBar.getMenu(menuCtr).getMenuComponents()) |
|---|
| 106 | { |
|---|
| 107 | JMenuItem item = (JMenuItem) comp; |
|---|
| 108 | |
|---|
| 109 | String itemName = item.getText().replaceAll(" ", ""); |
|---|
| 110 | |
|---|
| 111 | Properties property = Properties.valueOf(itemName); |
|---|
| 112 | |
|---|
| 113 | if (property.getType() == PropertyTypes.Multiple) |
|---|
| 114 | { |
|---|
| 115 | item.addActionListener(multipleChangeListener); |
|---|
| 116 | } |
|---|
| 117 | else if (property.getType() == PropertyTypes.Optional) |
|---|
| 118 | { |
|---|
| 119 | item.addActionListener(optionalChangeListener); |
|---|
| 120 | } |
|---|
| 121 | else |
|---|
| 122 | { |
|---|
| 123 | throw new RuntimeException("Property type not accounted for"); |
|---|
| 124 | } |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | String eventTime = ""; |
|---|
| 130 | |
|---|
| 131 | txtEventStart.setText(eventTime); |
|---|
| 132 | |
|---|
| 133 | txtEventStart.addKeyListener(new KeyListener() |
|---|
| 134 | { |
|---|
| 135 | |
|---|
| 136 | @Override |
|---|
| 137 | public void keyTyped(KeyEvent e) |
|---|
| 138 | { |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | @Override |
|---|
| 142 | public void keyPressed(KeyEvent e) |
|---|
| 143 | { |
|---|
| 144 | if (e.getKeyCode() == KeyEvent.VK_ENTER) |
|---|
| 145 | { |
|---|
| 146 | updateEventTime(); |
|---|
| 147 | } |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | @Override |
|---|
| 151 | public void keyReleased(KeyEvent e) |
|---|
| 152 | { |
|---|
| 153 | } |
|---|
| 154 | }); |
|---|
| 155 | this.addWindowListener(new WindowAdapter() |
|---|
| 156 | { |
|---|
| 157 | @Override |
|---|
| 158 | public void windowClosing(WindowEvent e) |
|---|
| 159 | { |
|---|
| 160 | //Add previous offset back in |
|---|
| 161 | //If we didn't adjust the offset, this will just set it to the old value |
|---|
| 162 | //If we deleted the first event(s), this will add the offsets, |
|---|
| 163 | //to ensure that events stay at the correct times |
|---|
| 164 | model.closePanels(); |
|---|
| 165 | } |
|---|
| 166 | }); |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | /** |
|---|
| 170 | * This method is called from within the constructor to initialize the form. |
|---|
| 171 | * WARNING: Do NOT modify this code. The content of this method is always |
|---|
| 172 | * regenerated by the Form Editor. |
|---|
| 173 | */ |
|---|
| 174 | @SuppressWarnings("unchecked") |
|---|
| 175 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
|---|
| 176 | private void initComponents() |
|---|
| 177 | { |
|---|
| 178 | |
|---|
| 179 | eventTabsPane = new javax.swing.JTabbedPane(); |
|---|
| 180 | bottomFramePanel = new javax.swing.JPanel(); |
|---|
| 181 | txtEventStart = new javax.swing.JTextField(); |
|---|
| 182 | btnRemoveCurrentEvent = new javax.swing.JButton(); |
|---|
| 183 | editorMenuBar = new javax.swing.JMenuBar(); |
|---|
| 184 | menuEvaluations = new javax.swing.JMenu(); |
|---|
| 185 | ATMS = new javax.swing.JCheckBoxMenuItem(); |
|---|
| 186 | ActivityLog = new javax.swing.JCheckBoxMenuItem(); |
|---|
| 187 | CAD = new javax.swing.JCheckBoxMenuItem(); |
|---|
| 188 | CMS = new javax.swing.JMenuItem(); |
|---|
| 189 | Facilitator = new javax.swing.JCheckBoxMenuItem(); |
|---|
| 190 | Radio = new javax.swing.JCheckBoxMenuItem(); |
|---|
| 191 | menuInstructor = new javax.swing.JMenu(); |
|---|
| 192 | MaintenanceRadio = new javax.swing.JCheckBoxMenuItem(); |
|---|
| 193 | TMTRadio = new javax.swing.JCheckBoxMenuItem(); |
|---|
| 194 | Telephone = new javax.swing.JCheckBoxMenuItem(); |
|---|
| 195 | menuAutoData = new javax.swing.JMenu(); |
|---|
| 196 | Audio = new javax.swing.JMenuItem(); |
|---|
| 197 | CADLog = new javax.swing.JMenuItem(); |
|---|
| 198 | CCTV = new javax.swing.JMenuItem(); |
|---|
| 199 | CHPRadio = new javax.swing.JCheckBoxMenuItem(); |
|---|
| 200 | Paramics = new javax.swing.JMenuItem(); |
|---|
| 201 | Tow = new javax.swing.JMenuItem(); |
|---|
| 202 | Unit = new javax.swing.JMenuItem(); |
|---|
| 203 | Witness = new javax.swing.JMenuItem(); |
|---|
| 204 | |
|---|
| 205 | setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); |
|---|
| 206 | setTitle("Event Editor"); |
|---|
| 207 | |
|---|
| 208 | org.jdesktop.layout.GroupLayout bottomFramePanelLayout = new org.jdesktop.layout.GroupLayout(bottomFramePanel); |
|---|
| 209 | bottomFramePanel.setLayout(bottomFramePanelLayout); |
|---|
| 210 | bottomFramePanelLayout.setHorizontalGroup( |
|---|
| 211 | bottomFramePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 212 | .add(0, 613, Short.MAX_VALUE) |
|---|
| 213 | ); |
|---|
| 214 | bottomFramePanelLayout.setVerticalGroup( |
|---|
| 215 | bottomFramePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 216 | .add(0, 34, Short.MAX_VALUE) |
|---|
| 217 | ); |
|---|
| 218 | |
|---|
| 219 | txtEventStart.setText("00:00:00"); |
|---|
| 220 | |
|---|
| 221 | btnRemoveCurrentEvent.setText("Remove This Event"); |
|---|
| 222 | btnRemoveCurrentEvent.addActionListener(new java.awt.event.ActionListener() |
|---|
| 223 | { |
|---|
| 224 | public void actionPerformed(java.awt.event.ActionEvent evt) |
|---|
| 225 | { |
|---|
| 226 | btnRemoveCurrentEventActionPerformed(evt); |
|---|
| 227 | } |
|---|
| 228 | }); |
|---|
| 229 | |
|---|
| 230 | menuEvaluations.setText("Evaluations"); |
|---|
| 231 | |
|---|
| 232 | ATMS.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 233 | ATMS.setText("ATMS"); |
|---|
| 234 | ATMS.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ATMSEval.png"))); // NOI18N |
|---|
| 235 | ATMS.addActionListener(new java.awt.event.ActionListener() |
|---|
| 236 | { |
|---|
| 237 | public void actionPerformed(java.awt.event.ActionEvent evt) |
|---|
| 238 | { |
|---|
| 239 | multipleChange(evt); |
|---|
| 240 | } |
|---|
| 241 | }); |
|---|
| 242 | menuEvaluations.add(ATMS); |
|---|
| 243 | |
|---|
| 244 | ActivityLog.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.ALT_MASK)); |
|---|
| 245 | ActivityLog.setText("Activity Log"); |
|---|
| 246 | ActivityLog.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ActivityLogEval.png"))); // NOI18N |
|---|
| 247 | ActivityLog.addActionListener(new java.awt.event.ActionListener() |
|---|
| 248 | { |
|---|
| 249 | public void actionPerformed(java.awt.event.ActionEvent evt) |
|---|
| 250 | { |
|---|
| 251 | multipleChange(evt); |
|---|
| 252 | } |
|---|
| 253 | }); |
|---|
| 254 | menuEvaluations.add(ActivityLog); |
|---|
| 255 | |
|---|
| 256 | CAD.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK)); |
|---|
| 257 | CAD.setText("CAD"); |
|---|
| 258 | CAD.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/CADEval.png"))); // NOI18N |
|---|
| 259 | CAD.addActionListener(new java.awt.event.ActionListener() |
|---|
| 260 | { |
|---|
| 261 | public void actionPerformed(java.awt.event.ActionEvent evt) |
|---|
| 262 | { |
|---|
| 263 | multipleChange(evt); |
|---|
| 264 | } |
|---|
| 265 | }); |
|---|
| 266 | menuEvaluations.add(CAD); |
|---|
| 267 | |
|---|
| 268 | CMS.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 269 | CMS.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/CMSEval.png"))); // NOI18N |
|---|
| 270 | CMS.setText("CMS"); |
|---|
| 271 | CMS.addMouseListener(new java.awt.event.MouseAdapter() |
|---|
| 272 | { |
|---|
| 273 | public void mouseClicked(java.awt.event.MouseEvent evt) |
|---|
| 274 | { |
|---|
| 275 | multipleChangeListener(evt); |
|---|
| 276 | } |
|---|
| 277 | }); |
|---|
| 278 | CMS.addActionListener(new java.awt.event.ActionListener() |
|---|
| 279 | { |
|---|
| 280 | public void actionPerformed(java.awt.event.ActionEvent evt) |
|---|
| 281 | { |
|---|
| 282 | multipleChange(evt); |
|---|
| 283 | } |
|---|
| 284 | }); |
|---|
| 285 | menuEvaluations.add(CMS); |
|---|
| 286 | |
|---|
| 287 | Facilitator.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 288 | Facilitator.setText("Facilitator"); |
|---|
| 289 | Facilitator.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/FacilitatorEval.png"))); // NOI18N |
|---|
| 290 | Facilitator.addActionListener(new java.awt.event.ActionListener() |
|---|
| 291 | { |
|---|
| 292 | public void actionPerformed(java.awt.event.ActionEvent evt) |
|---|
| 293 | { |
|---|
| 294 | optionalChange(evt); |
|---|
| 295 | } |
|---|
| 296 | }); |
|---|
| 297 | menuEvaluations.add(Facilitator); |
|---|
| 298 | |
|---|
| 299 | Radio.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 300 | Radio.setText("Radio"); |
|---|
| 301 | Radio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/RadioEval.png"))); // NOI18N |
|---|
| 302 | Radio.addActionListener(new java.awt.event.ActionListener() |
|---|
| 303 | { |
|---|
| 304 | public void actionPerformed(java.awt.event.ActionEvent evt) |
|---|
| 305 | { |
|---|
| 306 | optionalChange(evt); |
|---|
| 307 | } |
|---|
| 308 | }); |
|---|
| 309 | menuEvaluations.add(Radio); |
|---|
| 310 | |
|---|
| 311 | editorMenuBar.add(menuEvaluations); |
|---|
| 312 | |
|---|
| 313 | menuInstructor.setText("Instructor Actions"); |
|---|
| 314 | |
|---|
| 315 | MaintenanceRadio.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 316 | MaintenanceRadio.setText("Maintenance Radio"); |
|---|
| 317 | MaintenanceRadio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/MaintenanceRadio.png"))); // NOI18N |
|---|
| 318 | MaintenanceRadio.addActionListener(new java.awt.event.ActionListener() |
|---|
| 319 | { |
|---|
| 320 | public void actionPerformed(java.awt.event.ActionEvent evt) |
|---|
| 321 | { |
|---|
| 322 | optionalChange(evt); |
|---|
| 323 | } |
|---|
| 324 | }); |
|---|
| 325 | menuInstructor.add(MaintenanceRadio); |
|---|
| 326 | |
|---|
| 327 | TMTRadio.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 328 | TMTRadio.setText("TMT Radio"); |
|---|
| 329 | TMTRadio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TMTRadio.png"))); // NOI18N |
|---|
| 330 | TMTRadio.addActionListener(new java.awt.event.ActionListener() |
|---|
| 331 | { |
|---|
| 332 | public void actionPerformed(java.awt.event.ActionEvent evt) |
|---|
| 333 | { |
|---|
| 334 | optionalChange(evt); |
|---|
| 335 | } |
|---|
| 336 | }); |
|---|
| 337 | menuInstructor.add(TMTRadio); |
|---|
| 338 | |
|---|
| 339 | Telephone.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 340 | Telephone.setText("Telephone"); |
|---|
| 341 | Telephone.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Telephone.png"))); // NOI18N |
|---|
| 342 | Telephone.addActionListener(new java.awt.event.ActionListener() |
|---|
| 343 | { |
|---|
| 344 | public void actionPerformed(java.awt.event.ActionEvent evt) |
|---|
| 345 | { |
|---|
| 346 | optionalChange(evt); |
|---|
| 347 | } |
|---|
| 348 | }); |
|---|
| 349 | menuInstructor.add(Telephone); |
|---|
| 350 | |
|---|
| 351 | editorMenuBar.add(menuInstructor); |
|---|
| 352 | |
|---|
| 353 | menuAutoData.setText("Automated Data"); |
|---|
| 354 | |
|---|
| 355 | Audio.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 356 | Audio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Audio.png"))); // NOI18N |
|---|
| 357 | Audio.setText("Audio"); |
|---|
| 358 | menuAutoData.add(Audio); |
|---|
| 359 | |
|---|
| 360 | CADLog.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 361 | CADLog.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/CAD.png"))); // NOI18N |
|---|
| 362 | CADLog.setText("CAD Log"); |
|---|
| 363 | menuAutoData.add(CADLog); |
|---|
| 364 | |
|---|
| 365 | CCTV.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 366 | CCTV.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/CCTV.png"))); // NOI18N |
|---|
| 367 | CCTV.setText("CCTV"); |
|---|
| 368 | menuAutoData.add(CCTV); |
|---|
| 369 | |
|---|
| 370 | CHPRadio.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK)); |
|---|
| 371 | CHPRadio.setText("CHP Radio"); |
|---|
| 372 | CHPRadio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/CHPRadio.png"))); // NOI18N |
|---|
| 373 | CHPRadio.addActionListener(new java.awt.event.ActionListener() |
|---|
| 374 | { |
|---|
| 375 | public void actionPerformed(java.awt.event.ActionEvent evt) |
|---|
| 376 | { |
|---|
| 377 | optionalChange(evt); |
|---|
| 378 | } |
|---|
| 379 | }); |
|---|
| 380 | menuAutoData.add(CHPRadio); |
|---|
| 381 | |
|---|
| 382 | Paramics.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 383 | Paramics.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Paramics.png"))); // NOI18N |
|---|
| 384 | Paramics.setText("Paramics"); |
|---|
| 385 | menuAutoData.add(Paramics); |
|---|
| 386 | |
|---|
| 387 | Tow.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 388 | Tow.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Tow.png"))); // NOI18N |
|---|
| 389 | Tow.setText("Tow"); |
|---|
| 390 | menuAutoData.add(Tow); |
|---|
| 391 | |
|---|
| 392 | Unit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 393 | Unit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Unit.png"))); // NOI18N |
|---|
| 394 | Unit.setText("Unit"); |
|---|
| 395 | menuAutoData.add(Unit); |
|---|
| 396 | |
|---|
| 397 | Witness.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK)); |
|---|
| 398 | Witness.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Witness.png"))); // NOI18N |
|---|
| 399 | Witness.setText("Witness"); |
|---|
| 400 | menuAutoData.add(Witness); |
|---|
| 401 | |
|---|
| 402 | editorMenuBar.add(menuAutoData); |
|---|
| 403 | |
|---|
| 404 | setJMenuBar(editorMenuBar); |
|---|
| 405 | |
|---|
| 406 | org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); |
|---|
| 407 | getContentPane().setLayout(layout); |
|---|
| 408 | layout.setHorizontalGroup( |
|---|
| 409 | layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 410 | .add(org.jdesktop.layout.GroupLayout.TRAILING, eventTabsPane) |
|---|
| 411 | .add(layout.createSequentialGroup() |
|---|
| 412 | .addContainerGap() |
|---|
| 413 | .add(txtEventStart, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
|---|
| 414 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 415 | .add(bottomFramePanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
|---|
| 416 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 417 | .add(btnRemoveCurrentEvent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 226, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
|---|
| 418 | .addContainerGap()) |
|---|
| 419 | ); |
|---|
| 420 | layout.setVerticalGroup( |
|---|
| 421 | layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 422 | .add(layout.createSequentialGroup() |
|---|
| 423 | .addContainerGap() |
|---|
| 424 | .add(eventTabsPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 534, Short.MAX_VALUE) |
|---|
| 425 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 426 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 427 | .add(bottomFramePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
|---|
| 428 | .add(txtEventStart, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
|---|
| 429 | .add(btnRemoveCurrentEvent))) |
|---|
| 430 | ); |
|---|
| 431 | |
|---|
| 432 | pack(); |
|---|
| 433 | }// </editor-fold>//GEN-END:initComponents |
|---|
| 434 | |
|---|
| 435 | private void multipleChangeListener(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_multipleChangeListener |
|---|
| 436 | |
|---|
| 437 | }//GEN-LAST:event_multipleChangeListener |
|---|
| 438 | |
|---|
| 439 | private void multipleChange(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleChange |
|---|
| 440 | |
|---|
| 441 | }//GEN-LAST:event_multipleChange |
|---|
| 442 | |
|---|
| 443 | private void optionalChange(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_optionalChange |
|---|
| 444 | |
|---|
| 445 | }//GEN-LAST:event_optionalChange |
|---|
| 446 | |
|---|
| 447 | private void btnRemoveCurrentEventActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnRemoveCurrentEventActionPerformed |
|---|
| 448 | {//GEN-HEADEREND:event_btnRemoveCurrentEventActionPerformed |
|---|
| 449 | |
|---|
| 450 | int index = eventTabsPane.getSelectedIndex(); |
|---|
| 451 | |
|---|
| 452 | if (index >= 0 && eventTabsPane.getTabComponentAt(index) != null) |
|---|
| 453 | { |
|---|
| 454 | JPanel removable = (JPanel) eventTabsPane |
|---|
| 455 | .getSelectedComponent(); |
|---|
| 456 | PropertyPanel update = this.model.properties.removeProperty(removable); |
|---|
| 457 | |
|---|
| 458 | ((I_ScriptEventEditorPanel) update.getPanel()).removeAssociatedEvent(); |
|---|
| 459 | |
|---|
| 460 | } |
|---|
| 461 | |
|---|
| 462 | }//GEN-LAST:event_btnRemoveCurrentEventActionPerformed |
|---|
| 463 | |
|---|
| 464 | private void updateEventTime() |
|---|
| 465 | { |
|---|
| 466 | String[] tokens = txtEventStart.getText().split(":"); |
|---|
| 467 | |
|---|
| 468 | int hrs = Integer.parseInt(tokens[0]); |
|---|
| 469 | int mins = Integer.parseInt(tokens[1]); |
|---|
| 470 | int secs = Integer.parseInt(tokens[2]); |
|---|
| 471 | |
|---|
| 472 | int newTime = (3600 * hrs) + (60 * mins) + secs; |
|---|
| 473 | |
|---|
| 474 | int index = eventTabsPane.getSelectedIndex(); |
|---|
| 475 | |
|---|
| 476 | if (index >= 0 && eventTabsPane.getTabComponentAt(index) != null) |
|---|
| 477 | { |
|---|
| 478 | JPanel removable = (JPanel) eventTabsPane |
|---|
| 479 | .getSelectedComponent(); |
|---|
| 480 | I_ScriptEvent ise = this.model.eventMap.get(removable); |
|---|
| 481 | if (newTime != slice.getTime() && incident.changeEventStart(ise, slice.getTime(), newTime)) |
|---|
| 482 | { |
|---|
| 483 | this.model.properties.removeProperty(removable); |
|---|
| 484 | |
|---|
| 485 | } |
|---|
| 486 | SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss"); |
|---|
| 487 | df.setTimeZone(TimeZone.getTimeZone("GMT")); |
|---|
| 488 | String eventTime = df.format(new Date(slice.getTime() * 1000)); |
|---|
| 489 | txtEventStart.setText(eventTime); |
|---|
| 490 | } |
|---|
| 491 | } |
|---|
| 492 | // |
|---|
| 493 | // /** |
|---|
| 494 | // * @param args the command line arguments |
|---|
| 495 | // */ |
|---|
| 496 | // public static void main(String args[]) |
|---|
| 497 | // { |
|---|
| 498 | // java.awt.EventQueue.invokeLater(new Runnable() |
|---|
| 499 | // { |
|---|
| 500 | // public void run() |
|---|
| 501 | // { |
|---|
| 502 | // new Editor(new IncidentEditorFrame( |
|---|
| 503 | // new ScriptIncident(100, null, null, null), |
|---|
| 504 | // new ScriptBuilderFrame())).setVisible(true); |
|---|
| 505 | // } |
|---|
| 506 | // }); |
|---|
| 507 | // } |
|---|
| 508 | |
|---|
| 509 | // Variables declaration - do not modify//GEN-BEGIN:variables |
|---|
| 510 | private javax.swing.JCheckBoxMenuItem ATMS; |
|---|
| 511 | private javax.swing.JCheckBoxMenuItem ActivityLog; |
|---|
| 512 | private javax.swing.JMenuItem Audio; |
|---|
| 513 | private javax.swing.JCheckBoxMenuItem CAD; |
|---|
| 514 | private javax.swing.JMenuItem CADLog; |
|---|
| 515 | private javax.swing.JMenuItem CCTV; |
|---|
| 516 | private javax.swing.JCheckBoxMenuItem CHPRadio; |
|---|
| 517 | private javax.swing.JMenuItem CMS; |
|---|
| 518 | private javax.swing.JCheckBoxMenuItem Facilitator; |
|---|
| 519 | private javax.swing.JCheckBoxMenuItem MaintenanceRadio; |
|---|
| 520 | private javax.swing.JMenuItem Paramics; |
|---|
| 521 | private javax.swing.JCheckBoxMenuItem Radio; |
|---|
| 522 | private javax.swing.JCheckBoxMenuItem TMTRadio; |
|---|
| 523 | private javax.swing.JCheckBoxMenuItem Telephone; |
|---|
| 524 | private javax.swing.JMenuItem Tow; |
|---|
| 525 | private javax.swing.JMenuItem Unit; |
|---|
| 526 | private javax.swing.JMenuItem Witness; |
|---|
| 527 | private javax.swing.JPanel bottomFramePanel; |
|---|
| 528 | private javax.swing.JButton btnRemoveCurrentEvent; |
|---|
| 529 | private javax.swing.JMenuBar editorMenuBar; |
|---|
| 530 | private javax.swing.JTabbedPane eventTabsPane; |
|---|
| 531 | private javax.swing.JMenu menuAutoData; |
|---|
| 532 | private javax.swing.JMenu menuEvaluations; |
|---|
| 533 | private javax.swing.JMenu menuInstructor; |
|---|
| 534 | private javax.swing.JTextField txtEventStart; |
|---|
| 535 | // End of variables declaration//GEN-END:variables |
|---|
| 536 | |
|---|
| 537 | @Override |
|---|
| 538 | public void update(Observable o, Object arg) |
|---|
| 539 | { |
|---|
| 540 | |
|---|
| 541 | final PropertyUpdate update = (PropertyUpdate) arg; |
|---|
| 542 | final ImageIcon image = update.getPanel().getProperty().getImage(); |
|---|
| 543 | final String caption = update.getPanel().title(); |
|---|
| 544 | |
|---|
| 545 | final JLabel title = new JLabel(caption, image, JLabel.CENTER); |
|---|
| 546 | |
|---|
| 547 | /* |
|---|
| 548 | final BorderLayout layout = new BorderLayout(); |
|---|
| 549 | final JPanel title = new JPanel(layout); |
|---|
| 550 | title.setOpaque(false); |
|---|
| 551 | title.add(new JLabel(image), BorderLayout.WEST); |
|---|
| 552 | title.add(new JLabel(caption), BorderLayout.EAST); |
|---|
| 553 | */ |
|---|
| 554 | if (update.getType() == UpdateType.Add) |
|---|
| 555 | { |
|---|
| 556 | eventTabsPane.insertTab(null, null, |
|---|
| 557 | update.getPanel().getPanel(), null, update.getPosition()); |
|---|
| 558 | eventTabsPane.setTabComponentAt(update.getPosition(), title); |
|---|
| 559 | eventTabsPane.setSelectedIndex(update.getPosition()); |
|---|
| 560 | topFrame.repaint(); |
|---|
| 561 | } |
|---|
| 562 | else if (update.getType() == UpdateType.Remove) |
|---|
| 563 | { |
|---|
| 564 | eventTabsPane.remove(update.getPanel().getPanel()); |
|---|
| 565 | topFrame.repaint(); |
|---|
| 566 | } |
|---|
| 567 | else if (update.getType() == UpdateType.TitleChange) |
|---|
| 568 | { |
|---|
| 569 | final int index = eventTabsPane.indexOfComponent( |
|---|
| 570 | update.getPanel().getPanel()); |
|---|
| 571 | |
|---|
| 572 | new Thread(new Runnable() |
|---|
| 573 | { |
|---|
| 574 | public void run() |
|---|
| 575 | { |
|---|
| 576 | Color c = eventTabsPane.getForegroundAt(index); |
|---|
| 577 | eventTabsPane.setForegroundAt(index, Color.blue); |
|---|
| 578 | try |
|---|
| 579 | { |
|---|
| 580 | Thread.sleep(350); |
|---|
| 581 | } |
|---|
| 582 | catch (Exception e) |
|---|
| 583 | { |
|---|
| 584 | } |
|---|
| 585 | if (index < eventTabsPane.getTabCount()) |
|---|
| 586 | { |
|---|
| 587 | eventTabsPane.setTabComponentAt(index, title); |
|---|
| 588 | } |
|---|
| 589 | try |
|---|
| 590 | { |
|---|
| 591 | Thread.sleep(350); |
|---|
| 592 | } |
|---|
| 593 | catch (Exception e) |
|---|
| 594 | { |
|---|
| 595 | } |
|---|
| 596 | if (index < eventTabsPane.getTabCount()) |
|---|
| 597 | { |
|---|
| 598 | eventTabsPane.setForegroundAt(index, c); |
|---|
| 599 | } |
|---|
| 600 | } |
|---|
| 601 | }).start(); |
|---|
| 602 | } |
|---|
| 603 | else |
|---|
| 604 | { |
|---|
| 605 | throw new RuntimeException("UpdateType not accounted for"); |
|---|
| 606 | } |
|---|
| 607 | } |
|---|
| 608 | |
|---|
| 609 | } |
|---|