source: tmcsimulator-scriptbuilder/trunk/src/event/editor/CADLogPanel.java @ 130

Revision 130, 3.4 KB checked in by bmcguffin, 9 years ago (diff)

Changed implementation of save function for event editor panels. Instead of updating their model objects whenever the enter key is pressed, panels are now notified when the window is closed and update their information then.

Line 
1package event.editor;
2
3import java.awt.event.*;
4import java.util.Observable;
5import scriptbuilder.structures.events.CADEvent;
6import scriptbuilder.structures.events.I_ScriptEvent;
7
8/**
9 *
10 * @author nathaniellehrer
11 */
12public class CADLogPanel extends javax.swing.JPanel implements I_ScriptEventEditorPanel
13{
14
15    private ActionListener removeListener;
16    private CADEvent event;
17
18    /**
19     * Creates new form DetailPanel
20     */
21    public CADLogPanel()
22    {
23        initComponents();
24    }
25    /**
26     * Load the script event associated with this editor panel.
27     *
28     * @param sei The script event in question
29     */
30    @Override
31    public void getEventObject(I_ScriptEvent sei)
32    {
33        event = (CADEvent) sei;
34        CadTextField.setText(event.detail);
35    }
36
37    @Override
38    public void update(Observable o, Object arg)
39    {
40        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
41    }
42
43    @Override
44    public boolean removeAssociatedEvent()
45    {
46        event.removeThis();
47        event = null;
48        return true;
49    }
50
51    @Override
52    public void uponClose()
53    {
54        event.detail = CadTextField.getText();
55    }
56
57    /**
58     * This method is called from within the constructor to initialize the form.
59     * WARNING: Do NOT modify this code. The content of this method is always
60     * regenerated by the Form Editor.
61     */
62    @SuppressWarnings("unchecked")
63    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
64    private void initComponents()
65    {
66
67        jLabel1 = new javax.swing.JLabel();
68        jScrollPane1 = new javax.swing.JScrollPane();
69        CadTextField = new javax.swing.JTextArea();
70
71        jLabel1.setText("Cad Log Text");
72
73        CadTextField.setColumns(20);
74        CadTextField.setRows(5);
75        jScrollPane1.setViewportView(CadTextField);
76
77        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
78        this.setLayout(layout);
79        layout.setHorizontalGroup(
80            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
81            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
82                .addContainerGap()
83                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
84                    .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 506, Short.MAX_VALUE)
85                    .add(layout.createSequentialGroup()
86                        .add(jLabel1)
87                        .add(0, 0, Short.MAX_VALUE)))
88                .addContainerGap())
89        );
90        layout.setVerticalGroup(
91            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
92            .add(layout.createSequentialGroup()
93                .add(19, 19, 19)
94                .add(jLabel1)
95                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
96                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
97                .addContainerGap())
98        );
99    }// </editor-fold>//GEN-END:initComponents
100
101
102    // Variables declaration - do not modify//GEN-BEGIN:variables
103    private javax.swing.JTextArea CadTextField;
104    private javax.swing.JLabel jLabel1;
105    private javax.swing.JScrollPane jScrollPane1;
106    // End of variables declaration//GEN-END:variables
107
108}
Note: See TracBrowser for help on using the repository browser.