View Javadoc
1   package info.mikethomas.fahview.v6project.panels;
2   
3   /*
4    * #%L
5    * This file is part of FAHView-v6project.
6    * %%
7    * Copyright (C) 2011 - 2017 Mike Thomas <mikepthomas@outlook.com>
8    * %%
9    * FAHView is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as published by
11   * the Free Software Foundation, either version 3 of the License, or
12   * (at your option) any later version.
13   * %
14   * FAHView is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * %
19   * You should have received a copy of the GNU General Public License
20   * along with FAHView.  If not, see <http://www.gnu.org/licenses/>.
21   * #L%
22   */
23  
24  import info.mikethomas.fahview.v6project.utilities.LogReader;
25  import info.mikethomas.fahview.v6project.utilities.ProgressCellRenderer;
26  import javax.swing.JTable;
27  
28  /**
29   * The main User Interface of the FAHView program.
30   *
31   * @author <a href="mailto:mikepthomas@outlook.com">Michael Thomas</a>
32   * @version $Id: $Id
33   */
34  public class QueuePanel extends javax.swing.JPanel {
35  
36      /**
37       * Creates new form QueuePanel
38       */
39      public QueuePanel() {
40          initComponents();
41  
42          table.getColumn("Progress").setCellRenderer(new ProgressCellRenderer());
43      }
44  
45      /**
46       * Get this QueuePanel table instance
47       *
48       * @return JTable table
49       */
50      public JTable getTable() {
51          return table;
52      }
53  
54      /**
55       * Set the Status value in the QueuePanel table to a specified value at the
56       * required position
57       *
58       * @param position location in the table to change value.
59       * @param value the value to change to
60       */
61      protected void setStatus(int position, int value) {
62          table.getModel().setValueAt(value, position, 1);
63      }
64  
65      /**
66       * Set the Percentage value in the QueuePanel table to a specified value at the
67       * required position
68       *
69       * @param position location in the table to change value.
70       * @param value the value to change to
71       */
72      protected void setPercentage(int position, String value) {
73          table.getModel().setValueAt(value, position, 2);
74      }
75  
76      /**
77       * Set the Project value in the QueuePanel table to a specified value at the
78       * required position
79       *
80       * @param position location in the table to change value.
81       * @param value the value to change to
82       */
83      protected void setProject(int position, String value) {
84          table.getModel().setValueAt(value, position, 3);
85      }
86  
87      /**
88       * Set the Issue time for the current work unit
89       *
90       * @param issued the issue time for current work unit
91       */
92      protected void setIssued(String issued) {
93          this.issued.setText(issued);
94      }
95  
96      /**
97       * Set the Work server for the current work unit
98       *
99       * @param workServer the work server for current work unit
100      */
101     protected void setWorkServer(String workServer) {
102         this.workServer.setText(workServer);
103     }
104 
105     /**
106      * Set the Collection server for the current work unit
107      *
108      * @param collectionServer the collection server for current work unit
109      */
110     protected void setCollectionServer(String collectionServer) {
111         this.collectionServer.setText(collectionServer);
112     }
113 
114     /**
115      * Set the User Name for the current work unit
116      *
117      * @param userName the user name for current work unit
118      */
119     protected void setUserName(String userName) {
120         this.userName.setText(userName);
121     }
122 
123     /**
124      * Set the Team Number for the current work unit
125      *
126      * @param teamNumber the team number for current work unit
127      */
128     protected void setTeamNumber(String teamNumber) {
129         this.teamNumber.setText(teamNumber);
130     }
131 
132     /**
133      * Set the Core Type for the current work unit
134      *
135      * @param core the core type for current work unit
136      */
137     protected void setCore(String core) {
138         this.core.setText(core);
139     }
140 
141     /**
142      * This method is called from within the constructor to initialize the form.
143      * WARNING: Do NOT modify this code. The content of this method is always
144      * regenerated by the Form Editor.
145      */
146     @SuppressWarnings("unchecked")
147     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
148     private void initComponents() {
149 
150         queueWindow = new javax.swing.JScrollPane();
151         table = new javax.swing.JTable();
152         currentWU = new javax.swing.JInternalFrame();
153         issuedLabel = new javax.swing.JLabel();
154         workServerLabel = new javax.swing.JLabel();
155         collectionServerLabel = new javax.swing.JLabel();
156         UserNameLabel = new javax.swing.JLabel();
157         TeamNumberLabel = new javax.swing.JLabel();
158         issued = new javax.swing.JLabel();
159         workServer = new javax.swing.JLabel();
160         collectionServer = new javax.swing.JLabel();
161         userName = new javax.swing.JLabel();
162         teamNumber = new javax.swing.JLabel();
163         coreLabel = new javax.swing.JLabel();
164         core = new javax.swing.JLabel();
165 
166         table.setModel(new javax.swing.table.DefaultTableModel(
167             new Object [][] {
168                 {"0", null, "0%", null},
169                 {"1", null, "0%", null},
170                 {"2", null, "0%", null},
171                 {"3", null, "0%", null},
172                 {"4", null, "0%", null},
173                 {"5", null, "0%", null},
174                 {"6", null, "0%", null},
175                 {"7", null, "0%", null},
176                 {"8", null, "0%", null},
177                 {"9", null, "0%", null}
178             },
179             new String [] {
180                 "Position", "Status", "Progress", "Project"
181             }
182         ) {
183             Class[] types = new Class [] {
184                 java.lang.String.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class
185             };
186             boolean[] canEdit = new boolean [] {
187                 true, false, true, false
188             };
189 
190             public Class getColumnClass(int columnIndex) {
191                 return types [columnIndex];
192             }
193 
194             public boolean isCellEditable(int rowIndex, int columnIndex) {
195                 return canEdit [columnIndex];
196             }
197         });
198         table.setEnabled(false);
199         queueWindow.setViewportView(table);
200 
201         currentWU.setVisible(true);
202 
203         issuedLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
204         org.openide.awt.Mnemonics.setLocalizedText(issuedLabel, org.openide.util.NbBundle.getMessage(QueuePanel.class, "QueuePanel.issuedLabel.text")); // NOI18N
205 
206         workServerLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
207         org.openide.awt.Mnemonics.setLocalizedText(workServerLabel, org.openide.util.NbBundle.getMessage(QueuePanel.class, "QueuePanel.workServerLabel.text")); // NOI18N
208 
209         collectionServerLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
210         org.openide.awt.Mnemonics.setLocalizedText(collectionServerLabel, org.openide.util.NbBundle.getMessage(QueuePanel.class, "QueuePanel.collectionServerLabel.text")); // NOI18N
211 
212         UserNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
213         org.openide.awt.Mnemonics.setLocalizedText(UserNameLabel, org.openide.util.NbBundle.getMessage(QueuePanel.class, "QueuePanel.UserNameLabel.text")); // NOI18N
214 
215         TeamNumberLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
216         org.openide.awt.Mnemonics.setLocalizedText(TeamNumberLabel, org.openide.util.NbBundle.getMessage(QueuePanel.class, "QueuePanel.TeamNumberLabel.text")); // NOI18N
217 
218         coreLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
219         org.openide.awt.Mnemonics.setLocalizedText(coreLabel, org.openide.util.NbBundle.getMessage(QueuePanel.class, "QueuePanel.coreLabel.text")); // NOI18N
220 
221         org.jdesktop.layout.GroupLayout currentWULayout = new org.jdesktop.layout.GroupLayout(currentWU.getContentPane());
222         currentWU.getContentPane().setLayout(currentWULayout);
223         currentWULayout.setHorizontalGroup(
224             currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
225             .add(currentWULayout.createSequentialGroup()
226                 .addContainerGap()
227                 .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
228                     .add(currentWULayout.createSequentialGroup()
229                         .add(6, 6, 6)
230                         .add(coreLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
231                     .add(org.jdesktop.layout.GroupLayout.TRAILING, UserNameLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
232                     .add(issuedLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
233                     .add(workServerLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
234                     .add(collectionServerLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
235                     .add(org.jdesktop.layout.GroupLayout.TRAILING, TeamNumberLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
236                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
237                 .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
238                     .add(issued, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
239                     .add(workServer, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
240                     .add(collectionServer, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
241                     .add(userName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
242                     .add(teamNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
243                     .add(core, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE))
244                 .addContainerGap())
245         );
246         currentWULayout.setVerticalGroup(
247             currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
248             .add(currentWULayout.createSequentialGroup()
249                 .addContainerGap()
250                 .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
251                     .add(issuedLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
252                     .add(issued, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
253                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
254                 .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
255                     .add(workServerLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
256                     .add(workServer, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
257                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
258                 .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
259                     .add(collectionServerLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
260                     .add(collectionServer, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
261                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
262                 .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
263                     .add(UserNameLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
264                     .add(userName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
265                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
266                 .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
267                     .add(TeamNumberLabel)
268                     .add(teamNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
269                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
270                 .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
271                     .add(coreLabel)
272                     .add(core, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
273                 .addContainerGap(110, Short.MAX_VALUE))
274         );
275 
276         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
277         this.setLayout(layout);
278         layout.setHorizontalGroup(
279             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
280             .add(layout.createSequentialGroup()
281                 .addContainerGap()
282                 .add(queueWindow, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 320, Short.MAX_VALUE)
283                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
284                 .add(currentWU, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
285                 .addContainerGap())
286         );
287         layout.setVerticalGroup(
288             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
289             .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
290                 .addContainerGap()
291                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
292                     .add(currentWU)
293                     .add(queueWindow, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
294                 .addContainerGap())
295         );
296     }// </editor-fold>//GEN-END:initComponents
297     // Variables declaration - do not modify//GEN-BEGIN:variables
298     private javax.swing.JLabel TeamNumberLabel;
299     private javax.swing.JLabel UserNameLabel;
300     private javax.swing.JLabel collectionServer;
301     private javax.swing.JLabel collectionServerLabel;
302     private javax.swing.JLabel core;
303     private javax.swing.JLabel coreLabel;
304     private javax.swing.JInternalFrame currentWU;
305     private javax.swing.JLabel issued;
306     private javax.swing.JLabel issuedLabel;
307     private javax.swing.JScrollPane queueWindow;
308     private javax.swing.JTable table;
309     private javax.swing.JLabel teamNumber;
310     private javax.swing.JLabel userName;
311     private javax.swing.JLabel workServer;
312     private javax.swing.JLabel workServerLabel;
313     // End of variables declaration//GEN-END:variables
314 }