Ignore:
Timestamp:
03/15/2017 10:20:21 AM (9 years ago)
Author:
jdalbey
Message:

Merge CAD Client updates for multiple incident view windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/client/cadclientgui/screens/UnitStatus.java

    r3 r59  
    44import java.awt.Component; 
    55import java.awt.Dimension; 
     6import java.awt.Point; 
    67import java.awt.Toolkit; 
    78import java.awt.datatransfer.DataFlavor; 
     
    1718import java.rmi.RemoteException; 
    1819import java.util.List; 
    19  
    2020import javax.swing.Box; 
    2121import javax.swing.BoxLayout; 
     
    2828import javax.swing.JTable; 
    2929import javax.swing.ListSelectionModel; 
    30 import javax.swing.RowSorter; 
    3130import javax.swing.RowSorter.SortKey; 
    3231import javax.swing.SwingUtilities; 
     
    3433import javax.swing.table.DefaultTableModel; 
    3534import javax.swing.table.TableCellRenderer; 
    36  
    3735import tmcsim.client.cadclientgui.enums.CADDataEnums; 
    3836import tmcsim.client.cadclientgui.enums.CADScriptTags.UNIT_TAGS; 
     
    4139 
    4240/** 
    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 * 
    4646 * @author Vincent 
    4747 */ 
    48  
    49 public class UnitStatus extends JFrame { 
    50  
     48public class UnitStatus extends JFrame 
     49{ 
    5150    private final int ONE_SECOND = 1000; 
    52      
    5351    private final String SCREEN_TITLE = "(Shift + F4)  Unit Status"; 
    54  
    5552    private final Dimension SCREEN_DIMENSIONS = new Dimension(1400, 250); 
    56  
    5753    private final Dimension DROP_DOWN_MENU_LABEL_DIMENSIONS = new Dimension( 
    5854            170, 20); 
    59  
    6055    private final Dimension DROP_DOWN_MENU_DIMENSIONS = new Dimension(170, 300); 
    61  
    6256    private final Dimension BUTTON_DIMENSIONS = new Dimension(100, 25); 
    63  
    6457    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    }; 
    7975    private final String LABEL_SPACING = "     "; 
    80  
    8176    // this box holds both the table and the buttons below 
    8277    private Box unitStatusFrame; 
    83  
    8478    private JTable unitStatusTable; 
    8579    private JFrame unitStatusMenu; 
    8680    private JFrame unitStatusWithAssignedIncMenu; 
    87  
    8881    // labels for the drop down menu 
    8982    private JLabel[] dropDownLabels = new JLabel[LABELS.length]; 
    9083    private JLabel[] dropDownWithAssignedIncLabels = new JLabel[WITH_ASSIGNED_INC_LABELS.length]; 
    91  
    9284    private JButton buttonEnrt; 
    9385    private JButton buttonStage; 
     
    10193    private JButton buttonOOS; 
    10294 
    103     public UnitStatus() { 
     95    public UnitStatus() 
     96    { 
    10497        initComponents(); 
    10598    } 
    10699 
    107     private void initComponents() { 
     100    private void initComponents() 
     101    { 
    108102        initializeTable(); 
    109103        initControllers(); 
     
    138132     * drop feature. 
    139133     */ 
    140     private void initializeTable() { 
    141         unitStatusTable = new JTable() { 
     134    private void initializeTable() 
     135    { 
     136        unitStatusTable = new JTable() 
     137        { 
    142138            /** 
    143139             * 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) 
    147144             */ 
    148145            public Component prepareRenderer(TableCellRenderer renderer, 
    149                     int row, int column) { 
     146                    int row, int column) 
     147            { 
    150148                Component comp = super.prepareRenderer(renderer, row, column); 
    151149 
    152150                int unitNumColumn = 2; 
    153                 try { 
     151                try 
     152                { 
    154153                    switch (ScreenManager.theCoordinator 
    155154                            .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; 
    173173                    } 
    174                 } catch (RemoteException e) { 
     174                } catch (RemoteException e) 
     175                { 
    175176                    e.printStackTrace(); 
    176177                } 
    177178 
    178                 if (getSelectedRow() == row) { 
     179                if (getSelectedRow() == row) 
     180                { 
    179181                    comp.setForeground(Color.WHITE); 
    180182                    comp.setBackground(Color.BLUE); 
     
    198200                .setColumnIdentifiers(TableHeaders.UNIT_STATUS_HEADERS); 
    199201 
    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                { 
    204208                    return false; 
    205209                } 
     
    207211            } 
    208212 
    209             public int getSourceActions(JComponent c) { 
     213            public int getSourceActions(JComponent c) 
     214            { 
    210215                return TransferHandler.COPY_OR_MOVE; 
    211216            } 
    212217 
    213             protected Transferable createTransferable(JComponent c) { 
     218            protected Transferable createTransferable(JComponent c) 
     219            { 
    214220                return new StringSelection((String) unitStatusTable.getValueAt( 
    215221                        unitStatusTable.getSelectedRow(), 2)); 
    216222            } 
    217  
    218223        }); 
    219224 
    220         for (int i = 0; i < unitStatusTable.getColumnCount(); i++) { 
     225        for (int i = 0; i < unitStatusTable.getColumnCount(); i++) 
     226        { 
    221227            unitStatusTable.getColumnModel().getColumn(i) 
    222228                    .setPreferredWidth(COLUMN_WIDTH); 
     
    228234     * screen. 
    229235     */ 
    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            { 
    233248                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 
    234260                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                    { 
    238271                        if (ScreenManager.theCoordinator 
    239272                                .getCadDataUnitStatus(unitNum) == UnitStatusEnums.Enroute 
    240273                                || ScreenManager.theCoordinator 
    241                                         .getCadDataUnitStatus(unitNum) == UnitStatusEnums.Arrived) { 
     274                                .getCadDataUnitStatus(unitNum) == UnitStatusEnums.Arrived) 
     275                        { 
    242276                            openDropDownWithAssignedIncMenu(e); 
    243                         } else { 
     277                        } 
     278                        else 
     279                        { 
    244280                            openDropDownMenu(e); 
    245281                        } 
    246                     } catch (RemoteException e1) { 
     282                    } catch (RemoteException e1) 
     283                    { 
    247284                        e1.printStackTrace(); 
    248285                    } 
    249                 } else { 
     286                } 
     287                else 
     288                { 
    250289                    closeDropDownMenu(); 
    251290                    closeDropDownWithAssignedIncMenu(); 
     
    253292            } 
    254293 
    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            { 
    265308            } 
    266309        }); 
    267310 
    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            { 
    273319                closeDropDownMenu(); 
    274320            } 
    275321 
    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            { 
    280328            } 
    281329        }); 
     
    286334     * on the table. 
    287335     */ 
    288     private void initializeDropDownMenus() { 
     336    private void initializeDropDownMenus() 
     337    { 
    289338        Box menu = new Box(BoxLayout.Y_AXIS); 
    290339        initializeDropDownLabels(); 
     
    319368     * labels are not implemented so no listeners are added. 
    320369     */ 
    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        { 
    323374            dropDownLabels[i] = new JLabel(LABEL_SPACING + LABELS[i]); 
    324375            dropDownLabels[i].setMaximumSize(DROP_DOWN_MENU_LABEL_DIMENSIONS); 
     
    330381     * Sets the text and size and adds a listener to each activated label. 
    331382     */ 
    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        { 
    334387            dropDownWithAssignedIncLabels[i] = new JLabel(LABEL_SPACING 
    335388                    + WITH_ASSIGNED_INC_LABELS[i]); 
     
    347400     * between. 
    348401     */ 
    349     private void addLabelsToBox(Box menu) { 
     402    private void addLabelsToBox(Box menu) 
     403    { 
    350404        menu.add(dropDownLabels[0]); 
    351405        menu.add(dropDownLabels[1]); 
     
    400454     * between. 
    401455     */ 
    402     private void addWithAssignedIncLabelsToBox(Box menu) { 
     456    private void addWithAssignedIncLabelsToBox(Box menu) 
     457    { 
    403458        menu.add(dropDownWithAssignedIncLabels[0]); 
    404459        menu.add(dropDownWithAssignedIncLabels[1]); 
     
    454509     * Creates each button and handles the action performed by the button. 
    455510     */ 
    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                { 
    460519                    ScreenManager.theCoordinator.setCadDataUnitValue( 
    461520                            (String) unitStatusTable.getValueAt( 
    462                                     unitStatusTable.getSelectedRow(), 2), 
     521                            unitStatusTable.getSelectedRow(), 2), 
    463522                            UNIT_TAGS.STATUS, "ENRT"); 
    464523                    ScreenManager.theCoordinator.setCadDataUnitValue( 
    465524                            (String) unitStatusTable.getValueAt( 
    466                                     unitStatusTable.getSelectedRow(), 2), 
     525                            unitStatusTable.getSelectedRow(), 2), 
    467526                            UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Enroute); 
    468                 } catch (RemoteException e) { 
     527                } catch (RemoteException e) 
     528                { 
    469529                    e.printStackTrace(); 
    470530                } 
     
    473533        })); 
    474534        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        })); 
    489553        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        })); 
    510578        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        })); 
    525597        bottomButtons.add(buttonDash1 = makeButton("-", null)); 
    526598        bottomButtons.add(buttonDash2 = makeButton("-", null)); 
    527599        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                { 
    531606                    ScreenManager.theCoordinator.setCadDataUnitValue( 
    532607                            (String) unitStatusTable.getValueAt( 
    533                                     unitStatusTable.getSelectedRow(), 2), 
     608                            unitStatusTable.getSelectedRow(), 2), 
    534609                            UNIT_TAGS.STATUS, "10-8"); 
    535610                    ScreenManager.theCoordinator.setCadDataUnitValue( 
    536611                            (String) unitStatusTable.getValueAt( 
    537                                     unitStatusTable.getSelectedRow(), 2), 
     612                            unitStatusTable.getSelectedRow(), 2), 
    538613                            UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Assignable); 
    539                 } catch (RemoteException e) { 
     614                } catch (RemoteException e) 
     615                { 
    540616                    e.printStackTrace(); 
    541617                } 
     
    543619            } 
    544620        })); 
    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                { 
    548627                    ScreenManager.theCoordinator.setCadDataUnitValue( 
    549628                            (String) unitStatusTable.getValueAt( 
    550                                     unitStatusTable.getSelectedRow(), 2), 
     629                            unitStatusTable.getSelectedRow(), 2), 
    551630                            UNIT_TAGS.STATUS, "OFC"); 
    552631                    ScreenManager.theCoordinator.setCadDataUnitValue( 
    553632                            (String) unitStatusTable.getValueAt( 
    554                                     unitStatusTable.getSelectedRow(), 2), 
     633                            unitStatusTable.getSelectedRow(), 2), 
    555634                            UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Arrived); 
    556                 } catch (RemoteException e) { 
     635                } catch (RemoteException e) 
     636                { 
    557637                    e.printStackTrace(); 
    558638                } 
     
    560640            } 
    561641        })); 
    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                { 
    565648                    ScreenManager.theCoordinator.setCadDataUnitValue( 
    566649                            (String) unitStatusTable.getValueAt( 
    567                                     unitStatusTable.getSelectedRow(), 2), 
     650                            unitStatusTable.getSelectedRow(), 2), 
    568651                            UNIT_TAGS.STATUS, "OOS"); 
    569652                    ScreenManager.theCoordinator.setCadDataUnitValue( 
    570653                            (String) unitStatusTable.getValueAt( 
    571                                     unitStatusTable.getSelectedRow(), 2), 
     654                            unitStatusTable.getSelectedRow(), 2), 
    572655                            UNIT_TAGS.UNIT_STATUS, 
    573656                            UnitStatusEnums.NotAssignable); 
    574                 } catch (RemoteException e) { 
     657                } catch (RemoteException e) 
     658                { 
    575659                    e.printStackTrace(); 
    576660                } 
     
    582666    /* 
    583667     * Makes a JButton with an text and listener. 
    584      *  
     668     * 
    585669     * @param text the text to be displayed 
    586      *  
     670     * 
    587671     * @param listener the action listener for this button. 
    588      *  
     672     * 
    589673     * @return the JButton. 
    590674     */ 
    591     public JButton makeButton(String text, ActionListener listener) { 
     675    public JButton makeButton(String text, ActionListener listener) 
     676    { 
    592677        JButton button = new JButton(text); 
    593678        button.setBackground(Color.GRAY); 
     
    606691     * Sets the highlighted color(when the mouse is over it) of the JLabels. 
    607692     * Note: the color is not shown until .setOpaque(true) is called. 
    608      *  
     693     * 
    609694     * @param color the highlighted color 
    610695     */ 
    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        { 
    613700            dropDownLabels[i].setBackground(color); 
    614701        } 
     
    618705     * Sets the highlighted color(when the mouse is over it) of the JLabels. 
    619706     * Note: the color is not shown until .setOpaque(true) is called. 
    620      *  
     707     * 
    621708     * @param color the highlighted color 
    622709     */ 
    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        { 
    625714            dropDownWithAssignedIncLabels[i].setBackground(color); 
    626715        } 
     
    630719     * Sets all JLabels to not display a highlighted background 
    631720     */ 
    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        { 
    634725            dropDownLabels[i].setOpaque(false); 
    635726        } 
     
    639730     * Sets all JLabels to not display a highlighted background 
    640731     */ 
    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        { 
    643736            dropDownWithAssignedIncLabels[i].setOpaque(false); 
    644737        } 
     
    647740    /* 
    648741     * Sets the label to have a highlighted background. 
    649      *  
     742     * 
    650743     * @param label the label that is selected/highlighted 
    651744     */ 
    652     public void selectLabel(Object label) { 
     745    public void selectLabel(Object label) 
     746    { 
    653747        ((JLabel) label).setOpaque(true); 
    654748    } 
     
    657751     * Performs the label action depending on which label was clicked. 
    658752     */ 
    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 
    688796        } 
    689797    } 
     
    692800     * Performs the label action depending on which label was clicked. 
    693801     */ 
    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 
    712828            int idColumn = 0; 
    713829            ScreenManager.openIncidentViewer(Integer 
    714830                    .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... 
    756886        } 
    757887    } 
     
    763893     * designates. 
    764894     */ 
    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            { 
    771905                unSelectAllLabels(); 
    772906                selectLabel(e.getSource()); 
     
    775909            } 
    776910        }); 
    777         label.addMouseListener(new MouseListener() { 
    778             public void mouseClicked(MouseEvent e) { 
     911        label.addMouseListener(new MouseListener() 
     912        { 
     913            public void mouseClicked(MouseEvent e) 
     914            { 
    779915                performLabelAction(e.getSource()); 
    780916                unSelectAllLabels(); 
     
    784920            } 
    785921 
    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            { 
    796936            } 
    797937        }); 
     
    804944     * designates. 
    805945     */ 
    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            { 
    812956                unSelectAllLabels(); 
    813957                selectLabel(e.getSource()); 
     
    816960            } 
    817961        }); 
    818         label.addMouseListener(new MouseListener() { 
    819             public void mouseClicked(MouseEvent e) { 
     962        label.addMouseListener(new MouseListener() 
     963        { 
     964            public void mouseClicked(MouseEvent e) 
     965            { 
    820966                performWithAssignedIncLabelAction(e.getSource()); 
    821967                unSelectAllLabels(); 
     
    825971            } 
    826972 
    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            { 
    837987            } 
    838988        }); 
     
    842992     * Displays the menu where the right click occurred. 
    843993     */ 
    844     public void openDropDownMenu(MouseEvent e) { 
     994    public void openDropDownMenu(MouseEvent e) 
     995    { 
    845996        unitStatusMenu.setLocation(e.getX() + this.getX(), 
    846997                e.getY() + this.getY()); 
     
    8511002     * Displays the menu where the right click occurred. 
    8521003     */ 
    853     public void openDropDownWithAssignedIncMenu(MouseEvent e) { 
     1004    public void openDropDownWithAssignedIncMenu(MouseEvent e) 
     1005    { 
    8541006        unitStatusWithAssignedIncMenu.setLocation(e.getX() + this.getX(), 
    8551007                e.getY() + this.getY()); 
     
    8601012     * Hides the menu. 
    8611013     */ 
    862     public void closeDropDownMenu() { 
     1014    public void closeDropDownMenu() 
     1015    { 
    8631016        unSelectAllLabels(); 
    8641017        unitStatusMenu.revalidate(); 
     
    8701023     * Hides the menu. 
    8711024     */ 
    872     public void closeDropDownWithAssignedIncMenu() { 
     1025    public void closeDropDownWithAssignedIncMenu() 
     1026    { 
    8731027        unSelectAllLabels(); 
    8741028        unitStatusWithAssignedIncMenu.revalidate(); 
     
    8791033    /* 
    8801034     * 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) 
    8821036     * and applies them to the updated model it receives from the server. 
    8831037     */ 
    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            { 
    8871044                int index = unitStatusTable.getSelectedRow(); 
    8881045                List<? extends SortKey> keys = unitStatusTable.getRowSorter().getSortKeys(); 
    8891046                int[] columnWidths = new int[20]; 
    890                 for(int i = 0; i < unitStatusTable.getColumnCount(); i++){ 
     1047                for (int i = 0; i < unitStatusTable.getColumnCount(); i++) 
     1048                { 
    8911049                    columnWidths[i] = unitStatusTable.getColumnModel().getColumn(i).getWidth(); 
    8921050                } 
    893                  
     1051 
    8941052                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                { 
    8971056                    unitStatusTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidths[i]); 
    8981057                } 
    8991058                unitStatusTable.getRowSorter().setSortKeys(keys); 
    9001059                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        } 
    9071067    } 
    9081068 
     
    9101070     * Makes screen visible. 
    9111071     */ 
    912     public void open() { 
     1072    public void open() 
     1073    { 
    9131074        setVisible(true); 
    9141075    } 
     
    9171078     * Hides screen. 
    9181079     */ 
    919     public void close() { 
     1080    public void close() 
     1081    { 
    9201082        setVisible(false); 
    9211083    } 
     
    9231085    /** 
    9241086     * 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//    } 
    9431130    /** 
    9441131     * Removes drag and drop feature/button clicking. 
    9451132     */ 
    946     public void removeDispatcherAuthority() { 
     1133    public void removeDispatcherAuthority() 
     1134    { 
    9471135        unitStatusTable.setTransferHandler(new TransferHandler("")); 
    9481136        buttonEnrt.setEnabled(false); 
     
    9571145        buttonOOS.setEnabled(false); 
    9581146    } 
    959  
    9601147} 
Note: See TracChangeset for help on using the changeset viewer.