Changeset 4329


Ignore:
Timestamp:
2003-05-26T15:50:54+12:00 (21 years ago)
Author:
jmt12
Message:

Metadata changes update appropriately - John

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/table/GTableModel.java

    r4312 r4329  
    3939import org.greenstone.gatherer.msm.MSMEvent;
    4040import org.greenstone.gatherer.msm.MSMListener;
     41import org.greenstone.gatherer.msm.MSMUtils;
    4142import org.greenstone.gatherer.util.ArrayTools;
    4243/** 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.
     
    5051     private ArrayList current_metadata    = new ArrayList();
    5152     /** The metadata currently assigned at the file level. */
    52      private ArrayList file_metadata       = new ArrayList();
     53     private ArrayList file_metadata       = null; // new ArrayList();
    5354     /** The metadata currently assigned at the folder level. */
    54      private ArrayList inherited_metadata  = new ArrayList();
     55     private ArrayList inherited_metadata  = null; // new ArrayList();
    5556     /** The metadata currently unassigned. */
    56      private ArrayList unassigned_metadata = new ArrayList();
     57     private ArrayList unassigned_metadata = null; // new ArrayList();
    5758     /** The file nodes this model is built upon. */
    5859     private FileNode[] file_nodes;
     
    7980     public GTableModel(JTable table) {
    8081          this.builder = null;
     82          this.file_metadata = current_metadata;
     83          this.inherited_metadata = current_metadata;
    8184          this.table = table;
     85          this.unassigned_metadata = current_metadata;
    8286          //changeView();
    8387          // Register this model with the msm manager.
     
    149153     public void changeView(int view) {
    150154          //current_view = view;
     155          /*
    151156          switch(view) {
    152157          case SHOW_ASSIGNED:
     
    155160                current_metadata.addAll(file_metadata);
    156161                current_metadata.addAll(inherited_metadata);
    157                 Collections.sort(current_metadata);
     162                Collections.sort(current_metadata, MSMUtils.METADATA_COMPARATOR);
    158163                break;
    159164          case SHOW_FILE:
     
    171176          default:
    172177                // SHOW_ALL
    173                 ///ystem.err.println("Show all");
     178                System.err.println("Show all");
    174179                // Create a new array from the three other arrays.
    175180                current_metadata = new ArrayList();
     
    177182                current_metadata.addAll(inherited_metadata);
    178183                current_metadata.addAll(unassigned_metadata);
    179                 Collections.sort(current_metadata);
     184                Collections.sort(current_metadata, MSMUtils.METADATA_COMPARATOR);
    180185          }
    181186          // Inform everyone that the model has changed.
    182187          fireTableDataChanged();
     188          */
    183189     }
    184190
     
    286292          // First check whether this record is one of those that we have showing.
    287293          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                /*
    290303                // 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).
    291304                if(old_data != null) {
    292                      ///ystem.err.println("Remove: " + old_data);
     305                     System.err.println("Remove: " + old_data);
    293306                     // Determine the level of this metadata
    294                      ArrayList modified_metadata;
     307                     ArrayList modified_metadata = null;
    295308                     if(old_data.isFileLevel()) {
    296309                          modified_metadata = file_metadata;
     
    299312                          modified_metadata = inherited_metadata;
    300313                     }
     314                     
    301315                     int index = -1;
    302316                     if((index = modified_metadata.indexOf(old_data)) != -1) {
     
    356370                     remove(unassigned_metadata, new Metadata(new_data.getElement()));
    357371                     // Determine if we are adding the new node at the file or folder level.
    358                      ArrayList modified_metadata;
     372                     ArrayList modified_metadata = null;
    359373                     if(new_data.isFileLevel()) {
    360374                          modified_metadata = file_metadata;
     
    392406                // 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.
    393407                //changeView(current_view);
     408                */
    394409          }
    395410          else {
     
    571586                //activity_bar.setValue(activity_bar.getMaximum());
    572587                //activity_bar.setString(Gatherer.dictionary.get("MetaEdit.Ready"));
     588                Collections.sort(current_metadata, MSMUtils.METADATA_COMPARATOR);
     589                fireTableDataChanged();
    573590                // Finally complete
    574591                complete = true;
Note: See TracChangeset for help on using the changeset viewer.