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

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

Revision 92, 9.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.

RevLine 
1package event.editor;
2
3import java.awt.event.*;
4import java.util.Observable;
5import scriptbuilder.structures.events.I_ScriptEvent;
6import scriptbuilder.structures.events.UnitEvent;
7
8/**
9 *
10 * @author nathaniellehrer
11 */
12public class UnitPanel extends javax.swing.JPanel implements I_ScriptEventEditorPanel
13{
14
15    private ActionListener removeListener;
16    private UnitEvent event;
17
18    /**
19     * Creates new form UnitPanel
20     */
21    public UnitPanel()
22    {
23        initComponents();
24
25        txtUnitNumber.addFocusListener(new FocusListener()
26        {
27
28            public void focusGained(FocusEvent e)
29            {
30                help.setText("Unit number is formatted as #-#\t\tExample: 5-5");
31            }
32
33            public void focusLost(FocusEvent e)
34            {
35                help.setText("");
36            }
37
38        });
39    }
40
41    @Override
42    public void getEventObject(I_ScriptEvent sei)
43    {
44        event = (UnitEvent) sei;
45        txtUnitNumber.setText(event.unitNum);
46        for (int i = 0; i < ActiveDropdown.getItemCount(); i++)
47        {
48            if (event.unitActive.equalsIgnoreCase((String) ActiveDropdown.getItemAt(i)))
49            {
50                ActiveDropdown.setSelectedIndex(i);
51            }
52        }
53        txtUnitNumber.addKeyListener(new KeyListener()
54        {
55            public void keyTyped(KeyEvent e)
56            {
57            }
58            public void keyPressed(KeyEvent e)
59            {
60                if (e.getKeyCode() == KeyEvent.VK_ENTER)
61                {
62                    event.unitNum = txtUnitNumber.getText();
63                }
64            }
65            public void keyReleased(KeyEvent e)
66            {
67            }
68        });
69        ActiveDropdown.addActionListener(new ActionListener()
70        {
71
72            public void actionPerformed(ActionEvent e)
73            {
74                event.unitActive = ActiveDropdown.getSelectedItem().toString();
75            }
76        });
77        for (int i = 0; i < PrimaryDropdown.getItemCount(); i++)
78        {
79            if (event.unitPrimary.equalsIgnoreCase((String) PrimaryDropdown.getItemAt(i)))
80            {
81                PrimaryDropdown.setSelectedIndex(i);
82            }
83        }
84        PrimaryDropdown.addActionListener(new ActionListener()
85        {
86
87            public void actionPerformed(ActionEvent e)
88            {
89                event.unitPrimary = PrimaryDropdown.getSelectedItem().toString();
90            }
91        });
92        boolean containsItem = false;
93        for (int i = 0; i < StatusDropdown.getItemCount() && !containsItem; i++)
94        {
95            if (event.unitStatus.equalsIgnoreCase((String) StatusDropdown.getItemAt(i)))
96            {
97                StatusDropdown.setSelectedIndex(i);
98                containsItem = true;
99            }
100        }
101        if (!containsItem)
102        {
103            StatusDropdown.addItem(event.unitStatus);
104            StatusDropdown.setSelectedItem(StatusDropdown.getItemCount() - 1);
105        }
106        StatusDropdown.addActionListener(new ActionListener()
107        {
108
109            public void actionPerformed(ActionEvent e)
110            {
111                event.unitStatus = StatusDropdown.getSelectedItem().toString();
112            }
113        });
114    }
115
116    @Override
117    public void update(Observable o, Object arg)
118    {
119        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
120    }
121   
122    @Override
123    public boolean removeAssociatedEvent()
124    {
125        event.removeThis();
126        event = null;
127        return true;
128    }
129
130    /**
131     * This method is called from within the constructor to initialize the form.
132     * WARNING: Do NOT modify this code. The content of this method is always
133     * regenerated by the Form Editor.
134     */
135    @SuppressWarnings("unchecked")
136    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
137    private void initComponents()
138    {
139
140        jLabel1 = new javax.swing.JLabel();
141        txtUnitNumber = new javax.swing.JFormattedTextField();
142        jLabel2 = new javax.swing.JLabel();
143        StatusDropdown = new javax.swing.JComboBox();
144        jLabel3 = new javax.swing.JLabel();
145        PrimaryDropdown = new javax.swing.JComboBox();
146        jLabel4 = new javax.swing.JLabel();
147        ActiveDropdown = new javax.swing.JComboBox();
148        help = new javax.swing.JLabel();
149
150        jLabel1.setText("Unit Number");
151
152        txtUnitNumber.setText("  -  ");
153        txtUnitNumber.setToolTipText("");
154
155        jLabel2.setText("Status");
156
157        StatusDropdown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1098", "1097", "ENRT" }));
158
159        jLabel3.setText("Primary");
160
161        PrimaryDropdown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "True", "False" }));
162
163        jLabel4.setText("Active");
164
165        ActiveDropdown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "True", "False" }));
166
167        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
168        this.setLayout(layout);
169        layout.setHorizontalGroup(
170            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
171            .add(layout.createSequentialGroup()
172                .addContainerGap()
173                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
174                    .add(org.jdesktop.layout.GroupLayout.TRAILING, help, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 565, Short.MAX_VALUE)
175                    .add(layout.createSequentialGroup()
176                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
177                            .add(jLabel1)
178                            .add(jLabel2))
179                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
180                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
181                            .add(StatusDropdown, 0, 475, Short.MAX_VALUE)
182                            .add(txtUnitNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 475, Short.MAX_VALUE)))
183                    .add(layout.createSequentialGroup()
184                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
185                            .add(jLabel3)
186                            .add(jLabel4))
187                        .add(43, 43, 43)
188                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
189                            .add(ActiveDropdown, 0, 475, Short.MAX_VALUE)
190                            .add(PrimaryDropdown, 0, 475, Short.MAX_VALUE))))
191                .addContainerGap())
192        );
193        layout.setVerticalGroup(
194            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
195            .add(layout.createSequentialGroup()
196                .add(47, 47, 47)
197                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
198                    .add(jLabel1)
199                    .add(txtUnitNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
200                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
201                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
202                    .add(jLabel2)
203                    .add(StatusDropdown, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
204                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
205                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
206                    .add(jLabel3)
207                    .add(PrimaryDropdown, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
208                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
209                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
210                    .add(jLabel4)
211                    .add(ActiveDropdown, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
212                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 128, Short.MAX_VALUE)
213                .add(help, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
214                .addContainerGap())
215        );
216    }// </editor-fold>//GEN-END:initComponents
217
218
219    // Variables declaration - do not modify//GEN-BEGIN:variables
220    private javax.swing.JComboBox ActiveDropdown;
221    private javax.swing.JComboBox PrimaryDropdown;
222    private javax.swing.JComboBox StatusDropdown;
223    private javax.swing.JLabel help;
224    private javax.swing.JLabel jLabel1;
225    private javax.swing.JLabel jLabel2;
226    private javax.swing.JLabel jLabel3;
227    private javax.swing.JLabel jLabel4;
228    private javax.swing.JFormattedTextField txtUnitNumber;
229    // End of variables declaration//GEN-END:variables
230
231}
Note: See TracBrowser for help on using the repository browser.