package event.editor; import java.awt.event.*; import java.util.ArrayList; import java.util.Observable; import javax.swing.JCheckBox; import scriptbuilder.structures.events.ParamicsEvent; import scriptbuilder.structures.events.ScriptEventInterface; /** * * @author nathaniellehrer */ public class ParamicsPanel extends javax.swing.JPanel implements RemoveablePanel, ScriptEventEditorPanel { private ActionListener removeListener; private ParamicsEvent event; /** * Creates new form ParamicsPanel */ public ParamicsPanel() { initComponents(); } public void setRemoveListener(ActionListener listener) { removeListener = listener; } public void getEventObject(ScriptEventInterface sei) { event = (ParamicsEvent) sei; boolean containsItem = false; for (int i = 0; i < LocationDropdown.getItemCount() && !containsItem; i++) { if (event.locationID.equalsIgnoreCase(LocationDropdown.getItemAt(i).toString())) { LocationDropdown.setSelectedIndex(i); containsItem = true; } } if (!containsItem) { LocationDropdown.addItem(event.locationID); LocationDropdown.setSelectedItem(LocationDropdown.getItemCount() - 1); } for (int i = 0; i < StatusDropdown.getItemCount(); i++) { if (event.status.equalsIgnoreCase(StatusDropdown.getItemAt(i).toString())) { StatusDropdown.setSelectedIndex(i); } } for (int i = 0; i < TypeDropdown.getItemCount(); i++) { if (event.type.equalsIgnoreCase(TypeDropdown.getItemAt(i).toString())) { TypeDropdown.setSelectedIndex(i); } } ArrayList lanes = new ArrayList(); lanes.add(jCheckBox1); lanes.add(jCheckBox2); lanes.add(jCheckBox3); lanes.add(jCheckBox4); lanes.add(jCheckBox5); lanes.add(jCheckBox6); lanes.add(jCheckBox7); lanes.add(jCheckBox8); lanes.add(jCheckBox9); lanes.add(jCheckBox10); for (Integer num : event.laneNums) { lanes.get(num - 1).doClick(); } } public void update(Observable o, Object arg) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { removeButton = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); StatusDropdown = new javax.swing.JComboBox(); TypeDropdown = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jCheckBox1 = new javax.swing.JCheckBox(); jCheckBox2 = new javax.swing.JCheckBox(); jCheckBox3 = new javax.swing.JCheckBox(); jCheckBox4 = new javax.swing.JCheckBox(); jCheckBox5 = new javax.swing.JCheckBox(); jCheckBox6 = new javax.swing.JCheckBox(); jCheckBox7 = new javax.swing.JCheckBox(); jCheckBox8 = new javax.swing.JCheckBox(); jCheckBox9 = new javax.swing.JCheckBox(); jCheckBox10 = new javax.swing.JCheckBox(); LocationDropdown = new javax.swing.JComboBox(); removeButton.setText("Remove"); removeButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { removeThisProperty(evt); } }); jLabel1.setText("Location"); jLabel2.setText("Status"); StatusDropdown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "New", "Changed", "Cleared" })); TypeDropdown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Lane Breakdown", "Lane Obstruction" })); jLabel3.setText("Incident Type"); jLabel4.setText("Lanes affected:"); jCheckBox1.setText("Lane 1"); jCheckBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox1ActionPerformed(evt); } }); jCheckBox2.setText("Lane 2"); jCheckBox2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox2ActionPerformed(evt); } }); jCheckBox3.setText("Lane 3"); jCheckBox3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox3ActionPerformed(evt); } }); jCheckBox4.setText("Lane 4"); jCheckBox4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox4ActionPerformed(evt); } }); jCheckBox5.setText("Lane 5"); jCheckBox5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox5ActionPerformed(evt); } }); jCheckBox6.setText("Lane 8"); jCheckBox6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox6ActionPerformed(evt); } }); jCheckBox7.setText("Lane 6"); jCheckBox7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox7ActionPerformed(evt); } }); jCheckBox8.setText("Lane 7"); jCheckBox8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox8ActionPerformed(evt); } }); jCheckBox9.setText("Lane 10"); jCheckBox9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox9ActionPerformed(evt); } }); jCheckBox10.setText("Lane 9"); jCheckBox10.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox10ActionPerformed(evt); } }); LocationDropdown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "187_S_55_ML", "187_N_405_HV" })); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel3) .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() .add(jLabel4) .add(18, 18, 18) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jCheckBox2) .add(jCheckBox1)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jCheckBox3) .add(jCheckBox4)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(jCheckBox7) .add(jCheckBox5)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jCheckBox8) .add(jCheckBox6)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jCheckBox10) .add(jCheckBox9))) .add(removeButton) .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel1) .add(jLabel2)) .add(36, 36, 36) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, TypeDropdown, 0, 597, Short.MAX_VALUE) .add(StatusDropdown, 0, 597, Short.MAX_VALUE) .add(LocationDropdown, 0, 597, Short.MAX_VALUE)))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(removeButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel1) .add(LocationDropdown, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(StatusDropdown, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel2)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel3) .add(TypeDropdown, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(18, 18, 18) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel4) .add(jCheckBox1)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jCheckBox2)) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(jCheckBox5) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jCheckBox7)) .add(layout.createSequentialGroup() .add(jCheckBox3) .add(2, 2, 2) .add(jCheckBox4)) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(layout.createSequentialGroup() .add(jCheckBox10) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jCheckBox9)) .add(layout.createSequentialGroup() .add(jCheckBox8) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jCheckBox6))))) .addContainerGap(116, Short.MAX_VALUE)) ); }// //GEN-END:initComponents private void removeThisProperty(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeThisProperty if (removeListener != null) { removeListener.actionPerformed(new ActionEvent(this, 0, "")); } }//GEN-LAST:event_removeThisProperty private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jCheckBox1ActionPerformed private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox2ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jCheckBox2ActionPerformed private void jCheckBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox3ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jCheckBox3ActionPerformed private void jCheckBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox4ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jCheckBox4ActionPerformed private void jCheckBox5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox5ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jCheckBox5ActionPerformed private void jCheckBox6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox6ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jCheckBox6ActionPerformed private void jCheckBox7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox7ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jCheckBox7ActionPerformed private void jCheckBox8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox8ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jCheckBox8ActionPerformed private void jCheckBox9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox9ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jCheckBox9ActionPerformed private void jCheckBox10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox10ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jCheckBox10ActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox LocationDropdown; private javax.swing.JComboBox StatusDropdown; private javax.swing.JComboBox TypeDropdown; private javax.swing.JCheckBox jCheckBox1; private javax.swing.JCheckBox jCheckBox10; private javax.swing.JCheckBox jCheckBox2; private javax.swing.JCheckBox jCheckBox3; private javax.swing.JCheckBox jCheckBox4; private javax.swing.JCheckBox jCheckBox5; private javax.swing.JCheckBox jCheckBox6; private javax.swing.JCheckBox jCheckBox7; private javax.swing.JCheckBox jCheckBox8; private javax.swing.JCheckBox jCheckBox9; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JButton removeButton; // End of variables declaration//GEN-END:variables }