source: tmcsimulator-scriptbuilder/trunk/src/event/editor/ParamicsPanel.java @ 92

Revision 92, 19.0 KB checked in by bmcguffin, 9 years ago (diff)

Removed superfluous "Remove" buttons on several panels.

Removed interface "RemovablePanel?" as it was no longer necessary or useful; removed related methods from classes implementing it.

Line 
1package event.editor;
2
3import java.awt.event.*;
4import java.util.ArrayList;
5import java.util.Observable;
6import javax.swing.JCheckBox;
7import scriptbuilder.structures.events.ParamicsEvent;
8import scriptbuilder.structures.events.I_ScriptEvent;
9
10/**
11 *
12 * @author nathaniellehrer
13 */
14public class ParamicsPanel extends javax.swing.JPanel implements I_ScriptEventEditorPanel
15{
16
17    private ActionListener removeListener;
18    private ParamicsEvent event;
19
20    /**
21     * Creates new form ParamicsPanel
22     */
23    public ParamicsPanel()
24    {
25        initComponents();
26    }
27
28    @Override
29    public void getEventObject(I_ScriptEvent sei)
30    {
31        event = (ParamicsEvent) sei;
32        boolean containsItem = false;
33        for (int i = 0; i < LocationDropdown.getItemCount() && !containsItem; i++)
34        {
35            if (event.locationID.equalsIgnoreCase(LocationDropdown.getItemAt(i).toString()))
36            {
37                LocationDropdown.setSelectedIndex(i);
38                containsItem = true;
39            }
40        }
41
42        if (!containsItem)
43        {
44            LocationDropdown.addItem(event.locationID);
45            LocationDropdown.setSelectedItem(LocationDropdown.getItemCount() - 1);
46        }
47        LocationDropdown.addActionListener(new ActionListener()
48        {
49
50            @Override
51            public void actionPerformed(ActionEvent e)
52            {
53                event.locationID = LocationDropdown.getSelectedItem().toString();
54            }
55        });
56        for (int i = 0; i < StatusDropdown.getItemCount(); i++)
57        {
58            if (event.status.equalsIgnoreCase(StatusDropdown.getItemAt(i).toString()))
59            {
60                StatusDropdown.setSelectedIndex(i);
61            }
62        }
63        StatusDropdown.addActionListener(new ActionListener()
64        {
65
66            @Override
67            public void actionPerformed(ActionEvent e)
68            {
69                event.status = StatusDropdown.getSelectedItem().toString();
70            }
71        });
72        for (int i = 0; i < TypeDropdown.getItemCount(); i++)
73        {
74            if (event.type.equalsIgnoreCase(TypeDropdown.getItemAt(i).toString()))
75            {
76                TypeDropdown.setSelectedIndex(i);
77            }
78        }
79        TypeDropdown.addActionListener(new ActionListener()
80        {
81
82            @Override
83            public void actionPerformed(ActionEvent e)
84            {
85                event.type = TypeDropdown.getSelectedItem().toString();
86            }
87        });
88        ArrayList<JCheckBox> lanes = new ArrayList<JCheckBox>();
89        lanes.add(jCheckBox1);
90        lanes.add(jCheckBox2);
91        lanes.add(jCheckBox3);
92        lanes.add(jCheckBox4);
93        lanes.add(jCheckBox5);
94        lanes.add(jCheckBox6);
95        lanes.add(jCheckBox7);
96        lanes.add(jCheckBox8);
97        lanes.add(jCheckBox9);
98        lanes.add(jCheckBox10);
99        for (Integer num : event.laneNums)
100        {
101            lanes.get(num - 1).doClick();
102        }
103    }
104
105    @Override
106    public void update(Observable o, Object arg)
107    {
108        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
109    }
110   
111    @Override
112    public boolean removeAssociatedEvent()
113    {
114        event.removeThis();
115        event = null;
116        return true;
117    }
118
119    /**
120     * This method is called from within the constructor to initialize the form.
121     * WARNING: Do NOT modify this code. The content of this method is always
122     * regenerated by the Form Editor.
123     */
124    @SuppressWarnings("unchecked")
125    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
126    private void initComponents()
127    {
128
129        jLabel1 = new javax.swing.JLabel();
130        jLabel2 = new javax.swing.JLabel();
131        StatusDropdown = new javax.swing.JComboBox();
132        TypeDropdown = new javax.swing.JComboBox();
133        jLabel3 = new javax.swing.JLabel();
134        jLabel4 = new javax.swing.JLabel();
135        jCheckBox1 = new javax.swing.JCheckBox();
136        jCheckBox2 = new javax.swing.JCheckBox();
137        jCheckBox3 = new javax.swing.JCheckBox();
138        jCheckBox4 = new javax.swing.JCheckBox();
139        jCheckBox5 = new javax.swing.JCheckBox();
140        jCheckBox6 = new javax.swing.JCheckBox();
141        jCheckBox7 = new javax.swing.JCheckBox();
142        jCheckBox8 = new javax.swing.JCheckBox();
143        jCheckBox9 = new javax.swing.JCheckBox();
144        jCheckBox10 = new javax.swing.JCheckBox();
145        LocationDropdown = new javax.swing.JComboBox();
146
147        jLabel1.setText("Location");
148
149        jLabel2.setText("Status");
150
151        StatusDropdown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "New", "Changed", "Cleared" }));
152
153        TypeDropdown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Lane Breakdown", "Lane Obstruction" }));
154
155        jLabel3.setText("Incident Type");
156
157        jLabel4.setText("Lanes affected:");
158
159        jCheckBox1.setText("Lane 1");
160        jCheckBox1.addActionListener(new java.awt.event.ActionListener()
161        {
162            public void actionPerformed(java.awt.event.ActionEvent evt)
163            {
164                jCheckBox1ActionPerformed(evt);
165            }
166        });
167
168        jCheckBox2.setText("Lane 2");
169        jCheckBox2.addActionListener(new java.awt.event.ActionListener()
170        {
171            public void actionPerformed(java.awt.event.ActionEvent evt)
172            {
173                jCheckBox2ActionPerformed(evt);
174            }
175        });
176
177        jCheckBox3.setText("Lane 3");
178        jCheckBox3.addActionListener(new java.awt.event.ActionListener()
179        {
180            public void actionPerformed(java.awt.event.ActionEvent evt)
181            {
182                jCheckBox3ActionPerformed(evt);
183            }
184        });
185
186        jCheckBox4.setText("Lane 4");
187        jCheckBox4.addActionListener(new java.awt.event.ActionListener()
188        {
189            public void actionPerformed(java.awt.event.ActionEvent evt)
190            {
191                jCheckBox4ActionPerformed(evt);
192            }
193        });
194
195        jCheckBox5.setText("Lane 5");
196        jCheckBox5.addActionListener(new java.awt.event.ActionListener()
197        {
198            public void actionPerformed(java.awt.event.ActionEvent evt)
199            {
200                jCheckBox5ActionPerformed(evt);
201            }
202        });
203
204        jCheckBox6.setText("Lane 8");
205        jCheckBox6.addActionListener(new java.awt.event.ActionListener()
206        {
207            public void actionPerformed(java.awt.event.ActionEvent evt)
208            {
209                jCheckBox6ActionPerformed(evt);
210            }
211        });
212
213        jCheckBox7.setText("Lane 6");
214        jCheckBox7.addActionListener(new java.awt.event.ActionListener()
215        {
216            public void actionPerformed(java.awt.event.ActionEvent evt)
217            {
218                jCheckBox7ActionPerformed(evt);
219            }
220        });
221
222        jCheckBox8.setText("Lane 7");
223        jCheckBox8.addActionListener(new java.awt.event.ActionListener()
224        {
225            public void actionPerformed(java.awt.event.ActionEvent evt)
226            {
227                jCheckBox8ActionPerformed(evt);
228            }
229        });
230
231        jCheckBox9.setText("Lane 10");
232        jCheckBox9.addActionListener(new java.awt.event.ActionListener()
233        {
234            public void actionPerformed(java.awt.event.ActionEvent evt)
235            {
236                jCheckBox9ActionPerformed(evt);
237            }
238        });
239
240        jCheckBox10.setText("Lane 9");
241        jCheckBox10.addActionListener(new java.awt.event.ActionListener()
242        {
243            public void actionPerformed(java.awt.event.ActionEvent evt)
244            {
245                jCheckBox10ActionPerformed(evt);
246            }
247        });
248
249        LocationDropdown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "187_S_55_ML", "187_N_405_HV" }));
250
251        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
252        this.setLayout(layout);
253        layout.setHorizontalGroup(
254            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
255            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
256                .addContainerGap()
257                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
258                    .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel3)
259                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
260                        .add(jLabel4)
261                        .add(18, 18, 18)
262                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
263                            .add(jCheckBox2)
264                            .add(jCheckBox1))
265                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
266                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
267                            .add(jCheckBox3)
268                            .add(jCheckBox4))
269                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
270                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
271                            .add(jCheckBox7)
272                            .add(jCheckBox5))
273                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
274                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
275                            .add(jCheckBox8)
276                            .add(jCheckBox6))
277                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
278                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
279                            .add(jCheckBox10)
280                            .add(jCheckBox9)))
281                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
282                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
283                            .add(jLabel1)
284                            .add(jLabel2))
285                        .add(36, 36, 36)
286                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
287                            .add(org.jdesktop.layout.GroupLayout.TRAILING, TypeDropdown, 0, 597, Short.MAX_VALUE)
288                            .add(StatusDropdown, 0, 597, Short.MAX_VALUE)
289                            .add(LocationDropdown, 0, 597, Short.MAX_VALUE))))
290                .addContainerGap())
291        );
292        layout.setVerticalGroup(
293            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
294            .add(layout.createSequentialGroup()
295                .add(41, 41, 41)
296                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
297                    .add(jLabel1)
298                    .add(LocationDropdown, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
299                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
300                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
301                    .add(StatusDropdown, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
302                    .add(jLabel2))
303                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
304                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
305                    .add(jLabel3)
306                    .add(TypeDropdown, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
307                .add(18, 18, 18)
308                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
309                    .add(layout.createSequentialGroup()
310                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
311                            .add(jLabel4)
312                            .add(jCheckBox1))
313                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
314                        .add(jCheckBox2))
315                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
316                        .add(layout.createSequentialGroup()
317                            .add(jCheckBox5)
318                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
319                            .add(jCheckBox7))
320                        .add(layout.createSequentialGroup()
321                            .add(jCheckBox3)
322                            .add(2, 2, 2)
323                            .add(jCheckBox4))
324                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
325                            .add(layout.createSequentialGroup()
326                                .add(jCheckBox10)
327                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
328                                .add(jCheckBox9))
329                            .add(layout.createSequentialGroup()
330                                .add(jCheckBox8)
331                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
332                                .add(jCheckBox6)))))
333                .addContainerGap(116, Short.MAX_VALUE))
334        );
335    }// </editor-fold>//GEN-END:initComponents
336
337    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
338        if (jCheckBox1.isSelected())
339        {
340            if (!event.laneNums.contains(1))
341            {
342                event.laneNums.add(1);
343            }
344        }
345        else
346        {
347            if (event.laneNums.contains(1))
348            {
349                event.laneNums.remove(1);
350            }
351        }
352    }//GEN-LAST:event_jCheckBox1ActionPerformed
353
354    private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox2ActionPerformed
355        if (jCheckBox2.isSelected())
356        {
357            if (!event.laneNums.contains(2))
358            {
359                event.laneNums.add(2);
360            }
361        }
362        else
363        {
364            if (event.laneNums.contains(2))
365            {
366                event.laneNums.remove(2);
367            }
368        }
369    }//GEN-LAST:event_jCheckBox2ActionPerformed
370
371    private void jCheckBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox3ActionPerformed
372        if (jCheckBox3.isSelected())
373        {
374            if (!event.laneNums.contains(3))
375            {
376                event.laneNums.add(3);
377            }
378        }
379        else
380        {
381            if (event.laneNums.contains(3))
382            {
383                event.laneNums.remove(3);
384            }
385        }
386    }//GEN-LAST:event_jCheckBox3ActionPerformed
387
388    private void jCheckBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox4ActionPerformed
389        if (jCheckBox4.isSelected())
390        {
391            if (!event.laneNums.contains(4))
392            {
393                event.laneNums.add(4);
394            }
395        }
396        else
397        {
398            if (event.laneNums.contains(4))
399            {
400                event.laneNums.remove(4);
401            }
402        }
403    }//GEN-LAST:event_jCheckBox4ActionPerformed
404
405    private void jCheckBox5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox5ActionPerformed
406        if (jCheckBox5.isSelected())
407        {
408            if (!event.laneNums.contains(5))
409            {
410                event.laneNums.add(5);
411            }
412        }
413        else
414        {
415            if (event.laneNums.contains(5))
416            {
417                event.laneNums.remove(5);
418            }
419        }
420    }//GEN-LAST:event_jCheckBox5ActionPerformed
421
422    private void jCheckBox6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox6ActionPerformed
423        if (jCheckBox6.isSelected())
424        {
425            if (!event.laneNums.contains(6))
426            {
427                event.laneNums.add(6);
428            }
429        }
430        else
431        {
432            if (event.laneNums.contains(6))
433            {
434                event.laneNums.remove(6);
435            }
436        }
437    }//GEN-LAST:event_jCheckBox6ActionPerformed
438
439    private void jCheckBox7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox7ActionPerformed
440        if (jCheckBox7.isSelected())
441        {
442            if (!event.laneNums.contains(7))
443            {
444                event.laneNums.add(7);
445            }
446        }
447        else
448        {
449            if (event.laneNums.contains(7))
450            {
451                event.laneNums.remove(7);
452            }
453        }
454    }//GEN-LAST:event_jCheckBox7ActionPerformed
455
456    private void jCheckBox8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox8ActionPerformed
457        if (jCheckBox8.isSelected())
458        {
459            if (!event.laneNums.contains(8))
460            {
461                event.laneNums.add(8);
462            }
463        }
464        else
465        {
466            if (event.laneNums.contains(8))
467            {
468                event.laneNums.remove(8);
469            }
470        }
471    }//GEN-LAST:event_jCheckBox8ActionPerformed
472
473    private void jCheckBox9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox9ActionPerformed
474        if (jCheckBox9.isSelected())
475        {
476            if (!event.laneNums.contains(9))
477            {
478                event.laneNums.add(9);
479            }
480        }
481        else
482        {
483            if (event.laneNums.contains(9))
484            {
485                event.laneNums.remove(9);
486            }
487        }
488    }//GEN-LAST:event_jCheckBox9ActionPerformed
489
490    private void jCheckBox10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox10ActionPerformed
491        if (jCheckBox10.isSelected())
492        {
493            if (!event.laneNums.contains(10))
494            {
495                event.laneNums.add(10);
496            }
497        }
498        else
499        {
500            if (event.laneNums.contains(10))
501            {
502                event.laneNums.remove(10);
503            }
504        }
505    }//GEN-LAST:event_jCheckBox10ActionPerformed
506
507
508    // Variables declaration - do not modify//GEN-BEGIN:variables
509    private javax.swing.JComboBox LocationDropdown;
510    private javax.swing.JComboBox StatusDropdown;
511    private javax.swing.JComboBox TypeDropdown;
512    private javax.swing.JCheckBox jCheckBox1;
513    private javax.swing.JCheckBox jCheckBox10;
514    private javax.swing.JCheckBox jCheckBox2;
515    private javax.swing.JCheckBox jCheckBox3;
516    private javax.swing.JCheckBox jCheckBox4;
517    private javax.swing.JCheckBox jCheckBox5;
518    private javax.swing.JCheckBox jCheckBox6;
519    private javax.swing.JCheckBox jCheckBox7;
520    private javax.swing.JCheckBox jCheckBox8;
521    private javax.swing.JCheckBox jCheckBox9;
522    private javax.swing.JLabel jLabel1;
523    private javax.swing.JLabel jLabel2;
524    private javax.swing.JLabel jLabel3;
525    private javax.swing.JLabel jLabel4;
526    // End of variables declaration//GEN-END:variables
527
528}
Note: See TracBrowser for help on using the repository browser.