Index: trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java
===================================================================
--- trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java	(revision 8782)
+++ trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java	(revision 8793)
@@ -57,11 +57,11 @@
 import org.greenstone.gatherer.Dictionary;
 import org.greenstone.gatherer.GetOpt;
+import org.greenstone.gatherer.cdm.*;
 import org.greenstone.gatherer.gui.GComboBox;
 import org.greenstone.gatherer.gui.GLIButton;
+import org.greenstone.gatherer.gui.HelpFrame;
 import org.greenstone.gatherer.gui.ModalDialog;
 import org.greenstone.gatherer.gui.NonWhitespaceField;
 import org.greenstone.gatherer.gui.TransformCharacterTextField;
-import org.greenstone.gatherer.gui.HelpFrame;
-import org.greenstone.gatherer.cdm.*;
 import org.greenstone.gatherer.util.Codec;
 import org.greenstone.gatherer.util.Utility;
@@ -84,6 +84,8 @@
     static final private Dimension ADD_FILE_SIZE = new Dimension(400,125);
     static final private Dimension ADD_SET_SIZE = new Dimension(400,150);
+    static final private Dimension OPEN_SETS_SIZE = new Dimension(400,135);
     static final private Dimension ADD_OR_EDIT_ATTRIBUTE_SIZE = new Dimension(600,325);
     static final private Dimension ADD_OR_EDIT_VALUE_SIZE = new Dimension(600,440);
+    
     static final private Dimension COMPONENT_SIZE = new Dimension(300,30);
     static final private Dimension SIZE = new Dimension(800,480);
@@ -115,4 +117,5 @@
     /** A reference to ourselves so our inner classes can dispose of us. */
     private GEMS self = null;
+    private String gsdl_path = null;
     private int current_attribute = -1;
     private int current_attribute_type = -1;
@@ -189,5 +192,8 @@
 	// Load configuration file
 	try {
+           
 	    config = new Configuration(go.gsdl_path, null, null);
+        
+           
 	}
 	catch (Exception exception) {
@@ -195,5 +201,5 @@
 	}
         GEMS GEMS;
-	GEMS = new GEMS();
+	GEMS = new GEMS(go.gsdl_path);
     }
 
@@ -203,10 +209,11 @@
      * @param action a systematic action that should be performed
      */
-    public GEMS()
+    public GEMS(String gsdl_path)
     {
 	this.dialog_options = new String[2];
 	this.screen_size = config.screen_size;
 	this.self = this;
-
+        this.gsdl_path = gsdl_path;
+        
 	// Initialise some common images
 	Utility.initImages(this);
@@ -731,15 +738,15 @@
 	    // File -> Open
 	    if (event_source == file_open) {
-		JFileChooser metadata_set_file_chooser = new JFileChooser(new File(Utility.METADATA_DIR));
-		metadata_set_file_chooser.setFileFilter(new MetadataSetFileFilter());
-		if (metadata_set_file_chooser.showDialog(this, Dictionary.get("General.Open")) == JFileChooser.APPROVE_OPTION) {
-		    MetadataSet metadata_set = msm.loadMetadataSet(metadata_set_file_chooser.getSelectedFile());
-		    // Update tree
-                    //only update tree if the metadata_set return is not null(it will be null if set is already
-                    //opened-Attila - oct 19 0 4
-                    if(metadata_set != null) {
-                        model.add(null, metadata_set, GEMSNode.SET);
-                    }
-		}
+                
+                //we first launch the dialog to determine where the jfilechooser should be opened
+                //ie: for collection specific sets - attila dec10-04
+                String set_directory = Utility.METADATA_DIR;
+                
+                SetSelectionDialog m = new SetSelectionDialog();
+                m.show();
+                    
+                //once we have clicked 'ok' on the jdialog above, then we should have
+                //the directory pointer in string set_directory...and pass it to the jfilechoose constru
+       
                
 		return;
@@ -858,4 +865,38 @@
 
 
+    private class ActionTask
+	extends Thread {
+	private int action;
+	public ActionTask(int action) {
+	    this.action = action;
+	}
+	public void run() {
+	    boolean complete = false;
+	    while(!complete) {
+		if(self.isVisible()) {
+		    switch(action) {
+		    case ADD_SET:
+			add_set_action_listener.actionPerformed(new ActionEvent(this, 0, "Blarg!"));
+			break;
+		    case REMOVE_SET:
+			if(!mds_tree.isSelectionEmpty()) {
+			    remove_set_action_listener.actionPerformed(new ActionEvent(this, 0, "Blarg!"));
+			}
+			break;
+		    }
+		    complete = true;
+		}
+		else {
+		    try {
+			synchronized(this) {
+			    wait(100);
+			}
+		    }
+		    catch(Exception exception) {
+		    }
+		}
+	    }
+	}
+    }
     //callback method
      protected void processWindowEvent(WindowEvent evt){
@@ -1107,5 +1148,8 @@
                 language_box.addItem(languagecodes.get(p).toString());
             }
-            
+           
+           String code = Configuration.getLanguage();
+           language_box.setSelectedItem(code);
+           //System.out.println(code);
         }
 	/** Any implementation of ActionListener must include this method so that we can be informed when an action as occured on our registered component, allowing us to add a new attribute to the selected set or element.
@@ -1122,4 +1166,6 @@
           //allow user to choose language when they create attr
           
+      
+            
             
           if(source == popupListener.menuAddAttributeAttribute) {  
@@ -2066,5 +2112,171 @@
 	}
     }
+	////
+    private class SetSelectionDialog
+	extends ModalDialog
+	implements ActionListener {
+	private JButton cancel_button = null;
+	private JButton ok_button = null;
+	//private JTextField name_field = null;
+	//private JTextField namespace_field = null;
+        private JComboBox existingSetJComboBox = new JComboBox();
+            
+	public SetSelectionDialog() {
+	    super(self);
+	    setModal(true);
+	    setSize(OPEN_SETS_SIZE);
+	    Dictionary.setText(this, "Open Sets");
+
+	    // Creation
+	    JPanel content_pane = (JPanel) getContentPane();
+	    content_pane.setBackground(config.getColor("coloring.collection_heading_background", false));
+	    JPanel center_pane = new JPanel();
+	    center_pane.setOpaque(false);
+
+	
+	    JPanel boxes_pane = new JPanel();
+
+	    JPanel button_pane = new JPanel();
+	    button_pane.setOpaque(false);
+
+	    ok_button = new GLIButton();
+	    ok_button.setMnemonic(KeyEvent.VK_O);
+	    Dictionary.setBoth(ok_button, "General.OK", "General.OK_Tooltip");
+	    cancel_button = new GLIButton();
+	    cancel_button.setMnemonic(KeyEvent.VK_C);
+	    Dictionary.setBoth(cancel_button, "General.Cancel", "General.Pure_Cancel_Tooltip");
+	    TextFieldEnabler ok_button_enabler = new TextFieldEnabler(ok_button);
+
+	    // Connection
+	    cancel_button.addActionListener(this);
+	    ok_button.addActionListener(this);
+	   // ok_button_enabler.add(name_field);
+	   // ok_button_enabler.add(namespace_field);
+
+	    // Layout
 	 
+           // label_pane.add
+	  //  boxes_pane.setLayout(new GridLayout(2,1,0,5));
+            boxes_pane.setLayout(new GridLayout(4,1));
+	  //  boxes_pane.add(name_field);
+	   // boxes_pane.add(namespace_field);
+            
+            JLabel inheritJLabel = new JLabel(); 
+            Dictionary.setText(inheritJLabel, "GEMS.inheritMetadataSet");
+	   
+            //label_pane.add(inheritJLabel);
+	    
+            
+            //add inherit metadata set functionality
+           // String[] s = msm.getSets().toArray();
+            
+          //JComboBox existingSetJComboBox = new JComboBox(new String(msm.getSetsForInherit().toArray()));
+           
+            int getSetsLen = msm.getSets().toArray().length;
+            Vector theSets = msm.getSets();
+          //  System.out.println(Configuration.gsdl_path);
+            File[] col_dir = new File(Configuration.gsdl_path + "/collect").listFiles();
+            
+            existingSetJComboBox.addItem("Default Metadata Sets                                                                                                                        #% " + Configuration.gsdl_path + "gli/metadata");
+                
+            for(int k = 0; k < col_dir.length; k++){
+                //MetadataSet ms = (MetadataSet)theSets.elementAt(k);
+                
+                  if(col_dir[k].isDirectory() && col_dir[k].getName().compareTo("CVS") != 0) {
+                    
+                       File metadir = new File(col_dir[k].toString() + "/metadata");
+                    if(metadir.exists())   
+                        existingSetJComboBox.addItem(new String(col_dir[k].getName() + " Collection Sets                                                                                                     #% " + col_dir[k].toString() + "/metadata"));
+                 
+                  }
+                  
+              //  existingSetJComboBox.addItem(new String(ms.getName() + "                                                                             #% " + ms.getFile().toString()));
+                
+            }
+            //add sets to existingSetJComboBox
+            
+            existingSetJComboBox.setSelectedIndex(0);
+            //String tempstr = new String();
+            JLabel dummyl = new JLabel();
+            Dictionary.setText(dummyl, "GEMS.Add_Set.No_Inherit");
+            
+            
+            
+            //existingSetJComboBox.addItem("Do not inherit");
+           // existingSetJComboBox.setSelectedIndex(getSetsLen);
+            boxes_pane.add(new JLabel("Select which group of metadata sets you wish to edit:\n\n\n\n"));
+            boxes_pane.add(new JLabel("\n"));
+            boxes_pane.add(existingSetJComboBox);
+            boxes_pane.add(new JLabel("\n"));
+	   // center_pane.setLayout(new BorderLayout(5,0));
+	  //  center_pane.add(label_pane, BorderLayout.WEST);
+	  //  center_pane.add(boxes_pane, BorderLayout.CENTER);
+
+	   // button_pane.setLayout(new GridLayout(1,3,0,5));
+            button_pane.setLayout(new GridLayout(1,3,0,5));
+	    button_pane.add(ok_button);
+	    button_pane.add(cancel_button);
+           
+            
+	    content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+	    content_pane.setLayout(new BorderLayout());
+	    content_pane.add(boxes_pane, BorderLayout.CENTER);
+	    content_pane.add(button_pane, BorderLayout.SOUTH);
+         
+	    setLocation((config.screen_size.width - ADD_SET_SIZE.width) / 2, (config.screen_size.height - ADD_SET_SIZE.height) / 2);
+	}
+	/** Any implementation of ActionListener must include this method so that we can be informed when an action as occured on our registered component, allowing us to
+	 * @param event An <strong>ActionEvent</strong> containing information about the event.
+	 */
+   
+	public void actionPerformed(ActionEvent event) {
+	    Object source = event.getSource();
+            
+            
+          // if(a_set_exists_with_this_namespace(namespace_field.getText()) == false){
+	    if(source == ok_button) {
+                //this code below handles whether we inherit from an existing set or not
+             
+               // String namespace_str = namespace_field.getText();
+		//String name_str = Codec.transform(Codec.transformUnicode(name_field.getText()), Codec.TEXT_TO_DOM);
+                String loc = (String) existingSetJComboBox.getSelectedItem();
+                
+                String [] whereto = loc.split("#%");
+                String set_directory = whereto[1].trim();
+                
+                //load the jfilechooser:
+                 
+		JFileChooser metadata_set_file_chooser = new JFileChooser(new File(set_directory));
+		metadata_set_file_chooser.setFileFilter(new MetadataSetFileFilter());
+		if (metadata_set_file_chooser.showDialog(this, Dictionary.get("General.Open")) == JFileChooser.APPROVE_OPTION) {
+		    MetadataSet metadata_set = msm.loadMetadataSet(metadata_set_file_chooser.getSelectedFile());
+		    // Update tree
+                    //only update tree if the metadata_set return is not null(it will be null if set is already
+                    //opened-Attila - oct 19 0 4
+                    if(metadata_set != null) {
+                        model.add(null, metadata_set, GEMSNode.SET);
+                    }
+		}
+                
+         
+                setVisible(false);
+            }
+	    else if(source == cancel_button) {
+		setVisible(false);
+	    }
+	    else {
+		//name_field.setText("");
+		setVisible(true);
+	    }
+	}
+		  
+	public void dispose() {
+	    cancel_button = null;
+	    ok_button = null;
+	    super.dispose();
+	}
+    }
+    
+    ////
     private class AddOrEditValueActionListener
 	extends ModalDialog
@@ -2768,5 +2980,5 @@
 	    menuAddSet = new JMenuItem();
             //Dictionary.setText(menuAddSet,"GEMS.Popup.menuAddSet");
-            Dictionary.setText(menuAddSet,"GEMS.Add_Set_Tooltip");
+            //Dictionary.setText(menuAddSet,"GEMS.Add_Set_Tooltip");
             
 	    menuRenameSet = new JMenuItem();
Index: trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java
===================================================================
--- trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java	(revision 8782)
+++ trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java	(revision 8793)
@@ -47,4 +47,5 @@
 import org.greenstone.gatherer.util.Utility;
 import org.greenstone.gatherer.collection.CollectionManager;
+import org.greenstone.gatherer.file.*;
 import org.greenstone.gatherer.util.XMLTools;
 import org.apache.xerces.parsers.*;
@@ -518,5 +519,5 @@
 			    //File value_file = new File(file, value_element.getName() + ".mdv");
 			    ///ystem.err.println("Saving value file: " + value_file.toString());
-			    //XMLTools.export(value_tree.getDocument(), value_file);
+			    //Utility.export(value_tree.getDocument(), value_file);
 			    // If this is a hierarchy element, write hierarchy file.
 			    //if(value_element.getNamespace().equals(MetadataSetManager.HIDDEN) || value_tree.isHierarchy()) {
