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

Revision 1, 16.3 KB checked in by bmcguffin, 9 years ago (diff)

2017/07/18: Uploaded entire prototype to SVN repo.

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.ScriptEventInterface;
9
10/**
11 *
12 * @author nathaniellehrer
13 */
14public class ParamicsPanel extends javax.swing.JPanel implements RemoveablePanel, 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    public void setRemoveListener(ActionListener listener)
29    {
30        removeListener = listener;
31    }
32
33    public void getEventObject(ScriptEventInterface sei)
34    {
35        event = (ParamicsEvent) sei;
36        boolean containsItem = false;
37        for (int i = 0; i < LocationDropdown.getItemCount() && !containsItem; i++)
38        {
39            if (event.locationID.equalsIgnoreCase(LocationDropdown.getItemAt(i).toString()))
40            {
41                LocationDropdown.setSelectedIndex(i);
42                containsItem = true;
43            }
44        }
45        if (!containsItem)
46        {
47            LocationDropdown.addItem(event.locationID);
48            LocationDropdown.setSelectedItem(LocationDropdown.getItemCount() - 1);
49        }
50        for (int i = 0; i < StatusDropdown.getItemCount(); i++)
51        {
52            if (event.status.equalsIgnoreCase(StatusDropdown.getItemAt(i).toString()))
53            {
54                StatusDropdown.setSelectedIndex(i);
55            }
56        }
57        for (int i = 0; i < TypeDropdown.getItemCount(); i++)
58        {
59            if (event.type.equalsIgnoreCase(TypeDropdown.getItemAt(i).toString()))
60            {
61                TypeDropdown.setSelectedIndex(i);
62            }
63        }
64        ArrayList<JCheckBox> lanes = new ArrayList<JCheckBox>();
65        lanes.add(jCheckBox1);
66        lanes.add(jCheckBox2);
67        lanes.add(jCheckBox3);
68        lanes.add(jCheckBox4);
69        lanes.add(jCheckBox5);
70        lanes.add(jCheckBox6);
71        lanes.add(jCheckBox7);
72        lanes.add(jCheckBox8);
73        lanes.add(jCheckBox9);
74        lanes.add(jCheckBox10);
75        for (Integer num : event.laneNums)
76        {
77            lanes.get(num - 1).doClick();
78        }
79    }
80
81    public void update(Observable o, Object arg)
82    {
83        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
84    }
85
86    /**
87     * This method is called from within the constructor to initialize the form.
88     * WARNING: Do NOT modify this code. The content of this method is always
89     * regenerated by the Form Editor.
90     */
91    @SuppressWarnings("unchecked")
92    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
93    private void initComponents()
94    {
95
96        removeButton = new javax.swing.JButton();
97        jLabel1 = new javax.swing.JLabel();
98        jLabel2 = new javax.swing.JLabel();
99        StatusDropdown = new javax.swing.JComboBox();
100        TypeDropdown = new javax.swing.JComboBox();
101        jLabel3 = new javax.swing.JLabel();
102        jLabel4 = new javax.swing.JLabel();
103        jCheckBox1 = new javax.swing.JCheckBox();
104        jCheckBox2 = new javax.swing.JCheckBox();
105        jCheckBox3 = new javax.swing.JCheckBox();
106        jCheckBox4 = new javax.swing.JCheckBox();
107        jCheckBox5 = new javax.swing.JCheckBox();
108        jCheckBox6 = new javax.swing.JCheckBox();
109        jCheckBox7 = new javax.swing.JCheckBox();
110        jCheckBox8 = new javax.swing.JCheckBox();
111        jCheckBox9 = new javax.swing.JCheckBox();
112        jCheckBox10 = new javax.swing.JCheckBox();
113        LocationDropdown = new javax.swing.JComboBox();
114
115        removeButton.setText("Remove");
116        removeButton.addMouseListener(new java.awt.event.MouseAdapter()
117        {
118            public void mouseClicked(java.awt.event.MouseEvent evt)
119            {
120                removeThisProperty(evt);
121            }
122        });
123
124        jLabel1.setText("Location");
125
126        jLabel2.setText("Status");
127
128        StatusDropdown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "New", "Changed", "Cleared" }));
129
130        TypeDropdown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Lane Breakdown", "Lane Obstruction" }));
131
132        jLabel3.setText("Incident Type");
133
134        jLabel4.setText("Lanes affected:");
135
136        jCheckBox1.setText("Lane 1");
137        jCheckBox1.addActionListener(new java.awt.event.ActionListener()
138        {
139            public void actionPerformed(java.awt.event.ActionEvent evt)
140            {
141                jCheckBox1ActionPerformed(evt);
142            }
143        });
144
145        jCheckBox2.setText("Lane 2");
146        jCheckBox2.addActionListener(new java.awt.event.ActionListener()
147        {
148            public void actionPerformed(java.awt.event.ActionEvent evt)
149            {
150                jCheckBox2ActionPerformed(evt);
151            }
152        });
153
154        jCheckBox3.setText("Lane 3");
155        jCheckBox3.addActionListener(new java.awt.event.ActionListener()
156        {
157            public void actionPerformed(java.awt.event.ActionEvent evt)
158            {
159                jCheckBox3ActionPerformed(evt);
160            }
161        });
162
163        jCheckBox4.setText("Lane 4");
164        jCheckBox4.addActionListener(new java.awt.event.ActionListener()
165        {
166            public void actionPerformed(java.awt.event.ActionEvent evt)
167            {
168                jCheckBox4ActionPerformed(evt);
169            }
170        });
171
172        jCheckBox5.setText("Lane 5");
173        jCheckBox5.addActionListener(new java.awt.event.ActionListener()
174        {
175            public void actionPerformed(java.awt.event.ActionEvent evt)
176            {
177                jCheckBox5ActionPerformed(evt);
178            }
179        });
180
181        jCheckBox6.setText("Lane 8");
182        jCheckBox6.addActionListener(new java.awt.event.ActionListener()
183        {
184            public void actionPerformed(java.awt.event.ActionEvent evt)
185            {
186                jCheckBox6ActionPerformed(evt);
187            }
188        });
189
190        jCheckBox7.setText("Lane 6");
191        jCheckBox7.addActionListener(new java.awt.event.ActionListener()
192        {
193            public void actionPerformed(java.awt.event.ActionEvent evt)
194            {
195                jCheckBox7ActionPerformed(evt);
196            }
197        });
198
199        jCheckBox8.setText("Lane 7");
200        jCheckBox8.addActionListener(new java.awt.event.ActionListener()
201        {
202            public void actionPerformed(java.awt.event.ActionEvent evt)
203            {
204                jCheckBox8ActionPerformed(evt);
205            }
206        });
207
208        jCheckBox9.setText("Lane 10");
209        jCheckBox9.addActionListener(new java.awt.event.ActionListener()
210        {
211            public void actionPerformed(java.awt.event.ActionEvent evt)
212            {
213                jCheckBox9ActionPerformed(evt);
214            }
215        });
216
217        jCheckBox10.setText("Lane 9");
218        jCheckBox10.addActionListener(new java.awt.event.ActionListener()
219        {
220            public void actionPerformed(java.awt.event.ActionEvent evt)
221            {
222                jCheckBox10ActionPerformed(evt);
223            }
224        });
225
226        LocationDropdown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "187_S_55_ML", "187_N_405_HV" }));
227
228        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
229        this.setLayout(layout);
230        layout.setHorizontalGroup(
231            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
232            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
233                .addContainerGap()
234                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
235                    .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel3)
236                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
237                        .add(jLabel4)
238                        .add(18, 18, 18)
239                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
240                            .add(jCheckBox2)
241                            .add(jCheckBox1))
242                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
243                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
244                            .add(jCheckBox3)
245                            .add(jCheckBox4))
246                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
247                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
248                            .add(jCheckBox7)
249                            .add(jCheckBox5))
250                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
251                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
252                            .add(jCheckBox8)
253                            .add(jCheckBox6))
254                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
255                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
256                            .add(jCheckBox10)
257                            .add(jCheckBox9)))
258                    .add(removeButton)
259                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
260                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
261                            .add(jLabel1)
262                            .add(jLabel2))
263                        .add(36, 36, 36)
264                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
265                            .add(org.jdesktop.layout.GroupLayout.TRAILING, TypeDropdown, 0, 597, Short.MAX_VALUE)
266                            .add(StatusDropdown, 0, 597, Short.MAX_VALUE)
267                            .add(LocationDropdown, 0, 597, Short.MAX_VALUE))))
268                .addContainerGap())
269        );
270        layout.setVerticalGroup(
271            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
272            .add(layout.createSequentialGroup()
273                .addContainerGap()
274                .add(removeButton)
275                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
276                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
277                    .add(jLabel1)
278                    .add(LocationDropdown, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
279                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
280                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
281                    .add(StatusDropdown, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
282                    .add(jLabel2))
283                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
284                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
285                    .add(jLabel3)
286                    .add(TypeDropdown, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
287                .add(18, 18, 18)
288                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
289                    .add(layout.createSequentialGroup()
290                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
291                            .add(jLabel4)
292                            .add(jCheckBox1))
293                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
294                        .add(jCheckBox2))
295                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
296                        .add(layout.createSequentialGroup()
297                            .add(jCheckBox5)
298                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
299                            .add(jCheckBox7))
300                        .add(layout.createSequentialGroup()
301                            .add(jCheckBox3)
302                            .add(2, 2, 2)
303                            .add(jCheckBox4))
304                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
305                            .add(layout.createSequentialGroup()
306                                .add(jCheckBox10)
307                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
308                                .add(jCheckBox9))
309                            .add(layout.createSequentialGroup()
310                                .add(jCheckBox8)
311                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
312                                .add(jCheckBox6)))))
313                .addContainerGap(116, Short.MAX_VALUE))
314        );
315    }// </editor-fold>//GEN-END:initComponents
316
317    private void removeThisProperty(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeThisProperty
318        if (removeListener != null)
319        {
320            removeListener.actionPerformed(new ActionEvent(this, 0, ""));
321        }
322    }//GEN-LAST:event_removeThisProperty
323
324    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
325        // TODO add your handling code here:
326    }//GEN-LAST:event_jCheckBox1ActionPerformed
327
328    private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox2ActionPerformed
329        // TODO add your handling code here:
330    }//GEN-LAST:event_jCheckBox2ActionPerformed
331
332    private void jCheckBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox3ActionPerformed
333        // TODO add your handling code here:
334    }//GEN-LAST:event_jCheckBox3ActionPerformed
335
336    private void jCheckBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox4ActionPerformed
337        // TODO add your handling code here:
338    }//GEN-LAST:event_jCheckBox4ActionPerformed
339
340    private void jCheckBox5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox5ActionPerformed
341        // TODO add your handling code here:
342    }//GEN-LAST:event_jCheckBox5ActionPerformed
343
344    private void jCheckBox6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox6ActionPerformed
345        // TODO add your handling code here:
346    }//GEN-LAST:event_jCheckBox6ActionPerformed
347
348    private void jCheckBox7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox7ActionPerformed
349        // TODO add your handling code here:
350    }//GEN-LAST:event_jCheckBox7ActionPerformed
351
352    private void jCheckBox8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox8ActionPerformed
353        // TODO add your handling code here:
354    }//GEN-LAST:event_jCheckBox8ActionPerformed
355
356    private void jCheckBox9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox9ActionPerformed
357        // TODO add your handling code here:
358    }//GEN-LAST:event_jCheckBox9ActionPerformed
359
360    private void jCheckBox10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox10ActionPerformed
361        // TODO add your handling code here:
362    }//GEN-LAST:event_jCheckBox10ActionPerformed
363
364
365    // Variables declaration - do not modify//GEN-BEGIN:variables
366    private javax.swing.JComboBox LocationDropdown;
367    private javax.swing.JComboBox StatusDropdown;
368    private javax.swing.JComboBox TypeDropdown;
369    private javax.swing.JCheckBox jCheckBox1;
370    private javax.swing.JCheckBox jCheckBox10;
371    private javax.swing.JCheckBox jCheckBox2;
372    private javax.swing.JCheckBox jCheckBox3;
373    private javax.swing.JCheckBox jCheckBox4;
374    private javax.swing.JCheckBox jCheckBox5;
375    private javax.swing.JCheckBox jCheckBox6;
376    private javax.swing.JCheckBox jCheckBox7;
377    private javax.swing.JCheckBox jCheckBox8;
378    private javax.swing.JCheckBox jCheckBox9;
379    private javax.swing.JLabel jLabel1;
380    private javax.swing.JLabel jLabel2;
381    private javax.swing.JLabel jLabel3;
382    private javax.swing.JLabel jLabel4;
383    private javax.swing.JButton removeButton;
384    // End of variables declaration//GEN-END:variables
385
386}
Note: See TracBrowser for help on using the repository browser.