Index: trunk/gli/src/org/greenstone/gatherer/metadata/MetadataElement.java
===================================================================
--- trunk/gli/src/org/greenstone/gatherer/metadata/MetadataElement.java	(revision 10970)
+++ trunk/gli/src/org/greenstone/gatherer/metadata/MetadataElement.java	(revision 10971)
@@ -31,4 +31,5 @@
 import org.greenstone.gatherer.Configuration;
 import org.greenstone.gatherer.util.XMLTools;
+import org.greenstone.gatherer.util.StaticStrings;
 import org.w3c.dom.*;
 
@@ -41,5 +42,8 @@
     private Element metadata_element_element = null;
     private MetadataValueTreeModel metadata_value_tree_model = null;
-
+    /* this is true if the metadata element comes with a pre defined set of values */
+    private boolean predefined_values = false;
+    /* This restricts the user to only the predefined values */
+    private boolean restricted_values = false;
 
     public MetadataElement(String metadata_element_name_full, Element metadata_element_element)
@@ -48,7 +52,23 @@
 	this.metadata_element_element = metadata_element_element;
 	this.metadata_value_tree_model = new MetadataValueTreeModel(this);
-    }
-
-
+	if (metadata_element_element.getAttribute(StaticStrings.PREDEFINED_METADATA_ATTRIBUTE).equals("true")) {
+	    predefined_values = true;
+	    loadOptionList();
+	    if (metadata_element_element.getAttribute(StaticStrings.RESTRICTED_METADATA_ATTRIBUTE).equals("true")) {
+		// cant have restricted values if no predefined values
+		restricted_values = true;
+	    }
+	}
+    }
+	
+    // do this better
+    protected boolean loadOptionList() {
+	NodeList values = metadata_element_element.getElementsByTagName("Value");
+	for (int i=0; i<values.getLength(); i++) {
+	    String val = XMLTools.getValue(values.item(i));
+	    addMetadataValue(val);
+	}
+	return true;
+    }
     public MetadataValueTreeNode addMetadataValue(String metadata_value)
     {
@@ -170,4 +190,11 @@
     }
 
+    public boolean isPredefined() {
+	return predefined_values;
+    }
+
+    public boolean isRestricted() {
+	return restricted_values;
+    }
 
     public boolean isSubelement()
Index: trunk/gli/src/org/greenstone/gatherer/metadata/MetadataValueTableModel.java
===================================================================
--- trunk/gli/src/org/greenstone/gatherer/metadata/MetadataValueTableModel.java	(revision 10970)
+++ trunk/gli/src/org/greenstone/gatherer/metadata/MetadataValueTableModel.java	(revision 10971)
@@ -220,7 +220,21 @@
 	Gatherer.g_man.wait(true);
 
+	
+	// Check for a restricted metadata element
+	MetadataElement metadata_element = metadata_value_table_entry.getMetadataElement();
+	if (!new_metadata_value.equals("") && metadata_element.isRestricted()) {
+	    if (metadata_element.getMetadataValueTreeNode((String)new_metadata_value)==null) {
+		WarningDialog dialog = new WarningDialog("warning.InvalidMetadata", "InvalidMetadata.Title", Dictionary.get("InvalidMetadata.Message"), null, false);
+		int dialog_result = dialog.display();
+		dialog.dispose();
+		Gatherer.g_man.wait(false);
+		return;
+		
+	    }
+	}
+	
 	// Metadata value added
-	if (old_metadata_value.equals("") && !new_metadata_value.equals("")) {
- 	    // If we're adding metadata to folders display the warning
+	if (old_metadata_value.equals("") && !new_metadata_value.equals("")) {    
+	    // If we're adding metadata to folders display the warning
  	    if (!file_nodes[0].isLeaf()) {
  		WarningDialog dialog = new WarningDialog("warning.DirectoryLevelMetadata", "DirectoryLevelMetadata.Title", Dictionary.get("DirectoryLevelMetadata.Message"), null, true);
@@ -233,5 +247,4 @@
  	    }
 
-	    MetadataElement metadata_element = metadata_value_table_entry.getMetadataElement();
 	    MetadataValueTreeNode metadata_value_tree_node = metadata_element.addMetadataValue((String) new_metadata_value);
 	    MetadataValue metadata_value = new MetadataValue(metadata_element, metadata_value_tree_node);
@@ -247,5 +260,4 @@
 	// Metadata value replaced
 	else {
-	    MetadataElement metadata_element = metadata_value_table_entry.getMetadataElement();
 	    MetadataValueTreeNode metadata_value_tree_node = metadata_element.addMetadataValue((String) new_metadata_value);
 	    MetadataValue metadata_value = new MetadataValue(metadata_element, metadata_value_tree_node);
