Changeset 5864


Ignore:
Timestamp:
2003-11-18T08:37:33+13:00 (20 years ago)
Author:
jmt12
Message:

I believe I have now finished adding tests for missing arguments when configuring a plugin or classifier. I cleared up that weird issue where it would complain about missing an argument, but if you then hit cancel you'd end up with an empty argument anyway.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/ArgumentConfiguration.java

    r5758 r5864  
    9191    setModal(true);
    9292    setSize(SIZE);
    93     setJMenuBar(new SimpleMenuBar("designingacollection")); // can we tell whether we are doing a classifier or plugin, to make the help more specific??   
     93    setJMenuBar(new SimpleMenuBar("designingacollection")); // can we tell whether we are doing a classifier or plugin, to make the help more specific??
    9494    Dictionary.setText(this, "CDM.ArgumentConfiguration.Title");
    9595
     
    323323        Collections.sort(options_model);
    324324        value = new JComboBox(options_model.toArray());
     325        ((JComboBox)value).setEditable(true);
    325326        ((JComboBox)value).addActionListener(new ToolTipUpdater());
    326327        if(existing_value != null) {
     
    506507      return argument;
    507508       }
    508        
     509
    509510    public Object getValue() {
    510511        if(value instanceof JComboBox) {
     
    536537         case Argument.ENUM:
    537538            ListOption option = (ListOption)((JComboBox)value).getSelectedItem();
    538             if(option == null || option.getValue().length() == 0) {
    539                String args[] = new String[1];
    540                args[0] = argument.getName();
    541                JOptionPane.showMessageDialog(self, Dictionary.get("CDM.ArgumentConfiguration.No_Value", args), Dictionary.get("CDM.ArgumentConfiguration.Error_Title"), JOptionPane.ERROR_MESSAGE);
    542                return false;
    543             }
    544             result = option.getValue();
    545             if(result.length() > 0) {
    546                argument.setValue(result);
     539            if(option != null && option.getValue().length() > 0) {
     540               argument.setValue(option.getValue());
    547541            }
    548542            else {
    549                if(argument.isRequired()) {
    550               String args[] = new String[1];
    551               args[0] = argument.getName();
    552               JOptionPane.showMessageDialog(self, Dictionary.get("CDM.ArgumentConfiguration.Required_Argument", args), Dictionary.get("CDM.ArgumentConfiguration.Error_Title"), JOptionPane.ERROR_MESSAGE);
    553               args = null;
    554               return false;
    555                }
    556                else {
    557               argument.setValue(null);
    558                }
     543            String args[] = new String[1];
     544            args[0] = argument.getName();
     545            if(argument.isRequired()) {
     546                JOptionPane.showMessageDialog(self, Dictionary.get("CDM.ArgumentConfiguration.Required_Argument", args), Dictionary.get("CDM.ArgumentConfiguration.Error_Title"), JOptionPane.ERROR_MESSAGE);
     547            }
     548            // They've left the field blank
     549            else {
     550                JOptionPane.showMessageDialog(self, Dictionary.get("CDM.ArgumentConfiguration.No_Value", args), Dictionary.get("CDM.ArgumentConfiguration.Error_Title"), JOptionPane.ERROR_MESSAGE);
     551                argument.setValue(null);
     552            }
     553            args = null;
     554            return false;
    559555            }
    560556            argument.setAssigned(true);
     
    582578            }
    583579            else {
     580            String args[] = new String[1];
     581            args[0] = argument.getName();
    584582            if(argument.isRequired()) {
    585                 String args[] = new String[1];
    586                 args[0] = argument.getName();
    587583                JOptionPane.showMessageDialog(self, Dictionary.get("CDM.ArgumentConfiguration.Required_Argument", args), Dictionary.get("CDM.ArgumentConfiguration.Error_Title"), JOptionPane.ERROR_MESSAGE);
    588                 args = null;
    589                 return false;
    590584            }
     585            // They've left the field blank
    591586            else {
    592                 argument.setValue(null);
    593             }
     587                JOptionPane.showMessageDialog(self, Dictionary.get("CDM.ArgumentConfiguration.No_Value", args), Dictionary.get("CDM.ArgumentConfiguration.Error_Title"), JOptionPane.ERROR_MESSAGE);
     588                argument.setValue(null);
     589            }
     590            args = null;
     591            return false;
    594592            }
    595593            argument.setAssigned(true);
     
    626624            }
    627625            else {
    628             if(argument.isRequired()) {
    629                 String args[] = new String[1];
    630                 args[0] = argument.getName();
    631                 JOptionPane.showMessageDialog(self, Dictionary.get("CDM.ArgumentConfiguration.Required_Argument", args), Dictionary.get("CDM.ArgumentConfiguration.Error_Title"), JOptionPane.ERROR_MESSAGE);
    632                 return false;
    633             }
    634             else {
    635                 argument.setValue(null);
    636             }
    637             }
    638             argument.setAssigned(true);
     626            String args[] = new String[1];
     627            args[0] = argument.getName();
     628            if(argument.isRequired()) {
     629                JOptionPane.showMessageDialog(self, Dictionary.get("CDM.ArgumentConfiguration.Required_Argument", args), Dictionary.get("CDM.ArgumentConfiguration.Error_Title"), JOptionPane.ERROR_MESSAGE);
     630            }
     631            // They've left the field blank
     632            else {
     633                JOptionPane.showMessageDialog(self, Dictionary.get("CDM.ArgumentConfiguration.No_Value", args), Dictionary.get("CDM.ArgumentConfiguration.Error_Title"), JOptionPane.ERROR_MESSAGE);
     634                argument.setValue(null);
     635            }
     636            args = null;
     637            return false;
     638            }
     639            argument.setAssigned(true);
    639640            return true;
    640641        }
Note: See TracChangeset for help on using the changeset viewer.