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/AssignedIncidents.java

    r3 r59  
    44import java.awt.Component; 
    55import java.awt.Dimension; 
     6import java.awt.Point; 
    67import java.awt.Toolkit; 
    78import java.awt.datatransfer.DataFlavor; 
     
    1415import java.rmi.RemoteException; 
    1516import java.util.List; 
    16  
    1717import javax.swing.Box; 
    1818import javax.swing.BoxLayout; 
     
    2323import javax.swing.JTable; 
    2424import javax.swing.ListSelectionModel; 
     25import javax.swing.RowSorter.SortKey; 
    2526import javax.swing.SwingUtilities; 
    2627import javax.swing.TransferHandler; 
    27 import javax.swing.RowSorter.SortKey; 
    2828import javax.swing.table.DefaultTableModel; 
    2929import javax.swing.table.TableCellRenderer; 
    30  
    3130import tmcsim.client.cadclientgui.enums.CADDataEnums; 
    3231import tmcsim.client.cadclientgui.enums.CADScriptTags.UNIT_TAGS; 
     
    3635 
    3736/** 
    38  * This class contains the view and controller for the AssignedIncidents screen. The view was not built using a GUI builder plug-in 
    39  * (but may want to consider doing so in the future), and the controller uses listeners to control how the view and data act.  
    40  *  
     37 * This class contains the view and controller for the AssignedIncidents screen. 
     38 * The view was not built using a GUI builder plug-in (but may want to consider 
     39 * doing so in the future), and the controller uses listeners to control how the 
     40 * view and data act. 
     41 * 
    4142 * @author Vincent 
    4243 */ 
    43  
    44 public class AssignedIncidents extends JFrame { 
    45  
     44public class AssignedIncidents extends JFrame 
     45{ 
    4646    private final String SCREEN_TITLE = "(Shift + F3)  Assigned Incidents"; 
    47  
    4847    private final Dimension SCREEN_DIMENSIONS = new Dimension(1400, 250); 
    49  
    5048    private final Dimension DROP_DOWN_MENU_LABEL_DIMENSIONS = new Dimension( 
    5149            170, 20); 
    52  
    5350    private final Dimension DROP_DOWN_MENU_DIMENSIONS = new Dimension(170, 230); 
    54  
    5551    private final int COLUMN_WIDTH = 120; 
    56  
    57     private final String[] LABELS = { "Add Resources...", "Greater Alarm...", 
    58             "Reconfigure", "Open", "Recall Incident", "Cancel", "Reassign", 
    59             "Link/Append", "Map", "Recall Linked Incidents", "Read Notes", 
    60             "Page...", "Mail...", "Fax..." }; 
    61  
     52    private final String[] LABELS = 
     53    { 
     54        "Add Resources...", "Greater Alarm...", 
     55        "Reconfigure", "Open", "Recall Incident", "Cancel", "Reassign", 
     56        "Link/Append", "Map", "Recall Linked Incidents", "Read Notes", 
     57        "Page...", "Mail...", "Fax..." 
     58    }; 
    6259    private final String LABEL_SPACING = "     "; 
    63  
    6460    private JTable assignedIncidentsTable; 
    6561    private JFrame assignedIncidentsMenu; 
    66  
    6762    // labels for the drop down menu 
    6863    private JLabel[] dropDownLabels = new JLabel[LABELS.length]; 
    69  
    7064    private long lastLeftClick;// used for double clicking feature 
    7165 
    72     public AssignedIncidents() { 
     66    public AssignedIncidents() 
     67    { 
    7368        initComponents(); 
    7469    } 
    7570 
    76     private void initComponents() { 
     71    private void initComponents() 
     72    { 
    7773        initializeTable(); 
    7874        initController(); 
     
    9894     * drop feature. 
    9995     */ 
    100     private void initializeTable() { 
    101         assignedIncidentsTable = new JTable(){ 
     96    private void initializeTable() 
     97    { 
     98        assignedIncidentsTable = new JTable() 
     99        { 
    102100            /* 
    103101             * Custom renderer to set different background/foreground colors 
    104102             * @see javax.swing.JTable#prepareRenderer(javax.swing.table.TableCellRenderer, int, int) 
    105103             */ 
    106             public Component prepareRenderer(TableCellRenderer renderer, int row, int column){ 
     104            public Component prepareRenderer(TableCellRenderer renderer, int row, int column) 
     105            { 
    107106                Component comp = super.prepareRenderer(renderer, row, column); 
    108                  
     107 
    109108                comp.setForeground(Color.BLACK); 
    110109                comp.setBackground(Color.CYAN); 
    111                 if(assignedIncidentsTable.getModel().getColumnName(column).equals("Unit/s")){//4 is the column for "Unit/s" 
    112                   System.out.println("Commenting this line breaks the client"); 
     110                if (assignedIncidentsTable.getModel().getColumnName(column).equals("Unit/s")) 
     111                {//4 is the column for "Unit/s" 
     112                    //System.out.println("Diagnostic: in AssignedIncidents.prepareRenderer()"); //Commenting this line breaks the client 
    113113                    comp.setBackground(Color.BLACK); 
    114114                    int primaryColumn = 3; 
    115                     try { 
    116                         switch(ScreenManager.theCoordinator.getCadDataUnitStatus( 
    117                                (String) assignedIncidentsTable.getValueAt(row,primaryColumn))){ 
    118                             case Assignable: 
    119                                 comp.setForeground(Color.GREEN); 
    120                                 break; 
    121                             case Arrived: 
    122                                 comp.setForeground(Color.YELLOW); 
    123                                 break; 
    124                             case Enroute: 
    125                                 comp.setForeground(Color.CYAN); 
    126                                 break; 
    127                         }  
    128                     }catch (RemoteException e){ 
    129                       e.printStackTrace(); 
     115                    try 
     116                    { 
     117                        // get the unit name from the table   JD 
     118                        String unitname = (String) assignedIncidentsTable.getValueAt(row, primaryColumn); 
     119                        // Validate that unitname isn't blank 
     120                        if (!unitname.equals("")) 
     121                        { 
     122                            // Fetch the unit's current status from server 
     123                            UnitStatusEnums ustatus =  ScreenManager.theCoordinator.getCadDataUnitStatus(unitname); 
     124                            // Decide which color to use for displaying the status 
     125                            switch (ustatus) 
     126                            { 
     127                                case Assignable: 
     128                                    comp.setForeground(Color.GREEN); 
     129                                    break; 
     130                                case Arrived: 
     131                                    comp.setForeground(Color.YELLOW); 
     132                                    break; 
     133                                case Enroute: 
     134                                    comp.setForeground(Color.CYAN); 
     135                                    break; 
     136                            } 
     137                        } 
     138                    } catch (RemoteException e) 
     139                    { 
     140                        e.printStackTrace(); 
    130141                    } 
    131142                } 
    132                  
    133                 if (getSelectedRow() == row){ 
     143 
     144                if (getSelectedRow() == row) 
     145                { 
    134146                    comp.setForeground(Color.WHITE); 
    135147                    comp.setBackground(Color.BLUE); 
    136148                } 
    137                  
     149 
    138150                return comp; 
    139151            } 
    140              
    141             public Class getColumnClass(int c) { 
     152 
     153            public Class getColumnClass(int c) 
     154            { 
    142155                return getValueAt(0, c).getClass(); 
    143156            } 
    144              
    145157        }; 
    146          
     158 
    147159        assignedIncidentsTable.setOpaque(true); 
    148160        assignedIncidentsTable.setIntercellSpacing(new Dimension(1, 0)); 
     
    153165        assignedIncidentsTable.setAutoCreateRowSorter(true); 
    154166        assignedIncidentsTable.setModel(new DefaultTableModel()); 
    155          
     167 
    156168        ((DefaultTableModel) assignedIncidentsTable.getModel()).setColumnIdentifiers(TableHeaders.ASSIGNED_INCIDENTS_HEADERS); 
    157          
    158         assignedIncidentsTable.setTransferHandler(new TransferHandler(){ 
    159              
    160             public boolean canImport(TransferHandler.TransferSupport info) { 
     169 
     170        assignedIncidentsTable.setTransferHandler(new TransferHandler() 
     171        { 
     172            public boolean canImport(TransferHandler.TransferSupport info) 
     173            { 
    161174                // Check for String flavor 
    162                 if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) { 
     175                if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) 
     176                { 
    163177                    return false; 
    164178                } 
    165179                return true; 
    166            } 
    167              
    168             public boolean importData(TransferHandler.TransferSupport info) { 
    169                 if (!info.isDrop()) { 
     180            } 
     181 
     182            public boolean importData(TransferHandler.TransferSupport info) 
     183            { 
     184                if (!info.isDrop()) 
     185                { 
    170186                    return false; 
    171187                } 
    172           
    173                 DefaultTableModel tableModel = (DefaultTableModel)assignedIncidentsTable.getModel(); 
    174                 JTable.DropLocation dl = (JTable.DropLocation)info.getDropLocation(); 
     188 
     189                DefaultTableModel tableModel = (DefaultTableModel) assignedIncidentsTable.getModel(); 
     190                JTable.DropLocation dl = (JTable.DropLocation) info.getDropLocation(); 
    175191                int index = dl.getRow(); 
    176           
     192 
    177193                // Get the string that is being dropped. 
    178194                Transferable t = info.getTransferable(); 
    179195                String data; 
    180                 try { 
    181                     data = (String)t.getTransferData(DataFlavor.stringFlavor); 
    182                 } 
    183                 catch (Exception e) { return false; } 
    184                                           
     196                try 
     197                { 
     198                    data = (String) t.getTransferData(DataFlavor.stringFlavor); 
     199                } catch (Exception e) 
     200                { 
     201                    return false; 
     202                } 
     203 
    185204                // Perform the actual import 
    186                 int incidentId = (Integer)assignedIncidentsTable.getValueAt(dl.getRow(), 0); 
    187                 try { 
    188                         ScreenManager.theCoordinator.setCadDataUnitAssignedId(data, incidentId); 
    189                         ScreenManager.theCoordinator.setCadDataUnitValue(data, 
    190                       UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Arrived); 
    191                      ScreenManager.theCoordinator.addCadDataIncidentAssignedUnitNum(incidentId, data); 
    192                      ScreenManager.theCoordinator.setCadDataIncidentStatus(incidentId, IncidentEnums.Assigned); 
    193                      } catch (RemoteException e) { 
    194                         e.printStackTrace(); 
    195                      } 
     205                int incidentId = (Integer) assignedIncidentsTable.getValueAt(dl.getRow(), 0); 
     206                try 
     207                { 
     208                    ScreenManager.theCoordinator.setCadDataUnitAssignedId(data, incidentId); 
     209                    ScreenManager.theCoordinator.setCadDataUnitValue(data, 
     210                            UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Arrived); 
     211                    ScreenManager.theCoordinator.addCadDataIncidentAssignedUnitNum(incidentId, data); 
     212                    ScreenManager.theCoordinator.setCadDataIncidentStatus(incidentId, IncidentEnums.Assigned); 
     213                } catch (RemoteException e) 
     214                { 
     215                    e.printStackTrace(); 
     216                } 
    196217                ScreenManager.refreshScreens(); 
    197218                return true; 
    198219            } 
    199220        }); 
    200          
    201         for(int i = 0; i < assignedIncidentsTable.getColumnCount(); i++){ 
     221 
     222        for (int i = 0; i < assignedIncidentsTable.getColumnCount(); i++) 
     223        { 
    202224            assignedIncidentsTable.getColumnModel().getColumn(i).setPreferredWidth(120); 
    203225        } 
    204226    } 
    205      
     227 
    206228    /* 
    207229     * Adds the key and mouse listeners for the table and component listener for 
    208230     * screen. 
    209231     */ 
    210     private void initController() { 
    211         assignedIncidentsTable.addMouseListener(new MouseListener() { 
    212             public void mouseClicked(MouseEvent e) { 
    213                 if (SwingUtilities.isLeftMouseButton(e)) { 
    214                     if (System.currentTimeMillis() - lastLeftClick < 1000) { 
     232    private void initController() 
     233    { 
     234        assignedIncidentsTable.addMouseListener(new MouseListener() 
     235        { 
     236            public void mouseClicked(MouseEvent e) 
     237            { 
     238                if (SwingUtilities.isLeftMouseButton(e)) 
     239                { 
     240                    // TODO:  Use e.getClickCount() == 2 
     241                    if (System.currentTimeMillis() - lastLeftClick < 1000) 
     242                    { 
    215243                        int idColumn = 0; 
    216                         ScreenManager 
    217                                 .openIncidentViewer((Integer) assignedIncidentsTable 
    218                                         .getValueAt(assignedIncidentsTable 
    219                                                 .getSelectedRow(), idColumn)); 
    220                     } else { 
     244                        int selectedRow = assignedIncidentsTable.getSelectedRow(); 
     245                        try 
     246                        { 
     247                            int selectedValue = (Integer) assignedIncidentsTable.getValueAt(selectedRow, idColumn); 
     248                            ScreenManager.openIncidentViewer(selectedValue); 
     249                        } catch (IndexOutOfBoundsException ex) 
     250                        { 
     251                            ex.printStackTrace(); 
     252                        } 
     253                    } 
     254                    else 
     255                    { 
    221256                        lastLeftClick = System.currentTimeMillis(); 
    222257                    } 
    223258                } 
    224                 if (SwingUtilities.isRightMouseButton(e)) { 
     259                if (SwingUtilities.isRightMouseButton(e)) 
     260                { 
     261                    // Fixed to force right click to cause the row to be selected. JD 
     262                    // get the coordinates of the mouse click 
     263                    Point p = e.getPoint(); 
     264                    // get the row index that contains that coordinate 
     265                    int rowNumber = assignedIncidentsTable.rowAtPoint(p); 
     266                    // Get the ListSelectionModel of the JTable 
     267                    ListSelectionModel model = assignedIncidentsTable.getSelectionModel(); 
     268                    // set the selected interval of rows. Using the "rowNumber" 
     269                    // variable for the beginning and end selects only that one row. 
     270                    model.setSelectionInterval(rowNumber, rowNumber); 
     271                    // go open the drop down menu 
    225272                    openDropDownMenu(e); 
    226                 } else { 
     273                } 
     274                else 
     275                { 
    227276                    closeDropDownMenu(); 
    228277                } 
    229278            } 
    230279 
    231             public void mouseEntered(MouseEvent e) { 
    232             } 
    233  
    234             public void mouseExited(MouseEvent e) { 
    235             } 
    236  
    237             public void mousePressed(MouseEvent e) { 
    238             } 
    239  
    240             public void mouseReleased(MouseEvent e) { 
     280            public void mouseEntered(MouseEvent e) 
     281            { 
     282            } 
     283 
     284            public void mouseExited(MouseEvent e) 
     285            { 
     286            } 
     287 
     288            public void mousePressed(MouseEvent e) 
     289            { 
     290            } 
     291 
     292            public void mouseReleased(MouseEvent e) 
     293            { 
    241294            } 
    242295        }); 
    243296 
    244         addComponentListener(new ComponentListener() { 
    245             public void componentHidden(ComponentEvent e) { 
    246             } 
    247  
    248             public void componentMoved(ComponentEvent e) { 
     297        addComponentListener(new ComponentListener() 
     298        { 
     299            public void componentHidden(ComponentEvent e) 
     300            { 
     301            } 
     302 
     303            public void componentMoved(ComponentEvent e) 
     304            { 
    249305                closeDropDownMenu(); 
    250306            } 
    251307 
    252             public void componentResized(ComponentEvent e) { 
    253             } 
    254  
    255             public void componentShown(ComponentEvent e) { 
     308            public void componentResized(ComponentEvent e) 
     309            { 
     310            } 
     311 
     312            public void componentShown(ComponentEvent e) 
     313            { 
    256314            } 
    257315        }); 
     
    262320     * on the table. 
    263321     */ 
    264     private void initializeDropDownMenu() { 
     322    private void initializeDropDownMenu() 
     323    { 
    265324        Box menu = new Box(BoxLayout.Y_AXIS); 
    266325        initializeDropDownLabels(); 
     
    282341     * Sets the text and size and adds a listener to each activated label. 
    283342     */ 
    284     private void initializeDropDownLabels() { 
    285         for (int i = 0; i < dropDownLabels.length; i++) { 
     343    private void initializeDropDownLabels() 
     344    { 
     345        for (int i = 0; i < dropDownLabels.length; i++) 
     346        { 
    286347            dropDownLabels[i] = new JLabel(LABEL_SPACING + LABELS[i]); 
    287348            dropDownLabels[i].setMaximumSize(DROP_DOWN_MENU_LABEL_DIMENSIONS); 
     
    298359     * between. 
    299360     */ 
    300     private void addLabelsToBox(Box menu) { 
     361    private void addLabelsToBox(Box menu) 
     362    { 
    301363        menu.add(dropDownLabels[0]); 
    302364        menu.add(dropDownLabels[1]); 
     
    335397     * Sets the highlighted color(when the mouse is over it) of the JLabels. 
    336398     * Note: the color is not shown until .setOpaque(true) is called. 
    337      *  
     399     * 
    338400     * @param color the highlighted color 
    339401     */ 
    340     public void setMenuHighlightedBackground(Color color) { 
    341         for (int i = 0; i < dropDownLabels.length; i++) { 
     402    public void setMenuHighlightedBackground(Color color) 
     403    { 
     404        for (int i = 0; i < dropDownLabels.length; i++) 
     405        { 
    342406            dropDownLabels[i].setBackground(color); 
    343407        } 
     
    347411     * Sets all JLabels to not display a highlighted background 
    348412     */ 
    349     public void unSelectAllLabels() { 
    350         for (int i = 0; i < dropDownLabels.length; i++) { 
     413    public void unSelectAllLabels() 
     414    { 
     415        for (int i = 0; i < dropDownLabels.length; i++) 
     416        { 
    351417            dropDownLabels[i].setOpaque(false); 
    352418        } 
     
    355421    /* 
    356422     * Sets the label to have a highlighted background. 
    357      *  
     423     * 
    358424     * @param label the label that is selected/highlighted 
    359425     */ 
    360     public void selectLabel(Object label) { 
     426    public void selectLabel(Object label) 
     427    { 
    361428        ((JLabel) label).setOpaque(true); 
    362429    } 
     
    365432     * Performs the label action depending on which label was clicked. 
    366433     */ 
    367     public void performLabelAction(Object label) { 
    368         if (label.equals(dropDownLabels[0])) {// Add Resources 
    369  
    370         } else if (label.equals(dropDownLabels[1])) {// Greater Alarm 
    371  
    372         } else if (label.equals(dropDownLabels[2])) {// Reconfigure 
    373  
    374         } else if (label.equals(dropDownLabels[3])) {// Open 
     434    public void performLabelAction(Object label) 
     435    { 
     436        if (label.equals(dropDownLabels[0])) 
     437        {// Add Resources 
     438        } 
     439        else if (label.equals(dropDownLabels[1])) 
     440        {// Greater Alarm 
     441        } 
     442        else if (label.equals(dropDownLabels[2])) 
     443        {// Reconfigure 
     444        } 
     445        else if (label.equals(dropDownLabels[3])) 
     446        {// Open 
     447            int idColumn = 0; 
     448            int selectedRow = assignedIncidentsTable.getSelectedRow(); 
     449            try 
     450            { 
     451                int selectedValue = (Integer) assignedIncidentsTable.getValueAt(selectedRow, idColumn); 
     452                ScreenManager.openIncidentViewer(selectedValue); 
     453            } catch (IndexOutOfBoundsException ex) 
     454            { 
     455                ex.printStackTrace(); 
     456            } 
     457        } 
     458        else if (label.equals(dropDownLabels[4])) 
     459        {// Recall Incident 
     460        } 
     461        else if (label.equals(dropDownLabels[5])) 
     462        {// Cancel 
     463        } 
     464        else if (label.equals(dropDownLabels[6])) 
     465        {// Reassign 
     466        } 
     467        else if (label.equals(dropDownLabels[7])) 
     468        {// Link append 
     469        } 
     470        else if (label.equals(dropDownLabels[8])) 
     471        {// Map 
     472        } 
     473        else if (label.equals(dropDownLabels[9])) 
     474        {// Recall Linked Incidents 
     475        } 
     476        else if (label.equals(dropDownLabels[10])) 
     477        {// Read Notes 
    375478            int idColumn = 0; 
    376479            ScreenManager.openIncidentViewer((Integer) assignedIncidentsTable 
    377480                    .getValueAt(assignedIncidentsTable.getSelectedRow(), 
    378                             idColumn)); 
    379         } else if (label.equals(dropDownLabels[4])) {// Recall Incident 
    380  
    381         } else if (label.equals(dropDownLabels[5])) {// Cancel 
    382  
    383         } else if (label.equals(dropDownLabels[6])) {// Reassign 
    384  
    385         } else if (label.equals(dropDownLabels[7])) {// Link append 
    386  
    387         } else if (label.equals(dropDownLabels[8])) {// Map 
    388  
    389         } else if (label.equals(dropDownLabels[9])) {// Recall Linked Incidents 
    390  
    391         } else if (label.equals(dropDownLabels[10])) {// Read Notes 
    392             int idColumn = 0; 
    393             ScreenManager.openIncidentViewer((Integer) assignedIncidentsTable 
    394                     .getValueAt(assignedIncidentsTable.getSelectedRow(), 
    395                             idColumn)); 
    396         } else if (label.equals(dropDownLabels[11])) {// Page 
    397  
    398         } else if (label.equals(dropDownLabels[12])) {// Mail 
    399  
    400         } else if (label.equals(dropDownLabels[13])) {// Fax 
    401  
     481                    idColumn)); 
     482        } 
     483        else if (label.equals(dropDownLabels[11])) 
     484        {// Page 
     485        } 
     486        else if (label.equals(dropDownLabels[12])) 
     487        {// Mail 
     488        } 
     489        else if (label.equals(dropDownLabels[13])) 
     490        {// Fax 
    402491        } 
    403492    } 
     
    409498     * designates. 
    410499     */ 
    411     public void addMouseListenersToLabel(JLabel label) { 
    412         label.addMouseMotionListener(new MouseMotionListener() { 
    413             public void mouseDragged(MouseEvent e) { 
    414             } 
    415  
    416             public void mouseMoved(MouseEvent e) { 
     500    public void addMouseListenersToLabel(JLabel label) 
     501    { 
     502        label.addMouseMotionListener(new MouseMotionListener() 
     503        { 
     504            public void mouseDragged(MouseEvent e) 
     505            { 
     506            } 
     507 
     508            public void mouseMoved(MouseEvent e) 
     509            { 
    417510                unSelectAllLabels(); 
    418511                selectLabel(e.getSource()); 
     
    421514            } 
    422515        }); 
    423         label.addMouseListener(new MouseListener() { 
    424             public void mouseClicked(MouseEvent e) { 
     516        label.addMouseListener(new MouseListener() 
     517        { 
     518            public void mouseClicked(MouseEvent e) 
     519            { 
    425520                performLabelAction(e.getSource()); 
    426521                unSelectAllLabels(); 
     
    430525            } 
    431526 
    432             public void mouseEntered(MouseEvent e) { 
    433             } 
    434  
    435             public void mouseExited(MouseEvent e) { 
    436             } 
    437  
    438             public void mousePressed(MouseEvent e) { 
    439             } 
    440  
    441             public void mouseReleased(MouseEvent e) { 
     527            public void mouseEntered(MouseEvent e) 
     528            { 
     529            } 
     530 
     531            public void mouseExited(MouseEvent e) 
     532            { 
     533            } 
     534 
     535            public void mousePressed(MouseEvent e) 
     536            { 
     537            } 
     538 
     539            public void mouseReleased(MouseEvent e) 
     540            { 
    442541            } 
    443542        }); 
     
    447546     * Displays the menu where the right click occurred. 
    448547     */ 
    449     public void openDropDownMenu(MouseEvent e) { 
     548    public void openDropDownMenu(MouseEvent e) 
     549    { 
    450550        assignedIncidentsMenu.setLocation(e.getX() + this.getX(), e.getY() 
    451551                + this.getY()); 
     
    456556     * Hides the menu. 
    457557     */ 
    458     public void closeDropDownMenu() { 
     558    public void closeDropDownMenu() 
     559    { 
    459560        unSelectAllLabels(); 
    460561        assignedIncidentsMenu.revalidate(); 
     
    465566    /* 
    466567     * Refreshes the data in the table by updating all data and repainting the 
    467      * screen. It saves user preferences(like column sizes, selected row, sorted preferences)  
     568     * screen. It saves user preferences(like column sizes, selected row, sorted preferences) 
    468569     * and applies them to the updated model it receives from the server. 
    469570     */ 
    470     public void refreshTable() { 
    471          
    472         if(assignedIncidentsTable.getTableHeader().getResizingColumn() == null){//only update info if resize not in progress 
    473               try { 
     571    public void refreshTable() 
     572    { 
     573 
     574        if (assignedIncidentsTable.getTableHeader().getResizingColumn() == null) 
     575        {//only update info if resize not in progress 
     576            try 
     577            { 
    474578                int index = assignedIncidentsTable.getSelectedRow(); 
    475579                int[] columnWidths = new int[20]; 
    476580                List<? extends SortKey> keys = assignedIncidentsTable.getRowSorter().getSortKeys(); 
    477                 for(int i = 0; i < assignedIncidentsTable.getColumnCount(); i++){ 
     581                for (int i = 0; i < assignedIncidentsTable.getColumnCount(); i++) 
     582                { 
    478583                    columnWidths[i] = assignedIncidentsTable.getColumnModel().getColumn(i).getWidth(); 
    479584                } 
    480                  
     585 
    481586                assignedIncidentsTable.setModel(ScreenManager.theCoordinator.getCadDataTable(CADDataEnums.TABLE.ASSIGNED_INCIDENTS)); 
    482                  
    483                 for(int i = 0; i < assignedIncidentsTable.getColumnCount(); i++){ 
     587 
     588                for (int i = 0; i < assignedIncidentsTable.getColumnCount(); i++) 
     589                { 
    484590                    assignedIncidentsTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidths[i]); 
    485591                } 
    486592                assignedIncidentsTable.getRowSorter().setSortKeys(keys); 
    487593                assignedIncidentsTable.getSelectionModel().setSelectionInterval(index, index); 
    488                 } catch (RemoteException e) { 
    489                     e.printStackTrace(); 
    490                 } 
    491                 revalidate(); 
    492                 repaint(); 
    493           } 
     594            } catch (RemoteException e) 
     595            { 
     596                e.printStackTrace(); 
     597            } 
     598            revalidate(); 
     599            repaint(); 
     600        } 
    494601    } 
    495602 
     
    497604     * Makes screen visible. 
    498605     */ 
    499     public void open() { 
     606    public void open() 
     607    { 
    500608        setVisible(true); 
    501609    } 
     
    504612     * Hides screen. 
    505613     */ 
    506     public void close() { 
     614    public void close() 
     615    { 
    507616        setVisible(false); 
    508617    } 
    509  
    510618} 
Note: See TracChangeset for help on using the changeset viewer.