Changeset 59 in tmcsimulator for trunk/src/tmcsim/client/cadclientgui/screens/UnitStatus.java
- Timestamp:
- 03/15/2017 10:20:21 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/client/cadclientgui/screens/UnitStatus.java
r3 r59 4 4 import java.awt.Component; 5 5 import java.awt.Dimension; 6 import java.awt.Point; 6 7 import java.awt.Toolkit; 7 8 import java.awt.datatransfer.DataFlavor; … … 17 18 import java.rmi.RemoteException; 18 19 import java.util.List; 19 20 20 import javax.swing.Box; 21 21 import javax.swing.BoxLayout; … … 28 28 import javax.swing.JTable; 29 29 import javax.swing.ListSelectionModel; 30 import javax.swing.RowSorter;31 30 import javax.swing.RowSorter.SortKey; 32 31 import javax.swing.SwingUtilities; … … 34 33 import javax.swing.table.DefaultTableModel; 35 34 import javax.swing.table.TableCellRenderer; 36 37 35 import tmcsim.client.cadclientgui.enums.CADDataEnums; 38 36 import tmcsim.client.cadclientgui.enums.CADScriptTags.UNIT_TAGS; … … 41 39 42 40 /** 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 * 41 * This class contains the view and controller for the UnitStatus screen. The 42 * view was not built using a GUI builder plug-in (but may want to consider 43 * doing so in the future), and the controller uses listeners to control how the 44 * view and data act. 45 * 46 46 * @author Vincent 47 47 */ 48 49 public class UnitStatus extends JFrame { 50 48 public class UnitStatus extends JFrame 49 { 51 50 private final int ONE_SECOND = 1000; 52 53 51 private final String SCREEN_TITLE = "(Shift + F4) Unit Status"; 54 55 52 private final Dimension SCREEN_DIMENSIONS = new Dimension(1400, 250); 56 57 53 private final Dimension DROP_DOWN_MENU_LABEL_DIMENSIONS = new Dimension( 58 54 170, 20); 59 60 55 private final Dimension DROP_DOWN_MENU_DIMENSIONS = new Dimension(170, 300); 61 62 56 private final Dimension BUTTON_DIMENSIONS = new Dimension(100, 25); 63 64 57 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 58 private final String[] LABELS = 59 { 60 "10-8", "OFC", "OOS", 61 "Open Unit Details", "Open Unit Activity Log", "Map", 62 "Change Vehicle", "Unit Poll", "Quick Note...", 63 "Activate User Timer...", "Filters", "Page...", "Roster System", 64 "10-10" 65 }; 66 private final String[] WITH_ASSIGNED_INC_LABELS = 67 { 68 "STAGE", "10-97", 69 "10-8", "ASSIGNED ALT...", "ENRT ALT...", "10-97 ALT...", 70 "Open Incident", "Recall Incident", "Open Unit Details", 71 "Open Unit Activity Log", "Map", "Recall Linked Incidents", 72 "Cancel", "Reassign", "Duplicate", "Unit Poll", "Quick Note...", 73 "Activate User Timer...", "Filters", "Page...", "Fax..." 74 }; 79 75 private final String LABEL_SPACING = " "; 80 81 76 // this box holds both the table and the buttons below 82 77 private Box unitStatusFrame; 83 84 78 private JTable unitStatusTable; 85 79 private JFrame unitStatusMenu; 86 80 private JFrame unitStatusWithAssignedIncMenu; 87 88 81 // labels for the drop down menu 89 82 private JLabel[] dropDownLabels = new JLabel[LABELS.length]; 90 83 private JLabel[] dropDownWithAssignedIncLabels = new JLabel[WITH_ASSIGNED_INC_LABELS.length]; 91 92 84 private JButton buttonEnrt; 93 85 private JButton buttonStage; … … 101 93 private JButton buttonOOS; 102 94 103 public UnitStatus() { 95 public UnitStatus() 96 { 104 97 initComponents(); 105 98 } 106 99 107 private void initComponents() { 100 private void initComponents() 101 { 108 102 initializeTable(); 109 103 initControllers(); … … 138 132 * drop feature. 139 133 */ 140 private void initializeTable() { 141 unitStatusTable = new JTable() { 134 private void initializeTable() 135 { 136 unitStatusTable = new JTable() 137 { 142 138 /** 143 139 * Custom renderer to set different background/foreground colors 144 * 145 * @see javax.swing.JTable#prepareRenderer(javax.swing.table.TableCellRenderer, 146 * int, int) 140 * 141 * @see 142 * javax.swing.JTable#prepareRenderer(javax.swing.table.TableCellRenderer, 143 * int, int) 147 144 */ 148 145 public Component prepareRenderer(TableCellRenderer renderer, 149 int row, int column) { 146 int row, int column) 147 { 150 148 Component comp = super.prepareRenderer(renderer, row, column); 151 149 152 150 int unitNumColumn = 2; 153 try { 151 try 152 { 154 153 switch (ScreenManager.theCoordinator 155 154 .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; 155 .getValueAt(row, unitNumColumn))) 156 { 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 173 } 174 } catch (RemoteException e) { 174 } catch (RemoteException e) 175 { 175 176 e.printStackTrace(); 176 177 } 177 178 178 if (getSelectedRow() == row) { 179 if (getSelectedRow() == row) 180 { 179 181 comp.setForeground(Color.WHITE); 180 182 comp.setBackground(Color.BLUE); … … 198 200 .setColumnIdentifiers(TableHeaders.UNIT_STATUS_HEADERS); 199 201 200 unitStatusTable.setTransferHandler(new TransferHandler() { 201 202 public boolean canImport(TransferHandler.TransferSupport info) { 203 if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) { 202 unitStatusTable.setTransferHandler(new TransferHandler() 203 { 204 public boolean canImport(TransferHandler.TransferSupport info) 205 { 206 if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) 207 { 204 208 return false; 205 209 } … … 207 211 } 208 212 209 public int getSourceActions(JComponent c) { 213 public int getSourceActions(JComponent c) 214 { 210 215 return TransferHandler.COPY_OR_MOVE; 211 216 } 212 217 213 protected Transferable createTransferable(JComponent c) { 218 protected Transferable createTransferable(JComponent c) 219 { 214 220 return new StringSelection((String) unitStatusTable.getValueAt( 215 221 unitStatusTable.getSelectedRow(), 2)); 216 222 } 217 218 223 }); 219 224 220 for (int i = 0; i < unitStatusTable.getColumnCount(); i++) { 225 for (int i = 0; i < unitStatusTable.getColumnCount(); i++) 226 { 221 227 unitStatusTable.getColumnModel().getColumn(i) 222 228 .setPreferredWidth(COLUMN_WIDTH); … … 228 234 * screen. 229 235 */ 230 private void initControllers() { 231 unitStatusTable.addMouseListener(new MouseListener() { 232 public void mouseClicked(MouseEvent e) { 236 //TODO: JD If one unit has been selected, but you right-click on a different one. 237 //Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Invalid index 238 // at javax.swing.DefaultRowSorter.convertRowIndexToModel(DefaultRowSorter.java:514) 239 // at javax.swing.JTable.convertRowIndexToModel(JTable.java:2642) 240 // at javax.swing.JTable.getValueAt(JTable.java:2717) 241 // at tmcsim.client.cadclientgui.screens.UnitStatus$3.mouseClicked(UnitStatus.java:234) 242 private void initControllers() 243 { 244 unitStatusTable.addMouseListener(new MouseListener() 245 { 246 public void mouseClicked(MouseEvent e) 247 { 233 248 int unitColumn = 2; 249 // Fixed to force right click to cause the row to be selected. JD 250 // get the coordinates of the mouse click 251 Point p = e.getPoint(); 252 // get the row index that contains that coordinate 253 int rowNumber = unitStatusTable.rowAtPoint(p); 254 // Get the ListSelectionModel of the JTable 255 ListSelectionModel model = unitStatusTable.getSelectionModel(); 256 // set the selected interval of rows. Using the "rowNumber" 257 // variable for the beginning and end selects only that one row. 258 model.setSelectionInterval(rowNumber, rowNumber); 259 234 260 String unitNum = (String) unitStatusTable.getValueAt( 235 unitStatusTable.getSelectedRow(), unitColumn); 236 if (SwingUtilities.isRightMouseButton(e)) { 237 try { 261 rowNumber, unitColumn); 262 // Validity check for non-empty unit number 263 if (unitNum.equals("")) 264 { 265 return; 266 } 267 if (SwingUtilities.isRightMouseButton(e)) 268 { 269 try 270 { 238 271 if (ScreenManager.theCoordinator 239 272 .getCadDataUnitStatus(unitNum) == UnitStatusEnums.Enroute 240 273 || ScreenManager.theCoordinator 241 .getCadDataUnitStatus(unitNum) == UnitStatusEnums.Arrived) { 274 .getCadDataUnitStatus(unitNum) == UnitStatusEnums.Arrived) 275 { 242 276 openDropDownWithAssignedIncMenu(e); 243 } else { 277 } 278 else 279 { 244 280 openDropDownMenu(e); 245 281 } 246 } catch (RemoteException e1) { 282 } catch (RemoteException e1) 283 { 247 284 e1.printStackTrace(); 248 285 } 249 } else { 286 } 287 else 288 { 250 289 closeDropDownMenu(); 251 290 closeDropDownWithAssignedIncMenu(); … … 253 292 } 254 293 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) { 294 public void mouseEntered(MouseEvent e) 295 { 296 } 297 298 public void mouseExited(MouseEvent e) 299 { 300 } 301 302 public void mousePressed(MouseEvent e) 303 { 304 } 305 306 public void mouseReleased(MouseEvent e) 307 { 265 308 } 266 309 }); 267 310 268 addComponentListener(new ComponentListener() { 269 public void componentHidden(ComponentEvent e) { 270 } 271 272 public void componentMoved(ComponentEvent e) { 311 addComponentListener(new ComponentListener() 312 { 313 public void componentHidden(ComponentEvent e) 314 { 315 } 316 317 public void componentMoved(ComponentEvent e) 318 { 273 319 closeDropDownMenu(); 274 320 } 275 321 276 public void componentResized(ComponentEvent e) { 277 } 278 279 public void componentShown(ComponentEvent e) { 322 public void componentResized(ComponentEvent e) 323 { 324 } 325 326 public void componentShown(ComponentEvent e) 327 { 280 328 } 281 329 }); … … 286 334 * on the table. 287 335 */ 288 private void initializeDropDownMenus() { 336 private void initializeDropDownMenus() 337 { 289 338 Box menu = new Box(BoxLayout.Y_AXIS); 290 339 initializeDropDownLabels(); … … 319 368 * labels are not implemented so no listeners are added. 320 369 */ 321 private void initializeDropDownLabels() { 322 for (int i = 0; i < dropDownLabels.length; i++) { 370 private void initializeDropDownLabels() 371 { 372 for (int i = 0; i < dropDownLabels.length; i++) 373 { 323 374 dropDownLabels[i] = new JLabel(LABEL_SPACING + LABELS[i]); 324 375 dropDownLabels[i].setMaximumSize(DROP_DOWN_MENU_LABEL_DIMENSIONS); … … 330 381 * Sets the text and size and adds a listener to each activated label. 331 382 */ 332 private void initializeDropDownWithAssignedIncLabels() { 333 for (int i = 0; i < dropDownWithAssignedIncLabels.length; i++) { 383 private void initializeDropDownWithAssignedIncLabels() 384 { 385 for (int i = 0; i < dropDownWithAssignedIncLabels.length; i++) 386 { 334 387 dropDownWithAssignedIncLabels[i] = new JLabel(LABEL_SPACING 335 388 + WITH_ASSIGNED_INC_LABELS[i]); … … 347 400 * between. 348 401 */ 349 private void addLabelsToBox(Box menu) { 402 private void addLabelsToBox(Box menu) 403 { 350 404 menu.add(dropDownLabels[0]); 351 405 menu.add(dropDownLabels[1]); … … 400 454 * between. 401 455 */ 402 private void addWithAssignedIncLabelsToBox(Box menu) { 456 private void addWithAssignedIncLabelsToBox(Box menu) 457 { 403 458 menu.add(dropDownWithAssignedIncLabels[0]); 404 459 menu.add(dropDownWithAssignedIncLabels[1]); … … 454 509 * Creates each button and handles the action performed by the button. 455 510 */ 456 public void initializeBottomButtons(Box bottomButtons) { 457 bottomButtons.add(buttonEnrt = makeButton("ENRT", new ActionListener() { 458 public void actionPerformed(ActionEvent arg0) { 459 try { 511 public void initializeBottomButtons(Box bottomButtons) 512 { 513 bottomButtons.add(buttonEnrt = makeButton("ENRT", new ActionListener() 514 { 515 public void actionPerformed(ActionEvent arg0) 516 { 517 try 518 { 460 519 ScreenManager.theCoordinator.setCadDataUnitValue( 461 520 (String) unitStatusTable.getValueAt( 462 unitStatusTable.getSelectedRow(), 2),521 unitStatusTable.getSelectedRow(), 2), 463 522 UNIT_TAGS.STATUS, "ENRT"); 464 523 ScreenManager.theCoordinator.setCadDataUnitValue( 465 524 (String) unitStatusTable.getValueAt( 466 unitStatusTable.getSelectedRow(), 2),525 unitStatusTable.getSelectedRow(), 2), 467 526 UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Enroute); 468 } catch (RemoteException e) { 527 } catch (RemoteException e) 528 { 469 529 e.printStackTrace(); 470 530 } … … 473 533 })); 474 534 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 })); 535 new ActionListener() 536 { 537 public void actionPerformed(ActionEvent arg0) 538 { 539 try 540 { 541 ScreenManager.theCoordinator.setCadDataUnitValue( 542 (String) unitStatusTable 543 .getValueAt(unitStatusTable 544 .getSelectedRow(), 2), 545 UNIT_TAGS.STATUS, "STAGE"); 546 } catch (RemoteException e) 547 { 548 e.printStackTrace(); 549 } 550 refreshTable(); 551 } 552 })); 489 553 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 })); 554 new ActionListener() 555 { 556 public void actionPerformed(ActionEvent arg0) 557 { 558 try 559 { 560 ScreenManager.theCoordinator.setCadDataUnitValue( 561 (String) unitStatusTable 562 .getValueAt(unitStatusTable 563 .getSelectedRow(), 2), 564 UNIT_TAGS.STATUS, "10-97"); 565 ScreenManager.theCoordinator.setCadDataUnitValue( 566 (String) unitStatusTable 567 .getValueAt(unitStatusTable 568 .getSelectedRow(), 2), 569 UNIT_TAGS.UNIT_STATUS, 570 UnitStatusEnums.Arrived); 571 } catch (RemoteException e) 572 { 573 e.printStackTrace(); 574 } 575 refreshTable(); 576 } 577 })); 510 578 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 })); 579 new ActionListener() 580 { 581 public void actionPerformed(ActionEvent arg0) 582 { 583 try 584 { 585 ScreenManager.theCoordinator.setCadDataUnitValue( 586 (String) unitStatusTable 587 .getValueAt(unitStatusTable 588 .getSelectedRow(), 2), 589 UNIT_TAGS.STATUS, "CODE 4"); 590 } catch (RemoteException e) 591 { 592 e.printStackTrace(); 593 } 594 refreshTable(); 595 } 596 })); 525 597 bottomButtons.add(buttonDash1 = makeButton("-", null)); 526 598 bottomButtons.add(buttonDash2 = makeButton("-", null)); 527 599 bottomButtons.add(buttonDash3 = makeButton("-", null)); 528 bottomButtons.add(button108 = makeButton("10-8", new ActionListener() { 529 public void actionPerformed(ActionEvent arg0) { 530 try { 600 bottomButtons.add(button108 = makeButton("10-8", new ActionListener() 601 { 602 public void actionPerformed(ActionEvent arg0) 603 { 604 try 605 { 531 606 ScreenManager.theCoordinator.setCadDataUnitValue( 532 607 (String) unitStatusTable.getValueAt( 533 unitStatusTable.getSelectedRow(), 2),608 unitStatusTable.getSelectedRow(), 2), 534 609 UNIT_TAGS.STATUS, "10-8"); 535 610 ScreenManager.theCoordinator.setCadDataUnitValue( 536 611 (String) unitStatusTable.getValueAt( 537 unitStatusTable.getSelectedRow(), 2),612 unitStatusTable.getSelectedRow(), 2), 538 613 UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Assignable); 539 } catch (RemoteException e) { 614 } catch (RemoteException e) 615 { 540 616 e.printStackTrace(); 541 617 } … … 543 619 } 544 620 })); 545 bottomButtons.add(buttonOFC = makeButton("OFC", new ActionListener() { 546 public void actionPerformed(ActionEvent arg0) { 547 try { 621 bottomButtons.add(buttonOFC = makeButton("OFC", new ActionListener() 622 { 623 public void actionPerformed(ActionEvent arg0) 624 { 625 try 626 { 548 627 ScreenManager.theCoordinator.setCadDataUnitValue( 549 628 (String) unitStatusTable.getValueAt( 550 unitStatusTable.getSelectedRow(), 2),629 unitStatusTable.getSelectedRow(), 2), 551 630 UNIT_TAGS.STATUS, "OFC"); 552 631 ScreenManager.theCoordinator.setCadDataUnitValue( 553 632 (String) unitStatusTable.getValueAt( 554 unitStatusTable.getSelectedRow(), 2),633 unitStatusTable.getSelectedRow(), 2), 555 634 UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Arrived); 556 } catch (RemoteException e) { 635 } catch (RemoteException e) 636 { 557 637 e.printStackTrace(); 558 638 } … … 560 640 } 561 641 })); 562 bottomButtons.add(buttonOOS = makeButton("OOS", new ActionListener() { 563 public void actionPerformed(ActionEvent arg0) { 564 try { 642 bottomButtons.add(buttonOOS = makeButton("OOS", new ActionListener() 643 { 644 public void actionPerformed(ActionEvent arg0) 645 { 646 try 647 { 565 648 ScreenManager.theCoordinator.setCadDataUnitValue( 566 649 (String) unitStatusTable.getValueAt( 567 unitStatusTable.getSelectedRow(), 2),650 unitStatusTable.getSelectedRow(), 2), 568 651 UNIT_TAGS.STATUS, "OOS"); 569 652 ScreenManager.theCoordinator.setCadDataUnitValue( 570 653 (String) unitStatusTable.getValueAt( 571 unitStatusTable.getSelectedRow(), 2),654 unitStatusTable.getSelectedRow(), 2), 572 655 UNIT_TAGS.UNIT_STATUS, 573 656 UnitStatusEnums.NotAssignable); 574 } catch (RemoteException e) { 657 } catch (RemoteException e) 658 { 575 659 e.printStackTrace(); 576 660 } … … 582 666 /* 583 667 * Makes a JButton with an text and listener. 584 * 668 * 585 669 * @param text the text to be displayed 586 * 670 * 587 671 * @param listener the action listener for this button. 588 * 672 * 589 673 * @return the JButton. 590 674 */ 591 public JButton makeButton(String text, ActionListener listener) { 675 public JButton makeButton(String text, ActionListener listener) 676 { 592 677 JButton button = new JButton(text); 593 678 button.setBackground(Color.GRAY); … … 606 691 * Sets the highlighted color(when the mouse is over it) of the JLabels. 607 692 * Note: the color is not shown until .setOpaque(true) is called. 608 * 693 * 609 694 * @param color the highlighted color 610 695 */ 611 public void setMenuHighlightedBackground(Color color) { 612 for (int i = 0; i < dropDownLabels.length; i++) { 696 public void setMenuHighlightedBackground(Color color) 697 { 698 for (int i = 0; i < dropDownLabels.length; i++) 699 { 613 700 dropDownLabels[i].setBackground(color); 614 701 } … … 618 705 * Sets the highlighted color(when the mouse is over it) of the JLabels. 619 706 * Note: the color is not shown until .setOpaque(true) is called. 620 * 707 * 621 708 * @param color the highlighted color 622 709 */ 623 public void setWithAssignedIncMenuHighlightedBackground(Color color) { 624 for (int i = 0; i < dropDownWithAssignedIncLabels.length; i++) { 710 public void setWithAssignedIncMenuHighlightedBackground(Color color) 711 { 712 for (int i = 0; i < dropDownWithAssignedIncLabels.length; i++) 713 { 625 714 dropDownWithAssignedIncLabels[i].setBackground(color); 626 715 } … … 630 719 * Sets all JLabels to not display a highlighted background 631 720 */ 632 public void unSelectAllLabels() { 633 for (int i = 0; i < dropDownLabels.length; i++) { 721 public void unSelectAllLabels() 722 { 723 for (int i = 0; i < dropDownLabels.length; i++) 724 { 634 725 dropDownLabels[i].setOpaque(false); 635 726 } … … 639 730 * Sets all JLabels to not display a highlighted background 640 731 */ 641 public void unSelectAllWithAssignedIncLabels() { 642 for (int i = 0; i < dropDownWithAssignedIncLabels.length; i++) { 732 public void unSelectAllWithAssignedIncLabels() 733 { 734 for (int i = 0; i < dropDownWithAssignedIncLabels.length; i++) 735 { 643 736 dropDownWithAssignedIncLabels[i].setOpaque(false); 644 737 } … … 647 740 /* 648 741 * Sets the label to have a highlighted background. 649 * 742 * 650 743 * @param label the label that is selected/highlighted 651 744 */ 652 public void selectLabel(Object label) { 745 public void selectLabel(Object label) 746 { 653 747 ((JLabel) label).setOpaque(true); 654 748 } … … 657 751 * Performs the label action depending on which label was clicked. 658 752 */ 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 753 public void performLabelAction(Object label) 754 { 755 if (label.equals(dropDownLabels[0])) 756 { // 10-8 757 } 758 else if (label.equals(dropDownLabels[1])) 759 { // OFC 760 } 761 else if (label.equals(dropDownLabels[2])) 762 { // OOS 763 } 764 else if (label.equals(dropDownLabels[3])) 765 { // Open Unit Details 766 } 767 else if (label.equals(dropDownLabels[4])) 768 { // Open Unit Activity Log 769 } 770 else if (label.equals(dropDownLabels[5])) 771 { // Map 772 } 773 else if (label.equals(dropDownLabels[6])) 774 { // Change Vehicle 775 } 776 else if (label.equals(dropDownLabels[7])) 777 { // Unit Poll 778 } 779 else if (label.equals(dropDownLabels[8])) 780 { // Quick Notes 781 } 782 else if (label.equals(dropDownLabels[9])) 783 { // Activate User Timer 784 } 785 else if (label.equals(dropDownLabels[10])) 786 { // Filters 787 } 788 else if (label.equals(dropDownLabels[11])) 789 { // Page 790 } 791 else if (label.equals(dropDownLabels[12])) 792 { // Roster System 793 } 794 else if (label.equals(dropDownLabels[13])) 795 { // 10-10 688 796 } 689 797 } … … 692 800 * Performs the label action depending on which label was clicked. 693 801 */ 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 802 public void performWithAssignedIncLabelAction(Object label) 803 { 804 if (label.equals(dropDownWithAssignedIncLabels[0])) 805 { // STAGE 806 } 807 else if (label.equals(dropDownWithAssignedIncLabels[1])) 808 { // 10-97 809 } 810 else if (label.equals(dropDownWithAssignedIncLabels[2])) 811 { // 10-8 812 } 813 else if (label.equals(dropDownWithAssignedIncLabels[3])) 814 { // ASSIGN 815 // ALT... 816 } 817 else if (label.equals(dropDownWithAssignedIncLabels[4])) 818 { // ENRT 819 // ALT... 820 } 821 else if (label.equals(dropDownWithAssignedIncLabels[5])) 822 { // 10-97 823 // ALT... 824 } 825 else if (label.equals(dropDownWithAssignedIncLabels[6])) 826 { // Open 827 // Incident 712 828 int idColumn = 0; 713 829 ScreenManager.openIncidentViewer(Integer 714 830 .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 831 unitStatusTable.getSelectedRow(), idColumn))); 832 } 833 else if (label.equals(dropDownWithAssignedIncLabels[7])) 834 { // Recall 835 // Incident 836 } 837 else if (label.equals(dropDownWithAssignedIncLabels[8])) 838 { // Open 839 // Unit 840 // Details 841 } 842 else if (label.equals(dropDownWithAssignedIncLabels[9])) 843 { // Open 844 // Unit 845 // Activity 846 // Log 847 } 848 else if (label.equals(dropDownWithAssignedIncLabels[10])) 849 { // Map 850 } 851 else if (label.equals(dropDownWithAssignedIncLabels[11])) 852 { // Recall 853 // Linked 854 // Incidents 855 } 856 else if (label.equals(dropDownWithAssignedIncLabels[12])) 857 { // Cancel 858 } 859 else if (label.equals(dropDownWithAssignedIncLabels[13])) 860 { // Reassign 861 } 862 else if (label.equals(dropDownWithAssignedIncLabels[14])) 863 { // Duplicate 864 } 865 else if (label.equals(dropDownWithAssignedIncLabels[15])) 866 { // Unit 867 // Poll 868 } 869 else if (label.equals(dropDownWithAssignedIncLabels[16])) 870 { // Quick 871 // Note... 872 } 873 else if (label.equals(dropDownWithAssignedIncLabels[17])) 874 { // Activate 875 // User 876 // Timer... 877 } 878 else if (label.equals(dropDownWithAssignedIncLabels[18])) 879 { // Filters 880 } 881 else if (label.equals(dropDownWithAssignedIncLabels[19])) 882 { // Page... 883 } 884 else if (label.equals(dropDownWithAssignedIncLabels[20])) 885 { // Fax... 756 886 } 757 887 } … … 763 893 * designates. 764 894 */ 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) { 895 public void addMouseListenersToLabel(JLabel label) 896 { 897 label.addMouseMotionListener(new MouseMotionListener() 898 { 899 public void mouseDragged(MouseEvent e) 900 { 901 } 902 903 public void mouseMoved(MouseEvent e) 904 { 771 905 unSelectAllLabels(); 772 906 selectLabel(e.getSource()); … … 775 909 } 776 910 }); 777 label.addMouseListener(new MouseListener() { 778 public void mouseClicked(MouseEvent e) { 911 label.addMouseListener(new MouseListener() 912 { 913 public void mouseClicked(MouseEvent e) 914 { 779 915 performLabelAction(e.getSource()); 780 916 unSelectAllLabels(); … … 784 920 } 785 921 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) { 922 public void mouseEntered(MouseEvent e) 923 { 924 } 925 926 public void mouseExited(MouseEvent e) 927 { 928 } 929 930 public void mousePressed(MouseEvent e) 931 { 932 } 933 934 public void mouseReleased(MouseEvent e) 935 { 796 936 } 797 937 }); … … 804 944 * designates. 805 945 */ 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) { 946 public void addMouseListenersToWithAssignedIncLabel(JLabel label) 947 { 948 label.addMouseMotionListener(new MouseMotionListener() 949 { 950 public void mouseDragged(MouseEvent e) 951 { 952 } 953 954 public void mouseMoved(MouseEvent e) 955 { 812 956 unSelectAllLabels(); 813 957 selectLabel(e.getSource()); … … 816 960 } 817 961 }); 818 label.addMouseListener(new MouseListener() { 819 public void mouseClicked(MouseEvent e) { 962 label.addMouseListener(new MouseListener() 963 { 964 public void mouseClicked(MouseEvent e) 965 { 820 966 performWithAssignedIncLabelAction(e.getSource()); 821 967 unSelectAllLabels(); … … 825 971 } 826 972 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) { 973 public void mouseEntered(MouseEvent e) 974 { 975 } 976 977 public void mouseExited(MouseEvent e) 978 { 979 } 980 981 public void mousePressed(MouseEvent e) 982 { 983 } 984 985 public void mouseReleased(MouseEvent e) 986 { 837 987 } 838 988 }); … … 842 992 * Displays the menu where the right click occurred. 843 993 */ 844 public void openDropDownMenu(MouseEvent e) { 994 public void openDropDownMenu(MouseEvent e) 995 { 845 996 unitStatusMenu.setLocation(e.getX() + this.getX(), 846 997 e.getY() + this.getY()); … … 851 1002 * Displays the menu where the right click occurred. 852 1003 */ 853 public void openDropDownWithAssignedIncMenu(MouseEvent e) { 1004 public void openDropDownWithAssignedIncMenu(MouseEvent e) 1005 { 854 1006 unitStatusWithAssignedIncMenu.setLocation(e.getX() + this.getX(), 855 1007 e.getY() + this.getY()); … … 860 1012 * Hides the menu. 861 1013 */ 862 public void closeDropDownMenu() { 1014 public void closeDropDownMenu() 1015 { 863 1016 unSelectAllLabels(); 864 1017 unitStatusMenu.revalidate(); … … 870 1023 * Hides the menu. 871 1024 */ 872 public void closeDropDownWithAssignedIncMenu() { 1025 public void closeDropDownWithAssignedIncMenu() 1026 { 873 1027 unSelectAllLabels(); 874 1028 unitStatusWithAssignedIncMenu.revalidate(); … … 879 1033 /* 880 1034 * 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) 1035 * screen. It saves user preferences(like column sizes, selected row, sorted preferences) 882 1036 * and applies them to the updated model it receives from the server. 883 1037 */ 884 public void refreshTable() { 885 if(unitStatusTable.getTableHeader().getResizingColumn() == null){//only update info if resize not in progress 886 try { 1038 public void refreshTable() 1039 { 1040 if (unitStatusTable.getTableHeader().getResizingColumn() == null) 1041 {//only update info if resize not in progress 1042 try 1043 { 887 1044 int index = unitStatusTable.getSelectedRow(); 888 1045 List<? extends SortKey> keys = unitStatusTable.getRowSorter().getSortKeys(); 889 1046 int[] columnWidths = new int[20]; 890 for(int i = 0; i < unitStatusTable.getColumnCount(); i++){ 1047 for (int i = 0; i < unitStatusTable.getColumnCount(); i++) 1048 { 891 1049 columnWidths[i] = unitStatusTable.getColumnModel().getColumn(i).getWidth(); 892 1050 } 893 1051 894 1052 unitStatusTable.setModel(ScreenManager.theCoordinator.getCadDataTable(CADDataEnums.TABLE.UNIT_STATUS)); 895 896 for(int i = 0; i < unitStatusTable.getColumnCount(); i++){ 1053 1054 for (int i = 0; i < unitStatusTable.getColumnCount(); i++) 1055 { 897 1056 unitStatusTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidths[i]); 898 1057 } 899 1058 unitStatusTable.getRowSorter().setSortKeys(keys); 900 1059 unitStatusTable.getSelectionModel().setSelectionInterval(index, index); 901 } catch (RemoteException e) { 902 e.printStackTrace(); 903 } 904 revalidate(); 905 repaint(); 906 } 1060 } catch (RemoteException e) 1061 { 1062 e.printStackTrace(); 1063 } 1064 revalidate(); 1065 repaint(); 1066 } 907 1067 } 908 1068 … … 910 1070 * Makes screen visible. 911 1071 */ 912 public void open() { 1072 public void open() 1073 { 913 1074 setVisible(true); 914 1075 } … … 917 1078 * Hides screen. 918 1079 */ 919 public void close() { 1080 public void close() 1081 { 920 1082 setVisible(false); 921 1083 } … … 923 1085 /** 924 1086 * 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 1087 * time every second. Seems redundant: refreshTable already takes care of 1088 * it. JD 1089 */ 1090 // public void handleUpdateTime() 1091 // { 1092 // int timerColumn = 13; 1093 // int unitColumn = 2; 1094 // for (int i = 0; i < unitStatusTable.getModel().getRowCount(); i++) 1095 // { 1096 // try 1097 // { 1098 // unitStatusTable.getModel().setValueAt( 1099 // ScreenManager.theCoordinator.getCadDataUnitValue( 1100 // (String) unitStatusTable.getModel().getValueAt( 1101 // i, unitColumn), UNIT_TAGS.TIMER), i, 1102 // timerColumn); 1103 // } catch (RemoteException e) 1104 // { 1105 // e.printStackTrace(); 1106 // } 1107 // } 1108 // } 1109 // 1110 // /** 1111 // * Replaces handleUpdateTime 1112 // */ 1113 // public void updateTimeColumn() 1114 // { 1115 // int unitColumn = 2; 1116 // try 1117 // { 1118 // DefaultTableModel dm = ScreenManager.theCoordinator.getCadDataTable(CADDataEnums.TABLE.UNIT_STATUS); 1119 // int size = dm.getRowCount(); 1120 // for (int i = 0; i < size; i++) 1121 // { 1122 // String cell = (String) dm.getValueAt(i, unitColumn); 1123 // String currTime = ScreenManager.theCoordinator.getCadDataUnitValue(cell, UNIT_TAGS.TIMER); 1124 // } 1125 // } catch (RemoteException e) 1126 // { 1127 // e.printStackTrace(); 1128 // } 1129 // } 943 1130 /** 944 1131 * Removes drag and drop feature/button clicking. 945 1132 */ 946 public void removeDispatcherAuthority() { 1133 public void removeDispatcherAuthority() 1134 { 947 1135 unitStatusTable.setTransferHandler(new TransferHandler("")); 948 1136 buttonEnrt.setEnabled(false); … … 957 1145 buttonOOS.setEnabled(false); 958 1146 } 959 960 1147 }
Note: See TracChangeset
for help on using the changeset viewer.
