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

source: tmcsimulator-scriptbuilder/trunk/src/event/editor/AudioPanel.java @ 180

Revision 180, 4.6 KB checked in by sdanthin, 6 years ago (diff)

PropertyPanels?.java added a function to get properties from a certain jPanel.
Editor.java used above function to auto-close the editor window when it has no more events contained.
AudioPanel?.java modified to NOT allow audioEvents in the Event Editor to be deleted.

RevLine 
1package event.editor;
2
3import java.awt.event.*;
4import java.util.Observable;
5import javax.swing.*;
6import scriptbuilder.structures.events.AudioEvent;
7import scriptbuilder.structures.events.I_ScriptEvent;
8
9/**
10 *
11 * @author nathaniellehrer
12 */
13public class AudioPanel extends javax.swing.JPanel implements I_ScriptEventEditorPanel
14{
15
16    private ActionListener removeListener;
17    private AudioEvent event;
18
19    /**
20     * Creates new form AudioPanel
21     */
22    public AudioPanel()
23    {
24        initComponents();
25    }
26
27    @Override
28    public void getEventObject(I_ScriptEvent sei)
29    {
30        event = (AudioEvent) sei;
31        audioFileText.setText(event.audioPath);
32        audioLengthText.setText(event.audioLength.toString());
33    }
34
35    @Override
36    public void update(Observable o, Object arg)
37    {
38        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
39    }
40
41    @Override
42    public boolean removeAssociatedEvent()
43    {
44        //this makes it not possible to remove an AudioEvent from the script without deleting its respective I_AudioEvent.
45//        event.removeThis();
46//        event = null;
47        return false;
48    }
49
50    @Override
51    public void uponClose()
52    {
53        if (event != null)
54        {
55            event.audioPath = audioFileText.getText();
56            try
57            {
58                event.audioLength = Integer.parseInt(audioLengthText.getText());
59            }
60            catch (Exception ex)
61            {
62
63            }
64        }
65    }
66
67    /**
68     * This method is called from within the constructor to initialize the form.
69     * WARNING: Do NOT modify this code. The content of this method is always
70     * regenerated by the Form Editor.
71     */
72    @SuppressWarnings("unchecked")
73    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
74    private void initComponents() {
75
76        jLabel1 = new javax.swing.JLabel();
77        audioFileText = new javax.swing.JTextField();
78        jLabel2 = new javax.swing.JLabel();
79        audioLengthText = new javax.swing.JFormattedTextField();
80
81        jLabel1.setText("Audio File");
82
83        audioFileText.setToolTipText("The path to the audio file");
84        audioFileText.setEnabled(false);
85
86        jLabel2.setText("Length");
87
88        audioLengthText.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(java.text.NumberFormat.getIntegerInstance())));
89
90        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
91        this.setLayout(layout);
92        layout.setHorizontalGroup(
93            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
94            .add(layout.createSequentialGroup()
95                .addContainerGap()
96                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
97                    .add(jLabel1)
98                    .add(jLabel2))
99                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
100                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
101                    .add(audioLengthText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE)
102                    .add(audioFileText))
103                .addContainerGap())
104        );
105        layout.setVerticalGroup(
106            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
107            .add(layout.createSequentialGroup()
108                .add(44, 44, 44)
109                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
110                    .add(audioFileText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
111                    .add(jLabel1))
112                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
113                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
114                    .add(audioLengthText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
115                    .add(jLabel2))
116                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
117        );
118    }// </editor-fold>//GEN-END:initComponents
119
120
121    // Variables declaration - do not modify//GEN-BEGIN:variables
122    private javax.swing.JTextField audioFileText;
123    private javax.swing.JFormattedTextField audioLengthText;
124    private javax.swing.JLabel jLabel1;
125    private javax.swing.JLabel jLabel2;
126    // End of variables declaration//GEN-END:variables
127
128}
Note: See TracBrowser for help on using the repository browser.