Warning: Can't use blame annotator:
svn blame failed on trunk/src/event/editor/TowPanel.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator-scriptbuilder/trunk/src/event/editor/TowPanel.java @ 140

Revision 140, 7.7 KB checked in by bmcguffin, 8 years ago (diff)

Fixed defect #67. Removing an event and then closing the event editor window no longer causes the program to hang; a null check for the event is encountered before taking action upon close of the window.

RevLine 
1package event.editor;
2
3import java.awt.event.*;
4import java.util.Observable;
5import scriptbuilder.structures.events.I_ScriptEvent;
6import scriptbuilder.structures.events.TowEvent;
7
8/**
9 *
10 * @author nathaniellehrer
11 */
12public class TowPanel extends javax.swing.JPanel implements I_ScriptEventEditorPanel
13{
14
15    private ActionListener removeListener;
16    private TowEvent event;
17
18    /**
19     * Creates new form TowPanel
20     */
21    public TowPanel()
22    {
23        initComponents();
24
25        txtConfirmationNumber.addFocusListener(new FocusListener()
26        {
27
28            public void focusGained(FocusEvent e)
29            {
30                help.setText("Confirmation number is formated as a telephone number. Example: (555)555-5555");
31            }
32
33            public void focusLost(FocusEvent e)
34            {
35                help.setText("");
36            }
37
38        });
39
40        txtPublicNumber.addFocusListener(new FocusListener()
41        {
42
43            public void focusGained(FocusEvent e)
44            {
45                help.setText("Public number is formated as a telephone number. Example: (555)555-5555");
46            }
47
48            public void focusLost(FocusEvent e)
49            {
50                help.setText("");
51            }
52
53        });
54
55    }
56
57    @Override
58    public void getEventObject(I_ScriptEvent sei)
59    {
60        event = (TowEvent) sei;
61        txtCompany.setText(event.towCompany);
62
63        txtBeat.setText(event.towBeat);
64
65        txtConfirmationNumber.setText("" + event.towConfNum);
66
67        txtPublicNumber.setText("" + event.towPubNum);
68
69    }
70
71    @Override
72    public void update(Observable o, Object arg)
73    {
74        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
75    }
76
77    @Override
78    public boolean removeAssociatedEvent()
79    {
80        event.removeThis();
81        event = null;
82        return true;
83    }
84
85    @Override
86    public void uponClose()
87    {
88        if (event != null)
89        {
90            event.towCompany = txtCompany.getText();
91            event.towBeat = txtBeat.getText();
92            event.towConfNum = txtConfirmationNumber.getText();
93            event.towPubNum = txtPublicNumber.getText();
94        }
95    }
96
97    /**
98     * This method is called from within the constructor to initialize the form.
99     * WARNING: Do NOT modify this code. The content of this method is always
100     * regenerated by the Form Editor.
101     */
102    @SuppressWarnings("unchecked")
103    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
104    private void initComponents()
105    {
106
107        jLabel1 = new javax.swing.JLabel();
108        txtCompany = new javax.swing.JTextField();
109        jLabel2 = new javax.swing.JLabel();
110        txtConfirmationNumber = new javax.swing.JFormattedTextField();
111        jLabel3 = new javax.swing.JLabel();
112        txtPublicNumber = new javax.swing.JFormattedTextField();
113        jLabel4 = new javax.swing.JLabel();
114        txtBeat = new javax.swing.JTextField();
115        help = new javax.swing.JLabel();
116
117        jLabel1.setText("Company");
118
119        jLabel2.setText("Confirmation Number");
120
121        try
122        {
123            txtConfirmationNumber.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)###-####")));
124        } catch (java.text.ParseException ex)
125        {
126            ex.printStackTrace();
127        }
128
129        jLabel3.setText("Public Number");
130
131        try
132        {
133            txtPublicNumber.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)###-####")));
134        } catch (java.text.ParseException ex)
135        {
136            ex.printStackTrace();
137        }
138
139        jLabel4.setText("Beat");
140
141        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
142        this.setLayout(layout);
143        layout.setHorizontalGroup(
144            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
145            .add(layout.createSequentialGroup()
146                .addContainerGap()
147                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
148                    .add(help, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 543, Short.MAX_VALUE)
149                    .add(layout.createSequentialGroup()
150                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
151                            .add(jLabel1)
152                            .add(jLabel2)
153                            .add(jLabel3)
154                            .add(jLabel4))
155                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
156                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
157                            .add(txtBeat, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
158                            .add(txtCompany, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
159                            .add(txtConfirmationNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
160                            .add(txtPublicNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE))))
161                .addContainerGap())
162        );
163        layout.setVerticalGroup(
164            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
165            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
166                .add(47, 47, 47)
167                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
168                    .add(jLabel1)
169                    .add(txtCompany, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
170                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
171                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
172                    .add(jLabel2)
173                    .add(txtConfirmationNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
174                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
175                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
176                    .add(jLabel3)
177                    .add(txtPublicNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
178                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
179                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
180                    .add(jLabel4)
181                    .add(txtBeat, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
182                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 72, Short.MAX_VALUE)
183                .add(help, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
184                .addContainerGap())
185        );
186    }// </editor-fold>//GEN-END:initComponents
187
188
189    // Variables declaration - do not modify//GEN-BEGIN:variables
190    private javax.swing.JLabel help;
191    private javax.swing.JLabel jLabel1;
192    private javax.swing.JLabel jLabel2;
193    private javax.swing.JLabel jLabel3;
194    private javax.swing.JLabel jLabel4;
195    private javax.swing.JTextField txtBeat;
196    private javax.swing.JTextField txtCompany;
197    private javax.swing.JFormattedTextField txtConfirmationNumber;
198    private javax.swing.JFormattedTextField txtPublicNumber;
199    // End of variables declaration//GEN-END:variables
200
201}
Note: See TracBrowser for help on using the repository browser.