Changeset 59 in tmcsimulator for trunk/src/tmcsim/client/cadclientgui/screens/PendingIncidents.java
- Timestamp:
- 03/15/2017 10:20:21 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/client/cadclientgui/screens/PendingIncidents.java
r3 r59 4 4 import java.awt.Component; 5 5 import java.awt.Dimension; 6 import java.awt.Point; 6 7 import java.awt.Toolkit; 7 8 import java.awt.datatransfer.DataFlavor; … … 14 15 import java.rmi.RemoteException; 15 16 import java.util.List; 16 17 17 import javax.swing.Box; 18 18 import javax.swing.BoxLayout; … … 23 23 import javax.swing.JTable; 24 24 import javax.swing.ListSelectionModel; 25 import javax.swing.RowSorter.SortKey; 25 26 import javax.swing.SwingUtilities; 26 27 import javax.swing.TransferHandler; 27 import javax.swing.RowSorter.SortKey;28 28 import javax.swing.table.DefaultTableModel; 29 29 import javax.swing.table.TableCellRenderer; 30 31 30 import tmcsim.client.cadclientgui.enums.CADDataEnums; 31 import tmcsim.client.cadclientgui.enums.CADDataEnums.INC_VAL; 32 import tmcsim.client.cadclientgui.enums.CADScriptTags.UNIT_TAGS; 32 33 import tmcsim.client.cadclientgui.enums.IncidentEnums; 33 34 import tmcsim.client.cadclientgui.enums.TableHeaders; 34 35 import tmcsim.client.cadclientgui.enums.UnitStatusEnums; 35 import tmcsim.client.cadclientgui.enums.CADDataEnums.INC_VAL;36 import tmcsim.client.cadclientgui.enums.CADScriptTags.UNIT_TAGS;37 36 38 37 /** 39 * This class contains the view and controller for the PendingIncidents screen. The view was not built using a GUI builder plug-in 40 * (but may want to consider doing so in the future), and the controller uses listeners to control how the view and data act. 41 * 38 * This class contains the view and controller for the PendingIncidents screen. 39 * The view was not built using a GUI builder plug-in (but may want to consider 40 * doing so in the future), and the controller uses listeners to control how the 41 * view and data act. 42 * 42 43 * @author Vincent 43 44 */ 44 45 public class PendingIncidents extends JFrame { 46 45 public class PendingIncidents extends JFrame 46 { 47 47 private final String SCREEN_TITLE = "(Shift + F2) Pending Incidents"; 48 49 private final Dimension SCREEN_DIMENSIONS = new Dimension(1400,250); 50 51 private final Dimension DROP_DOWN_MENU_LABEL_DIMENSIONS = new Dimension(170,20); 52 53 private final Dimension DROP_DOWN_MENU_DIMENSIONS = new Dimension(170,180); 54 48 private final Dimension SCREEN_DIMENSIONS = new Dimension(1400, 250); 49 private final Dimension DROP_DOWN_MENU_LABEL_DIMENSIONS = new Dimension(170, 20); 50 private final Dimension DROP_DOWN_MENU_DIMENSIONS = new Dimension(170, 180); 55 51 private final int COLUMN_WIDTH = 120; 56 57 private final String[] LABELS = {"Recommend...", "Add Resources...", "Open", "Recall Incident", 58 "Cancel", "Link/Append", "Map", "Recall Linked Incidents", "Read Notes", "Mail...", "Fax..."}; 59 52 private final String[] LABELS = 53 { 54 "Recommend...", "Add Resources...", "Open", "Recall Incident", 55 "Cancel", "Link/Append", "Map", "Recall Linked Incidents", "Read Notes", "Mail...", "Fax..." 56 }; 60 57 private final String LABEL_SPACING = " "; 61 62 58 private JTable pendingIncidentsTable; 63 59 private JFrame pendingIncidentsMenu; 64 65 60 //labels for the drop down menu 66 61 private JLabel[] dropDownLabels = new JLabel[LABELS.length]; 67 68 62 private long lastLeftClick;//used for double clicking feature 69 70 public PendingIncidents(){ 63 64 public PendingIncidents() 65 { 71 66 initComponents(); 72 67 } 73 74 private void initComponents() { 68 69 private void initComponents() 70 { 75 71 initializeTable(); 76 72 initControllers(); 77 73 initializeDropDownMenu(); 78 79 JScrollPane scrollpane = new JScrollPane(pendingIncidentsTable );74 75 JScrollPane scrollpane = new JScrollPane(pendingIncidentsTable); 80 76 scrollpane.getViewport().setBackground(Color.WHITE); 81 77 82 78 setTitle(SCREEN_TITLE); 83 79 setPreferredSize(SCREEN_DIMENSIONS); … … 86 82 pack(); 87 83 Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); 88 setLocation(0, (int) (dim.getHeight() *3/4));84 setLocation(0, (int) (dim.getHeight() * 3 / 4)); 89 85 setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); 90 setVisible(false); 91 } 92 86 setVisible(false); 87 } 88 93 89 /* 94 90 * Initializes the table and prepares the cell renderer for color management. It initializes the default settings 95 91 * and handles the drag and drop feature. 96 92 */ 97 private void initializeTable(){ 98 pendingIncidentsTable = new JTable(){ 93 private void initializeTable() 94 { 95 pendingIncidentsTable = new JTable() 96 { 99 97 /* 100 98 * Custom renderer to set different background/foreground colors 101 99 * @see javax.swing.JTable#prepareRenderer(javax.swing.table.TableCellRenderer, int, int) 102 100 */ 103 public Component prepareRenderer(TableCellRenderer renderer, int row, int column){ 101 public Component prepareRenderer(TableCellRenderer renderer, int row, int column) 102 { 104 103 Component comp = super.prepareRenderer(renderer, row, column); 105 104 106 105 comp.setForeground(Color.BLACK); 107 106 comp.setBackground(Color.CYAN); 108 109 if (getSelectedRow() == row){ 107 108 if (getSelectedRow() == row) 109 { 110 110 comp.setForeground(Color.WHITE); 111 111 comp.setBackground(Color.BLUE); 112 112 } 113 113 114 114 return comp; 115 115 } 116 117 public Class getColumnClass(int c) { 116 117 public Class getColumnClass(int c) 118 { 118 119 return getValueAt(0, c).getClass(); 119 120 } 120 121 }; 121 122 122 123 pendingIncidentsTable.setOpaque(true); 123 124 pendingIncidentsTable.setIntercellSpacing(new Dimension(1, 0)); … … 127 128 pendingIncidentsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 128 129 pendingIncidentsTable.setAutoCreateRowSorter(true); 129 130 130 131 pendingIncidentsTable.setModel(new DefaultTableModel()); 131 132 ((DefaultTableModel) pendingIncidentsTable.getModel()).setColumnIdentifiers(TableHeaders.PENDING_INCIDENTS_HEADERS); 132 133 pendingIncidentsTable.setTransferHandler(new TransferHandler(){ 134 135 public boolean canImport(TransferHandler.TransferSupport info) { 133 134 pendingIncidentsTable.setTransferHandler(new TransferHandler() 135 { 136 public boolean canImport(TransferHandler.TransferSupport info) 137 { 136 138 // Check for String flavor 137 if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) { 139 if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) 140 { 138 141 return false; 139 142 } 140 143 return true; 141 } 142 143 public boolean importData(TransferHandler.TransferSupport info) { 144 if (!info.isDrop()) { 144 } 145 146 public boolean importData(TransferHandler.TransferSupport info) 147 { 148 if (!info.isDrop()) 149 { 145 150 return false; 146 151 } 147 148 DefaultTableModel tableModel = (DefaultTableModel) pendingIncidentsTable.getModel();149 JTable.DropLocation dl = (JTable.DropLocation) info.getDropLocation();152 153 DefaultTableModel tableModel = (DefaultTableModel) pendingIncidentsTable.getModel(); 154 JTable.DropLocation dl = (JTable.DropLocation) info.getDropLocation(); 150 155 int index = dl.getRow(); 151 156 152 157 // Get the string that is being dropped. 153 158 Transferable t = info.getTransferable(); 154 159 String data; 155 try { 156 data = (String)t.getTransferData(DataFlavor.stringFlavor); 157 } 158 catch (Exception e) { return false; } 159 160 try 161 { 162 data = (String) t.getTransferData(DataFlavor.stringFlavor); 163 } catch (Exception e) 164 { 165 return false; 166 } 167 160 168 // Perform the actual import 161 169 // TODO 162 int incidentId = (Integer)pendingIncidentsTable.getValueAt(dl.getRow(), 0); 163 try { 164 String masterInc = (String) ScreenManager.theCoordinator. 165 getCadDataIncVal(INC_VAL.MASTER_INC, incidentId); 166 ScreenManager.theCoordinator.setCadDataUnitValue(data, 167 UNIT_TAGS.MASTER_INC_NUM, masterInc); 168 169 ScreenManager.theCoordinator.setCadDataUnitAssignedId(data, incidentId); 170 ScreenManager.theCoordinator.setCadDataUnitValue(data, 171 UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Arrived); 172 ScreenManager.theCoordinator.addCadDataIncidentAssignedUnitNum(incidentId, data); 173 ScreenManager.theCoordinator.setCadDataIncidentStatus(incidentId, IncidentEnums.Assigned); 174 } catch (RemoteException e) { 175 e.printStackTrace(); 176 } 170 int incidentId = (Integer) pendingIncidentsTable.getValueAt(dl.getRow(), 0); 171 try 172 { 173 String masterInc = (String) ScreenManager.theCoordinator. 174 getCadDataIncVal(INC_VAL.MASTER_INC, incidentId); 175 ScreenManager.theCoordinator.setCadDataUnitValue(data, 176 UNIT_TAGS.MASTER_INC_NUM, masterInc); 177 178 ScreenManager.theCoordinator.setCadDataUnitAssignedId(data, incidentId); 179 ScreenManager.theCoordinator.setCadDataUnitValue(data, 180 UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Arrived); 181 ScreenManager.theCoordinator.addCadDataIncidentAssignedUnitNum(incidentId, data); 182 ScreenManager.theCoordinator.setCadDataIncidentStatus(incidentId, IncidentEnums.Assigned); 183 } catch (RemoteException e) 184 { 185 e.printStackTrace(); 186 } 177 187 return true; 178 188 } 179 189 }); 180 for(int i = 0; i < pendingIncidentsTable.getColumnCount(); i++){ 190 for (int i = 0; i < pendingIncidentsTable.getColumnCount(); i++) 191 { 181 192 pendingIncidentsTable.getColumnModel().getColumn(i).setPreferredWidth(120); 182 193 } 183 194 } 184 185 /* 195 196 /* 186 197 * Adds the key and mouse listeners for the table and component listener for screen. 187 198 */ 188 private void initControllers(){ 189 pendingIncidentsTable.addMouseListener(new MouseListener(){ 190 public void mouseClicked(MouseEvent e) { 191 if(SwingUtilities.isLeftMouseButton(e)){ 192 if(System.currentTimeMillis() - lastLeftClick < 1000){ 199 private void initControllers() 200 { 201 pendingIncidentsTable.addMouseListener(new MouseListener() 202 { 203 public void mouseClicked(MouseEvent e) 204 { 205 if (SwingUtilities.isLeftMouseButton(e)) 206 { 207 if (System.currentTimeMillis() - lastLeftClick < 1000) 208 { 193 209 int idColumn = 0; 194 ScreenManager.openIncidentViewer((Integer) pendingIncidentsTable.getValueAt(pendingIncidentsTable.getSelectedRow(),idColumn)); 195 }else{ 210 ScreenManager.openIncidentViewer((Integer) pendingIncidentsTable.getValueAt(pendingIncidentsTable.getSelectedRow(), idColumn)); 211 } 212 else 213 { 196 214 lastLeftClick = System.currentTimeMillis(); 197 215 } 198 216 } 199 if(SwingUtilities.isRightMouseButton(e)){ 217 if (SwingUtilities.isRightMouseButton(e)) 218 { 219 // Fixed to force right click to cause the row to be selected. JD 220 // get the coordinates of the mouse click 221 Point p = e.getPoint(); 222 // get the row index that contains that coordinate 223 int rowNumber = pendingIncidentsTable.rowAtPoint(p); 224 // Get the ListSelectionModel of the JTable 225 ListSelectionModel model = pendingIncidentsTable.getSelectionModel(); 226 // set the selected interval of rows. Using the "rowNumber" 227 // variable for the beginning and end selects only that one row. 228 model.setSelectionInterval(rowNumber, rowNumber); 229 // go open the drop down menu 200 230 openDropDownMenu(e); 201 }else{ 231 } 232 else 233 { 202 234 closeDropDownMenu(); 203 235 } 204 236 } 205 public void mouseEntered(MouseEvent e) {} 206 public void mouseExited(MouseEvent e) {} 207 public void mousePressed(MouseEvent e) {} 208 public void mouseReleased(MouseEvent e) {} 237 238 public void mouseEntered(MouseEvent e) 239 { 240 } 241 242 public void mouseExited(MouseEvent e) 243 { 244 } 245 246 public void mousePressed(MouseEvent e) 247 { 248 } 249 250 public void mouseReleased(MouseEvent e) 251 { 252 } 209 253 }); 210 211 addComponentListener( new ComponentListener(){ 212 public void componentHidden(ComponentEvent e) {} 213 public void componentMoved(ComponentEvent e) { 254 255 addComponentListener(new ComponentListener() 256 { 257 public void componentHidden(ComponentEvent e) 258 { 259 } 260 261 public void componentMoved(ComponentEvent e) 262 { 214 263 closeDropDownMenu(); 215 264 } 216 public void componentResized(ComponentEvent e) {} 217 public void componentShown(ComponentEvent e) {} 265 266 public void componentResized(ComponentEvent e) 267 { 268 } 269 270 public void componentShown(ComponentEvent e) 271 { 272 } 218 273 }); 219 274 } 220 275 221 276 /* 222 277 * Creates the drop down menu that appears when a right click is performed on the table. 223 278 */ 224 private void initializeDropDownMenu(){ 279 private void initializeDropDownMenu() 280 { 225 281 Box menu = new Box(BoxLayout.Y_AXIS); 226 282 initializeDropDownLabels(); 227 283 addLabelsToBox(menu); 228 284 229 285 //Sets the highlighted background color, note that it does not become "Highlighted" until opaque(true) is called 230 286 setMenuHighlightedBackground(Color.BLUE); 231 287 232 288 pendingIncidentsMenu = new JFrame(); 233 289 pendingIncidentsMenu.getContentPane().add(menu); … … 237 293 pendingIncidentsMenu.setVisible(false); 238 294 } 239 295 240 296 /* 241 297 * Sets the text and size and adds a listener to each label. 242 298 */ 243 private void initializeDropDownLabels(){ 244 for(int i = 0; i < dropDownLabels.length; i++){ 299 private void initializeDropDownLabels() 300 { 301 for (int i = 0; i < dropDownLabels.length; i++) 302 { 245 303 dropDownLabels[i] = new JLabel(LABEL_SPACING + LABELS[i]); 246 304 dropDownLabels[i].setMaximumSize(DROP_DOWN_MENU_LABEL_DIMENSIONS); … … 252 310 addMouseListenersToLabel(dropDownLabels[8]); 253 311 } 254 255 /* 256 * Add the labels to the box in order with separators and spacings in between. 257 */ 258 private void addLabelsToBox(Box menu){ 312 313 /* 314 * Add the labels to the box in order with separators and spacings in between. 315 */ 316 private void addLabelsToBox(Box menu) 317 { 259 318 menu.add(dropDownLabels[0]); 260 319 menu.add(dropDownLabels[1]); 261 320 262 321 menu.add(Box.createVerticalStrut(5)); 263 322 menu.add(new JSeparator()); 264 323 menu.add(Box.createVerticalStrut(5)); 265 324 266 325 menu.add(dropDownLabels[2]); 267 326 menu.add(dropDownLabels[3]); 268 327 menu.add(dropDownLabels[4]); 269 328 menu.add(dropDownLabels[5]); 270 329 271 330 menu.add(Box.createVerticalStrut(5)); 272 331 menu.add(new JSeparator()); 273 332 menu.add(Box.createVerticalStrut(5)); 274 333 275 334 menu.add(dropDownLabels[6]); 276 335 menu.add(dropDownLabels[7]); 277 336 menu.add(dropDownLabels[8]); 278 337 279 338 menu.add(Box.createVerticalStrut(5)); 280 339 menu.add(new JSeparator()); 281 340 menu.add(Box.createVerticalStrut(5)); 282 341 283 342 menu.add(dropDownLabels[9]); 284 343 menu.add(dropDownLabels[10]); 285 286 menu.add(Box.createVerticalStrut(5)); 287 } 288 344 345 menu.add(Box.createVerticalStrut(5)); 346 } 347 289 348 /* 290 349 * Sets the highlighted color(when the mouse is over it) of the JLabels. … … 292 351 * @param color the highlighted color 293 352 */ 294 public void setMenuHighlightedBackground(Color color){ 295 for(int i = 0; i < dropDownLabels.length; i++){ 353 public void setMenuHighlightedBackground(Color color) 354 { 355 for (int i = 0; i < dropDownLabels.length; i++) 356 { 296 357 dropDownLabels[i].setBackground(color); 297 358 } 298 359 } 299 360 300 361 /* 301 362 * Sets all JLabels to not display a highlighted background 302 363 */ 303 public void unSelectAllLabels(){ 304 for(int i = 0; i < dropDownLabels.length; i++){ 364 public void unSelectAllLabels() 365 { 366 for (int i = 0; i < dropDownLabels.length; i++) 367 { 305 368 dropDownLabels[i].setOpaque(false); 306 369 } … … 311 374 * @param label the label that is selected/highlighted 312 375 */ 313 public void selectLabel(Object label){ 314 ((JLabel)label).setOpaque(true); 315 } 316 376 public void selectLabel(Object label) 377 { 378 ((JLabel) label).setOpaque(true); 379 } 380 317 381 /* 318 382 * Performs the label action depending on which label was clicked. 319 383 */ 320 public void performLabelAction(Object label){ 321 if(label.equals(dropDownLabels[0])){//Recommend 322 323 }else if(label.equals(dropDownLabels[1])){//Add Resources 324 325 }else if(label.equals(dropDownLabels[2])){//Open 326 int idColumn = 0; 384 public void performLabelAction(Object label) 385 { 386 if (label.equals(dropDownLabels[0])) 387 {//Recommend 388 } 389 else if (label.equals(dropDownLabels[1])) 390 {//Add Resources 391 } 392 else if (label.equals(dropDownLabels[2])) 393 {//Open 394 int idColumn = 0; 327 395 ScreenManager.openIncidentViewer((Integer) pendingIncidentsTable.getValueAt( 328 pendingIncidentsTable.getSelectedRow(),idColumn)); 329 }else if(label.equals(dropDownLabels[3])){//Recall Incident 330 331 }else if(label.equals(dropDownLabels[4])){//Cancel 332 }else if(label.equals(dropDownLabels[5])){//Link Append 333 334 }else if(label.equals(dropDownLabels[6])){//Map 335 336 }else if(label.equals(dropDownLabels[7])){//Recall Linked Incidents 337 338 }else if(label.equals(dropDownLabels[8])){//Read Notes 339 int idColumn = 0; 396 pendingIncidentsTable.getSelectedRow(), idColumn)); 397 } 398 else if (label.equals(dropDownLabels[3])) 399 {//Recall Incident 400 } 401 else if (label.equals(dropDownLabels[4])) 402 {//Cancel 403 } 404 else if (label.equals(dropDownLabels[5])) 405 {//Link Append 406 } 407 else if (label.equals(dropDownLabels[6])) 408 {//Map 409 } 410 else if (label.equals(dropDownLabels[7])) 411 {//Recall Linked Incidents 412 } 413 else if (label.equals(dropDownLabels[8])) 414 {//Read Notes 415 int idColumn = 0; 340 416 ScreenManager.openIncidentViewer((Integer) pendingIncidentsTable.getValueAt( 341 pendingIncidentsTable.getSelectedRow(),idColumn)); 342 }else if(label.equals(dropDownLabels[9])){//Mail 343 344 }else if(label.equals(dropDownLabels[10])){//Fax 345 346 } 347 } 348 349 /* 350 * Factory method. Adds a mouse listeners to the label. The MouseMotionListener detects 417 pendingIncidentsTable.getSelectedRow(), idColumn)); 418 } 419 else if (label.equals(dropDownLabels[9])) 420 {//Mail 421 } 422 else if (label.equals(dropDownLabels[10])) 423 {//Fax 424 } 425 } 426 427 /* 428 * Factory method. Adds a mouse listeners to the label. The MouseMotionListener detects 351 429 * the mouse's location to highlight the label. The MouseListener detects 352 430 * for clicks and performs the action of the label designates. 353 431 */ 354 public void addMouseListenersToLabel(JLabel label){ 355 label.addMouseMotionListener(new MouseMotionListener(){ 356 public void mouseDragged(MouseEvent e) {} 357 public void mouseMoved(MouseEvent e) { 432 public void addMouseListenersToLabel(JLabel label) 433 { 434 label.addMouseMotionListener(new MouseMotionListener() 435 { 436 public void mouseDragged(MouseEvent e) 437 { 438 } 439 440 public void mouseMoved(MouseEvent e) 441 { 358 442 unSelectAllLabels(); 359 443 selectLabel(e.getSource()); … … 362 446 } 363 447 }); 364 label.addMouseListener(new MouseListener() { 365 public void mouseClicked(MouseEvent e) { 448 label.addMouseListener(new MouseListener() 449 { 450 public void mouseClicked(MouseEvent e) 451 { 366 452 performLabelAction(e.getSource()); 367 453 unSelectAllLabels(); … … 370 456 pendingIncidentsMenu.setVisible(false); 371 457 } 372 public void mouseEntered(MouseEvent e) {} 373 public void mouseExited(MouseEvent e) {} 374 public void mousePressed(MouseEvent e) {} 375 public void mouseReleased(MouseEvent e) {} 458 459 public void mouseEntered(MouseEvent e) 460 { 461 } 462 463 public void mouseExited(MouseEvent e) 464 { 465 } 466 467 public void mousePressed(MouseEvent e) 468 { 469 } 470 471 public void mouseReleased(MouseEvent e) 472 { 473 } 376 474 }); 377 475 } 378 476 379 477 /* 380 478 * Displays the menu where the right click occurred. 381 479 */ 382 public void openDropDownMenu(MouseEvent e){ 480 public void openDropDownMenu(MouseEvent e) 481 { 383 482 pendingIncidentsMenu.setLocation(e.getX() + this.getX(), e.getY() + this.getY()); 384 483 pendingIncidentsMenu.setVisible(true); 385 484 } 386 485 387 486 /* 388 487 * Hides the menu. 389 488 */ 390 public void closeDropDownMenu(){ 489 public void closeDropDownMenu() 490 { 391 491 unSelectAllLabels(); 392 492 pendingIncidentsMenu.revalidate(); … … 394 494 pendingIncidentsMenu.setVisible(false); 395 495 } 396 496 397 497 /* 398 498 * Refreshes the data in the table by updating all data and repainting the 399 * screen. It saves user preferences(like column sizes, selected row, sorted preferences) 499 * screen. It saves user preferences(like column sizes, selected row, sorted preferences) 400 500 * and applies them to the updated model it receives from the server. 401 501 */ 402 public void refreshTable(){ 403 404 if(pendingIncidentsTable.getTableHeader().getResizingColumn() == null){//only update info if resize not in progress 405 try { 406 int index = pendingIncidentsTable.getSelectedRow(); 407 int[] columnWidths = new int[20]; 408 List<? extends SortKey> keys = pendingIncidentsTable.getRowSorter().getSortKeys(); 409 for(int i = 0; i < pendingIncidentsTable.getColumnCount(); i++){ 410 columnWidths[i] = pendingIncidentsTable.getColumnModel().getColumn(i).getWidth(); 411 } 412 413 pendingIncidentsTable.setModel(ScreenManager.theCoordinator.getCadDataTable(CADDataEnums.TABLE.PENDING_INCIDENTS)); 414 415 for(int i = 0; i < pendingIncidentsTable.getColumnCount(); i++){ 416 pendingIncidentsTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidths[i]); 417 } 418 pendingIncidentsTable.getRowSorter().setSortKeys(keys); 419 pendingIncidentsTable.getSelectionModel().setSelectionInterval(index, index); 420 } catch (RemoteException e) { 502 public void refreshTable() 503 { 504 505 if (pendingIncidentsTable.getTableHeader().getResizingColumn() == null) 506 {//only update info if resize not in progress 507 try 508 { 509 int index = pendingIncidentsTable.getSelectedRow(); 510 int[] columnWidths = new int[20]; 511 List<? extends SortKey> keys = pendingIncidentsTable.getRowSorter().getSortKeys(); 512 for (int i = 0; i < pendingIncidentsTable.getColumnCount(); i++) 513 { 514 columnWidths[i] = pendingIncidentsTable.getColumnModel().getColumn(i).getWidth(); 515 } 516 517 pendingIncidentsTable.setModel(ScreenManager.theCoordinator.getCadDataTable(CADDataEnums.TABLE.PENDING_INCIDENTS)); 518 519 for (int i = 0; i < pendingIncidentsTable.getColumnCount(); i++) 520 { 521 pendingIncidentsTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidths[i]); 522 } 523 pendingIncidentsTable.getRowSorter().setSortKeys(keys); 524 pendingIncidentsTable.getSelectionModel().setSelectionInterval(index, index); 525 } catch (RemoteException e) 526 { 421 527 e.printStackTrace(); 422 528 } 423 529 revalidate(); 424 530 repaint(); 425 }426 } 427 428 /* 531 } 532 } 533 534 /* 429 535 * Makes screen visible. 430 536 */ 431 public void open(){ 537 public void open() 538 { 432 539 setVisible(true); 433 540 } 434 541 435 542 /* 436 543 * Hides screen. 437 544 */ 438 public void close(){ 545 public void close() 546 { 439 547 setVisible(false); 440 548 } 441 442 549 }
Note: See TracChangeset
for help on using the changeset viewer.
