Changeset 4312


Ignore:
Timestamp:
2003-05-23T16:35:38+12:00 (21 years ago)
Author:
jmt12
Message:

temporarily disabled the idea of different model views

File:
1 edited

Legend:

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

    r4293 r4312  
    5858     private FileNode[] file_nodes;
    5959     /** 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;
    6464
    6565     /** An icon showing the current state of the table build. */
    66      private JProgressBar activity_bar;
     66     //private JProgressBar activity_bar;
    6767     /** The table this model is being displayed in. */
    6868     private JTable table;
     
    7777     static final private String[] COLUMN_NAMES = {"", Gatherer.dictionary.get("Metadata.Element"),  Gatherer.dictionary.get("Metadata.Value")};
    7878
     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
    7999     /** 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) {
    81102          this.activity_bar = activity_bar;
    82103          this.assigned_metadata_view = assigned_metadata_view;
     
    89110                Gatherer.c_man.getCollection().msm.addMSMListener(this);
    90111          }
    91      }
     112        }
     113     */
    92114
    93115     /** This constuctor starts by creating an empty model then, using a separate model builder thread, builds a model from the given files. */
     116     /*
    94117     public GTableModel(JTable table, JToggleButton assigned_metadata_view, JToggleButton unassigned_metadata_view, JProgressBar activity_bar, FileNode[] file_nodes) {
    95118          this(table, assigned_metadata_view, unassigned_metadata_view, activity_bar);
     
    101124          }
    102125     }
    103 
     126     */
     127
     128     public void changeView() {
     129          changeView(SHOW_ALL);
     130     }
     131
     132     /*
    104133     public void changeView() {
    105134          boolean show_assigned = assigned_metadata_view.isSelected();
     
    115144          }
    116145     }
     146     */
    117147
    118148     /** Change the current view by changing the model that the table is currently based on. */
    119149     public void changeView(int view) {
    120           current_view = view;
     150          //current_view = view;
    121151          switch(view) {
    122152          case SHOW_ASSIGNED:
     
    151181          // Inform everyone that the model has changed.
    152182          fireTableDataChanged();
    153      } 
     183     }
    154184
    155185     /** 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. */
     
    234264     /** Allows access to this models current view. */
    235265     public int getView() {
    236           return current_view;
     266          return SHOW_ALL; //current_view;
    237267     }
    238268
     
    361391                }
    362392                // 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);
    364394          }
    365395          else {
     
    442472                Vector elements = Gatherer.c_man.getCollection().msm.getElements();
    443473                // 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"));
    449479                //long start = System.currentTimeMillis();
    450480               
     
    473503                                data.inc();
    474504                                // 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) {
    476511                                     fireTableRowsUpdated(index, index);
    477512                                }
    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                                //}
    484514                          }
    485515                          // Ensure the metadata's element is in our list of showable elements.
     
    490520                                known_elements.add(data.getElement());
    491521                                // 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);
    493529                                     fireTableRowsInserted(index, index);
    494530                                }
    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                                //}
    506535                          }
    507536                          else {
     
    509538                          }
    510539                     }
    511                      activity_bar.setValue(activity_bar.getValue() + 1);
     540                     //activity_bar.setValue(activity_bar.getValue() + 1);
    512541                     Gatherer.g_man.metaedit_pane.validateMetadataTable();
    513542                }
     
    520549                          int index = add(unassigned_metadata, data);
    521550                          // 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);
    523557                                fireTableRowsInserted(index, index);
    524558                          }
    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);
    536565                     Gatherer.g_man.metaedit_pane.validateMetadataTable();
    537566                }
    538567                //long end = System.currentTimeMillis();
    539568                ///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"));
    544573                // Finally complete
    545574                complete = true;
Note: See TracChangeset for help on using the changeset viewer.