Index: /gli/trunk/classes/dictionary.properties
===================================================================
--- /gli/trunk/classes/dictionary.properties	(revision 16679)
+++ /gli/trunk/classes/dictionary.properties	(revision 16680)
@@ -146,4 +146,5 @@
 CDM.GUI.SuperCollection:Cross-Collection Search
 CDM.GUI.Translation:Translate Text
+CDM.GUI.DepositorMetadata:Depositor Metadata
 CDM.HelpButton:Help for this screen
 CDM.HelpButton_Tooltip:Open up the GLI help for this screen
@@ -279,4 +280,5 @@
 CDM.TranslationManager.Translation:Translated Text
 CDM.TranslationManager.Translation_Tooltip:Enter the translation of the string here
+CDM.DepositorMetadataManager.Warning:At least one metadata element should be selected.
 #*******************
 #
Index: /gli/trunk/help/en/depositormetadatasettings.htm
===================================================================
--- /gli/trunk/help/en/depositormetadatasettings.htm	(revision 16680)
+++ /gli/trunk/help/en/depositormetadatasettings.htm	(revision 16680)
@@ -0,0 +1,23 @@
+<html>
+<head>
+<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>The Greenstone Librarian Interface - Help Pages</title>
+</head>
+<body bgcolor="#E0F0E0">
+<table width="100%" cellspacing="0" cellpadding="5" bgcolor="#B0D0B0" border="2">
+<tr>
+<td width="15%" align="center"><img width="45" src="../gatherer_medium.gif" height="45"></td><td width="*" align="center"><a name="depositormetadata"><font size="5" face="Verdana"><strong>8.8: Depositor Metadata</strong></font></a></td><td width="15%" align="center"><img width="45" src="../gatherer_medium.gif" height="45"></td>
+</tr>
+</table>
+
+
+<p>The Greenstone Depositor enables user to add new items into an existing collection through web interface. This section describes the Depositor Metadata pane, where you can specify which metadata fields should be used to describe the new items added through Depositor. Any metadata sets that have been associated with the current collection will be available for selection. If there is no other metadata set than the "Greenstone Extracted Metadata Set" associated to the collection, the "Dublin Core Metadata Set" will be used as default. To learn more about the Depositor, see the online tutorial exercise at http://wiki.greenstone.org/wiki/gsdoc/tutorial/en/depositor.htm. Under the "Format" tab, click "Depositor Metadata".</p>
+
+<p>The Depositor Metadata panel shows a checklist of available metadata fields. If there were more than one metadata sets associated with the collection, two adjacent metadata sets are displayed with different colors. Hover the mouse over a metadata element: a tool-tip displaying its description will appear.</p>
+
+<p>Check those you want to be used to describe new items when they are deposited through the Depositor. A drop-down list contains two components will appear right after the element. This allows you to specify the input container of the element in the web interface. "text" means that a single text input will be used, whereas "textarea" means that a multi-line text input will be used. Select an appropirate one for the field.</p>
+
+<p>At least one metadata element must be selected. If there is only one selected element in the list, de-select it will pop-up a warning message: "At least one metadata element should be selected.".</p>
+
+</body>
+</html>
Index: /gli/trunk/help/en/help.xml
===================================================================
--- /gli/trunk/help/en/help.xml	(revision 16679)
+++ /gli/trunk/help/en/help.xml	(revision 16680)
@@ -440,4 +440,13 @@
 <Text id="fc-m3">This pane shows the contents of the collection's extra.dm macro file. This is where collection specific macros can be defined. To learn more about macros, see Chapter 3 of the Greenstone Developer's Guide.</Text>
 </Section>
+<Section name="depositormetadatasettings">
+<Title>
+<Text id="dm-1">Depositor Metadata</Text>
+</Title>
+<Text id="dm-2">The Greenstone Depositor enables user to add new items into an existing collection through web interface. This section describes the Depositor Metadata pane, where you can specify which metadata fields should be used to describe the new items added through Depositor. Any metadata sets that have been associated with the current collection will be available for selection. If there is no other metadata set than the "Greenstone Extracted Metadata Set" associated to the collection, the "Dublin Core Metadata Set" will be used as default. To learn more about the Depositor, see the online tutorial exercise at http://wiki.greenstone.org/wiki/gsdoc/tutorial/en/depositor.htm. Under the "Format" tab, click "Depositor Metadata".</Text>
+<Text id="dm-3">The Depositor Metadata panel shows a checklist of available metadata fields. If there were more than one metadata sets associated with the collection, two adjacent metadata sets are displayed with different colors. Hover the mouse over a metadata element: a tool-tip displaying its description will appear.</Text>
+<Text id="dm-4">Check those you want to be used to describe new items when they are deposited through the Depositor. A drop-down list contains two components will appear right after the element. This allows you to specify the input container of the element in the web interface. "text" means that a single text input will be used, whereas "textarea" means that a multi-line text input will be used. Select an appropirate one for the field.</Text>
+<Text id="dm-5">At least one metadata element must be selected. If there is only one selected element in the list, de-select it will pop-up a warning message: <AutoText key="glidict::CDM.DepositorMetadataManager.Warning"/>.</Text>
+</Section>
 </Section>
 <Section name="miscellaneous">
Index: /gli/trunk/help/en/help_index.xml
===================================================================
--- /gli/trunk/help/en/help_index.xml	(revision 16679)
+++ /gli/trunk/help/en/help_index.xml	(revision 16680)
@@ -1,2 +1,2 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<Document><Section name="introduction"><Title>Introduction</Title><Section name="ofmiceandmenus"><Title>Of Mice and Menus</Title></Section><Section name="howtoavoidthisdocument"><Title>How to Avoid Reading This Document</Title></Section></Section><Section name="startingoff"><Title>Starting Off</Title><Section name="creatingacollection"><Title>Creating a New Collection</Title></Section><Section name="savingacollection"><Title>Saving the Collection</Title></Section><Section name="openingacollection"><Title>Opening an Existing Collection</Title></Section><Section name="deletingcollections"><Title>Deleting Collections</Title></Section></Section><Section name="downloadingfiles"><Title>Downloading Files from the Internet</Title><Section name="themirrorview"><Title>The Download view</Title></Section></Section><Section name="collectingfiles"><Title>Collecting Files for Your Collection</Title><Section name="thegatherview"><Title>The Gather View</Title></Section><Section name="creatingshortcuts"><Title>Creating A Shortcut in the Workspace Tree</Title></Section><Section name="creatingfolders"><Title>Creating Folders</Title></Section><Section name="addingfiles"><Title>Adding Files</Title></Section><Section name="replacingfiles"><Title>Renaming and Replacing Files</Title></Section><Section name="removingfiles"><Title>Removing Files</Title></Section><Section name="explodingfiles"><Title>"Exploding" Metadata Files</Title></Section><Section name="filteringthetree"><Title>Filtering the Trees</Title></Section></Section><Section name="enrichingacollection"><Title>Enriching Your Collection with Metadata</Title><Section name="theenrichview"><Title>The Enrich View</Title></Section><Section name="selectingmetadatasets"><Title>Selecting Metadata Sets</Title></Section><Section name="appendingmetadata"><Title>Appending New Metadata</Title></Section><Section name="addingpreviouslydefinedmetadata"><Title>Adding Previously Defined Metadata</Title></Section><Section name="updatingmetadata"><Title>Editing or Removing Metadata</Title></Section><Section name="reviewingmetadata"><Title>Reviewing Assigned Metadata</Title></Section><Section name="importingpreviouslyassignedmetadata"><Title>Importing Previously Assigned Metadata</Title></Section></Section><Section name="designingacollection"><Title>Configuring Your Collection</Title><Section name="thedesignview"><Title>The Design View</Title></Section><Section name="plugins"><Title>Document Plugins</Title></Section><Section name="searchindexes"><Title>Search Indexes</Title></Section><Section name="partitionindexes"><Title>Partition Indexes</Title><Section name="definefilters"><Title>Define Filters</Title></Section><Section name="assignpartitions"><Title>Assign Partitions</Title></Section><Section name="assignlanguages"><Title>Assign Languages</Title></Section></Section><Section name="classifiers"><Title>Browsing Classifiers</Title></Section></Section><Section name="producingthecollection"><Title>Producing Your Collection</Title><Section name="thecreateview"><Title>The Create View</Title></Section><Section name="builderrors"><Title>Errors in collection building</Title></Section><Section name="expertbuilding"><Title>Create view in Expert mode</Title></Section></Section><Section name="formattingacollection"><Title>Customizing Your Collection's Appearance</Title><Section name="theformatview"><Title>The Format View</Title></Section><Section name="generalsettings"><Title>General</Title></Section><Section name="searchmetadatasettings"><Title>Search</Title></Section><Section name="formatstatements"><Title>Format Features</Title></Section><Section name="translatetext"><Title>Translate Text</Title></Section><Section name="xcollectionsearching"><Title>Cross-Collection Search</Title></Section><Section name="collectionspecificmacros"><Title>Collection Specific Macros</Title></Section></Section><Section name="miscellaneous"><Title>Miscellaneous</Title><Section name="preferences"><Title>Preferences</Title></Section><Section name="fileassociations"><Title>File Associations</Title></Section><Section name="exporting"><Title>Exporting collections to other formats</Title></Section><Section name="exportingcollections"><Title>Exporting Collections to CD/DVD</Title></Section></Section></Document>
+<Document><Section name="introduction"><Title>Introduction</Title><Section name="ofmiceandmenus"><Title>Of Mice and Menus</Title></Section><Section name="howtoavoidthisdocument"><Title>How to Avoid Reading This Document</Title></Section></Section><Section name="startingoff"><Title>Starting Off</Title><Section name="creatingacollection"><Title>Creating a New Collection</Title></Section><Section name="savingacollection"><Title>Saving the Collection</Title></Section><Section name="openingacollection"><Title>Opening an Existing Collection</Title></Section><Section name="deletingcollections"><Title>Deleting Collections</Title></Section></Section><Section name="downloadingfiles"><Title>Downloading Files from the Internet</Title><Section name="themirrorview"><Title>The Download view</Title></Section></Section><Section name="collectingfiles"><Title>Collecting Files for Your Collection</Title><Section name="thegatherview"><Title>The Gather View</Title></Section><Section name="creatingshortcuts"><Title>Creating A Shortcut in the Workspace Tree</Title></Section><Section name="creatingfolders"><Title>Creating Folders</Title></Section><Section name="addingfiles"><Title>Adding Files</Title></Section><Section name="replacingfiles"><Title>Renaming and Replacing Files</Title></Section><Section name="removingfiles"><Title>Removing Files</Title></Section><Section name="explodingfiles"><Title>"Exploding" Metadata Files</Title></Section><Section name="filteringthetree"><Title>Filtering the Trees</Title></Section></Section><Section name="enrichingacollection"><Title>Enriching Your Collection with Metadata</Title><Section name="theenrichview"><Title>The Enrich View</Title></Section><Section name="selectingmetadatasets"><Title>Selecting Metadata Sets</Title></Section><Section name="appendingmetadata"><Title>Appending New Metadata</Title></Section><Section name="addingpreviouslydefinedmetadata"><Title>Adding Previously Defined Metadata</Title></Section><Section name="updatingmetadata"><Title>Editing or Removing Metadata</Title></Section><Section name="reviewingmetadata"><Title>Reviewing Assigned Metadata</Title></Section><Section name="importingpreviouslyassignedmetadata"><Title>Importing Previously Assigned Metadata</Title></Section></Section><Section name="designingacollection"><Title>Configuring Your Collection</Title><Section name="thedesignview"><Title>The Design View</Title></Section><Section name="plugins"><Title>Document Plugins</Title></Section><Section name="searchindexes"><Title>Search Indexes</Title></Section><Section name="partitionindexes"><Title>Partition Indexes</Title><Section name="definefilters"><Title>Define Filters</Title></Section><Section name="assignpartitions"><Title>Assign Partitions</Title></Section><Section name="assignlanguages"><Title>Assign Languages</Title></Section></Section><Section name="classifiers"><Title>Browsing Classifiers</Title></Section></Section><Section name="producingthecollection"><Title>Producing Your Collection</Title><Section name="thecreateview"><Title>The Create View</Title></Section><Section name="builderrors"><Title>Errors in collection building</Title></Section><Section name="expertbuilding"><Title>Create view in Expert mode</Title></Section></Section><Section name="formattingacollection"><Title>Customizing Your Collection's Appearance</Title><Section name="theformatview"><Title>The Format View</Title></Section><Section name="generalsettings"><Title>General</Title></Section><Section name="searchmetadatasettings"><Title>Search</Title></Section><Section name="formatstatements"><Title>Format Features</Title></Section><Section name="translatetext"><Title>Translate Text</Title></Section><Section name="xcollectionsearching"><Title>Cross-Collection Search</Title></Section><Section name="collectionspecificmacros"><Title>Collection Specific Macros</Title></Section><Section name="depositormetadatasettings"><Title>Depositor Metadata</Title></Section></Section><Section name="miscellaneous"><Title>Miscellaneous</Title><Section name="preferences"><Title>Preferences</Title></Section><Section name="fileassociations"><Title>File Associations</Title></Section><Section name="exporting"><Title>Exporting collections to other formats</Title></Section><Section name="exportingcollections"><Title>Exporting Collections to CD/DVD</Title></Section></Section></Document>
Index: /gli/trunk/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java	(revision 16679)
+++ /gli/trunk/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java	(revision 16680)
@@ -78,4 +78,6 @@
     /** The text translation manager. */
     static public TranslationView translation_manager;
+    /** A manager of configuring depositor metadata */ 
+    static public DepositorMetadataManager depositormetadata_manager;
     /** These mark what needs to happen when building a collection where ONLY design options have been changed.
         The build requirements of the higher numbers must include doing everything from the lower numbers. */
@@ -128,4 +130,5 @@
 	supercollection_manager = new SuperCollectionManager(collect_config.getSuperCollection());
 	searchmetadata_manager = new SearchMetadataManager();
+	depositormetadata_manager = new DepositorMetadataManager();
 	translation_manager = new TranslationView();
     if (Gatherer.GS3) {
@@ -160,4 +163,6 @@
 	supercollection_manager.destroy();
 	supercollection_manager = null;
+	depositormetadata_manager.destroy();
+	depositormetadata_manager = null;
 	translation_manager.destroy();
 	translation_manager = null;
@@ -178,4 +183,5 @@
 	language_manager.modeChanged(mode);
 	searchmetadata_manager.modeChanged(mode);
+	depositormetadata_manager.modeChanged(mode);
     }
 
Index: /gli/trunk/src/org/greenstone/gatherer/cdm/DepositorMetadataManager.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/cdm/DepositorMetadataManager.java	(revision 16680)
+++ /gli/trunk/src/org/greenstone/gatherer/cdm/DepositorMetadataManager.java	(revision 16680)
@@ -0,0 +1,527 @@
+/**
+ *#########################################################################
+ *
+ * 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.
+ *
+ * Author: John Thompson, Greenstone Digital Library, University of Waikato
+ *
+ * Copyright (C) 1999 New Zealand Digital Library Project
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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.cdm;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.util.ArrayList;
+
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+
+import org.greenstone.gatherer.Configuration;
+import org.greenstone.gatherer.Dictionary;
+import org.greenstone.gatherer.Gatherer;
+import org.greenstone.gatherer.collection.CollectionManager;
+import org.greenstone.gatherer.gui.DesignPaneHeader;
+import org.greenstone.gatherer.gui.GComboBox;
+import org.greenstone.gatherer.metadata.MetadataElement;
+import org.greenstone.gatherer.metadata.MetadataSet;
+import org.greenstone.gatherer.metadata.MetadataSetManager;
+import org.greenstone.gatherer.util.Utility;
+
+/**
+ * This manager implements the "Depositor Metadata" section in GLI Format Panel, where 
+ * users can customize which metadata elements will be used to describe an item when deposited in the Depositor.
+ *      
+ * @author Anna Huang, Greenstone Digital Library, University of Waikato
+ * @version 1.0
+ */
+public class DepositorMetadataManager {
+    /** Display controls of the element */
+    static private Dimension LABEL_SIZE = new Dimension(150, 15);
+    static private Dimension ROW_SIZE = new Dimension(400, 20);
+    
+    /** Available types, corresponds to the HTML input types */ 
+    static private String[] TYPEOPTIONS = new String[]{"text", "textarea"};
+    /** Default elements to be used in Depositor */
+    static private String DEFAULT_METADATA_ELEMENTS = "dc.Title, dc.Creator, dc.Description";
+    /** Definition attribute of a metadata element */ 
+    static private String DEFINITION = "definition";
+    
+    /** Display controls */
+    private Control controls;	
+    /** List of MetadataElementEntry objects, each represents a metadata element */
+    private ArrayList metadata_checklist_model = null;	
+    /** Collection configuration file manager */ 
+    private CollectionMetaManager collmeta_manager = CollectionDesignManager.collectionmeta_manager;
+    
+    public DepositorMetadataManager() {
+    }
+    
+    /** Destructor. */
+    public void destroy() {
+	if (controls != null) {
+	    controls.destroy();
+	    controls = null;
+	}
+	if(metadata_checklist_model != null) {
+	    metadata_checklist_model.clear();
+	    metadata_checklist_model = null;
+	}
+    }
+		
+    public Control getControls() {
+	if (controls == null) {
+	    controls = new DepositorControl();
+	}
+	return controls;
+    }
+	
+    /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
+     * @param mode the new mode as an int
+     */
+    public void modeChanged(int mode) {
+    }
+	
+    /**
+     * The implementation of this display control is similar to the <code>ArgumentConfiguration</code>, 
+     * where each component in the central panel is another JPanel component consists of a checkbox and a drop down list. 
+     */
+    private class DepositorControl
+	extends JPanel
+	implements Control {		
+		
+	private JPanel central_pane = null;
+
+	public DepositorControl() {
+	    super();
+
+	    JPanel header_panel = new DesignPaneHeader("CDM.GUI.DepositorMetadata", "depositormetadatasettings");
+			
+	    // load all possible metadata sets, and existing configuration
+	    buildModel();
+	    
+	    central_pane = new JPanel();
+	    central_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+	    central_pane.setLayout(new BoxLayout(central_pane, BoxLayout.Y_AXIS));	
+									
+	    // build the central pane, ie. create gui component for each metadata element 
+	    buildPane();		
+
+	    JPanel collection_checklist_pane = new JPanel();
+	    collection_checklist_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
+	    collection_checklist_pane.setLayout(new BorderLayout());
+	    collection_checklist_pane.add(new JScrollPane(central_pane), BorderLayout.CENTER);
+
+	    setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
+	    setLayout(new BorderLayout());
+	    add(header_panel, BorderLayout.NORTH);
+	    add(collection_checklist_pane, BorderLayout.CENTER);
+	}
+		
+	public void destroy() {
+	}
+
+	public void gainFocus() {
+	}
+		
+	public void loseFocus() {			
+	    StringBuffer converted_javascript = new StringBuffer();
+			
+	    // get currently selected metadata elements and create the javascript associative array variable
+	    if (metadata_checklist_model != null) {
+		int size = metadata_checklist_model.size();
+		for(int i = 0; i < size; i++) {				
+		    MetadataElementEntry entry = (MetadataElementEntry) metadata_checklist_model.get(i);
+					
+		    if (entry.isSelected()) {					
+			StringBuffer element = new StringBuffer();
+			element.append("{\"name\":\"").append(entry.name).append("\",");
+			element.append("\"label\":\"").append(entry.label).append("\",");
+			element.append("\"tooltip\":\"").append(entry.name).append(": ").append(entry.tooltip).append("\",");
+			element.append("\"type\":\"").append(entry.getType()).append("\"}");
+			if(converted_javascript.length() != 0) {
+			    converted_javascript.append(", ");
+			}
+			converted_javascript.append(element);
+			element = null;
+		    }				
+		}
+				
+		// if none of the elements were selected, use the default setting				
+		if (converted_javascript.length() == 0) {
+		    System.err.println("Error: DepositorMetadataMananger should have at least one selected metadata element.");
+		}
+
+		// save to the configuration file
+		CollectionMeta depositor_metadata_meta = collmeta_manager.getMetadatum("depositormetadata", true);
+		depositor_metadata_meta.setValue(converted_javascript.toString());			
+	    }		
+	}
+		
+	private void buildModel()
+	{
+	    metadata_checklist_model = new ArrayList();
+	    String current_coll_name = CollectionManager.getLoadedCollectionName();
+			
+	    // get the elements that have already been used in depositor
+	    // add the "depositormetadata" meta if not found in the configuration file
+	    CollectionMeta depositor_metadata_meta = collmeta_manager.getMetadatum("depositormetadata", true);			
+	    String selected_metadata_javascript = depositor_metadata_meta.getValue(true);
+			
+	    // load all MDSets in the collection, ie. .mds files in the collection's metadata directory
+	    String file_name = Gatherer.getCollectDirectoryPath() + File.separator + current_coll_name + File.separator + "metadata";
+	    ArrayList metadata_sets = MetadataSetManager.listMetadataSets(new File(file_name));
+	    
+	    // if the collection doesn't have a metadata directory, load all the MDSets in the global GLI/metadata directory 
+	    if (metadata_sets == null) {
+		file_name = org.greenstone.gatherer.gems.MetadataSetManager.getGLIMetadataDirectoryPath();
+		metadata_sets = MetadataSetManager.listMetadataSets(new File(file_name));
+	    } 
+			
+	    // always load the dc mds
+	    boolean found = false;
+	    for (int i = 0, j = metadata_sets.size(); i < j; i++) {
+		if (((MetadataSet) metadata_sets.get(i)).getNamespace().equals("dc")) {
+		    found = true;
+		    break;
+		}					
+	    }
+	    if (found == false) {
+		file_name = org.greenstone.gatherer.gems.MetadataSetManager.getGLIMetadataDirectoryPath();
+		file_name += "dublin.mds";
+		File dublin_mds_file = new File(file_name);
+		if (dublin_mds_file.exists()) {
+		    MetadataSetManager.loadMetadataSet(dublin_mds_file);					
+		    metadata_sets = MetadataSetManager.getMetadataSets();
+		}
+	    }			
+
+	    // unload the ex mds
+	    for (int i = 0, j = metadata_sets.size(); i < j; i++) {
+		if (((MetadataSet) metadata_sets.get(i)).getNamespace().equals("ex")) {
+		    metadata_sets.remove(i);
+		    break;
+		}
+	    }
+			
+	    if (metadata_sets == null) {
+		System.err.println("Error: DepositorMetadataMananger can't find any valid metadata set files.");
+		return;
+	    }			
+			
+	    // load all the metadata elements
+	    for (int i = 0, j = metadata_sets.size(); i < j; i++) {
+		MetadataSet metadata_set = (MetadataSet) metadata_sets.get(i);				
+		ArrayList elements = metadata_set.getMetadataSetElements(); 
+		
+		for (int k = 0; elements != null && k < elements.size(); k++) {
+		    MetadataElement element = (MetadataElement) elements.get(k);
+		    // all names are language independent at the moment. 
+		    MetadataElementEntry entry = new MetadataElementEntry (element.getFullName(), element.getName(), false);
+		    entry.setToolTip(element.getAttribute(DEFINITION, "en"));
+		    metadata_checklist_model.add(entry);
+		}
+	    }	
+	    
+	    if (!selected_metadata_javascript.equals("")) {
+		for (int i = 0, j = metadata_checklist_model.size(); i < j; i++) {
+		    MetadataElementEntry entry = (MetadataElementEntry) metadata_checklist_model.get(i);
+		    
+		    String temp = "\"name\":\"" + entry.name + "\"";
+		    if (selected_metadata_javascript.indexOf(temp) != -1) {
+			entry.setSelected(true);
+			entry.type = getValueFromJSAssociatedArray(selected_metadata_javascript, entry.name, "type");						
+		    }
+		    temp = null;
+		}	
+	    } else {				
+		// use default elements				
+		for (int i = 0, j = metadata_checklist_model.size(); i < j; i++) {
+		    MetadataElementEntry entry = (MetadataElementEntry) metadata_checklist_model.get(i);
+		    if (DEFAULT_METADATA_ELEMENTS.indexOf(entry.name) != -1) {
+			entry.setSelected(true);
+			entry.type = TYPEOPTIONS[0];
+		    }
+		}
+	    }					
+	}	
+	
+	private void buildPane() {
+	    // use different background color for two adjacent metadata sets
+	    String current_namespace = null;
+	    String current_bgcolor_name = null;
+	    for (int i = 0, j = metadata_checklist_model.size(); i < j; i++) {
+		MetadataElementEntry entry = (MetadataElementEntry) metadata_checklist_model.get(i);
+		
+		if (current_namespace == null) {
+		    current_namespace = entry.namespace;
+		    current_bgcolor_name = "coloring.collection_tree_background";
+		} else {
+		    if (!entry.namespace.equals(current_namespace)) {
+			current_namespace = entry.namespace;
+			current_bgcolor_name = (current_bgcolor_name == "coloring.collection_tree_background") ? "coloring.collection_heading_background" : "coloring.collection_tree_background";
+		    }
+		}			
+		
+		if (entry.getGUIControl() == null) {
+		    MetadataElementControl element_control = entry.initGUIControl(current_bgcolor_name);					
+		    central_pane.add(element_control, BorderLayout.NORTH);
+		}				
+	    }
+	    
+	}
+		
+	/**
+	 * Retrieve the value for the specified element in the given javascript associative array expression
+	 *  
+	 * @param text
+	 * @param identifier
+	 * @param elem_name
+	 * @return
+	 */
+	private String getValueFromJSAssociatedArray(String text, String identifier, String elem_name) {
+	    int p = text.indexOf(elem_name, text.indexOf(identifier));
+	    if (p == -1) {
+		return null;
+	    }
+	    p = text.indexOf("\":\"", p);
+	    if (p == -1) {
+		return null;
+	    }
+	    p += 3;
+			
+	    return text.substring(p, text.indexOf("\"", p));			
+	}
+    }
+	
+    private class MetadataElementControl extends JPanel {
+	
+	private JCheckBox enabled = null;
+	private JComponent value_control = null;		
+		
+	public MetadataElementControl (MetadataElementEntry entry, String background_color_name) {
+						
+	    String tip = "<html>" + entry.tooltip + "</html>";
+	    tip = Utility.formatHTMLWidth(tip, 80);
+	    
+	    setBackground(Configuration.getColor(background_color_name, false));
+	    setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
+	    setLayout(new BorderLayout());
+	    setPreferredSize(ROW_SIZE);
+			
+	    // the checkbox component
+	    enabled = new JCheckBox(entry.name);
+	    enabled.setSelected(entry.selected);
+	    enabled.setOpaque(false);
+	    enabled.setPreferredSize(LABEL_SIZE);
+	    enabled.setToolTipText(entry.tooltip);
+	    add(enabled, BorderLayout.WEST);
+			
+	    // the drop down list component
+	    ArrayList option_list = new ArrayList();
+	    for (int i = 0; i < TYPEOPTIONS.length; i++) {
+		option_list.add(TYPEOPTIONS[i]);
+	    }
+	    value_control = new GComboBox(option_list.toArray(), false, false);
+	    selectValue((JComboBox)value_control, entry.type); 
+	    value_control.setOpaque(true);			
+	    if (entry.selected) { 
+		value_control.setBackground(Color.white);
+		value_control.setEnabled(true);
+	    } else {
+		value_control.setBackground(Color.lightGray);
+		value_control.setEnabled(false);
+		value_control.setVisible(false);
+	    }							
+	    add(value_control, BorderLayout.CENTER);
+	    
+	    enabled.addActionListener(new EnabledListener(value_control));
+	}
+				
+	private boolean selectValue(JComboBox combobox, String target) {
+	    if (target == null) {
+		combobox.setSelectedIndex(0);
+		return false;
+	    }
+			
+	    for (int i = 0; i < combobox.getItemCount(); i++) {				
+		if (combobox.getItemAt(i).toString().equals(target)) {
+		    combobox.setSelectedIndex(i);
+		    return true;
+		}
+	    }
+	    return false;
+	}
+		
+	private class EnabledListener
+	    implements ActionListener {			
+	    private JComponent target = null;
+	    
+	    public EnabledListener(JComponent target) {
+		this.target = target;
+	    }
+	    
+	    public void actionPerformed(ActionEvent event) {
+		JCheckBox source = (JCheckBox)event.getSource();
+		
+		// check at least one of the elements should be ticked
+		checkTickedElements(source);
+				
+		// update the status of the drop-down list component associated with the current checkbox 
+		if (this.target == null) {
+		    return;
+		}				
+				
+		if(source.isSelected()) {
+		    target.setBackground(Color.white);
+		    target.setEnabled(true);
+		    target.setVisible(true);
+		}
+		else {
+		    target.setBackground(Color.lightGray);
+		    target.setEnabled(false);
+		    target.setVisible(false);
+		}				
+	    }
+			
+	    private void checkTickedElements(JCheckBox source) {
+		if (source.isSelected()) {
+		    return;
+		}
+				
+		boolean b = false;
+		for (int i = 0, j = metadata_checklist_model.size(); i < j; i++) {
+		    if (((MetadataElementEntry) metadata_checklist_model.get(i)).gui_object.enabled.isSelected()) {
+			b = true;
+			break;
+		    }
+		}
+				
+		// there must be at least one element selected in the list 
+		if (b == false) {
+		    Object[] options = {Dictionary.get("General.OK")};
+		    JOptionPane.showOptionDialog(Gatherer.g_man, Dictionary.get("CDM.DepositorMetadataManager.Warning"), Dictionary.get("General.Warning"), JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
+		    
+		    source.setSelected(true);
+		}
+	    }
+	}
+	
+    }
+	
+    private class MetadataElementEntry implements Comparable {
+	/** namespace, used to distinguish different metadata sets and use different colors when displaying */
+	String namespace = null;
+	/** identifier, with namespace */
+	String name = null;
+	/** language independent label, without namespace, used for display in the depositor web page, eg. Title */
+	String label = null;	
+	/** type of the element: text or textarea */
+	String type = null;
+	/** description of the element, used in web page */
+	String tooltip = null;		
+	/** whether current element is selected or not */
+	boolean selected ;
+	/** GUI component object associated with this element */ 
+	MetadataElementControl gui_object = null;
+		
+	/**
+	 * Constructor
+	 * @param name Language independent identifier of the element with namespace, eg. dc.Title
+	 * @param label Language independent label of the element, without namespace, eg. Title 
+	 * @param selected Whether the current element has been selected as depositor metadata element 
+	 */
+	public MetadataElementEntry(String name, String label, boolean selected) {
+	    this.name = name;
+	    this.label = label;
+	    this.selected = selected;
+	    
+	    if (name.indexOf(".") != -1) {
+		namespace = name.substring(0, name.indexOf("."));
+	    }
+	}
+		
+	/**
+	 * Initiate the <code>MetadataElementControl<code> GUI component object associated with this element, with the specified background color  
+	 * @param background_color_name System configured color name for the background, eg. "coloring.collection_heading_background", or "coloring.collection_tree_background"
+	 * @return the initialized component object
+	 */
+	public MetadataElementControl initGUIControl (String background_color_name) {
+	    gui_object = new MetadataElementControl(this, background_color_name);
+	    return gui_object;
+	}
+	
+	/**
+	 * Get the associated GUI component
+	 * @return
+	 */
+	public MetadataElementControl getGUIControl() {
+	    return gui_object;
+	}
+		
+	/**
+	 * Set selected
+	 * @param b
+	 */
+	public void setSelected(boolean b) {
+	    this.selected = b;
+	}
+		
+	public boolean isSelected() {
+	    return gui_object.enabled.isSelected();
+	}
+		
+	/**
+	 * Get the selected type for the element
+	 * @return type
+	 */
+	public String getType() {
+	    return ((JComboBox) gui_object.value_control).getSelectedItem().toString();
+	}
+		
+	public void setToolTip (String tip) {
+	    if (tip == null) {
+		tooltip = "";
+		return;
+	    }
+	    this.tooltip = tip;
+	}
+
+	public int compareTo(Object obj) {
+	    return compareTo((MetadataElementEntry) obj);
+	}
+		
+	public int compareTo(MetadataElementEntry obj) {
+	    return this.name.compareTo(obj.name);
+	}
+	
+    }
+    
+}
Index: /gli/trunk/src/org/greenstone/gatherer/gui/FormatPane.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/gui/FormatPane.java	(revision 16679)
+++ /gli/trunk/src/org/greenstone/gatherer/gui/FormatPane.java	(revision 16680)
@@ -70,5 +70,5 @@
             contents = new String []{ "CDM.GUI.General", "CDM.GUI.SearchMetadata", "CDM.GUI.Formats", "CDM.GUI.Translation" };
         } else {
-            contents = new String []{ "CDM.GUI.General", "CDM.GUI.SearchMetadata", "CDM.GUI.Formats", "CDM.GUI.Translation", "CDM.GUI.SuperCollection","CDM.GUI.Macros" };
+            contents = new String []{ "CDM.GUI.General", "CDM.GUI.SearchMetadata", "CDM.GUI.Formats", "CDM.GUI.Translation", "CDM.GUI.SuperCollection","CDM.GUI.Macros", "CDM.GUI.DepositorMetadata" };
         }
         JPanel side_panel = new JPanel ();
@@ -170,4 +170,7 @@
             return CollectionDesignManager.supercollection_manager.getControls ();
         }
+	if(type.equals ("CDM.GUI.DepositorMetadata")) {
+	    return CollectionDesignManager.depositormetadata_manager.getControls ();
+	}
         return null;
     }
Index: /gsdl/trunk/macros/deposit.dm
===================================================================
--- /gsdl/trunk/macros/deposit.dm	(revision 16679)
+++ /gsdl/trunk/macros/deposit.dm	(revision 16680)
@@ -16,4 +16,11 @@
 # collector
 _globallinks_ {_homelink_}
+
+# metadata fields that will be displayed in the step1 page, 
+# this is determined by the depositormetadata macro defined in the collection's collect.cfg
+_metadataconf_ {var DepositorMDFields = new Array();}
+
+# store any existing metadata values
+_cachedmetadatavalues_ {var CachedMDValues = new Array();}
 
 #######################################################################
@@ -146,9 +153,64 @@
 
 #here goes the "memorization" macros for each form field.  
-_di1md.dc.Title_ {_If_("_:cgiargdi1md.dc.Title_" eq  "_cgiargdi1md.dc.Title_",_cgiargdi1md.dc.Title_,)}
-_di1md.dc.Creator_ {_If_("_:cgiargdi1md.dc.Creator_" eq  "_cgiargdi1md.dc.Creator_",_cgiargdi1md.dc.Creator_,)}
-_di1md.dc.Description_ {_If_("_:cgiargdi1md.dc.Description_" eq  "_cgiargdi1md.dc.Description_",_cgiargdi1md.dc.Description_,)}
+#_di1md.Title_ {_If_("_:cgiargdi1md.Title_" eq  "_cgiargdi1md.Title_",_cgiargdi1md.Title_,)}
+#_di1md.Creator_ {_If_("_:cgiargdi1md.Creator_" eq  "_cgiargdi1md.Creator_",_cgiargdi1md.Creator_,)}
+#_di1md.Description_ {_If_("_:cgiargdi1md.Description_" eq  "_cgiargdi1md.Description_",_cgiargdi1md.Description_,)}
+#_di1md.Subject_ {_If_("_:cgiargdi1md.Subject_" eq "_cgiargdi1md.Subject_",_cgiargdi1md.Subject,)}
 
 _step1scriptextra_ {
+
+_metadataconf_
+_cachedmetadatavalues_
+
+function loadForm() \{
+
+	var formcontainer = document.getElementById('formcontainer');
+	
+	if (!formcontainer) \{
+		return;
+	\}
+	
+	for (i=0; i < DepositorMDFields.length; i++) \{
+		if (DepositorMDFields[i]==null) \{
+			continue;
+		\}
+		metadataField = DepositorMDFields[i];
+		
+		var labelCell = document.createElement("td");
+		labelCell.innerHTML = metadataField.label + ": ";
+		labelCell.setAttribute("title", metadataField.tooltip);							
+
+		var cachedValue;
+		if(CachedMDValues[0] !=null && CachedMDValues[0]["di1md." + metadataField.name])\{
+			cachedValue = CachedMDValues[0]["di1md." + metadataField.name];
+		\} else \{
+			cachedValue = "";
+		\}
+		
+		var inputObj; 
+		if (metadataField.type=="text") \{
+			inputObj = document.createElement("input");				
+			inputObj.setAttribute("type","text");			
+			inputObj.setAttribute("size","74");	
+			inputObj.setAttribute("value", cachedValue);
+		\} 
+		else if (metadataField.type=="textarea") \{
+			inputObj = document.createElement("textarea");				
+			inputObj.setAttribute("rows","5");
+			inputObj.setAttribute("cols", "40");
+			inputObj.innerHTML = cachedValue;
+		\}	
+		inputObj.setAttribute("name", "di1md."+ metadataField.name);		
+		
+		var inputCell = document.createElement("td");
+		inputCell.appendChild(inputObj);		
+								
+		var entry = document.createElement("tr");	
+		entry.appendChild(labelCell);
+		entry.appendChild(inputCell);
+		
+		formcontainer.appendChild(entry);
+	\}
+\}
 
 function check\_submit (gotopage) \{
@@ -157,4 +219,8 @@
   form.submit();
 \}
+
+if (window.addEventListener) window.addEventListener("load", loadForm, false);
+else if (window.attachEvent) window.attachEvent("onload", loadForm);
+
 }
 
@@ -165,4 +231,5 @@
 <input type=hidden name="e" value="_decodedcompressedoptions_">
 <input type=hidden name="p" value="_cgiargp_">
+
 
 <center>
@@ -178,26 +245,6 @@
 
 <!--input goes here-->
-<p><table>
-<tr>
-  <td>_textTitle_:</td>
-  <td> <input type=text name=di1md.dc.Title value="_di1md.dc.Title_" size=74></td>
-</tr>
-<tr>
-  <td>_textCreator_:</td>
-  <td><input type=text name=di1md.dc.Creator value = "_di1md.dc.Creator_" size=74></td>
-</tr>
-<tr>
-  <td>_textDescription_:</td>
-  <td> <textarea rows=5 cols=40 name=di1md.dc.Description>_di1md.dc.Description_</textarea></td>
-
-</tr>
-</table>
-
-<!--
-<BR>
-<BR>
-<p>_textDescription_: <textarea rows=5 cols=20 name=di1md.dc.Description>_di1md.dc.Description_</textarea></p>
-</ul>
--->
+<!--dynamic load the metadata elements as configured in the collection's collect.cfg-->
+<p><table id="formcontainer"></table>
 
 <div class="divbar">&nbsp;</div>
@@ -249,6 +296,6 @@
 
 #here goes the "memorization" macros for each form field.  
-#_di1_ {_If_("_:cgiargdi1md.dc.Title_" eq  "_cgiargdi1md.dc.Title_",_cgiargdi1md.dc.Title_,)}
-#_di1md.dc.Creator_ {_If_("_:cgiargdi1md.dc.Creator_" eq  "_cgiargdi1md.dc.Creator_",_cgiargdi1md.dc.Creator_,)}
+#_di1_ {_If_("_:cgiargdi1md.Title_" eq  "_cgiargdi1md.Title_",_cgiargdi1md.Title_,)}
+#_di1md.Creator_ {_If_("_:cgiargdi1md.Creator_" eq  "_cgiargdi1md.Creator_",_cgiargdi1md.Creator_,)}
 
 _step3scriptextra_ {
Index: /gsdl/trunk/runtime-src/src/recpt/depositoraction.cpp
===================================================================
--- /gsdl/trunk/runtime-src/src/recpt/depositoraction.cpp	(revision 16679)
+++ /gsdl/trunk/runtime-src/src/recpt/depositoraction.cpp	(revision 16680)
@@ -362,4 +362,43 @@
       args["di1lastpage"] = lastpage_textt;      
     }
+
+    // create cached metadata values
+    text_t cached_metadata_values = "";
+    cgiargsclass::const_iterator args_here = args.begin();
+    cgiargsclass::const_iterator args_end = args.end();
+    while (args_here != args_end) {
+      text_t args_name = (*args_here).first;
+      int prefix_len = macro_prefix.size();
+      text_t args_prefix = substr(args_name.begin(),args_name.begin()+prefix_len+3);
+
+      if (args_prefix == (macro_prefix+"md.")) {     
+	text_t args_val = args[args_name];
+	text_t args_suffix = substr(args_name.begin()+prefix_len+3,args_name.end()); 
+
+	text_tarray mdvalues;
+	splitchar (args_val.begin(), args_val.end(), ',', mdvalues);
+	int numvalues = mdvalues.size();
+
+	for (int i = 0; i < numvalues; ++i) {
+	  if (!mdvalues[i].empty()) {	      
+	    decode_cgi_arg(mdvalues[i]);
+
+	    if (cached_metadata_values == "") {
+	      cached_metadata_values = "var CachedMDValues = new Array(\\{";
+	    } else {
+	      cached_metadata_values += ",";
+	    }
+
+	    cached_metadata_values += "\"" + args_name + "\":\"" + args_val + "\"";
+	  }
+	}	
+      }
+      ++args_here;
+    }
+
+    if (cached_metadata_values != "") {
+      cached_metadata_values += "\\});";
+      args["cachedMDValues"] = cached_metadata_values;
+    }
   }
   return true;
@@ -420,5 +459,32 @@
   text_t depositorbar = "<table class=wizardbar border=0 cellspacing=4 cellpadding=0><tr>\n";
 
-  if(stepstring == "step") {
+  if(stepstring == "step") {   
+    // check configured metadata elements
+    if (args["metadataconf"] == "var DepositorMDFields = new Array();" || args["metadataconf"] == "") {
+      text_t cfgfile_name = filename_cat (collecthome, args[macro_prefix + "dirname"], "etc", "collect.cfg");
+      text_t cfgfile_content;
+      text_t metadata_str;
+      
+      if (read_file (cfgfile_name, cfgfile_content)) {
+	text_t::const_iterator here = cfgfile_content.begin();
+	text_t::const_iterator end = cfgfile_content.end();
+	while (here != end) {
+	  here = findchar (here, end, 'd');
+	  if (here == end) break;
+	  if ((here+17 < end) && (substr (here, here+17) == "depositormetadata")) {
+	    here = findchar (here, end, '"');
+	    if (here == end) break;	 
+	    text_t enddelimit = "\"\n";
+	    getdelimitstr (here+1, end, enddelimit, metadata_str);
+	    args["metadataconf"] = "var DepositorMDFields = new Array("+metadata_str+");";	    
+	  }
+	  ++here;
+	}
+      }
+
+      if (metadata_str == "") {
+	args["metadataconf"] = "var DepositorMDFields = new Array({\"name\":\"dc.Title\",\"label\":\"Title\",\"tooltip\":\"dc.Title: A name given to the resource.\",\"type\":\"text\"}, {\"name\":\"dc.Creator\",\"label\":\"Creator\",\"tooltip\":\"dc.Creator: An entity primarily responsible for making the content of the resource.\",\"type\":\"text\"}, {\"name\":\"dc.Description\",\"label\":\"Description\",\"tooltip\":\"dc.Description: An account of the content of the resource.\",\"type\":\"textarea\"});";
+      }
+    }
 
     here = depositor_page.begin();
@@ -444,5 +510,5 @@
       depositorbar += "<td>_icongreyarrow_</td>\n";
 
-    }
+    }    
 
     //the build and preview pages are always last
@@ -467,5 +533,12 @@
 
     depositorbar += "</tr></table>\n";
-    
+
+    // set the javascript so that the metadata form can read the existing values
+    if (args["cachedMDValues"] != "") {
+      disp.setmacro("cachedmetadatavalues", "depositor", args["cachedMDValues"]);
+    }
+    if (args["metadataconf"] != "") {
+      disp.setmacro("metadataconf", "depositor", args["metadataconf"]);
+    }    
   }
   
@@ -710,5 +783,5 @@
     metadata_file += "        <Description>\n";
 
-
+    
     cgiargsclass::const_iterator args_here = args.begin();
     cgiargsclass::const_iterator args_end = args.end();
@@ -735,5 +808,5 @@
 	    decode_cgi_arg(mdvalues[i]);
 
-	    metadata_file += "            <Metadata mode=\"accumulate\" name=\"";
+	    metadata_file += "            <Metadata mode=\"accumulate\" name=\"";	    
 	    metadata_file += args_suffix;
 	    metadata_file += "\">";
@@ -743,7 +816,5 @@
 	  }
 	}
-
-      }	
-
+      }	      
 
       ++args_here;
