source: tmcsimulator-scriptbuilder/trunk/src/event/editor/MaintenanceRadioPanel.java @ 89

Revision 89, 3.5 KB checked in by bmcguffin, 9 years ago (diff)

Added dropdown menu item to ScriptBuilderFrame?: "Delete Incident". When clicked, user may select an existing incident to delete. Program will prompt user to confirm the deletion, then remove the incident from the script and refresh the display.

Added button to individual event editor window: "Remove this event". When clicked, the currently displayed event will be removed from the timeslice it is in. The display will be refreshed accordingly. NOTE: This still has some bugs, namely that the last remaining event in a timeslice fails to be deleted.

Restructured Interface ScriptEventEditorPanel? to include a removeAssociatedEvent method, which calls a new method in I_ScriptEvent called removeThis, which causes the event to be removed from its timeslice.

Editor.Java previously contained several classes and enums, none of which were set to private scope. Moved these extra classes to their own files to decrease clutter in Editor.java and increase readability of all files.

Line 
1package event.editor;
2
3import java.awt.event.*;
4import java.util.Observable;
5import scriptbuilder.structures.events.*;
6
7/**
8 *
9 * @author nathaniellehrer
10 */
11public class MaintenanceRadioPanel extends javax.swing.JPanel implements ScriptEventEditorPanel
12{
13
14    private ActionListener removeListener;
15    private MaintenanceRadioEvent event;
16
17    /**
18     * Creates new form MaintenanceRadio
19     */
20    public MaintenanceRadioPanel()
21    {
22        initComponents();
23    }
24
25    public void getEventObject(I_ScriptEvent sei)
26    {
27        event = (MaintenanceRadioEvent) sei;
28        jTextArea1.setText(event.message);
29        jTextArea1.addKeyListener(new KeyListener()
30        {
31
32            public void keyTyped(KeyEvent e)
33            {
34            }
35
36            public void keyPressed(KeyEvent e)
37            {
38                if (e.getKeyCode() == KeyEvent.VK_ENTER)
39                {
40                    event.message = jTextArea1.getText();
41                }
42            }
43
44            public void keyReleased(KeyEvent e)
45            {
46            }
47        });
48    }
49
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        ((I_ScriptEvent)event).removeThis();
59        event = null;
60        return true;
61    }
62
63    /**
64     * This method is called from within the constructor to initialize the form.
65     * WARNING: Do NOT modify this code. The content of this method is always
66     * regenerated by the Form Editor.
67     */
68    @SuppressWarnings("unchecked")
69    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
70    private void initComponents() {
71
72        jScrollPane1 = new javax.swing.JScrollPane();
73        jTextArea1 = new javax.swing.JTextArea();
74        jLabel1 = new javax.swing.JLabel();
75
76        jTextArea1.setColumns(20);
77        jTextArea1.setRows(5);
78        jTextArea1.setToolTipText("The radio transmission");
79        jScrollPane1.setViewportView(jTextArea1);
80
81        jLabel1.setText("Transmission:");
82
83        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
84        this.setLayout(layout);
85        layout.setHorizontalGroup(
86            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
87            .add(layout.createSequentialGroup()
88                .addContainerGap()
89                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
90                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 583, Short.MAX_VALUE)
91                    .add(jLabel1))
92                .addContainerGap())
93        );
94        layout.setVerticalGroup(
95            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
96            .add(layout.createSequentialGroup()
97                .addContainerGap()
98                .add(jLabel1)
99                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
100                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 95, Short.MAX_VALUE)
101                .addContainerGap())
102        );
103    }// </editor-fold>//GEN-END:initComponents
104
105
106    // Variables declaration - do not modify//GEN-BEGIN:variables
107    private javax.swing.JLabel jLabel1;
108    private javax.swing.JScrollPane jScrollPane1;
109    private javax.swing.JTextArea jTextArea1;
110    // End of variables declaration//GEN-END:variables
111
112}
Note: See TracBrowser for help on using the repository browser.