Changeset 4312
- Timestamp:
- 2003-05-23T16:35:38+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/table/GTableModel.java
r4293 r4312 58 58 private FileNode[] file_nodes; 59 59 /** The current view. */ 60 private int current_view;61 62 private JToggleButton assigned_metadata_view;63 private JToggleButton unassigned_metadata_view;60 //private int current_view; 61 62 //private JToggleButton assigned_metadata_view; 63 //private JToggleButton unassigned_metadata_view; 64 64 65 65 /** An icon showing the current state of the table build. */ 66 private JProgressBar activity_bar;66 //private JProgressBar activity_bar; 67 67 /** The table this model is being displayed in. */ 68 68 private JTable table; … … 77 77 static final private String[] COLUMN_NAMES = {"", Gatherer.dictionary.get("Metadata.Element"), Gatherer.dictionary.get("Metadata.Value")}; 78 78 79 public GTableModel(JTable table) { 80 this.builder = null; 81 this.table = table; 82 //changeView(); 83 // Register this model with the msm manager. 84 if(Gatherer.c_man.ready()) { 85 Gatherer.c_man.getCollection().msm.addMSMListener(this); 86 } 87 } 88 89 public GTableModel(JTable table, FileNode[] file_nodes) { 90 this(table); 91 this.file_nodes = file_nodes; 92 if(file_nodes != null && file_nodes.length > 0) { 93 // Create model builder 94 builder = new ModelBuilder(); 95 builder.start(); 96 } 97 } 98 79 99 /** The default constructor creates a new empty model with the current view set to an emtpy 'all metadata'. */ 80 public GTableModel(JTable table, JToggleButton assigned_metadata_view, JToggleButton unassigned_metadata_view, JProgressBar activity_bar) { 100 /* 101 public GTableModel(JTable table, JToggleButton assigned_metadata_view, JToggleButton unassigned_metadata_view, JProgressBar activity_bar) { 81 102 this.activity_bar = activity_bar; 82 103 this.assigned_metadata_view = assigned_metadata_view; … … 89 110 Gatherer.c_man.getCollection().msm.addMSMListener(this); 90 111 } 91 } 112 } 113 */ 92 114 93 115 /** This constuctor starts by creating an empty model then, using a separate model builder thread, builds a model from the given files. */ 116 /* 94 117 public GTableModel(JTable table, JToggleButton assigned_metadata_view, JToggleButton unassigned_metadata_view, JProgressBar activity_bar, FileNode[] file_nodes) { 95 118 this(table, assigned_metadata_view, unassigned_metadata_view, activity_bar); … … 101 124 } 102 125 } 103 126 */ 127 128 public void changeView() { 129 changeView(SHOW_ALL); 130 } 131 132 /* 104 133 public void changeView() { 105 134 boolean show_assigned = assigned_metadata_view.isSelected(); … … 115 144 } 116 145 } 146 */ 117 147 118 148 /** Change the current view by changing the model that the table is currently based on. */ 119 149 public void changeView(int view) { 120 current_view = view;150 //current_view = view; 121 151 switch(view) { 122 152 case SHOW_ASSIGNED: … … 151 181 // Inform everyone that the model has changed. 152 182 fireTableDataChanged(); 153 } 183 } 154 184 155 185 /** Called whenever an element in a set is added, edited or removed from the metadata set manager. We listen for this just incase the name of one of the elements currently shown changes. After that the table will be up to date, as the element references are otherwise live. */ … … 234 264 /** Allows access to this models current view. */ 235 265 public int getView() { 236 return current_view;266 return SHOW_ALL; //current_view; 237 267 } 238 268 … … 361 391 } 362 392 // As a current visible table is most likely affected, update the table component. We do this by calling changeView so as to also update any compound list. 363 changeView(current_view);393 //changeView(current_view); 364 394 } 365 395 else { … … 442 472 Vector elements = Gatherer.c_man.getCollection().msm.getElements(); 443 473 // Show some visual indication that building is occuring. 444 assigned_metadata_view.setEnabled(false);445 unassigned_metadata_view.setEnabled(false);446 activity_bar.setMaximum(file_nodes.length + elements.size());447 activity_bar.setValue(0);448 activity_bar.setString(Gatherer.dictionary.get("MetaEdit.Building"));474 //assigned_metadata_view.setEnabled(false); 475 //unassigned_metadata_view.setEnabled(false); 476 //activity_bar.setMaximum(file_nodes.length + elements.size()); 477 //activity_bar.setValue(0); 478 //activity_bar.setString(Gatherer.dictionary.get("MetaEdit.Building")); 449 479 //long start = System.currentTimeMillis(); 450 480 … … 473 503 data.inc(); 474 504 // If the table shown is stale, refresh it. 475 if((modified_metadata == file_metadata && current_view == SHOW_FILE) || (modified_metadata == inherited_metadata && current_view == SHOW_INHERITED)) { 505 //if((modified_metadata == file_metadata && current_view == SHOW_FILE) || (modified_metadata == inherited_metadata && current_view == SHOW_INHERITED)) { 506 // fireTableRowsUpdated(index, index); 507 //} 508 // We may have to update a compound list 509 //else if(current_view == SHOW_ALL || current_view == SHOW_ASSIGNED) { 510 if((index = current_metadata.indexOf(data)) == -1) { 476 511 fireTableRowsUpdated(index, index); 477 512 } 478 // We may have to update a compound list 479 else if(current_view == SHOW_ALL || current_view == SHOW_ASSIGNED) { 480 if((index = current_metadata.indexOf(data)) == -1) { 481 fireTableRowsUpdated(index, index); 482 } 483 } 513 //} 484 514 } 485 515 // Ensure the metadata's element is in our list of showable elements. … … 490 520 known_elements.add(data.getElement()); 491 521 // If the table shown is stale, refresh it. 492 if((modified_metadata == file_metadata && current_view == SHOW_FILE) || (modified_metadata == inherited_metadata && current_view == SHOW_INHERITED)) { 522 //if((modified_metadata == file_metadata && current_view == SHOW_FILE) || (modified_metadata == inherited_metadata && current_view == SHOW_INHERITED)) { 523 // fireTableRowsInserted(index, index); 524 //} 525 // We may have to update a compound list 526 //else if(current_view == SHOW_ALL || current_view == SHOW_ASSIGNED) { 527 if((index = current_metadata.indexOf(data)) == -1) { 528 index = add(current_metadata, data); 493 529 fireTableRowsInserted(index, index); 494 530 } 495 // We may have to update a compound list 496 else if(current_view == SHOW_ALL || current_view == SHOW_ASSIGNED) { 497 if((index = current_metadata.indexOf(data)) == -1) { 498 index = add(current_metadata, data); 499 fireTableRowsInserted(index, index); 500 } 501 else { 502 fireTableRowsUpdated(index, index); 503 504 } 505 } 531 else { 532 fireTableRowsUpdated(index, index); 533 } 534 //} 506 535 } 507 536 else { … … 509 538 } 510 539 } 511 activity_bar.setValue(activity_bar.getValue() + 1);540 //activity_bar.setValue(activity_bar.getValue() + 1); 512 541 Gatherer.g_man.metaedit_pane.validateMetadataTable(); 513 542 } … … 520 549 int index = add(unassigned_metadata, data); 521 550 // Inform everyone that the model has changed, but only if it affects the current view. 522 if(current_view == SHOW_UNASSIGNED) { 551 //if(current_view == SHOW_UNASSIGNED) { 552 // fireTableRowsInserted(index, index); 553 //} 554 //else if(current_view == SHOW_ALL) { 555 if((index = current_metadata.indexOf(data)) == -1) { 556 index = add(current_metadata, data); 523 557 fireTableRowsInserted(index, index); 524 558 } 525 else if(current_view == SHOW_ALL) { 526 if((index = current_metadata.indexOf(data)) == -1) { 527 index = add(current_metadata, data); 528 fireTableRowsInserted(index, index); 529 } 530 else { 531 fireTableRowsUpdated(index, index); 532 } 533 } 534 } 535 activity_bar.setValue(activity_bar.getValue() + 1); 559 else { 560 fireTableRowsUpdated(index, index); 561 } 562 //} 563 } 564 //activity_bar.setValue(activity_bar.getValue() + 1); 536 565 Gatherer.g_man.metaedit_pane.validateMetadataTable(); 537 566 } 538 567 //long end = System.currentTimeMillis(); 539 568 ///ystem.err.println("Took " + (end - start) + "ms to build table."); 540 assigned_metadata_view.setEnabled(true);541 unassigned_metadata_view.setEnabled(true);542 activity_bar.setValue(activity_bar.getMaximum());543 activity_bar.setString(Gatherer.dictionary.get("MetaEdit.Ready"));569 //assigned_metadata_view.setEnabled(true); 570 //unassigned_metadata_view.setEnabled(true); 571 //activity_bar.setValue(activity_bar.getMaximum()); 572 //activity_bar.setString(Gatherer.dictionary.get("MetaEdit.Ready")); 544 573 // Finally complete 545 574 complete = true;
Note:
See TracChangeset
for help on using the changeset viewer.