Ignore:
Timestamp:
08/23/2019 01:49:50 PM (7 years ago)
Author:
jdalbey
Message:

Coordinator.java, AssignedIncidents?.java, UnitStatus?.java, CADMenu.java: Add comments and error messages. Add revision number to CAD Menu.

File:
1 edited

Legend:

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

    r445 r475  
    122122                    return new JLabel("?"); 
    123123                } 
    124  
     124                // Assign a color to the auxiliary units column, labeled "Unit/s"     
    125125                comp.setForeground(Color.BLACK); 
    126126                comp.setBackground(Color.CYAN); 
    127127                if (assignedIncidentsTable.getModel().getColumnName(column).equals("Unit/s")) 
    128                 {//4 is the column for "Unit/s" 
     128                { 
    129129                    //System.out.println("Diagnostic: in AssignedIncidents.prepareRenderer()"); //Commenting this line breaks the client 
    130130                    comp.setBackground(Color.BLACK); 
     
    134134                        // get the unit name from the table   JD 
    135135                        String unitname = (String) assignedIncidentsTable.getValueAt(row, primaryColumn); 
    136                         // Validate that unitname isn't blank 
    137                         if (!unitname.equals("")) 
     136                        // Validate that unitname isn't blank ... I think the reason this happens intermittently 
     137                        // is a race condition in refreshTable() that resulted in blank unitname. 
     138                        if (unitname != null && unitname.length() > 0) 
    138139                        { 
    139140                            // Fetch the unit's current status from server 
     
    155156                            } 
    156157                        } 
     158                        else 
     159                        { 
     160                            System.out.println("Blank unitname found in AssignedIncidents prepareRenderer."); 
     161                        } 
    157162                    } catch (RemoteException e) 
    158163                    { 
    159                         e.printStackTrace(); 
     164                        System.out.println("RemoteException in AssignedIncidents prepareRenderer: "+ e.getMessage()); 
    160165                    } 
    161166                } 
     
    592597    public void refreshTable() 
    593598    { 
    594  
     599        //only update info if resize not in progress 
    595600        if (assignedIncidentsTable.getTableHeader().getResizingColumn() == null) 
    596         {//only update info if resize not in progress 
     601        { 
     602            // Note the odd comment in legacy code in prepare renderer: 
     603            // "//Commenting this line breaks the client" 
     604            // Maybe because the sout accidentally solves a concurrency problem, slowing down 
     605            // the prepare Renderer until the RMI call can complete. 
     606            int index = assignedIncidentsTable.getSelectedRow(); 
     607            int[] columnWidths = new int[20]; 
     608            List<? extends SortKey> keys = assignedIncidentsTable.getRowSorter().getSortKeys(); 
     609            for (int i = 0; i < assignedIncidentsTable.getColumnCount(); i++) 
     610            { 
     611                columnWidths[i] = assignedIncidentsTable.getColumnModel().getColumn(i).getWidth(); 
     612            } 
     613 
     614            // Update the model here 
    597615            try 
    598616            { 
    599                 int index = assignedIncidentsTable.getSelectedRow(); 
    600                 int[] columnWidths = new int[20]; 
    601                 List<? extends SortKey> keys = assignedIncidentsTable.getRowSorter().getSortKeys(); 
    602                 for (int i = 0; i < assignedIncidentsTable.getColumnCount(); i++) 
    603                 { 
    604                     columnWidths[i] = assignedIncidentsTable.getColumnModel().getColumn(i).getWidth(); 
    605                 } 
    606  
    607617                assignedIncidentsTable.setModel(ScreenManager.theCoordinator.getCadDataTable(CADDataEnums.TABLE.ASSIGNED_INCIDENTS)); 
    608  
    609                 for (int i = 0; i < assignedIncidentsTable.getColumnCount(); i++) 
    610                 { 
    611                     assignedIncidentsTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidths[i]); 
    612                 } 
    613                 assignedIncidentsTable.getRowSorter().setSortKeys(keys); 
    614                 assignedIncidentsTable.getSelectionModel().setSelectionInterval(index, index); 
    615618            } catch (RemoteException ex) 
    616619            { 
     
    618621                System.out.println(ex.getMessage()); 
    619622            } 
     623 
     624            for (int i = 0; i < assignedIncidentsTable.getColumnCount(); i++) 
     625            { 
     626                assignedIncidentsTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidths[i]); 
     627            } 
     628            assignedIncidentsTable.getRowSorter().setSortKeys(keys); 
     629            assignedIncidentsTable.getSelectionModel().setSelectionInterval(index, index); 
     630             
    620631            revalidate(); 
    621632            repaint(); 
Note: See TracChangeset for help on using the changeset viewer.