source: tmcsimulator-scriptbuilder/trunk/src/event/editor/frame/Editor.java @ 101

Revision 101, 23.6 KB checked in by bmcguffin, 9 years ago (diff)

Added text field, txtEventStart, to bottom of event editor screen. This text field by default displays the time that the event starts. Altering this field will change the start time of the selected event to the new value.

Line 
1package event.editor.frame;
2
3import event.editor.I_ScriptEventEditorPanel;
4import java.awt.BorderLayout;
5import java.awt.Color;
6import java.awt.FlowLayout;
7import javax.swing.*;
8import java.util.*;
9import java.awt.event.*;
10import java.text.SimpleDateFormat;
11import scriptbuilder.gui.IncidentEditorFrame;
12import scriptbuilder.gui.panels.IncidentTimelinePanel;
13import scriptbuilder.structures.ScriptEvent;
14import scriptbuilder.structures.ScriptIncident;
15import scriptbuilder.structures.TimeSlice;
16import scriptbuilder.structures.events.*;
17
18public class Editor extends javax.swing.JFrame implements Observer
19{
20
21    IncidentEditorFrame topFrame = null;
22
23    ScriptIncident incident = null;
24
25    TimeSlice slice = null;
26
27    private PropertyModel model = new PropertyModel();
28
29//    public PropertyModel getPropertyModel()
30//    {
31//        return model;
32//    }
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
59    }
60
61    private ActionListener optionalChangeListener = new ActionListener()
62    {
63        public void actionPerformed(ActionEvent evt)
64        {
65            JCheckBoxMenuItem src = (JCheckBoxMenuItem) evt.getSource();
66            Properties property = Properties.valueOf(src.getText().replaceAll(" ", ""));
67
68            if (src.isSelected())
69            {
70                model.addEventPanel(property, new CCTVEvent());
71            }
72            else
73            {
74                model.removeProperty(property);
75            }
76        }
77    };
78
79    private ActionListener multipleChangeListener = new ActionListener()
80    {
81        public void actionPerformed(ActionEvent evt)
82        {
83            JMenuItem src = (JMenuItem) evt.getSource();
84            model.addEventPanel(Properties.valueOf(src.getText().replaceAll(" ", "")), new CCTVEvent());
85        }
86    };
87
88    /**
89     * Blank constructor for a new editor.
90     */
91    public Editor(IncidentEditorFrame frame)
92    {
93        topFrame = frame;
94        initComponents();
95
96        incident = frame.getIncident();
97
98        model.addObserver(this);
99
100        // For each menu
101        for (int menuCtr = 0; menuCtr < jMenuBar1.getMenuCount(); menuCtr++)
102        {
103            // for each menu item
104            for (java.awt.Component comp : jMenuBar1.getMenu(menuCtr).getMenuComponents())
105            {
106                JMenuItem item = (JMenuItem) comp;
107
108                String itemName = item.getText().replaceAll(" ", "");
109
110                Properties property = Properties.valueOf(itemName);
111
112                if (property.getType() == PropertyTypes.Multiple)
113                {
114                    item.addActionListener(multipleChangeListener);
115                }
116                else if (property.getType() == PropertyTypes.Optional)
117                {
118                    item.addActionListener(optionalChangeListener);
119                }
120                else
121                {
122                    throw new RuntimeException("Property type not accounted for");
123                }
124            }
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        });
153    }
154
155    /**
156     * This method is called from within the constructor to initialize the form.
157     * WARNING: Do NOT modify this code. The content of this method is always
158     * regenerated by the Form Editor.
159     */
160    @SuppressWarnings("unchecked")
161    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
162    private void initComponents()
163    {
164
165        jPanel1 = new javax.swing.JPanel();
166        jTabbedPane1 = new javax.swing.JTabbedPane();
167        jPanel2 = new javax.swing.JPanel();
168        txtEventStart = new javax.swing.JTextField();
169        btnRemoveCurrentEvent = new javax.swing.JButton();
170        jMenuBar1 = new javax.swing.JMenuBar();
171        jMenu1 = new javax.swing.JMenu();
172        ATMS = new javax.swing.JCheckBoxMenuItem();
173        ActivityLog = new javax.swing.JCheckBoxMenuItem();
174        CAD = new javax.swing.JCheckBoxMenuItem();
175        CMS = new javax.swing.JMenuItem();
176        Facilitator = new javax.swing.JCheckBoxMenuItem();
177        Radio = new javax.swing.JCheckBoxMenuItem();
178        JMenu2 = new javax.swing.JMenu();
179        MaintenanceRadio = new javax.swing.JCheckBoxMenuItem();
180        TMTRadio = new javax.swing.JCheckBoxMenuItem();
181        Telephone = new javax.swing.JCheckBoxMenuItem();
182        jMenu3 = new javax.swing.JMenu();
183        Audio = new javax.swing.JMenuItem();
184        CADLog = new javax.swing.JMenuItem();
185        CCTV = new javax.swing.JMenuItem();
186        CHPRadio = new javax.swing.JCheckBoxMenuItem();
187        Paramics = new javax.swing.JMenuItem();
188        Tow = new javax.swing.JMenuItem();
189        Unit = new javax.swing.JMenuItem();
190        Witness = new javax.swing.JMenuItem();
191
192        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
193        jPanel1.setLayout(jPanel1Layout);
194        jPanel1Layout.setHorizontalGroup(
195            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
196            .add(0, 100, Short.MAX_VALUE)
197        );
198        jPanel1Layout.setVerticalGroup(
199            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
200            .add(0, 100, Short.MAX_VALUE)
201        );
202
203        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
204        setTitle("Event Editor");
205
206        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
207        jPanel2.setLayout(jPanel2Layout);
208        jPanel2Layout.setHorizontalGroup(
209            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
210            .add(0, 613, Short.MAX_VALUE)
211        );
212        jPanel2Layout.setVerticalGroup(
213            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
214            .add(0, 34, Short.MAX_VALUE)
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        });
227
228        jMenu1.setText("Evaluations");
229
230        ATMS.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
231        ATMS.setText("ATMS");
232        ATMS.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ATMSEval.png"))); // NOI18N
233        ATMS.addActionListener(new java.awt.event.ActionListener()
234        {
235            public void actionPerformed(java.awt.event.ActionEvent evt)
236            {
237                multipleChange(evt);
238            }
239        });
240        jMenu1.add(ATMS);
241
242        ActivityLog.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.ALT_MASK));
243        ActivityLog.setText("Activity Log");
244        ActivityLog.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ActivityLogEval.png"))); // NOI18N
245        ActivityLog.addActionListener(new java.awt.event.ActionListener()
246        {
247            public void actionPerformed(java.awt.event.ActionEvent evt)
248            {
249                multipleChange(evt);
250            }
251        });
252        jMenu1.add(ActivityLog);
253
254        CAD.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
255        CAD.setText("CAD");
256        CAD.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/CADEval.png"))); // NOI18N
257        CAD.addActionListener(new java.awt.event.ActionListener()
258        {
259            public void actionPerformed(java.awt.event.ActionEvent evt)
260            {
261                multipleChange(evt);
262            }
263        });
264        jMenu1.add(CAD);
265
266        CMS.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
267        CMS.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/CMSEval.png"))); // NOI18N
268        CMS.setText("CMS");
269        CMS.addMouseListener(new java.awt.event.MouseAdapter()
270        {
271            public void mouseClicked(java.awt.event.MouseEvent evt)
272            {
273                multipleChangeListener(evt);
274            }
275        });
276        CMS.addActionListener(new java.awt.event.ActionListener()
277        {
278            public void actionPerformed(java.awt.event.ActionEvent evt)
279            {
280                multipleChange(evt);
281            }
282        });
283        jMenu1.add(CMS);
284
285        Facilitator.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.CTRL_MASK));
286        Facilitator.setText("Facilitator");
287        Facilitator.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/FacilitatorEval.png"))); // NOI18N
288        Facilitator.addActionListener(new java.awt.event.ActionListener()
289        {
290            public void actionPerformed(java.awt.event.ActionEvent evt)
291            {
292                optionalChange(evt);
293            }
294        });
295        jMenu1.add(Facilitator);
296
297        Radio.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK));
298        Radio.setText("Radio");
299        Radio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/RadioEval.png"))); // NOI18N
300        Radio.addActionListener(new java.awt.event.ActionListener()
301        {
302            public void actionPerformed(java.awt.event.ActionEvent evt)
303            {
304                optionalChange(evt);
305            }
306        });
307        jMenu1.add(Radio);
308
309        jMenuBar1.add(jMenu1);
310
311        JMenu2.setText("Instructor Actions");
312
313        MaintenanceRadio.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.CTRL_MASK));
314        MaintenanceRadio.setText("Maintenance Radio");
315        MaintenanceRadio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/MaintenanceRadio.png"))); // NOI18N
316        MaintenanceRadio.addActionListener(new java.awt.event.ActionListener()
317        {
318            public void actionPerformed(java.awt.event.ActionEvent evt)
319            {
320                optionalChange(evt);
321            }
322        });
323        JMenu2.add(MaintenanceRadio);
324
325        TMTRadio.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
326        TMTRadio.setText("TMT Radio");
327        TMTRadio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TMTRadio.png"))); // NOI18N
328        TMTRadio.addActionListener(new java.awt.event.ActionListener()
329        {
330            public void actionPerformed(java.awt.event.ActionEvent evt)
331            {
332                optionalChange(evt);
333            }
334        });
335        JMenu2.add(TMTRadio);
336
337        Telephone.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
338        Telephone.setText("Telephone");
339        Telephone.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Telephone.png"))); // NOI18N
340        Telephone.addActionListener(new java.awt.event.ActionListener()
341        {
342            public void actionPerformed(java.awt.event.ActionEvent evt)
343            {
344                optionalChange(evt);
345            }
346        });
347        JMenu2.add(Telephone);
348
349        jMenuBar1.add(JMenu2);
350
351        jMenu3.setText("Automated Data");
352
353        Audio.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
354        Audio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Audio.png"))); // NOI18N
355        Audio.setText("Audio");
356        jMenu3.add(Audio);
357
358        CADLog.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
359        CADLog.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/CAD.png"))); // NOI18N
360        CADLog.setText("CAD Log");
361        jMenu3.add(CADLog);
362
363        CCTV.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK));
364        CCTV.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/CCTV.png"))); // NOI18N
365        CCTV.setText("CCTV");
366        jMenu3.add(CCTV);
367
368        CHPRadio.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
369        CHPRadio.setText("CHP Radio");
370        CHPRadio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/CHPRadio.png"))); // NOI18N
371        CHPRadio.addActionListener(new java.awt.event.ActionListener()
372        {
373            public void actionPerformed(java.awt.event.ActionEvent evt)
374            {
375                optionalChange(evt);
376            }
377        });
378        jMenu3.add(CHPRadio);
379
380        Paramics.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK));
381        Paramics.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Paramics.png"))); // NOI18N
382        Paramics.setText("Paramics");
383        jMenu3.add(Paramics);
384
385        Tow.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK));
386        Tow.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Tow.png"))); // NOI18N
387        Tow.setText("Tow");
388        jMenu3.add(Tow);
389
390        Unit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, java.awt.event.InputEvent.CTRL_MASK));
391        Unit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Unit.png"))); // NOI18N
392        Unit.setText("Unit");
393        jMenu3.add(Unit);
394
395        Witness.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK));
396        Witness.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Witness.png"))); // NOI18N
397        Witness.setText("Witness");
398        jMenu3.add(Witness);
399
400        jMenuBar1.add(jMenu3);
401
402        setJMenuBar(jMenuBar1);
403
404        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
405        getContentPane().setLayout(layout);
406        layout.setHorizontalGroup(
407            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
408            .add(org.jdesktop.layout.GroupLayout.TRAILING, jTabbedPane1)
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())
417        );
418        layout.setVerticalGroup(
419            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
420            .add(layout.createSequentialGroup()
421                .addContainerGap()
422                .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 534, Short.MAX_VALUE)
423                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
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)))
428        );
429
430        pack();
431    }// </editor-fold>//GEN-END:initComponents
432
433    private void multipleChangeListener(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_multipleChangeListener
434
435    }//GEN-LAST:event_multipleChangeListener
436
437    private void multipleChange(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleChange
438
439    }//GEN-LAST:event_multipleChange
440
441    private void optionalChange(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_optionalChange
442
443    }//GEN-LAST:event_optionalChange
444
445    private void btnRemoveCurrentEventActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnRemoveCurrentEventActionPerformed
446    {//GEN-HEADEREND:event_btnRemoveCurrentEventActionPerformed
447
448        int index = jTabbedPane1.getSelectedIndex();
449
450        if (index >= 0 && jTabbedPane1.getTabComponentAt(index) != null)
451        {
452            JPanel removable = (JPanel) jTabbedPane1
453                    .getSelectedComponent();
454            this.model.properties.removeProperty(removable);
455        }
456
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    }
488
489    /**
490     * @param args the command line arguments
491     */
492    public static void main(String args[])
493    {
494        java.awt.EventQueue.invokeLater(new Runnable()
495        {
496            public void run()
497            {
498                new Editor(new IncidentEditorFrame(new ScriptIncident(100, null, null, null))).setVisible(true);
499            }
500        });
501    }
502
503    // Variables declaration - do not modify//GEN-BEGIN:variables
504    private javax.swing.JCheckBoxMenuItem ATMS;
505    private javax.swing.JCheckBoxMenuItem ActivityLog;
506    private javax.swing.JMenuItem Audio;
507    private javax.swing.JCheckBoxMenuItem CAD;
508    private javax.swing.JMenuItem CADLog;
509    private javax.swing.JMenuItem CCTV;
510    private javax.swing.JCheckBoxMenuItem CHPRadio;
511    private javax.swing.JMenuItem CMS;
512    private javax.swing.JCheckBoxMenuItem Facilitator;
513    private javax.swing.JMenu JMenu2;
514    private javax.swing.JCheckBoxMenuItem MaintenanceRadio;
515    private javax.swing.JMenuItem Paramics;
516    private javax.swing.JCheckBoxMenuItem Radio;
517    private javax.swing.JCheckBoxMenuItem TMTRadio;
518    private javax.swing.JCheckBoxMenuItem Telephone;
519    private javax.swing.JMenuItem Tow;
520    private javax.swing.JMenuItem Unit;
521    private javax.swing.JMenuItem Witness;
522    private javax.swing.JButton btnRemoveCurrentEvent;
523    private javax.swing.JMenu jMenu1;
524    private javax.swing.JMenu jMenu3;
525    private javax.swing.JMenuBar jMenuBar1;
526    private javax.swing.JPanel jPanel1;
527    private javax.swing.JPanel jPanel2;
528    private javax.swing.JTabbedPane jTabbedPane1;
529    private javax.swing.JTextField txtEventStart;
530    // End of variables declaration//GEN-END:variables
531
532    @Override
533    public void update(Observable o, Object arg)
534    {
535
536        final PropertyUpdate update = (PropertyUpdate) arg;
537        final ImageIcon image = update.getPanel().getProperty().getImage();
538        final String caption = update.getPanel().title();
539
540        final JLabel title = new JLabel(caption, image, JLabel.CENTER);
541
542        /*
543         final BorderLayout layout = new BorderLayout();
544         final JPanel title = new JPanel(layout);
545         title.setOpaque(false);
546         title.add(new JLabel(image), BorderLayout.WEST);
547         title.add(new JLabel(caption), BorderLayout.EAST);
548         */
549        if (update.getType() == UpdateType.Add)
550        {
551            jTabbedPane1.insertTab(null, null,
552                    update.getPanel().getPanel(), null, update.getPosition());
553            jTabbedPane1.setTabComponentAt(update.getPosition(), title);
554            jTabbedPane1.setSelectedIndex(update.getPosition());
555            topFrame.repaint();
556        }
557        else if (update.getType() == UpdateType.Remove)
558        {
559            jTabbedPane1.remove(update.getPanel().getPanel());
560            if (update.getPanel().getPanel() instanceof I_ScriptEventEditorPanel)
561            {
562                ((I_ScriptEventEditorPanel) update.getPanel().getPanel()).removeAssociatedEvent();
563            }
564            topFrame.repaint();
565        }
566        else if (update.getType() == UpdateType.TitleChange)
567        {
568            final int index = jTabbedPane1.indexOfComponent(
569                    update.getPanel().getPanel());
570
571            new Thread(new Runnable()
572            {
573                public void run()
574                {
575                    Color c = jTabbedPane1.getForegroundAt(index);
576                    jTabbedPane1.setForegroundAt(index, Color.blue);
577                    try
578                    {
579                        Thread.sleep(350);
580                    }
581                    catch (Exception e)
582                    {
583                    }
584                    if (index < jTabbedPane1.getTabCount())
585                    {
586                        jTabbedPane1.setTabComponentAt(index, title);
587                    }
588                    try
589                    {
590                        Thread.sleep(350);
591                    }
592                    catch (Exception e)
593                    {
594                    }
595                    if (index < jTabbedPane1.getTabCount())
596                    {
597                        jTabbedPane1.setForegroundAt(index, c);
598                    }
599                }
600            }).start();
601        }
602        else
603        {
604            throw new RuntimeException("UpdateType not accounted for");
605        }
606    }
607
608}
Note: See TracBrowser for help on using the repository browser.