Changeset 8018


Ignore:
Timestamp:
2004-08-20T15:36:06+12:00 (20 years ago)
Author:
mdewsnip
Message:

Fixed the METADATUM argument case so the import.pl "sortmeta" option gets a metadata list correctly (it doesn't have all the metadata elements it should, but that is a bug in the metadata code which will soon be gone).

File:
1 edited

Legend:

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

    r7999 r8018  
    405405        switch(argument.getType()) {
    406406        case Argument.ENUM:
     407        case Argument.METADATUM:
    407408        JComboBox combobox = new JComboBox();
    408409        combobox.setEnabled(enable);
    409410        combobox.setToolTipText(tooltip);
    410         // Set enabled
    411         if(enable) {
    412             combobox.setBackground(Color.white);
    413         }
    414         else {
    415             combobox.setBackground(Color.lightGray);
    416         }
    417         // Build an option model, wrapping each entry of the list table.
    418         HashMap arg_list = argument.getOptions();
    419         Iterator it = arg_list.keySet().iterator();
    420         while(it.hasNext()) {
    421             combobox.addItem((String) it.next());
    422         }
    423         // Connect this up first, so that if a value is selected the tooltip updates accordingly.
    424         combobox.addActionListener(new ToolTipUpdater(arg_list));
    425         if(value != null) {
    426             // Set the selected string. However since they are all strings we had best iterate ourselves.
    427             for(int i = 0; i < combobox.getItemCount(); i++) {
    428             if(combobox.getItemAt(i).toString().equals(value)) {
     411        combobox.setBackground(enable ? Color.white : Color.lightGray);
     412
     413        // Build an option model, wrapping each entry of the list table
     414        if (argument.getType() == Argument.ENUM) {
     415            HashMap arg_list = argument.getOptions();
     416            Iterator it = arg_list.keySet().iterator();
     417            while (it.hasNext()) {
     418            combobox.addItem((String) it.next());
     419            }
     420
     421            // Connect this so if a value is selected the tooltip updates accordingly
     422            combobox.addActionListener(new ToolTipUpdater(arg_list));
     423        }
     424        if (argument.getType() == Argument.METADATUM) {
     425            Vector meta_list = Gatherer.c_man.getCollection().msm.getAssignedElements();
     426            for (int i = 0; i < meta_list.size(); i++) {
     427            combobox.addItem(meta_list.get(i));
     428            }
     429        }
     430
     431        if (value != null) {
     432            // Set the selected string
     433            for (int i = 0; i < combobox.getItemCount(); i++) {
     434            if (combobox.getItemAt(i).toString().equals(value)) {
    429435                combobox.setSelectedIndex(i);
    430436            }
     
    497503        // And remember it
    498504        value_control = textfield;
    499         break;
    500         case Argument.METADATUM:
    501         GComboBox gcombobox = new GComboBox(Gatherer.c_man.getCollection().msm.getAssignedElements(), false);
    502         gcombobox.setEnabled(enable);
    503         // Now ensure we have the existing value or default value selected if either exist.
    504         if(value != null) {
    505             boolean found = selectValue(gcombobox, value);
    506             // Its possible that this is a custom value and so doesn't exist in the combobox. If so add it and then select it
    507             if(!found) {
    508             gcombobox.addItem(value);
    509             gcombobox.setSelectedItem(value);
    510             }
    511         }
    512         add(gcombobox, BorderLayout.CENTER);
    513         value_control = gcombobox;
    514505        break;
    515506        }
Note: See TracChangeset for help on using the changeset viewer.