| 1 | package tmcsim.client.cadclientgui.screens; |
|---|
| 2 | |
|---|
| 3 | import java.awt.Color; |
|---|
| 4 | import java.awt.Component; |
|---|
| 5 | import java.awt.Dimension; |
|---|
| 6 | import java.awt.Toolkit; |
|---|
| 7 | import java.awt.datatransfer.DataFlavor; |
|---|
| 8 | import java.awt.datatransfer.StringSelection; |
|---|
| 9 | import java.awt.datatransfer.Transferable; |
|---|
| 10 | import java.awt.event.ActionEvent; |
|---|
| 11 | import java.awt.event.ActionListener; |
|---|
| 12 | import java.awt.event.ComponentEvent; |
|---|
| 13 | import java.awt.event.ComponentListener; |
|---|
| 14 | import java.awt.event.MouseEvent; |
|---|
| 15 | import java.awt.event.MouseListener; |
|---|
| 16 | import java.awt.event.MouseMotionListener; |
|---|
| 17 | import java.rmi.RemoteException; |
|---|
| 18 | import java.util.List; |
|---|
| 19 | |
|---|
| 20 | import javax.swing.Box; |
|---|
| 21 | import javax.swing.BoxLayout; |
|---|
| 22 | import javax.swing.JButton; |
|---|
| 23 | import javax.swing.JComponent; |
|---|
| 24 | import javax.swing.JFrame; |
|---|
| 25 | import javax.swing.JLabel; |
|---|
| 26 | import javax.swing.JScrollPane; |
|---|
| 27 | import javax.swing.JSeparator; |
|---|
| 28 | import javax.swing.JTable; |
|---|
| 29 | import javax.swing.ListSelectionModel; |
|---|
| 30 | import javax.swing.RowSorter; |
|---|
| 31 | import javax.swing.RowSorter.SortKey; |
|---|
| 32 | import javax.swing.SwingUtilities; |
|---|
| 33 | import javax.swing.TransferHandler; |
|---|
| 34 | import javax.swing.table.DefaultTableModel; |
|---|
| 35 | import javax.swing.table.TableCellRenderer; |
|---|
| 36 | |
|---|
| 37 | import tmcsim.client.cadclientgui.enums.CADDataEnums; |
|---|
| 38 | import tmcsim.client.cadclientgui.enums.CADScriptTags.UNIT_TAGS; |
|---|
| 39 | import tmcsim.client.cadclientgui.enums.TableHeaders; |
|---|
| 40 | import tmcsim.client.cadclientgui.enums.UnitStatusEnums; |
|---|
| 41 | |
|---|
| 42 | /** |
|---|
| 43 | * This class contains the view and controller for the UnitStatus screen. The view was not built using a GUI builder plug-in |
|---|
| 44 | * (but may want to consider doing so in the future), and the controller uses listeners to control how the view and data act. |
|---|
| 45 | * |
|---|
| 46 | * @author Vincent |
|---|
| 47 | */ |
|---|
| 48 | |
|---|
| 49 | public class UnitStatus extends JFrame { |
|---|
| 50 | |
|---|
| 51 | private final int ONE_SECOND = 1000; |
|---|
| 52 | |
|---|
| 53 | private final String SCREEN_TITLE = "(Shift + F4) Unit Status"; |
|---|
| 54 | |
|---|
| 55 | private final Dimension SCREEN_DIMENSIONS = new Dimension(1400, 250); |
|---|
| 56 | |
|---|
| 57 | private final Dimension DROP_DOWN_MENU_LABEL_DIMENSIONS = new Dimension( |
|---|
| 58 | 170, 20); |
|---|
| 59 | |
|---|
| 60 | private final Dimension DROP_DOWN_MENU_DIMENSIONS = new Dimension(170, 300); |
|---|
| 61 | |
|---|
| 62 | private final Dimension BUTTON_DIMENSIONS = new Dimension(100, 25); |
|---|
| 63 | |
|---|
| 64 | private final int COLUMN_WIDTH = 120; |
|---|
| 65 | |
|---|
| 66 | private final String[] LABELS = { "10-8", "OFC", "OOS", |
|---|
| 67 | "Open Unit Details", "Open Unit Activity Log", "Map", |
|---|
| 68 | "Change Vehicle", "Unit Poll", "Quick Note...", |
|---|
| 69 | "Activate User Timer...", "Filters", "Page...", "Roster System", |
|---|
| 70 | "10-10" }; |
|---|
| 71 | |
|---|
| 72 | private final String[] WITH_ASSIGNED_INC_LABELS = { "STAGE", "10-97", |
|---|
| 73 | "10-8", "ASSIGNED ALT...", "ENRT ALT...", "10-97 ALT...", |
|---|
| 74 | "Open Incident", "Recall Incident", "Open Unit Details", |
|---|
| 75 | "Open Unit Activity Log", "Map", "Recall Linked Incidents", |
|---|
| 76 | "Cancel", "Reassign", "Duplicate", "Unit Poll", "Quick Note...", |
|---|
| 77 | "Activate User Timer...", "Filters", "Page...", "Fax..." }; |
|---|
| 78 | |
|---|
| 79 | private final String LABEL_SPACING = " "; |
|---|
| 80 | |
|---|
| 81 | // this box holds both the table and the buttons below |
|---|
| 82 | private Box unitStatusFrame; |
|---|
| 83 | |
|---|
| 84 | private JTable unitStatusTable; |
|---|
| 85 | private JFrame unitStatusMenu; |
|---|
| 86 | private JFrame unitStatusWithAssignedIncMenu; |
|---|
| 87 | |
|---|
| 88 | // labels for the drop down menu |
|---|
| 89 | private JLabel[] dropDownLabels = new JLabel[LABELS.length]; |
|---|
| 90 | private JLabel[] dropDownWithAssignedIncLabels = new JLabel[WITH_ASSIGNED_INC_LABELS.length]; |
|---|
| 91 | |
|---|
| 92 | private JButton buttonEnrt; |
|---|
| 93 | private JButton buttonStage; |
|---|
| 94 | private JButton button1097; |
|---|
| 95 | private JButton buttonCode4; |
|---|
| 96 | private JButton buttonDash1; |
|---|
| 97 | private JButton buttonDash2; |
|---|
| 98 | private JButton buttonDash3; |
|---|
| 99 | private JButton button108; |
|---|
| 100 | private JButton buttonOFC; |
|---|
| 101 | private JButton buttonOOS; |
|---|
| 102 | |
|---|
| 103 | public UnitStatus() { |
|---|
| 104 | initComponents(); |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | private void initComponents() { |
|---|
| 108 | initializeTable(); |
|---|
| 109 | initControllers(); |
|---|
| 110 | initializeDropDownMenus(); |
|---|
| 111 | |
|---|
| 112 | JScrollPane scrollpane = new JScrollPane(unitStatusTable); |
|---|
| 113 | scrollpane.getViewport().setBackground(Color.WHITE); |
|---|
| 114 | |
|---|
| 115 | Box bottomButtons = new Box(BoxLayout.X_AXIS); |
|---|
| 116 | initializeBottomButtons(bottomButtons); |
|---|
| 117 | |
|---|
| 118 | unitStatusFrame = new Box(BoxLayout.Y_AXIS); |
|---|
| 119 | unitStatusFrame.add(bottomButtons); |
|---|
| 120 | |
|---|
| 121 | unitStatusFrame.add(scrollpane);// holds the table |
|---|
| 122 | unitStatusFrame.add(bottomButtons); |
|---|
| 123 | |
|---|
| 124 | setTitle(SCREEN_TITLE); |
|---|
| 125 | setPreferredSize(SCREEN_DIMENSIONS); |
|---|
| 126 | getContentPane().add(unitStatusFrame); |
|---|
| 127 | setResizable(true); |
|---|
| 128 | pack(); |
|---|
| 129 | Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); |
|---|
| 130 | setLocation(0, (int) (dim.getHeight() * 2 / 4)); |
|---|
| 131 | setDefaultCloseOperation(HIDE_ON_CLOSE); |
|---|
| 132 | setVisible(false); |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | /** |
|---|
| 136 | * Initializes the table and prepares the cell renderer for color |
|---|
| 137 | * management. It initializes the default settings and handles the drag and |
|---|
| 138 | * drop feature. |
|---|
| 139 | */ |
|---|
| 140 | private void initializeTable() { |
|---|
| 141 | unitStatusTable = new JTable() { |
|---|
| 142 | /** |
|---|
| 143 | * Custom renderer to set different background/foreground colors |
|---|
| 144 | * |
|---|
| 145 | * @see javax.swing.JTable#prepareRenderer(javax.swing.table.TableCellRenderer, |
|---|
| 146 | * int, int) |
|---|
| 147 | */ |
|---|
| 148 | public Component prepareRenderer(TableCellRenderer renderer, |
|---|
| 149 | int row, int column) { |
|---|
| 150 | Component comp = super.prepareRenderer(renderer, row, column); |
|---|
| 151 | |
|---|
| 152 | int unitNumColumn = 2; |
|---|
| 153 | try { |
|---|
| 154 | switch (ScreenManager.theCoordinator |
|---|
| 155 | .getCadDataUnitStatus((String) unitStatusTable |
|---|
| 156 | .getValueAt(row, unitNumColumn))) { |
|---|
| 157 | case Assignable: |
|---|
| 158 | comp.setForeground(Color.GREEN); |
|---|
| 159 | comp.setBackground(Color.BLACK); |
|---|
| 160 | break; |
|---|
| 161 | case Arrived: |
|---|
| 162 | comp.setForeground(Color.YELLOW); |
|---|
| 163 | comp.setBackground(Color.BLACK); |
|---|
| 164 | break; |
|---|
| 165 | case NotAssignable: |
|---|
| 166 | comp.setForeground(Color.BLACK); |
|---|
| 167 | comp.setBackground(Color.GRAY); |
|---|
| 168 | break; |
|---|
| 169 | case Enroute: |
|---|
| 170 | comp.setForeground(Color.CYAN); |
|---|
| 171 | comp.setBackground(Color.BLACK); |
|---|
| 172 | break; |
|---|
| 173 | } |
|---|
| 174 | } catch (RemoteException e) { |
|---|
| 175 | e.printStackTrace(); |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | if (getSelectedRow() == row) { |
|---|
| 179 | comp.setForeground(Color.WHITE); |
|---|
| 180 | comp.setBackground(Color.BLUE); |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | return comp; |
|---|
| 184 | } |
|---|
| 185 | }; |
|---|
| 186 | |
|---|
| 187 | unitStatusTable.setOpaque(true); |
|---|
| 188 | unitStatusTable.setIntercellSpacing(new Dimension(1, 0)); |
|---|
| 189 | unitStatusTable.setGridColor(Color.WHITE); |
|---|
| 190 | unitStatusTable.getTableHeader().setReorderingAllowed(false); |
|---|
| 191 | unitStatusTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|---|
| 192 | unitStatusTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
|---|
| 193 | unitStatusTable.setAutoCreateRowSorter(true); |
|---|
| 194 | unitStatusTable.setDragEnabled(true); |
|---|
| 195 | |
|---|
| 196 | unitStatusTable.setModel(new DefaultTableModel()); |
|---|
| 197 | ((DefaultTableModel) unitStatusTable.getModel()) |
|---|
| 198 | .setColumnIdentifiers(TableHeaders.UNIT_STATUS_HEADERS); |
|---|
| 199 | |
|---|
| 200 | unitStatusTable.setTransferHandler(new TransferHandler() { |
|---|
| 201 | |
|---|
| 202 | public boolean canImport(TransferHandler.TransferSupport info) { |
|---|
| 203 | if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) { |
|---|
| 204 | return false; |
|---|
| 205 | } |
|---|
| 206 | return true; |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | public int getSourceActions(JComponent c) { |
|---|
| 210 | return TransferHandler.COPY_OR_MOVE; |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | protected Transferable createTransferable(JComponent c) { |
|---|
| 214 | return new StringSelection((String) unitStatusTable.getValueAt( |
|---|
| 215 | unitStatusTable.getSelectedRow(), 2)); |
|---|
| 216 | } |
|---|
| 217 | |
|---|
| 218 | }); |
|---|
| 219 | |
|---|
| 220 | for (int i = 0; i < unitStatusTable.getColumnCount(); i++) { |
|---|
| 221 | unitStatusTable.getColumnModel().getColumn(i) |
|---|
| 222 | .setPreferredWidth(COLUMN_WIDTH); |
|---|
| 223 | } |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | /* |
|---|
| 227 | * Adds the key and mouse listeners for the table and component listener for |
|---|
| 228 | * screen. |
|---|
| 229 | */ |
|---|
| 230 | private void initControllers() { |
|---|
| 231 | unitStatusTable.addMouseListener(new MouseListener() { |
|---|
| 232 | public void mouseClicked(MouseEvent e) { |
|---|
| 233 | int unitColumn = 2; |
|---|
| 234 | String unitNum = (String) unitStatusTable.getValueAt( |
|---|
| 235 | unitStatusTable.getSelectedRow(), unitColumn); |
|---|
| 236 | if (SwingUtilities.isRightMouseButton(e)) { |
|---|
| 237 | try { |
|---|
| 238 | if (ScreenManager.theCoordinator |
|---|
| 239 | .getCadDataUnitStatus(unitNum) == UnitStatusEnums.Enroute |
|---|
| 240 | || ScreenManager.theCoordinator |
|---|
| 241 | .getCadDataUnitStatus(unitNum) == UnitStatusEnums.Arrived) { |
|---|
| 242 | openDropDownWithAssignedIncMenu(e); |
|---|
| 243 | } else { |
|---|
| 244 | openDropDownMenu(e); |
|---|
| 245 | } |
|---|
| 246 | } catch (RemoteException e1) { |
|---|
| 247 | e1.printStackTrace(); |
|---|
| 248 | } |
|---|
| 249 | } else { |
|---|
| 250 | closeDropDownMenu(); |
|---|
| 251 | closeDropDownWithAssignedIncMenu(); |
|---|
| 252 | } |
|---|
| 253 | } |
|---|
| 254 | |
|---|
| 255 | public void mouseEntered(MouseEvent e) { |
|---|
| 256 | } |
|---|
| 257 | |
|---|
| 258 | public void mouseExited(MouseEvent e) { |
|---|
| 259 | } |
|---|
| 260 | |
|---|
| 261 | public void mousePressed(MouseEvent e) { |
|---|
| 262 | } |
|---|
| 263 | |
|---|
| 264 | public void mouseReleased(MouseEvent e) { |
|---|
| 265 | } |
|---|
| 266 | }); |
|---|
| 267 | |
|---|
| 268 | addComponentListener(new ComponentListener() { |
|---|
| 269 | public void componentHidden(ComponentEvent e) { |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | public void componentMoved(ComponentEvent e) { |
|---|
| 273 | closeDropDownMenu(); |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | public void componentResized(ComponentEvent e) { |
|---|
| 277 | } |
|---|
| 278 | |
|---|
| 279 | public void componentShown(ComponentEvent e) { |
|---|
| 280 | } |
|---|
| 281 | }); |
|---|
| 282 | } |
|---|
| 283 | |
|---|
| 284 | /* |
|---|
| 285 | * Creates the drop down menu that appears when a right click is performed |
|---|
| 286 | * on the table. |
|---|
| 287 | */ |
|---|
| 288 | private void initializeDropDownMenus() { |
|---|
| 289 | Box menu = new Box(BoxLayout.Y_AXIS); |
|---|
| 290 | initializeDropDownLabels(); |
|---|
| 291 | addLabelsToBox(menu); |
|---|
| 292 | |
|---|
| 293 | setMenuHighlightedBackground(Color.BLUE); |
|---|
| 294 | |
|---|
| 295 | unitStatusMenu = new JFrame(); |
|---|
| 296 | unitStatusMenu.getContentPane().add(menu); |
|---|
| 297 | unitStatusMenu.setPreferredSize(DROP_DOWN_MENU_DIMENSIONS); |
|---|
| 298 | unitStatusMenu.setUndecorated(true); |
|---|
| 299 | unitStatusMenu.pack(); |
|---|
| 300 | unitStatusMenu.setVisible(false); |
|---|
| 301 | |
|---|
| 302 | menu = new Box(BoxLayout.Y_AXIS); |
|---|
| 303 | initializeDropDownWithAssignedIncLabels(); |
|---|
| 304 | addWithAssignedIncLabelsToBox(menu); |
|---|
| 305 | |
|---|
| 306 | setWithAssignedIncMenuHighlightedBackground(Color.BLUE); |
|---|
| 307 | |
|---|
| 308 | unitStatusWithAssignedIncMenu = new JFrame(); |
|---|
| 309 | unitStatusWithAssignedIncMenu.getContentPane().add(menu); |
|---|
| 310 | unitStatusWithAssignedIncMenu |
|---|
| 311 | .setPreferredSize(DROP_DOWN_MENU_DIMENSIONS); |
|---|
| 312 | unitStatusWithAssignedIncMenu.setUndecorated(true); |
|---|
| 313 | unitStatusWithAssignedIncMenu.pack(); |
|---|
| 314 | unitStatusWithAssignedIncMenu.setVisible(false); |
|---|
| 315 | } |
|---|
| 316 | |
|---|
| 317 | /* |
|---|
| 318 | * Sets the text and size and adds a listener to each label. Currently, |
|---|
| 319 | * labels are not implemented so no listeners are added. |
|---|
| 320 | */ |
|---|
| 321 | private void initializeDropDownLabels() { |
|---|
| 322 | for (int i = 0; i < dropDownLabels.length; i++) { |
|---|
| 323 | dropDownLabels[i] = new JLabel(LABEL_SPACING + LABELS[i]); |
|---|
| 324 | dropDownLabels[i].setMaximumSize(DROP_DOWN_MENU_LABEL_DIMENSIONS); |
|---|
| 325 | dropDownLabels[i].setForeground(Color.GRAY); |
|---|
| 326 | } |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | /* |
|---|
| 330 | * Sets the text and size and adds a listener to each activated label. |
|---|
| 331 | */ |
|---|
| 332 | private void initializeDropDownWithAssignedIncLabels() { |
|---|
| 333 | for (int i = 0; i < dropDownWithAssignedIncLabels.length; i++) { |
|---|
| 334 | dropDownWithAssignedIncLabels[i] = new JLabel(LABEL_SPACING |
|---|
| 335 | + WITH_ASSIGNED_INC_LABELS[i]); |
|---|
| 336 | dropDownWithAssignedIncLabels[i] |
|---|
| 337 | .setMaximumSize(DROP_DOWN_MENU_LABEL_DIMENSIONS); |
|---|
| 338 | dropDownWithAssignedIncLabels[i].setForeground(Color.GRAY); |
|---|
| 339 | } |
|---|
| 340 | dropDownWithAssignedIncLabels[6].setForeground(Color.BLACK); |
|---|
| 341 | addMouseListenersToWithAssignedIncLabel(dropDownWithAssignedIncLabels[6]); |
|---|
| 342 | |
|---|
| 343 | } |
|---|
| 344 | |
|---|
| 345 | /* |
|---|
| 346 | * Add the labels to the box in order with separators and spacings in |
|---|
| 347 | * between. |
|---|
| 348 | */ |
|---|
| 349 | private void addLabelsToBox(Box menu) { |
|---|
| 350 | menu.add(dropDownLabels[0]); |
|---|
| 351 | menu.add(dropDownLabels[1]); |
|---|
| 352 | menu.add(dropDownLabels[2]); |
|---|
| 353 | |
|---|
| 354 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 355 | menu.add(new JSeparator()); |
|---|
| 356 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 357 | |
|---|
| 358 | menu.add(dropDownLabels[3]); |
|---|
| 359 | menu.add(dropDownLabels[4]); |
|---|
| 360 | menu.add(dropDownLabels[5]); |
|---|
| 361 | |
|---|
| 362 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 363 | menu.add(new JSeparator()); |
|---|
| 364 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 365 | |
|---|
| 366 | menu.add(dropDownLabels[6]); |
|---|
| 367 | menu.add(dropDownLabels[7]); |
|---|
| 368 | menu.add(dropDownLabels[8]); |
|---|
| 369 | |
|---|
| 370 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 371 | menu.add(new JSeparator()); |
|---|
| 372 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 373 | |
|---|
| 374 | menu.add(dropDownLabels[9]); |
|---|
| 375 | menu.add(dropDownLabels[10]); |
|---|
| 376 | |
|---|
| 377 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 378 | menu.add(new JSeparator()); |
|---|
| 379 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 380 | |
|---|
| 381 | menu.add(dropDownLabels[11]); |
|---|
| 382 | |
|---|
| 383 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 384 | menu.add(new JSeparator()); |
|---|
| 385 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 386 | |
|---|
| 387 | menu.add(dropDownLabels[12]); |
|---|
| 388 | |
|---|
| 389 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 390 | menu.add(new JSeparator()); |
|---|
| 391 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 392 | |
|---|
| 393 | menu.add(dropDownLabels[13]); |
|---|
| 394 | |
|---|
| 395 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 396 | } |
|---|
| 397 | |
|---|
| 398 | /* |
|---|
| 399 | * Add the labels to the box in order with separators and spacings in |
|---|
| 400 | * between. |
|---|
| 401 | */ |
|---|
| 402 | private void addWithAssignedIncLabelsToBox(Box menu) { |
|---|
| 403 | menu.add(dropDownWithAssignedIncLabels[0]); |
|---|
| 404 | menu.add(dropDownWithAssignedIncLabels[1]); |
|---|
| 405 | menu.add(dropDownWithAssignedIncLabels[2]); |
|---|
| 406 | menu.add(dropDownWithAssignedIncLabels[3]); |
|---|
| 407 | menu.add(dropDownWithAssignedIncLabels[4]); |
|---|
| 408 | menu.add(dropDownWithAssignedIncLabels[5]); |
|---|
| 409 | |
|---|
| 410 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 411 | menu.add(new JSeparator()); |
|---|
| 412 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 413 | |
|---|
| 414 | menu.add(dropDownWithAssignedIncLabels[6]); |
|---|
| 415 | menu.add(dropDownWithAssignedIncLabels[7]); |
|---|
| 416 | menu.add(dropDownWithAssignedIncLabels[8]); |
|---|
| 417 | menu.add(dropDownWithAssignedIncLabels[9]); |
|---|
| 418 | menu.add(dropDownWithAssignedIncLabels[10]); |
|---|
| 419 | menu.add(dropDownWithAssignedIncLabels[11]); |
|---|
| 420 | |
|---|
| 421 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 422 | menu.add(new JSeparator()); |
|---|
| 423 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 424 | |
|---|
| 425 | menu.add(dropDownWithAssignedIncLabels[12]); |
|---|
| 426 | menu.add(dropDownWithAssignedIncLabels[13]); |
|---|
| 427 | menu.add(dropDownWithAssignedIncLabels[14]); |
|---|
| 428 | |
|---|
| 429 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 430 | menu.add(new JSeparator()); |
|---|
| 431 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 432 | |
|---|
| 433 | menu.add(dropDownWithAssignedIncLabels[15]); |
|---|
| 434 | menu.add(dropDownWithAssignedIncLabels[16]); |
|---|
| 435 | |
|---|
| 436 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 437 | menu.add(new JSeparator()); |
|---|
| 438 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 439 | |
|---|
| 440 | menu.add(dropDownWithAssignedIncLabels[17]); |
|---|
| 441 | menu.add(dropDownWithAssignedIncLabels[18]); |
|---|
| 442 | |
|---|
| 443 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 444 | menu.add(new JSeparator()); |
|---|
| 445 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 446 | |
|---|
| 447 | menu.add(dropDownWithAssignedIncLabels[19]); |
|---|
| 448 | menu.add(dropDownWithAssignedIncLabels[20]); |
|---|
| 449 | |
|---|
| 450 | menu.add(Box.createVerticalStrut(5)); |
|---|
| 451 | } |
|---|
| 452 | |
|---|
| 453 | /* |
|---|
| 454 | * Creates each button and handles the action performed by the button. |
|---|
| 455 | */ |
|---|
| 456 | public void initializeBottomButtons(Box bottomButtons) { |
|---|
| 457 | bottomButtons.add(buttonEnrt = makeButton("ENRT", new ActionListener() { |
|---|
| 458 | public void actionPerformed(ActionEvent arg0) { |
|---|
| 459 | try { |
|---|
| 460 | ScreenManager.theCoordinator.setCadDataUnitValue( |
|---|
| 461 | (String) unitStatusTable.getValueAt( |
|---|
| 462 | unitStatusTable.getSelectedRow(), 2), |
|---|
| 463 | UNIT_TAGS.STATUS, "ENRT"); |
|---|
| 464 | ScreenManager.theCoordinator.setCadDataUnitValue( |
|---|
| 465 | (String) unitStatusTable.getValueAt( |
|---|
| 466 | unitStatusTable.getSelectedRow(), 2), |
|---|
| 467 | UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Enroute); |
|---|
| 468 | } catch (RemoteException e) { |
|---|
| 469 | e.printStackTrace(); |
|---|
| 470 | } |
|---|
| 471 | refreshTable(); |
|---|
| 472 | } |
|---|
| 473 | })); |
|---|
| 474 | bottomButtons.add(buttonStage = makeButton("STAGE", |
|---|
| 475 | new ActionListener() { |
|---|
| 476 | public void actionPerformed(ActionEvent arg0) { |
|---|
| 477 | try { |
|---|
| 478 | ScreenManager.theCoordinator.setCadDataUnitValue( |
|---|
| 479 | (String) unitStatusTable |
|---|
| 480 | .getValueAt(unitStatusTable |
|---|
| 481 | .getSelectedRow(), 2), |
|---|
| 482 | UNIT_TAGS.STATUS, "STAGE"); |
|---|
| 483 | } catch (RemoteException e) { |
|---|
| 484 | e.printStackTrace(); |
|---|
| 485 | } |
|---|
| 486 | refreshTable(); |
|---|
| 487 | } |
|---|
| 488 | })); |
|---|
| 489 | bottomButtons.add(button1097 = makeButton("10-97", |
|---|
| 490 | new ActionListener() { |
|---|
| 491 | public void actionPerformed(ActionEvent arg0) { |
|---|
| 492 | try { |
|---|
| 493 | ScreenManager.theCoordinator.setCadDataUnitValue( |
|---|
| 494 | (String) unitStatusTable |
|---|
| 495 | .getValueAt(unitStatusTable |
|---|
| 496 | .getSelectedRow(), 2), |
|---|
| 497 | UNIT_TAGS.STATUS, "10-97"); |
|---|
| 498 | ScreenManager.theCoordinator.setCadDataUnitValue( |
|---|
| 499 | (String) unitStatusTable |
|---|
| 500 | .getValueAt(unitStatusTable |
|---|
| 501 | .getSelectedRow(), 2), |
|---|
| 502 | UNIT_TAGS.UNIT_STATUS, |
|---|
| 503 | UnitStatusEnums.Arrived); |
|---|
| 504 | } catch (RemoteException e) { |
|---|
| 505 | e.printStackTrace(); |
|---|
| 506 | } |
|---|
| 507 | refreshTable(); |
|---|
| 508 | } |
|---|
| 509 | })); |
|---|
| 510 | bottomButtons.add(buttonCode4 = makeButton("CODE 4", |
|---|
| 511 | new ActionListener() { |
|---|
| 512 | public void actionPerformed(ActionEvent arg0) { |
|---|
| 513 | try { |
|---|
| 514 | ScreenManager.theCoordinator.setCadDataUnitValue( |
|---|
| 515 | (String) unitStatusTable |
|---|
| 516 | .getValueAt(unitStatusTable |
|---|
| 517 | .getSelectedRow(), 2), |
|---|
| 518 | UNIT_TAGS.STATUS, "CODE 4"); |
|---|
| 519 | } catch (RemoteException e) { |
|---|
| 520 | e.printStackTrace(); |
|---|
| 521 | } |
|---|
| 522 | refreshTable(); |
|---|
| 523 | } |
|---|
| 524 | })); |
|---|
| 525 | bottomButtons.add(buttonDash1 = makeButton("-", null)); |
|---|
| 526 | bottomButtons.add(buttonDash2 = makeButton("-", null)); |
|---|
| 527 | bottomButtons.add(buttonDash3 = makeButton("-", null)); |
|---|
| 528 | bottomButtons.add(button108 = makeButton("10-8", new ActionListener() { |
|---|
| 529 | public void actionPerformed(ActionEvent arg0) { |
|---|
| 530 | try { |
|---|
| 531 | ScreenManager.theCoordinator.setCadDataUnitValue( |
|---|
| 532 | (String) unitStatusTable.getValueAt( |
|---|
| 533 | unitStatusTable.getSelectedRow(), 2), |
|---|
| 534 | UNIT_TAGS.STATUS, "10-8"); |
|---|
| 535 | ScreenManager.theCoordinator.setCadDataUnitValue( |
|---|
| 536 | (String) unitStatusTable.getValueAt( |
|---|
| 537 | unitStatusTable.getSelectedRow(), 2), |
|---|
| 538 | UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Assignable); |
|---|
| 539 | } catch (RemoteException e) { |
|---|
| 540 | e.printStackTrace(); |
|---|
| 541 | } |
|---|
| 542 | refreshTable(); |
|---|
| 543 | } |
|---|
| 544 | })); |
|---|
| 545 | bottomButtons.add(buttonOFC = makeButton("OFC", new ActionListener() { |
|---|
| 546 | public void actionPerformed(ActionEvent arg0) { |
|---|
| 547 | try { |
|---|
| 548 | ScreenManager.theCoordinator.setCadDataUnitValue( |
|---|
| 549 | (String) unitStatusTable.getValueAt( |
|---|
| 550 | unitStatusTable.getSelectedRow(), 2), |
|---|
| 551 | UNIT_TAGS.STATUS, "OFC"); |
|---|
| 552 | ScreenManager.theCoordinator.setCadDataUnitValue( |
|---|
| 553 | (String) unitStatusTable.getValueAt( |
|---|
| 554 | unitStatusTable.getSelectedRow(), 2), |
|---|
| 555 | UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Arrived); |
|---|
| 556 | } catch (RemoteException e) { |
|---|
| 557 | e.printStackTrace(); |
|---|
| 558 | } |
|---|
| 559 | refreshTable(); |
|---|
| 560 | } |
|---|
| 561 | })); |
|---|
| 562 | bottomButtons.add(buttonOOS = makeButton("OOS", new ActionListener() { |
|---|
| 563 | public void actionPerformed(ActionEvent arg0) { |
|---|
| 564 | try { |
|---|
| 565 | ScreenManager.theCoordinator.setCadDataUnitValue( |
|---|
| 566 | (String) unitStatusTable.getValueAt( |
|---|
| 567 | unitStatusTable.getSelectedRow(), 2), |
|---|
| 568 | UNIT_TAGS.STATUS, "OOS"); |
|---|
| 569 | ScreenManager.theCoordinator.setCadDataUnitValue( |
|---|
| 570 | (String) unitStatusTable.getValueAt( |
|---|
| 571 | unitStatusTable.getSelectedRow(), 2), |
|---|
| 572 | UNIT_TAGS.UNIT_STATUS, |
|---|
| 573 | UnitStatusEnums.NotAssignable); |
|---|
| 574 | } catch (RemoteException e) { |
|---|
| 575 | e.printStackTrace(); |
|---|
| 576 | } |
|---|
| 577 | refreshTable(); |
|---|
| 578 | } |
|---|
| 579 | })); |
|---|
| 580 | } |
|---|
| 581 | |
|---|
| 582 | /* |
|---|
| 583 | * Makes a JButton with an text and listener. |
|---|
| 584 | * |
|---|
| 585 | * @param text the text to be displayed |
|---|
| 586 | * |
|---|
| 587 | * @param listener the action listener for this button. |
|---|
| 588 | * |
|---|
| 589 | * @return the JButton. |
|---|
| 590 | */ |
|---|
| 591 | public JButton makeButton(String text, ActionListener listener) { |
|---|
| 592 | JButton button = new JButton(text); |
|---|
| 593 | button.setBackground(Color.GRAY); |
|---|
| 594 | button.setOpaque(false); |
|---|
| 595 | Dimension size = BUTTON_DIMENSIONS; |
|---|
| 596 | button.setPreferredSize(size); |
|---|
| 597 | button.setMinimumSize(size); |
|---|
| 598 | button.setMaximumSize(size); |
|---|
| 599 | button.addActionListener(listener); |
|---|
| 600 | button.setFocusable(false); |
|---|
| 601 | |
|---|
| 602 | return button; |
|---|
| 603 | } |
|---|
| 604 | |
|---|
| 605 | /* |
|---|
| 606 | * Sets the highlighted color(when the mouse is over it) of the JLabels. |
|---|
| 607 | * Note: the color is not shown until .setOpaque(true) is called. |
|---|
| 608 | * |
|---|
| 609 | * @param color the highlighted color |
|---|
| 610 | */ |
|---|
| 611 | public void setMenuHighlightedBackground(Color color) { |
|---|
| 612 | for (int i = 0; i < dropDownLabels.length; i++) { |
|---|
| 613 | dropDownLabels[i].setBackground(color); |
|---|
| 614 | } |
|---|
| 615 | } |
|---|
| 616 | |
|---|
| 617 | /* |
|---|
| 618 | * Sets the highlighted color(when the mouse is over it) of the JLabels. |
|---|
| 619 | * Note: the color is not shown until .setOpaque(true) is called. |
|---|
| 620 | * |
|---|
| 621 | * @param color the highlighted color |
|---|
| 622 | */ |
|---|
| 623 | public void setWithAssignedIncMenuHighlightedBackground(Color color) { |
|---|
| 624 | for (int i = 0; i < dropDownWithAssignedIncLabels.length; i++) { |
|---|
| 625 | dropDownWithAssignedIncLabels[i].setBackground(color); |
|---|
| 626 | } |
|---|
| 627 | } |
|---|
| 628 | |
|---|
| 629 | /* |
|---|
| 630 | * Sets all JLabels to not display a highlighted background |
|---|
| 631 | */ |
|---|
| 632 | public void unSelectAllLabels() { |
|---|
| 633 | for (int i = 0; i < dropDownLabels.length; i++) { |
|---|
| 634 | dropDownLabels[i].setOpaque(false); |
|---|
| 635 | } |
|---|
| 636 | } |
|---|
| 637 | |
|---|
| 638 | /* |
|---|
| 639 | * Sets all JLabels to not display a highlighted background |
|---|
| 640 | */ |
|---|
| 641 | public void unSelectAllWithAssignedIncLabels() { |
|---|
| 642 | for (int i = 0; i < dropDownWithAssignedIncLabels.length; i++) { |
|---|
| 643 | dropDownWithAssignedIncLabels[i].setOpaque(false); |
|---|
| 644 | } |
|---|
| 645 | } |
|---|
| 646 | |
|---|
| 647 | /* |
|---|
| 648 | * Sets the label to have a highlighted background. |
|---|
| 649 | * |
|---|
| 650 | * @param label the label that is selected/highlighted |
|---|
| 651 | */ |
|---|
| 652 | public void selectLabel(Object label) { |
|---|
| 653 | ((JLabel) label).setOpaque(true); |
|---|
| 654 | } |
|---|
| 655 | |
|---|
| 656 | /* |
|---|
| 657 | * Performs the label action depending on which label was clicked. |
|---|
| 658 | */ |
|---|
| 659 | public void performLabelAction(Object label) { |
|---|
| 660 | if (label.equals(dropDownLabels[0])) { // 10-8 |
|---|
| 661 | |
|---|
| 662 | } else if (label.equals(dropDownLabels[1])) { // OFC |
|---|
| 663 | |
|---|
| 664 | } else if (label.equals(dropDownLabels[2])) { // OOS |
|---|
| 665 | |
|---|
| 666 | } else if (label.equals(dropDownLabels[3])) { // Open Unit Details |
|---|
| 667 | |
|---|
| 668 | } else if (label.equals(dropDownLabels[4])) { // Open Unit Activity Log |
|---|
| 669 | |
|---|
| 670 | } else if (label.equals(dropDownLabels[5])) { // Map |
|---|
| 671 | |
|---|
| 672 | } else if (label.equals(dropDownLabels[6])) { // Change Vehicle |
|---|
| 673 | |
|---|
| 674 | } else if (label.equals(dropDownLabels[7])) { // Unit Poll |
|---|
| 675 | |
|---|
| 676 | } else if (label.equals(dropDownLabels[8])) { // Quick Notes |
|---|
| 677 | |
|---|
| 678 | } else if (label.equals(dropDownLabels[9])) { // Activate User Timer |
|---|
| 679 | |
|---|
| 680 | } else if (label.equals(dropDownLabels[10])) { // Filters |
|---|
| 681 | |
|---|
| 682 | } else if (label.equals(dropDownLabels[11])) { // Page |
|---|
| 683 | |
|---|
| 684 | } else if (label.equals(dropDownLabels[12])) { // Roster System |
|---|
| 685 | |
|---|
| 686 | } else if (label.equals(dropDownLabels[13])) { // 10-10 |
|---|
| 687 | |
|---|
| 688 | } |
|---|
| 689 | } |
|---|
| 690 | |
|---|
| 691 | /* |
|---|
| 692 | * Performs the label action depending on which label was clicked. |
|---|
| 693 | */ |
|---|
| 694 | public void performWithAssignedIncLabelAction(Object label) { |
|---|
| 695 | if (label.equals(dropDownWithAssignedIncLabels[0])) { // STAGE |
|---|
| 696 | |
|---|
| 697 | } else if (label.equals(dropDownWithAssignedIncLabels[1])) { // 10-97 |
|---|
| 698 | |
|---|
| 699 | } else if (label.equals(dropDownWithAssignedIncLabels[2])) { // 10-8 |
|---|
| 700 | |
|---|
| 701 | } else if (label.equals(dropDownWithAssignedIncLabels[3])) { // ASSIGN |
|---|
| 702 | // ALT... |
|---|
| 703 | |
|---|
| 704 | } else if (label.equals(dropDownWithAssignedIncLabels[4])) { // ENRT |
|---|
| 705 | // ALT... |
|---|
| 706 | |
|---|
| 707 | } else if (label.equals(dropDownWithAssignedIncLabels[5])) { // 10-97 |
|---|
| 708 | // ALT... |
|---|
| 709 | |
|---|
| 710 | } else if (label.equals(dropDownWithAssignedIncLabels[6])) { // Open |
|---|
| 711 | // Incident |
|---|
| 712 | int idColumn = 0; |
|---|
| 713 | ScreenManager.openIncidentViewer(Integer |
|---|
| 714 | .parseInt((String) unitStatusTable.getValueAt( |
|---|
| 715 | unitStatusTable.getSelectedRow(), idColumn))); |
|---|
| 716 | } else if (label.equals(dropDownWithAssignedIncLabels[7])) { // Recall |
|---|
| 717 | // Incident |
|---|
| 718 | |
|---|
| 719 | } else if (label.equals(dropDownWithAssignedIncLabels[8])) { // Open |
|---|
| 720 | // Unit |
|---|
| 721 | // Details |
|---|
| 722 | |
|---|
| 723 | } else if (label.equals(dropDownWithAssignedIncLabels[9])) { // Open |
|---|
| 724 | // Unit |
|---|
| 725 | // Activity |
|---|
| 726 | // Log |
|---|
| 727 | |
|---|
| 728 | } else if (label.equals(dropDownWithAssignedIncLabels[10])) { // Map |
|---|
| 729 | |
|---|
| 730 | } else if (label.equals(dropDownWithAssignedIncLabels[11])) { // Recall |
|---|
| 731 | // Linked |
|---|
| 732 | // Incidents |
|---|
| 733 | |
|---|
| 734 | } else if (label.equals(dropDownWithAssignedIncLabels[12])) { // Cancel |
|---|
| 735 | |
|---|
| 736 | } else if (label.equals(dropDownWithAssignedIncLabels[13])) { // Reassign |
|---|
| 737 | |
|---|
| 738 | } else if (label.equals(dropDownWithAssignedIncLabels[14])) { // Duplicate |
|---|
| 739 | |
|---|
| 740 | } else if (label.equals(dropDownWithAssignedIncLabels[15])) { // Unit |
|---|
| 741 | // Poll |
|---|
| 742 | |
|---|
| 743 | } else if (label.equals(dropDownWithAssignedIncLabels[16])) { // Quick |
|---|
| 744 | // Note... |
|---|
| 745 | |
|---|
| 746 | } else if (label.equals(dropDownWithAssignedIncLabels[17])) { // Activate |
|---|
| 747 | // User |
|---|
| 748 | // Timer... |
|---|
| 749 | |
|---|
| 750 | } else if (label.equals(dropDownWithAssignedIncLabels[18])) { // Filters |
|---|
| 751 | |
|---|
| 752 | } else if (label.equals(dropDownWithAssignedIncLabels[19])) { // Page... |
|---|
| 753 | |
|---|
| 754 | } else if (label.equals(dropDownWithAssignedIncLabels[20])) { // Fax... |
|---|
| 755 | |
|---|
| 756 | } |
|---|
| 757 | } |
|---|
| 758 | |
|---|
| 759 | /* |
|---|
| 760 | * Factory method. Adds a mouse listeners to the label. The |
|---|
| 761 | * MouseMotionListener detects the mouse's location to highlight the label. |
|---|
| 762 | * The MouseListener detects for clicks and performs the action of the label |
|---|
| 763 | * designates. |
|---|
| 764 | */ |
|---|
| 765 | public void addMouseListenersToLabel(JLabel label) { |
|---|
| 766 | label.addMouseMotionListener(new MouseMotionListener() { |
|---|
| 767 | public void mouseDragged(MouseEvent e) { |
|---|
| 768 | } |
|---|
| 769 | |
|---|
| 770 | public void mouseMoved(MouseEvent e) { |
|---|
| 771 | unSelectAllLabels(); |
|---|
| 772 | selectLabel(e.getSource()); |
|---|
| 773 | unitStatusMenu.revalidate(); |
|---|
| 774 | unitStatusMenu.repaint(); |
|---|
| 775 | } |
|---|
| 776 | }); |
|---|
| 777 | label.addMouseListener(new MouseListener() { |
|---|
| 778 | public void mouseClicked(MouseEvent e) { |
|---|
| 779 | performLabelAction(e.getSource()); |
|---|
| 780 | unSelectAllLabels(); |
|---|
| 781 | unitStatusMenu.revalidate(); |
|---|
| 782 | unitStatusMenu.repaint(); |
|---|
| 783 | unitStatusMenu.setVisible(false); |
|---|
| 784 | } |
|---|
| 785 | |
|---|
| 786 | public void mouseEntered(MouseEvent e) { |
|---|
| 787 | } |
|---|
| 788 | |
|---|
| 789 | public void mouseExited(MouseEvent e) { |
|---|
| 790 | } |
|---|
| 791 | |
|---|
| 792 | public void mousePressed(MouseEvent e) { |
|---|
| 793 | } |
|---|
| 794 | |
|---|
| 795 | public void mouseReleased(MouseEvent e) { |
|---|
| 796 | } |
|---|
| 797 | }); |
|---|
| 798 | } |
|---|
| 799 | |
|---|
| 800 | /* |
|---|
| 801 | * Factory method. Adds a mouse listeners to the label. The |
|---|
| 802 | * MouseMotionListener detects the mouse's location to highlight the label. |
|---|
| 803 | * The MouseListener detects for clicks and performs the action of the label |
|---|
| 804 | * designates. |
|---|
| 805 | */ |
|---|
| 806 | public void addMouseListenersToWithAssignedIncLabel(JLabel label) { |
|---|
| 807 | label.addMouseMotionListener(new MouseMotionListener() { |
|---|
| 808 | public void mouseDragged(MouseEvent e) { |
|---|
| 809 | } |
|---|
| 810 | |
|---|
| 811 | public void mouseMoved(MouseEvent e) { |
|---|
| 812 | unSelectAllLabels(); |
|---|
| 813 | selectLabel(e.getSource()); |
|---|
| 814 | unitStatusWithAssignedIncMenu.revalidate(); |
|---|
| 815 | unitStatusWithAssignedIncMenu.repaint(); |
|---|
| 816 | } |
|---|
| 817 | }); |
|---|
| 818 | label.addMouseListener(new MouseListener() { |
|---|
| 819 | public void mouseClicked(MouseEvent e) { |
|---|
| 820 | performWithAssignedIncLabelAction(e.getSource()); |
|---|
| 821 | unSelectAllLabels(); |
|---|
| 822 | unitStatusWithAssignedIncMenu.revalidate(); |
|---|
| 823 | unitStatusWithAssignedIncMenu.repaint(); |
|---|
| 824 | unitStatusWithAssignedIncMenu.setVisible(false); |
|---|
| 825 | } |
|---|
| 826 | |
|---|
| 827 | public void mouseEntered(MouseEvent e) { |
|---|
| 828 | } |
|---|
| 829 | |
|---|
| 830 | public void mouseExited(MouseEvent e) { |
|---|
| 831 | } |
|---|
| 832 | |
|---|
| 833 | public void mousePressed(MouseEvent e) { |
|---|
| 834 | } |
|---|
| 835 | |
|---|
| 836 | public void mouseReleased(MouseEvent e) { |
|---|
| 837 | } |
|---|
| 838 | }); |
|---|
| 839 | } |
|---|
| 840 | |
|---|
| 841 | /* |
|---|
| 842 | * Displays the menu where the right click occurred. |
|---|
| 843 | */ |
|---|
| 844 | public void openDropDownMenu(MouseEvent e) { |
|---|
| 845 | unitStatusMenu.setLocation(e.getX() + this.getX(), |
|---|
| 846 | e.getY() + this.getY()); |
|---|
| 847 | unitStatusMenu.setVisible(true); |
|---|
| 848 | } |
|---|
| 849 | |
|---|
| 850 | /* |
|---|
| 851 | * Displays the menu where the right click occurred. |
|---|
| 852 | */ |
|---|
| 853 | public void openDropDownWithAssignedIncMenu(MouseEvent e) { |
|---|
| 854 | unitStatusWithAssignedIncMenu.setLocation(e.getX() + this.getX(), |
|---|
| 855 | e.getY() + this.getY()); |
|---|
| 856 | unitStatusWithAssignedIncMenu.setVisible(true); |
|---|
| 857 | } |
|---|
| 858 | |
|---|
| 859 | /* |
|---|
| 860 | * Hides the menu. |
|---|
| 861 | */ |
|---|
| 862 | public void closeDropDownMenu() { |
|---|
| 863 | unSelectAllLabels(); |
|---|
| 864 | unitStatusMenu.revalidate(); |
|---|
| 865 | unitStatusMenu.repaint(); |
|---|
| 866 | unitStatusMenu.setVisible(false); |
|---|
| 867 | } |
|---|
| 868 | |
|---|
| 869 | /* |
|---|
| 870 | * Hides the menu. |
|---|
| 871 | */ |
|---|
| 872 | public void closeDropDownWithAssignedIncMenu() { |
|---|
| 873 | unSelectAllLabels(); |
|---|
| 874 | unitStatusWithAssignedIncMenu.revalidate(); |
|---|
| 875 | unitStatusWithAssignedIncMenu.repaint(); |
|---|
| 876 | unitStatusWithAssignedIncMenu.setVisible(false); |
|---|
| 877 | } |
|---|
| 878 | |
|---|
| 879 | /* |
|---|
| 880 | * Refreshes the data in the table by updating all data and repainting the |
|---|
| 881 | * screen. It saves user preferences(like column sizes, selected row, sorted preferences) |
|---|
| 882 | * and applies them to the updated model it receives from the server. |
|---|
| 883 | */ |
|---|
| 884 | public void refreshTable() { |
|---|
| 885 | if(unitStatusTable.getTableHeader().getResizingColumn() == null){//only update info if resize not in progress |
|---|
| 886 | try { |
|---|
| 887 | int index = unitStatusTable.getSelectedRow(); |
|---|
| 888 | List<? extends SortKey> keys = unitStatusTable.getRowSorter().getSortKeys(); |
|---|
| 889 | int[] columnWidths = new int[20]; |
|---|
| 890 | for(int i = 0; i < unitStatusTable.getColumnCount(); i++){ |
|---|
| 891 | columnWidths[i] = unitStatusTable.getColumnModel().getColumn(i).getWidth(); |
|---|
| 892 | } |
|---|
| 893 | |
|---|
| 894 | unitStatusTable.setModel(ScreenManager.theCoordinator.getCadDataTable(CADDataEnums.TABLE.UNIT_STATUS)); |
|---|
| 895 | |
|---|
| 896 | for(int i = 0; i < unitStatusTable.getColumnCount(); i++){ |
|---|
| 897 | unitStatusTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidths[i]); |
|---|
| 898 | } |
|---|
| 899 | unitStatusTable.getRowSorter().setSortKeys(keys); |
|---|
| 900 | unitStatusTable.getSelectionModel().setSelectionInterval(index, index); |
|---|
| 901 | } catch (RemoteException e) { |
|---|
| 902 | e.printStackTrace(); |
|---|
| 903 | } |
|---|
| 904 | revalidate(); |
|---|
| 905 | repaint(); |
|---|
| 906 | } |
|---|
| 907 | } |
|---|
| 908 | |
|---|
| 909 | /* |
|---|
| 910 | * Makes screen visible. |
|---|
| 911 | */ |
|---|
| 912 | public void open() { |
|---|
| 913 | setVisible(true); |
|---|
| 914 | } |
|---|
| 915 | |
|---|
| 916 | /* |
|---|
| 917 | * Hides screen. |
|---|
| 918 | */ |
|---|
| 919 | public void close() { |
|---|
| 920 | setVisible(false); |
|---|
| 921 | } |
|---|
| 922 | |
|---|
| 923 | /** |
|---|
| 924 | * This method is called every second in ScreenManger to update the display |
|---|
| 925 | * time every second. |
|---|
| 926 | */ |
|---|
| 927 | public void handleUpdateTime() { |
|---|
| 928 | int timerColumn = 13; |
|---|
| 929 | int unitColumn = 2; |
|---|
| 930 | for (int i = 0; i < unitStatusTable.getModel().getRowCount(); i++) { |
|---|
| 931 | try { |
|---|
| 932 | unitStatusTable.getModel().setValueAt( |
|---|
| 933 | ScreenManager.theCoordinator.getCadDataUnitValue( |
|---|
| 934 | (String) unitStatusTable.getModel().getValueAt( |
|---|
| 935 | i, unitColumn), UNIT_TAGS.TIMER), i, |
|---|
| 936 | timerColumn); |
|---|
| 937 | } catch (RemoteException e) { |
|---|
| 938 | e.printStackTrace(); |
|---|
| 939 | } |
|---|
| 940 | } |
|---|
| 941 | } |
|---|
| 942 | |
|---|
| 943 | /** |
|---|
| 944 | * Removes drag and drop feature/button clicking. |
|---|
| 945 | */ |
|---|
| 946 | public void removeDispatcherAuthority() { |
|---|
| 947 | unitStatusTable.setTransferHandler(new TransferHandler("")); |
|---|
| 948 | buttonEnrt.setEnabled(false); |
|---|
| 949 | buttonStage.setEnabled(false); |
|---|
| 950 | button1097.setEnabled(false); |
|---|
| 951 | buttonCode4.setEnabled(false); |
|---|
| 952 | buttonDash1.setEnabled(false); |
|---|
| 953 | buttonDash2.setEnabled(false); |
|---|
| 954 | buttonDash3.setEnabled(false); |
|---|
| 955 | button108.setEnabled(false); |
|---|
| 956 | buttonOFC.setEnabled(false); |
|---|
| 957 | buttonOOS.setEnabled(false); |
|---|
| 958 | } |
|---|
| 959 | |
|---|
| 960 | } |
|---|