| 1 | package event.editor; |
|---|
| 2 | |
|---|
| 3 | import java.awt.event.*; |
|---|
| 4 | import java.util.Observable; |
|---|
| 5 | import java.util.StringTokenizer; |
|---|
| 6 | import scriptbuilder.structures.events.I_ScriptEvent; |
|---|
| 7 | import scriptbuilder.structures.events.WitnessEvent; |
|---|
| 8 | |
|---|
| 9 | /** |
|---|
| 10 | * |
|---|
| 11 | * @author nathaniellehrer |
|---|
| 12 | */ |
|---|
| 13 | public class WitnessPanel extends javax.swing.JPanel implements I_ScriptEventEditorPanel |
|---|
| 14 | { |
|---|
| 15 | |
|---|
| 16 | private ActionListener removeListener; |
|---|
| 17 | private WitnessEvent event; |
|---|
| 18 | |
|---|
| 19 | /** |
|---|
| 20 | * Creates new form WitnessPanel |
|---|
| 21 | */ |
|---|
| 22 | public WitnessPanel() |
|---|
| 23 | { |
|---|
| 24 | initComponents(); |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | @Override |
|---|
| 28 | public void getEventObject(I_ScriptEvent sei) |
|---|
| 29 | { |
|---|
| 30 | event = (WitnessEvent) sei; |
|---|
| 31 | StringTokenizer st = new StringTokenizer(event.witnessName); |
|---|
| 32 | if (st.hasMoreTokens()) |
|---|
| 33 | { |
|---|
| 34 | txtFirstName.setText(st.nextToken()); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | txtLastName.setText(""); |
|---|
| 38 | while (st.hasMoreTokens()) |
|---|
| 39 | { |
|---|
| 40 | txtLastName.setText(txtLastName.getText() + st.nextToken()); |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | txtPhoneNumber.setText("" + event.witnessNum); |
|---|
| 44 | |
|---|
| 45 | txtAddress.setText(event.witnessAddress); |
|---|
| 46 | |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | @Override |
|---|
| 50 | public void update(Observable o, Object arg) |
|---|
| 51 | { |
|---|
| 52 | throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | @Override |
|---|
| 56 | public boolean removeAssociatedEvent() |
|---|
| 57 | { |
|---|
| 58 | event.removeThis(); |
|---|
| 59 | event = null; |
|---|
| 60 | return true; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | @Override |
|---|
| 64 | public void uponClose() |
|---|
| 65 | { |
|---|
| 66 | event.witnessName = txtFirstName.getText() + " " + txtLastName.getText(); |
|---|
| 67 | event.witnessNum = txtPhoneNumber.getText(); |
|---|
| 68 | event.witnessAddress = txtAddress.getText(); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | /** |
|---|
| 72 | * This method is called from within the constructor to initialize the form. |
|---|
| 73 | * WARNING: Do NOT modify this code. The content of this method is always |
|---|
| 74 | * regenerated by the Form Editor. |
|---|
| 75 | */ |
|---|
| 76 | @SuppressWarnings("unchecked") |
|---|
| 77 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
|---|
| 78 | private void initComponents() |
|---|
| 79 | { |
|---|
| 80 | |
|---|
| 81 | jLabel1 = new javax.swing.JLabel(); |
|---|
| 82 | txtFirstName = new javax.swing.JTextField(); |
|---|
| 83 | jLabel2 = new javax.swing.JLabel(); |
|---|
| 84 | txtLastName = new javax.swing.JTextField(); |
|---|
| 85 | jLabel3 = new javax.swing.JLabel(); |
|---|
| 86 | txtAddress = new javax.swing.JTextField(); |
|---|
| 87 | jLabel4 = new javax.swing.JLabel(); |
|---|
| 88 | txtPhoneNumber = new javax.swing.JFormattedTextField(); |
|---|
| 89 | |
|---|
| 90 | jLabel1.setText("First Name"); |
|---|
| 91 | |
|---|
| 92 | jLabel2.setText("Last Name"); |
|---|
| 93 | |
|---|
| 94 | jLabel3.setText("Street Address"); |
|---|
| 95 | |
|---|
| 96 | jLabel4.setText("Phone Number"); |
|---|
| 97 | |
|---|
| 98 | txtPhoneNumber.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("(###)###-####")))); |
|---|
| 99 | |
|---|
| 100 | org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); |
|---|
| 101 | this.setLayout(layout); |
|---|
| 102 | layout.setHorizontalGroup( |
|---|
| 103 | layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 104 | .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() |
|---|
| 105 | .addContainerGap() |
|---|
| 106 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) |
|---|
| 107 | .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() |
|---|
| 108 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 109 | .add(jLabel3) |
|---|
| 110 | .add(jLabel1) |
|---|
| 111 | .add(jLabel2)) |
|---|
| 112 | .add(15, 15, 15) |
|---|
| 113 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 114 | .add(org.jdesktop.layout.GroupLayout.TRAILING, txtLastName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 547, Short.MAX_VALUE) |
|---|
| 115 | .add(txtAddress, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 547, Short.MAX_VALUE) |
|---|
| 116 | .add(org.jdesktop.layout.GroupLayout.TRAILING, txtFirstName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 547, Short.MAX_VALUE))) |
|---|
| 117 | .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() |
|---|
| 118 | .add(jLabel4) |
|---|
| 119 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) |
|---|
| 120 | .add(txtPhoneNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 547, Short.MAX_VALUE))) |
|---|
| 121 | .addContainerGap()) |
|---|
| 122 | ); |
|---|
| 123 | layout.setVerticalGroup( |
|---|
| 124 | layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 125 | .add(layout.createSequentialGroup() |
|---|
| 126 | .add(47, 47, 47) |
|---|
| 127 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 128 | .add(txtFirstName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
|---|
| 129 | .add(jLabel1)) |
|---|
| 130 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 131 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 132 | .add(txtLastName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
|---|
| 133 | .add(jLabel2)) |
|---|
| 134 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 135 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 136 | .add(txtAddress, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
|---|
| 137 | .add(jLabel3)) |
|---|
| 138 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 139 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 140 | .add(jLabel4) |
|---|
| 141 | .add(txtPhoneNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
|---|
| 142 | .addContainerGap(168, Short.MAX_VALUE)) |
|---|
| 143 | ); |
|---|
| 144 | }// </editor-fold>//GEN-END:initComponents |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | // Variables declaration - do not modify//GEN-BEGIN:variables |
|---|
| 148 | private javax.swing.JLabel jLabel1; |
|---|
| 149 | private javax.swing.JLabel jLabel2; |
|---|
| 150 | private javax.swing.JLabel jLabel3; |
|---|
| 151 | private javax.swing.JLabel jLabel4; |
|---|
| 152 | private javax.swing.JTextField txtAddress; |
|---|
| 153 | private javax.swing.JTextField txtFirstName; |
|---|
| 154 | private javax.swing.JTextField txtLastName; |
|---|
| 155 | private javax.swing.JFormattedTextField txtPhoneNumber; |
|---|
| 156 | // End of variables declaration//GEN-END:variables |
|---|
| 157 | |
|---|
| 158 | } |
|---|