Changeset 475 in tmcsimulator


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.

Location:
trunk/src/tmcsim
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/application.properties

    r471 r475  
    1 #Mon, 29 Jul 2019 14:47:09 -0700 
     1#Wed, 21 Aug 2019 15:21:51 -0700 
    22 
    3 Application.revision=470 
     3Application.revision=473 
    44 
    5 Application.buildnumber=177 
     5Application.buildnumber=196 
  • trunk/src/tmcsim/cadsimulator/Coordinator.java

    r471 r475  
    144144     * Constructor. Call UnicastRemoteObject constructor and call 
    145145     * initializeSimulation. 
    146      * @param simTimeFilename name of the file where the simulation clock time is written 
    147      * @param commentLogname name of file where CADcommentLog is written 
     146     * @param simTimeFilename path to the file where the simulation clock time is written 
     147     * @param commentLogname path to the file where CADcommentLog is written 
    148148     * @throws RemoteException 
    149149     */ 
  • trunk/src/tmcsim/client/cadclientgui/data/CADData.java

    r310 r475  
    231231 
    232232    /** 
    233      * Sends all the objects for UnitStatus 
     233     * Accessor to the Unit Status table model  
    234234     * 
    235235     * @return DefaultTableModel for UnitStatus 
    236236     */ 
     237    synchronized 
    237238    public DefaultTableModel tableForUnitStatus() 
    238239    { 
    239         toUnitTableVector.clear(); 
    240         for (int i = 0; i < units.size(); i++) 
    241         { 
    242             toUnitTableVector.add(units.get(i).toVector()); 
     240        Vector<Object> toUnitTableVector = new Vector<Object>(); 
     241 
     242        // build a new unit table  
     243        for (Unit unit: units) 
     244        { 
     245            toUnitTableVector.add(unit.toVector()); 
    243246        } 
    244247        // Exception occurred here: http://pastebin.com/fvifM5i8 
     248        // Probably a distributed object concurrency problem. 
     249        // Assign the unit status table from the newly created vector 
    245250        unitStatusTableModel 
    246251                .setDataVector(toUnitTableVector, unitStatusHeaders); 
     252        // return a reference to the updated table 
    247253        return unitStatusTableModel; 
    248254    } 
    249  
    250255    /** 
    251256     * Sends all the objects for AssignedIncidents 
  • 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(); 
  • trunk/src/tmcsim/client/cadclientgui/screens/CADMenu.java

    r59 r475  
    2828import javax.swing.JFrame; 
    2929import javax.swing.JLabel; 
     30import tmcsim.common.RevisionNumber; 
    3031 
    3132/** 
     
    8081 
    8182        getContentPane().add(mainPanel); 
    82         setTitle("Inform CAD "); 
     83        setTitle("Inform CAD  ("+RevisionNumber.getAppVersion()+")"); 
    8384        // Load an image for the task bar icon --JD 
    8485        // First try to get the image from a local file 
  • trunk/src/tmcsim/client/cadclientgui/screens/UnitStatus.java

    r458 r475  
    165165                } 
    166166 
     167                // Set the cell colors depending on the unit's status 
    167168                int unitNumColumn = 2; 
    168169                try 
    169170                { 
    170                     switch (ScreenManager.theCoordinator 
    171                             .getCadDataUnitStatus((String) unitStatusTable 
    172                             .getValueAt(row, unitNumColumn))) 
     171                    String unitNum = (String) unitStatusTable.getValueAt(row, unitNumColumn); 
     172                     
     173                    UnitStatusEnums status = ScreenManager.theCoordinator 
     174                            .getCadDataUnitStatus(unitNum); 
     175                    switch (status) 
    173176                    { 
    174177                        case Assignable: 
     
    10881091                    unitStatusTable.getSelectionModel().setSelectionInterval(index, index); 
    10891092                }}); 
    1090  
     1093            // Perhaps these aren't needed since changing the model should cause auto repaint. 
    10911094            revalidate(); 
    10921095            repaint(); 
Note: See TracChangeset for help on using the changeset viewer.