Changeset 4329
- Timestamp:
- 2003-05-26T15:50:54+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/table/GTableModel.java
r4312 r4329 39 39 import org.greenstone.gatherer.msm.MSMEvent; 40 40 import org.greenstone.gatherer.msm.MSMListener; 41 import org.greenstone.gatherer.msm.MSMUtils; 41 42 import org.greenstone.gatherer.util.ArrayTools; 42 43 /** Provides the model for a GTable component, filling it with metadata values for the choosen files or folders. The model also provides several different view of this data; assigned folder metadata, assigned file metadata, all assigned metadata, unassigned metadata, and all metadata. It also differentiates between metadata that is common to all of the files or folders, and that which isn't. The building of the actual model is done on a separate thread so that the gui remains responsive, and the gui is intermitantly updated by this thread. Updating of the model is triggered by events recieved from the metadata set manager in terms of new or obsolete metadata. A new model is rebuilt whenever the user selects a different group of files or folders. … … 50 51 private ArrayList current_metadata = new ArrayList(); 51 52 /** The metadata currently assigned at the file level. */ 52 private ArrayList file_metadata = n ew ArrayList();53 private ArrayList file_metadata = null; // new ArrayList(); 53 54 /** The metadata currently assigned at the folder level. */ 54 private ArrayList inherited_metadata = n ew ArrayList();55 private ArrayList inherited_metadata = null; // new ArrayList(); 55 56 /** The metadata currently unassigned. */ 56 private ArrayList unassigned_metadata = n ew ArrayList();57 private ArrayList unassigned_metadata = null; // new ArrayList(); 57 58 /** The file nodes this model is built upon. */ 58 59 private FileNode[] file_nodes; … … 79 80 public GTableModel(JTable table) { 80 81 this.builder = null; 82 this.file_metadata = current_metadata; 83 this.inherited_metadata = current_metadata; 81 84 this.table = table; 85 this.unassigned_metadata = current_metadata; 82 86 //changeView(); 83 87 // Register this model with the msm manager. … … 149 153 public void changeView(int view) { 150 154 //current_view = view; 155 /* 151 156 switch(view) { 152 157 case SHOW_ASSIGNED: … … 155 160 current_metadata.addAll(file_metadata); 156 161 current_metadata.addAll(inherited_metadata); 157 Collections.sort(current_metadata );162 Collections.sort(current_metadata, MSMUtils.METADATA_COMPARATOR); 158 163 break; 159 164 case SHOW_FILE: … … 171 176 default: 172 177 // SHOW_ALL 173 ///ystem.err.println("Show all");178 System.err.println("Show all"); 174 179 // Create a new array from the three other arrays. 175 180 current_metadata = new ArrayList(); … … 177 182 current_metadata.addAll(inherited_metadata); 178 183 current_metadata.addAll(unassigned_metadata); 179 Collections.sort(current_metadata );184 Collections.sort(current_metadata, MSMUtils.METADATA_COMPARATOR); 180 185 } 181 186 // Inform everyone that the model has changed. 182 187 fireTableDataChanged(); 188 */ 183 189 } 184 190 … … 286 292 // First check whether this record is one of those that we have showing. 287 293 if(file_nodes != null && file_node != null && ArrayTools.contains(file_nodes, file_node)) { 288 Metadata old_data = event.getOldMetadata(); 289 Metadata new_data = event.getNewMetadata(); 294 // Brute force solution... rebuild the table. 295 if(file_nodes != null && file_nodes.length > 0) { 296 current_metadata.clear(); 297 // Create model builder 298 builder = new ModelBuilder(); 299 builder.start(); 300 } 301 302 /* 290 303 // If old metadata has been removed then remove it. Update the unassigned list if necessary (first checking if there are other metadata entries with the same element, and furthermore if the were inherited metadata being supressed). 291 304 if(old_data != null) { 292 ///ystem.err.println("Remove: " + old_data);305 System.err.println("Remove: " + old_data); 293 306 // Determine the level of this metadata 294 ArrayList modified_metadata ;307 ArrayList modified_metadata = null; 295 308 if(old_data.isFileLevel()) { 296 309 modified_metadata = file_metadata; … … 299 312 modified_metadata = inherited_metadata; 300 313 } 314 301 315 int index = -1; 302 316 if((index = modified_metadata.indexOf(old_data)) != -1) { … … 356 370 remove(unassigned_metadata, new Metadata(new_data.getElement())); 357 371 // Determine if we are adding the new node at the file or folder level. 358 ArrayList modified_metadata ;372 ArrayList modified_metadata = null; 359 373 if(new_data.isFileLevel()) { 360 374 modified_metadata = file_metadata; … … 392 406 // 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. 393 407 //changeView(current_view); 408 */ 394 409 } 395 410 else { … … 571 586 //activity_bar.setValue(activity_bar.getMaximum()); 572 587 //activity_bar.setString(Gatherer.dictionary.get("MetaEdit.Ready")); 588 Collections.sort(current_metadata, MSMUtils.METADATA_COMPARATOR); 589 fireTableDataChanged(); 573 590 // Finally complete 574 591 complete = true;
Note:
See TracChangeset
for help on using the changeset viewer.