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 @ 64

Revision 64, 8.0 KB checked in by bmcguffin, 9 years ago (diff)

Created the repeatable panel for the Incident Palette. The primary function of the palette is that it holds a series of copies of this panel. The panel displays critical information about the incident it's associated with; it also provides a button that, when clicked, causes this incident to be added to the script.

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