Warning: Can't use blame annotator:
svn blame failed on trunk/src/scriptbuilder/gui/panels/IncidentPaletteAddPanel.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/gui/panels/IncidentPaletteAddPanel.java @ 76

Revision 76, 8.2 KB checked in by bmcguffin, 9 years ago (diff)

Added javadoc for several files.

RevLine 
1/*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6package scriptbuilder.gui.panels;
7
8import java.text.DateFormat;
9import java.text.SimpleDateFormat;
10import java.util.Date;
11import java.util.TimeZone;
12import scriptbuilder.gui.IncidentPaletteFrame;
13import scriptbuilder.structures.ELEMENT;
14import scriptbuilder.structures.ScriptIncident;
15import scriptbuilder.structures.XMLWriter;
16
17/**
18 *
19 * @author Bryan McGuffin
20 */
21public class IncidentPaletteAddPanel extends javax.swing.JPanel
22{
23
24    /**
25     * The script incident represented by this panel.
26     */
27    public ScriptIncident incident;
28
29    IncidentPaletteFrame frame;
30
31    /**
32     * Create new IncidentPaletteAddPanel from the form.
33     *
34     * @param inc the incident to be represented in this panel.
35     * @param frame the parent palette which holds this panel.
36     */
37    public IncidentPaletteAddPanel(ScriptIncident inc, IncidentPaletteFrame frame)
38    {
39        incident = inc;
40
41        this.frame = frame;
42
43        initComponents();
44
45        SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
46        df.setTimeZone(TimeZone.getTimeZone("GMT"));
47        String incLength = df.format(new Date(incident.length * 1000));
48
49        labelIncidentTitle.setText(incident.number + ": " + incident.name);
50
51        labelIncidentLength.setText("Length: " + incLength);
52
53        labelIncidentEventCount.setText(incident.eventCount + " events");
54
55        txtIncidentDescription.setText(incident.description);
56
57    }
58
59    /**
60     * This method is called from within the constructor to initialize the form.
61     * WARNING: Do NOT modify this code. The content of this method is always
62     * regenerated by the Form Editor.
63     */
64    @SuppressWarnings("unchecked")
65    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
66    private void initComponents()
67    {
68
69        labelIncidentTitle = new javax.swing.JLabel();
70        jSeparator1 = new javax.swing.JSeparator();
71        btnAddIncident = new javax.swing.JButton();
72        txtIncidentStart = new javax.swing.JTextField();
73        labelIncidentLength = new javax.swing.JLabel();
74        labelIncidentEventCount = new javax.swing.JLabel();
75        jScrollPane1 = new javax.swing.JScrollPane();
76        txtIncidentDescription = new javax.swing.JTextArea();
77
78        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
79        setEnabled(false);
80        setMaximumSize(new java.awt.Dimension(524, 143));
81
82        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
83
84        btnAddIncident.setText("Add");
85        btnAddIncident.addActionListener(new java.awt.event.ActionListener()
86        {
87            public void actionPerformed(java.awt.event.ActionEvent evt)
88            {
89                btnAddIncidentActionPerformed(evt);
90            }
91        });
92
93        txtIncidentStart.setText("00:00:00");
94
95        txtIncidentDescription.setEditable(false);
96        txtIncidentDescription.setColumns(20);
97        txtIncidentDescription.setLineWrap(true);
98        txtIncidentDescription.setRows(5);
99        txtIncidentDescription.setToolTipText("");
100        txtIncidentDescription.setWrapStyleWord(true);
101        txtIncidentDescription.setMaximumSize(new java.awt.Dimension(240, 80));
102        txtIncidentDescription.setMinimumSize(new java.awt.Dimension(240, 80));
103        jScrollPane1.setViewportView(txtIncidentDescription);
104
105        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
106        this.setLayout(layout);
107        layout.setHorizontalGroup(
108            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
109            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
110                .addContainerGap()
111                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
112                    .addComponent(labelIncidentLength, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
113                    .addComponent(labelIncidentTitle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
114                    .addComponent(labelIncidentEventCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
115                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
116                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
117                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
118                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
119                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
120                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
121                    .addComponent(txtIncidentStart, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE)
122                    .addComponent(btnAddIncident, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
123                .addContainerGap())
124        );
125        layout.setVerticalGroup(
126            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
127            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
128                .addContainerGap()
129                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
130                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING)
131                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
132                        .addComponent(labelIncidentTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
133                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
134                        .addComponent(labelIncidentLength, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
135                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
136                        .addComponent(labelIncidentEventCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
137                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
138                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
139                        .addComponent(btnAddIncident, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
140                        .addGap(15, 15, 15)
141                        .addComponent(txtIncidentStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
142                .addContainerGap())
143        );
144    }// </editor-fold>//GEN-END:initComponents
145
146    private void btnAddIncidentActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnAddIncidentActionPerformed
147    {//GEN-HEADEREND:event_btnAddIncidentActionPerformed
148        String[] tokens = txtIncidentStart.getText().split(":");
149
150        int hrs = Integer.parseInt(tokens[0]);
151        int mins = Integer.parseInt(tokens[1]);
152        int secs = Integer.parseInt(tokens[2]);
153
154        int duration = (3600 * hrs) + (60 * mins) + secs;
155
156        incident.setOffset(duration);
157
158        frame.addIncidentToScript(this);
159    }//GEN-LAST:event_btnAddIncidentActionPerformed
160
161
162    // Variables declaration - do not modify//GEN-BEGIN:variables
163    private javax.swing.JButton btnAddIncident;
164    private javax.swing.JScrollPane jScrollPane1;
165    private javax.swing.JSeparator jSeparator1;
166    private javax.swing.JLabel labelIncidentEventCount;
167    private javax.swing.JLabel labelIncidentLength;
168    private javax.swing.JLabel labelIncidentTitle;
169    private javax.swing.JTextArea txtIncidentDescription;
170    private javax.swing.JTextField txtIncidentStart;
171    // End of variables declaration//GEN-END:variables
172}
Note: See TracBrowser for help on using the repository browser.