Changeset 475 in tmcsimulator for trunk/src/tmcsim/client/cadclientgui/screens/AssignedIncidents.java
- Timestamp:
- 08/23/2019 01:49:50 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/client/cadclientgui/screens/AssignedIncidents.java
r445 r475 122 122 return new JLabel("?"); 123 123 } 124 124 // Assign a color to the auxiliary units column, labeled "Unit/s" 125 125 comp.setForeground(Color.BLACK); 126 126 comp.setBackground(Color.CYAN); 127 127 if (assignedIncidentsTable.getModel().getColumnName(column).equals("Unit/s")) 128 { //4 is the column for "Unit/s"128 { 129 129 //System.out.println("Diagnostic: in AssignedIncidents.prepareRenderer()"); //Commenting this line breaks the client 130 130 comp.setBackground(Color.BLACK); … … 134 134 // get the unit name from the table JD 135 135 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) 138 139 { 139 140 // Fetch the unit's current status from server … … 155 156 } 156 157 } 158 else 159 { 160 System.out.println("Blank unitname found in AssignedIncidents prepareRenderer."); 161 } 157 162 } catch (RemoteException e) 158 163 { 159 e.printStackTrace();164 System.out.println("RemoteException in AssignedIncidents prepareRenderer: "+ e.getMessage()); 160 165 } 161 166 } … … 592 597 public void refreshTable() 593 598 { 594 599 //only update info if resize not in progress 595 600 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 597 615 try 598 616 { 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 607 617 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);615 618 } catch (RemoteException ex) 616 619 { … … 618 621 System.out.println(ex.getMessage()); 619 622 } 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 620 631 revalidate(); 621 632 repaint();
Note: See TracChangeset
for help on using the changeset viewer.
