Index: trunk/gli/src/org/greenstone/gatherer/gui/ArgumentControl.java
===================================================================
--- trunk/gli/src/org/greenstone/gatherer/gui/ArgumentControl.java	(revision 9139)
+++ trunk/gli/src/org/greenstone/gatherer/gui/ArgumentControl.java	(revision 9139)
@@ -0,0 +1,294 @@
+/**
+ *#########################################################################
+ *
+ * A component of the Gatherer application, part of the Greenstone digital
+ * library suite from the New Zealand Digital Library Project at the
+ * University of Waikato, New Zealand.
+ *
+ * <BR><BR>
+ *
+ * Author: John Thompson, Greenstone Digital Library, University of Waikato
+ *
+ * <BR><BR>
+ *
+ * Copyright (C) 1999 New Zealand Digital Library Project
+ *
+ * <BR><BR>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * <BR><BR>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * <BR><BR>
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *########################################################################
+ */
+package org.greenstone.gatherer.gui;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.text.*;
+
+import org.greenstone.gatherer.Configuration;
+import org.greenstone.gatherer.cdm.Argument;
+import org.greenstone.gatherer.util.Utility;
+import org.greenstone.gatherer.metadata.MetadataSetManager;
+
+public class ArgumentControl
+    extends JPanel {
+    static protected Dimension LABEL_SIZE = new Dimension(180, 25);
+    static protected Dimension ROW_SIZE = new Dimension(610, 30);
+    static protected Dimension SPINNER_SIZE = new Dimension(100, 25);
+    static protected String DESCRIPTION_SEP = " + ";
+
+    protected Argument argument;
+    protected JComponent value_control;
+    protected JCheckBox enabled;
+    public ArgumentControl(Argument argument, boolean enable, String value) {
+	super();
+	this.argument = argument;
+	String tooltip = Utility.formatHTMLWidth("<html>" + argument.getDescription() + "</html>", 60);
+	setBackground(Configuration.getColor("coloring.collection_tree_background", false));
+	setBorder(BorderFactory.createEmptyBorder(2,0,2,0));
+	setLayout(new BorderLayout());
+	setPreferredSize(ROW_SIZE);
+	setMaximumSize(ROW_SIZE);
+	
+	// Try to determine what the value_controls value should be.
+	if(value == null) {
+	    value = argument.getDefaultValue();
+	}
+	// Create a correct value control based on the argument provided.
+	switch(argument.getType()) {
+	case Argument.ENUM:
+	case Argument.METADATUM:
+	    JComboBox combobox = new JComboBox();
+	    combobox.setEnabled(enable);
+	    combobox.setToolTipText(tooltip);
+	    combobox.setBackground(enable ? Color.white : Color.lightGray);
+	    
+	    // Build an option model, wrapping each entry of the list table
+	    if (argument.getType() == Argument.ENUM) {
+		HashMap arg_list = argument.getOptions();
+		Iterator it = arg_list.keySet().iterator();
+		while (it.hasNext()) {
+		    combobox.addItem((String) it.next());
+		}
+
+		// Connect this so if a value is selected the tooltip updates accordingly
+		combobox.addActionListener(new ToolTipUpdater(arg_list));
+	    }
+	    if (argument.getType() == Argument.METADATUM) {
+		ArrayList every_metadata_set_element = MetadataSetManager.getEveryMetadataSetElement();
+		for (int i = 0; i < every_metadata_set_element.size(); i++) {
+		    combobox.addItem(every_metadata_set_element.get(i));
+		}
+	    }
+
+	    if (value != null) {
+		// Set the selected string
+		for (int i = 0; i < combobox.getItemCount(); i++) {
+		    if (combobox.getItemAt(i).toString().equals(value)) {
+			combobox.setSelectedIndex(i);
+		    }
+		}
+	    }
+	    // Layout
+	    add(combobox, BorderLayout.CENTER);
+	    // And remember
+	    value_control = combobox;
+	    break;
+	case Argument.FLAG:
+	    // Only need the check box.
+	    value_control = null;
+	    break;
+	case Argument.INTEGER:
+	    // Build a spinner
+	    int initial_value=0;
+	    if (value != null) {
+		try {
+		    initial_value = Integer.parseInt(value);
+		} catch (Exception exception) {
+		}
+	    }
+	    if (initial_value < argument.getMinimum()) {
+		initial_value = argument.getMinimum();
+	    } else if (initial_value > argument.getMaximum()) {
+		initial_value = argument.getMaximum();
+	    }
+	    JSpinner spinner = new JSpinner(new SpinnerNumberModel(initial_value, argument.getMinimum(), argument.getMaximum(), 1));		
+	    spinner.setEnabled(enable);
+	    spinner.setPreferredSize(SPINNER_SIZE);
+	    spinner.setToolTipText(tooltip);
+	    // Set enabled
+	    JComponent c = spinner.getEditor();
+	    if ( c instanceof JSpinner.DefaultEditor ) {
+		JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) c;
+		JFormattedTextField field = editor.getTextField();
+		field.setEditable(enable);
+		if(enable) {
+		    field.setBackground(Color.white);
+		}
+		else {
+		    field.setBackground(Color.lightGray);
+		}
+	    }
+	    // Layout
+	    add(new JLabel(), BorderLayout.CENTER);
+	    add(spinner, BorderLayout.EAST);
+	    // And remember it
+	    value_control = spinner;
+	    break;
+	case Argument.STRING:
+	    // Use a standard text field
+	    JTextField textfield = new JTextField();
+	    textfield.setEnabled(enable);
+	    textfield.setToolTipText(tooltip);
+	    // Set enabled
+	    if(enable) {
+		textfield.setBackground(Color.white);
+	    }
+	    else {
+		textfield.setBackground(Color.lightGray);
+	    }
+	    // If there was an original value, set it.
+	    if(value != null) {
+		textfield.setText(value);
+	    }
+	    // Layout
+	    add(textfield, BorderLayout.CENTER);
+	    // And remember it
+	    value_control = textfield;
+	    break;
+	}
+
+	// If the argument is required, then you don't get a choice of whether it is enabled.
+	if(argument.isRequired()) {
+	    JLabel label = new JLabel(argument.getName());
+	    label.setOpaque(false);
+	    label.setPreferredSize(LABEL_SIZE);
+	    label.setToolTipText(tooltip);
+	    add(label, BorderLayout.WEST);
+	}
+	else {
+	    enabled = new JCheckBox(argument.getName(), enable);
+	    enabled.setOpaque(false);
+	    enabled.setPreferredSize(LABEL_SIZE);
+	    enabled.setToolTipText(tooltip);
+	    // Connect
+	    enabled.addActionListener(new EnabledListener(value_control));
+	    // Layout
+	    add(enabled, BorderLayout.WEST);
+	}
+    }
+
+    /** Retrieve the control used for storing values.
+     * @return JComponent
+     */
+    public JComponent getValueControl() {
+	return value_control;
+    }
+
+    /** Method to ensure that a certain value is selected, if it exists within that combobox to begin with.
+     * @param combobox the JComboBox whose selection we are trying to preset
+     * @param target The desired value of the selection as a String
+     * @return true if the item was found and selected, false otherwise
+     */
+    public boolean selectValue(JComboBox combobox, String target) {
+	for(int i = 0; i < combobox.getItemCount(); i++) {
+	    if(combobox.getItemAt(i).toString().equals(target)) {
+		combobox.setSelectedIndex(i);
+		return true;
+	    }
+	}
+	return false;
+    }
+
+    /** Listens for actions apon the enable checkbox, and if detected enables or diables control appropriately. */
+    private class EnabledListener
+	implements ActionListener {
+	/** An editor component, such as a JComboBox or JTextField, that might have its enabled state changed by this listener. */
+	private JComponent target = null;
+	/** Constructor. */
+	public EnabledListener(JComponent target) {
+	    this.target = target;
+	}
+	/** Any implementation of ActionListener must include this method so that we can be informed when an action has been performed on or registered check box, prompting us to change the state of the other controls as per the users request.
+	 * @param event An <strong>ActionEvent</strong> containing information about the click.
+	 */
+	public void actionPerformed(ActionEvent event) {
+	    JCheckBox source = (JCheckBox)event.getSource();
+	    if(target != null) {
+		if(source.isSelected()) {
+		    target.setBackground(Color.white);
+		    target.setEnabled(true);
+		}
+		else {
+		    target.setBackground(Color.lightGray);
+		    target.setEnabled(false);
+		}
+		// Special case of stupid JSpinners who don't let their backgrounds change properly.
+		if(target instanceof JSpinner) {
+		    JSpinner spinner = (JSpinner) target;
+		    JComponent c = spinner.getEditor();
+		    if ( c instanceof JSpinner.DefaultEditor ) {
+			JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) c;
+			JFormattedTextField field = editor.getTextField();
+			field.setEditable(source.isSelected());
+			if(source.isSelected()) {
+			    field.setBackground(Color.white);
+			}
+			else {
+			    field.setBackground(Color.lightGray);
+			}
+		    }
+		}
+	    }
+	}
+    }
+
+   /** Listener that sets the tooltip associated to a combobox to the tooltip relevant to the selected item. */
+    private class ToolTipUpdater
+	implements ActionListener {
+	private HashMap arg_list;
+	public ToolTipUpdater(HashMap arg_list) {
+	    this.arg_list = arg_list;
+	}
+	/** Any implementation of an ActionListener must include this method so that we can be informed when the selection in a combobox has changed and update the tooltip accordingly.
+	 * @param event An <strong>ActionEvent</strong> containing information about the action that fired this call.
+	 */
+	public void actionPerformed(ActionEvent event) {
+	    JComboBox source = (JComboBox)event.getSource();
+	    String key = (String) source.getSelectedItem();
+	    if(arg_list != null) {
+		String description = (String) arg_list.get(key);
+		if(description != null) {
+		    description = Utility.formatHTMLWidth(DESCRIPTION_SEP + description, 60);
+		    String original = source.getToolTipText();
+		    if(original == null) {
+			original = "";
+		    }
+		    // Remove any existing extra description.
+		    if(original.indexOf(DESCRIPTION_SEP) != -1) {
+			original = original.substring(0, original.indexOf(DESCRIPTION_SEP));
+		    }
+		    source.setToolTipText(original + description);
+		}
+	    }
+	}
+    }
+}
Index: trunk/gli/src/org/greenstone/gatherer/gui/OptionsPane.java
===================================================================
--- trunk/gli/src/org/greenstone/gatherer/gui/OptionsPane.java	(revision 9137)
+++ trunk/gli/src/org/greenstone/gatherer/gui/OptionsPane.java	(revision 9139)
@@ -52,8 +52,6 @@
 import org.greenstone.gatherer.collection.Collection;
 import org.greenstone.gatherer.collection.CollectionManager;
-import org.greenstone.gatherer.metadata.MetadataSetManager;
 import org.greenstone.gatherer.util.AppendLineOnlyFileDocument;
 import org.greenstone.gatherer.util.AppendLineOnlyFileDocumentOwner;
-import org.greenstone.gatherer.util.Utility;
 
 /** This class serves as the data holder for all subclasses of option panes, such as Import options or All options. It also contains methods for creating each of the option lines as they would appear in the subpane. Futhermore it has a method for considering all the arguments and generating a <strong>String[]</strong> to allow you to pass them to the <strong>GShell</strong>.
@@ -73,9 +71,5 @@
     static private int IMPORT = 1;
     static private int MINIMUM_ROWS = 11;
-    static private Dimension LABEL_SIZE = new Dimension(180, 25);
-    static private Dimension ROW_SIZE = new Dimension(610, 30);
-    static private Dimension SPINNER_SIZE = new Dimension(100, 25);
-    static private String DESCRIPTION_SEP = " + ";
-
+ 
     /** All process messages are written to this log text area. */
     public JTextArea log_textarea = null;
@@ -120,5 +114,5 @@
      * @see org.greenstone.gatherer.collection.BuildOptions#getBuildValue
      * @see org.greenstone.gatherer.collection.BuildOptions#getBuildValueEnabled
-     * @see org.greenstone.gatherer.gui.OptionsPane.ArgumentControl
+     * @see org.greenstone.gatherer.gui.OptionsPane.MyArgumentControl
      */
     public JPanel buildBuild(JPanel pane) {
@@ -138,5 +132,5 @@
 		boolean enabled = build_options.getValueEnabled(argument.getName());
 		String value = build_options.getValue(argument.getName());
-		ArgumentControl argument_control = new ArgumentControl(BUILD, argument, enabled, value);
+		MyArgumentControl argument_control = new MyArgumentControl(BUILD, argument, enabled, value);
 		build_arguments.add(argument_control);
 	    }
@@ -198,5 +192,5 @@
 		boolean enabled = import_options.getValueEnabled(argument.getName());
 		String value = import_options.getValue(argument.getName());
-		ArgumentControl argument_control = new ArgumentControl(IMPORT, argument, enabled, value);
+		MyArgumentControl argument_control = new MyArgumentControl(IMPORT, argument, enabled, value);
 		import_arguments.add(argument_control);
 	    }
@@ -337,6 +331,6 @@
 	for(int i = 0; i < panel.getComponentCount(); i++) {
 	    Component component = panel.getComponent(i);
-	    if(component instanceof ArgumentControl) {
-		((ArgumentControl)component).update();
+	    if(component instanceof MyArgumentControl) {
+		((MyArgumentControl)component).update();
 	    }
 	}
@@ -359,5 +353,5 @@
 	// Loop through the controls, and if the current control is a JSpinner, commit its current editing
 	for(int i = 0; i < current_controls.size(); i++) {
-	    ArgumentControl control = (ArgumentControl) current_controls.get(i);
+	    MyArgumentControl control = (MyArgumentControl) current_controls.get(i);
 	    JComponent value_control = control.getValueControl();
 	    if(value_control instanceof JSpinner) {
@@ -385,170 +379,11 @@
     public void mouseReleased(MouseEvent e) {}
 
-    private class ArgumentControl
-	extends JPanel {
-	private Argument argument;
+    private class MyArgumentControl
+	extends ArgumentControl {
 	private int type;
-	private JComponent value_control;
-	private JCheckBox enabled;
-	public ArgumentControl(int type, Argument argument, boolean enable, String value) {
-	    super();
-	    this.argument = argument;
+
+	public MyArgumentControl(int type, Argument argument, boolean enable, String value) {
+	    super(argument, enable, value);
 	    this.type = type;
-	    String tooltip = Utility.formatHTMLWidth("<html>" + argument.getDescription() + "</html>", 60);
-	    // Because of the dynamic order of component creation/connection/layout, we can't really follow that pattern here.
-	    setBackground(Configuration.getColor("coloring.collection_tree_background", false));
-	    setBorder(BorderFactory.createEmptyBorder(2,0,2,0));
-	    setLayout(new BorderLayout());
-	    setPreferredSize(ROW_SIZE);
-	    setMaximumSize(ROW_SIZE);
-
-	    // Try to determine what the value_controls value should be.
-	    if(value == null) {
-		value = argument.getDefaultValue();
-	    }
-	    // Create a correct value control based on the argument provided.
-	    switch(argument.getType()) {
-	    case Argument.ENUM:
-	    case Argument.METADATUM:
-		JComboBox combobox = new JComboBox();
-		combobox.setEnabled(enable);
-		combobox.setToolTipText(tooltip);
-		combobox.setBackground(enable ? Color.white : Color.lightGray);
-
-		// Build an option model, wrapping each entry of the list table
-		if (argument.getType() == Argument.ENUM) {
-		    HashMap arg_list = argument.getOptions();
-		    Iterator it = arg_list.keySet().iterator();
-		    while (it.hasNext()) {
-			combobox.addItem((String) it.next());
-		    }
-
-		    // Connect this so if a value is selected the tooltip updates accordingly
-		    combobox.addActionListener(new ToolTipUpdater(arg_list));
-		}
-		if (argument.getType() == Argument.METADATUM) {
-		    ArrayList every_metadata_set_element = MetadataSetManager.getEveryMetadataSetElement();
-		    for (int i = 0; i < every_metadata_set_element.size(); i++) {
-			combobox.addItem(every_metadata_set_element.get(i));
-		    }
-		}
-
-		if (value != null) {
-		    // Set the selected string
-		    for (int i = 0; i < combobox.getItemCount(); i++) {
-			if (combobox.getItemAt(i).toString().equals(value)) {
-			    combobox.setSelectedIndex(i);
-			}
-		    }
-		}
-		// Layout
-		add(combobox, BorderLayout.CENTER);
-		// And remember
-		value_control = combobox;
-		break;
-	    case Argument.FLAG:
-		// Only need the check box.
-		value_control = null;
-		break;
-	    case Argument.INTEGER:
-		// Build a spinner
-		int initial_value=0;
-		if (value != null) {
-		    try {
-			initial_value = Integer.parseInt(value);
-		    } catch (Exception exception) {
-		    }
-		}
-		if (initial_value < argument.getMinimum()) {
-		    initial_value = argument.getMinimum();
-		} else if (initial_value > argument.getMaximum()) {
-		    initial_value = argument.getMaximum();
-		}
-		JSpinner spinner = new JSpinner(new SpinnerNumberModel(initial_value, argument.getMinimum(), argument.getMaximum(), 1));		
-		spinner.setEnabled(enable);
-		spinner.setPreferredSize(SPINNER_SIZE);
-		spinner.setToolTipText(tooltip);
-		// Set enabled
-		JComponent c = spinner.getEditor();
-		if ( c instanceof JSpinner.DefaultEditor ) {
-		    JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) c;
-		    JFormattedTextField field = editor.getTextField();
-		    field.setEditable(enable);
-		    if(enable) {
-			field.setBackground(Color.white);
-		    }
-		    else {
-			field.setBackground(Color.lightGray);
-		    }
-		}
-		// Layout
-		add(new JLabel(), BorderLayout.CENTER);
-		add(spinner, BorderLayout.EAST);
-		// And remember it
-		value_control = spinner;
-		break;
-	    case Argument.STRING:
-		// Use a standard text field
-		JTextField textfield = new JTextField();
-		textfield.setEnabled(enable);
-		textfield.setToolTipText(tooltip);
-		// Set enabled
-		if(enable) {
-		    textfield.setBackground(Color.white);
-		}
-		else {
-		    textfield.setBackground(Color.lightGray);
-		}
-		// If there was an original value, set it.
-		if(value != null) {
-		    textfield.setText(value);
-		}
-		// Layout
-		add(textfield, BorderLayout.CENTER);
-		// And remember it
-		value_control = textfield;
-		break;
-	    }
-
-	    // If the argument is required, then you don't get a choice of whether it is enabled.
-	    if(argument.isRequired()) {
-		JLabel label = new JLabel(argument.getName());
-		label.setOpaque(false);
-		label.setPreferredSize(LABEL_SIZE);
-		label.setToolTipText(tooltip);
-		add(label, BorderLayout.WEST);
-	    }
-	    else {
-		enabled = new JCheckBox(argument.getName(), enable);
-		enabled.setOpaque(false);
-		enabled.setPreferredSize(LABEL_SIZE);
-		enabled.setToolTipText(tooltip);
-		// Connect
-		enabled.addActionListener(new EnabledListener(value_control));
-		// Layout
-		add(enabled, BorderLayout.WEST);
-	    }
-	}
-
-	/** Retrieve the control used for storing values.
-	 * @return JComponent
-	 */
-	public JComponent getValueControl() {
-	    return value_control;
-	}
-
-	/** Method to ensure that a certain value is selected, if it exists within that combobox to begin with.
-	 * @param combobox the JComboBox whose selection we are trying to preset
-	 * @param target The desired value of the selection as a String
-	 * @return true if the item was found and selected, false otherwise
-	 */
-	public boolean selectValue(JComboBox combobox, String target) {
-	    for(int i = 0; i < combobox.getItemCount(); i++) {
-		if(combobox.getItemAt(i).toString().equals(target)) {
-		    combobox.setSelectedIndex(i);
-		    return true;
-		}
-	    }
-	    return false;
 	}
 
@@ -589,47 +424,4 @@
 		else {
 		    import_options.setValue(name, enable, value);
-		}
-	    }
-	}
-    }
-
-    /** Listens for actions apon the enable checkbox, and if detected enables or diables control appropriately. */
-    private class EnabledListener
-	implements ActionListener {
-	/** An editor component, such as a JComboBox or JTextField, that might have its enabled state changed by this listener. */
-	private JComponent target = null;
-	/** Constructor. */
-	public EnabledListener(JComponent target) {
-	    this.target = target;
-	}
-	/** Any implementation of ActionListener must include this method so that we can be informed when an action has been performed on or registered check box, prompting us to change the state of the other controls as per the users request.
-	 * @param event An <strong>ActionEvent</strong> containing information about the click.
-	 */
-	public void actionPerformed(ActionEvent event) {
-	    JCheckBox source = (JCheckBox)event.getSource();
-	    if(target != null) {
-		if(source.isSelected()) {
-		    target.setBackground(Color.white);
-		    target.setEnabled(true);
-		}
-		else {
-		    target.setBackground(Color.lightGray);
-		    target.setEnabled(false);
-		}
-		// Special case of stupid JSpinners who don't let their backgrounds change properly.
-		if(target instanceof JSpinner) {
-		    JSpinner spinner = (JSpinner) target;
-		    JComponent c = spinner.getEditor();
-		    if ( c instanceof JSpinner.DefaultEditor ) {
-			JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) c;
-			JFormattedTextField field = editor.getTextField();
-			field.setEditable(source.isSelected());
-			if(source.isSelected()) {
-			    field.setBackground(Color.white);
-			}
-			else {
-			    field.setBackground(Color.lightGray);
-			}
-		    }
 		}
 	    }
@@ -765,33 +557,3 @@
     }
 
-    /** Listener that sets the tooltip associated to a combobox to the tooltip relevant to the selected item. */
-    private class ToolTipUpdater
-	implements ActionListener {
-	private HashMap arg_list;
-	public ToolTipUpdater(HashMap arg_list) {
-	    this.arg_list = arg_list;
-	}
-	/** Any implementation of an ActionListener must include this method so that we can be informed when the selection in a combobox has changed and update the tooltip accordingly.
-	 * @param event An <strong>ActionEvent</strong> containing information about the action that fired this call.
-	 */
-	public void actionPerformed(ActionEvent event) {
-	    JComboBox source = (JComboBox)event.getSource();
-	    String key = (String) source.getSelectedItem();
-	    if(arg_list != null) {
-		String description = (String) arg_list.get(key);
-		if(description != null) {
-		    description = Utility.formatHTMLWidth(DESCRIPTION_SEP + description, 60);
-		    String original = source.getToolTipText();
-		    if(original == null) {
-			original = "";
-		    }
-		    // Remove any existing extra description.
-		    if(original.indexOf(DESCRIPTION_SEP) != -1) {
-			original = original.substring(0, original.indexOf(DESCRIPTION_SEP));
-		    }
-		    source.setToolTipText(original + description);
-		}
-	    }
-	}
-    }
 }
