Index: trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java
===================================================================
--- trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java	(revision 12664)
+++ trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java	(revision 12665)
@@ -76,6 +76,4 @@
  
     static final private Dimension SIZE = new Dimension(800,550);
-    static final private Dimension TREE_SIZE = new Dimension(250,550);
-    static final private Dimension TABLE_SIZE = new Dimension(550,200);
 
     private GEMS self = null;
@@ -84,5 +82,7 @@
     private DeleteMetadataSetPrompt delete_prompt;
     private NewMetadataSetPrompt new_prompt;   
-
+    
+    private JSplitPane splitPane = null;
+    private JSplitPane rightPane = null;
      
     /** Um, the size of the screen I'd guess. */
@@ -91,10 +91,10 @@
     private MetadataSetManager msm;
 
-    private MetadataElementTable meta_element_table; 
-    private LangDependElementTable lang_element_table; 
-
-    private MetadataSetTree  meta_set_tree;     
-
-    private  MetadataSetModel metadata_set_model;
+    private AttributeTable attribute_table;  // meta_element_table
+    private AttributeTable language_dependent_attribute_table; //lang_element_table; 
+
+    private MetadataSetTree meta_set_tree;     
+
+    private MetadataSetModel metadata_set_model;
 
     private boolean stand_alone = true;
@@ -125,6 +125,4 @@
 
     /** Constructor.
-     * @param set a MetadataSet that should be initially selected
-     * @param action a systematic action that should be performed
      */
     public GEMS(String gsdl_path, String metadata_path, boolean standalone, boolean new_set)
@@ -143,5 +141,5 @@
 			System.exit(0);
 		    }
-		    else{
+		    else {
 			notifyListeners();
 			setVisible(false);
@@ -161,32 +159,32 @@
         metadata_set_model.addObserver(meta_set_tree);
 
-	meta_element_table = new MetadataElementTable();
-	MetadataElementModel  mem= new MetadataElementModel();
-        mem.addMetadataElementListener((MetadataElementListener)meta_element_table);
-	meta_element_table.addAttributeListener(metadata_set_model);
-
-	lang_element_table = new LangDependElementTable();
-        mem.addMetadataElementListener((MetadataElementListener)lang_element_table);
-	lang_element_table.addAttributeListener(metadata_set_model);
+	attribute_table = new AttributeTable(false);
+	MetadataElementModel mem = new MetadataElementModel();
+        mem.addMetadataElementListener((MetadataElementListener)attribute_table);
+	attribute_table.addAttributeListener(metadata_set_model);
+
+	language_dependent_attribute_table = new AttributeTable(true);
+        mem.addMetadataElementListener((MetadataElementListener)language_dependent_attribute_table);
+	language_dependent_attribute_table.addAttributeListener(metadata_set_model);
 
       	MetadataSetInfo msti= new MetadataSetInfo();
-        msti.addMetadataSetListener((MetadataSetListener)meta_element_table);
-        msti.addMetadataSetListener((MetadataSetListener)lang_element_table);
+        msti.addMetadataSetListener((MetadataSetListener)attribute_table);
+        msti.addMetadataSetListener((MetadataSetListener)language_dependent_attribute_table);
         msti.setMetadataSetModel(metadata_set_model);
         
         open_prompt = new OpenMetadataSetPrompt(self,msm);
         open_prompt.addMetadataSetListener((MetadataSetListener)metadata_set_model);
-        open_prompt.addMetadataSetListener((MetadataSetListener)meta_element_table);        
-	open_prompt.addMetadataSetListener((MetadataSetListener)lang_element_table); 	
+        open_prompt.addMetadataSetListener((MetadataSetListener)attribute_table);        
+	open_prompt.addMetadataSetListener((MetadataSetListener)language_dependent_attribute_table); 	
 	
         delete_prompt = new DeleteMetadataSetPrompt(self,msm);
         delete_prompt.addMetadataSetListener((MetadataSetListener)metadata_set_model); 
-        delete_prompt.addMetadataSetListener((MetadataSetListener)meta_element_table);
-	delete_prompt.addMetadataSetListener((MetadataSetListener)lang_element_table);
+        delete_prompt.addMetadataSetListener((MetadataSetListener)attribute_table);
+	delete_prompt.addMetadataSetListener((MetadataSetListener)language_dependent_attribute_table);
 	
         new_prompt = new NewMetadataSetPrompt(self,msm);
         new_prompt.addMetadataSetListener((MetadataSetListener)metadata_set_model); 
-        new_prompt.addMetadataSetListener((MetadataSetListener)meta_element_table);
-        new_prompt.addMetadataSetListener((MetadataSetListener)lang_element_table);
+        new_prompt.addMetadataSetListener((MetadataSetListener)attribute_table);
+        new_prompt.addMetadataSetListener((MetadataSetListener)language_dependent_attribute_table);
   
 
@@ -199,11 +197,10 @@
 	}
 
+	// the set tree
         JScrollPane treePane = new JScrollPane(meta_set_tree);
-        treePane.setPreferredSize(TREE_SIZE);
-
-	JScrollPane tablePane = new JScrollPane(meta_element_table);
-        tablePane.setPreferredSize(TABLE_SIZE);
-
-        JScrollPane langTablePane =  new JScrollPane(lang_element_table);
+	// the language independent attributes
+	JScrollPane tablePane = new JScrollPane(attribute_table);
+	// the language dependent attributes
+	JScrollPane langTablePane =  new JScrollPane(language_dependent_attribute_table);
 
 
@@ -227,25 +224,25 @@
         leftPane.add(treePane,BorderLayout.CENTER);  
 	leftPane.add(buttonPane,BorderLayout.SOUTH);  
-
-	// Initialise popup menus
-	createAttributePopupMenu();
-	createElementPopupMenu();
-	createLanguageDependAttributePopupMenu();
          
-	JLabel  selected_language_label = new JLabel(Dictionary.get("GEMS.SelecedLanguage"));
+	JLabel selected_language_label = new JLabel(Dictionary.get("GEMS.SelectedLanguage"));
 	selected_language_label.setOpaque(true);
         
-        JComboBox language_combo = new JComboBox(new Vector(msm.getLanguageList()));
+	Vector language_vector = new Vector(msm.getLanguageList());
+        language_vector.add(0, Dictionary.get("GEMS.Language"));
+	JComboBox language_combo = new JComboBox(language_vector);
+	
 	language_combo.addActionListener(new ActionListener(){
 		public void actionPerformed(ActionEvent e){
 		    JComboBox language_combo = (JComboBox) e.getSource();
 		    String langInfo = (String)language_combo.getSelectedItem(); 
-                    String lang = langInfo.split("\\s")[0];     		    
-		    lang_element_table.languageSelected(lang);
+		    if (!langInfo.equals(Dictionary.get("GEMS.Language"))) {
+			String lang = langInfo.split("\\s")[0];     		    
+			language_dependent_attribute_table.addNewLanguage(lang);
+		    }
 		}
 
 	    });      
 
-       	JLabel  language_label = new JLabel(Dictionary.get("GEMS.LanguageDependent"));
+       	JLabel language_label = new JLabel(Dictionary.get("GEMS.LanguageDependent"));
 	language_label.setOpaque(true);
       
@@ -257,19 +254,22 @@
 
         JPanel languagePane =  new JPanel(new BorderLayout(5,5));
+	languagePane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
 	languagePane.add(language_label,BorderLayout.NORTH);  
         languagePane.add(selectLangPane,BorderLayout.CENTER);        
 
 
-        JPanel languageAttributePane =  new JPanel(new BorderLayout(5,5));
+        JPanel languageAttributePane =  new JPanel(new BorderLayout());
 	languageAttributePane.add(languagePane,BorderLayout.NORTH);  
         languageAttributePane.add(langTablePane,BorderLayout.CENTER);        
 
-
-        JPanel rightPane =  new JPanel(new BorderLayout(5,5));
-	rightPane.add(tablePane,BorderLayout.NORTH);  
-        rightPane.add(languageAttributePane,BorderLayout.CENTER); 
-
-	JSplitPane splitPane =  new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftPane,rightPane); 	
-                                    
+	JLabel attribute_label = new JLabel(Dictionary.get("GEMS.Attribute_Table"));
+	attribute_label.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+	JPanel mainAttributePane = new JPanel(new BorderLayout());
+	mainAttributePane.add(attribute_label, BorderLayout.NORTH);
+	mainAttributePane.add(tablePane, BorderLayout.CENTER);
+	
+	rightPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,mainAttributePane,languageAttributePane);
+	
+	splitPane =  new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftPane,rightPane); 	
 	getContentPane().add(splitPane,BorderLayout.CENTER);
 
@@ -279,4 +279,9 @@
     }
 
+    public void setVisible(boolean visible) {
+	super.setVisible(visible);
+	rightPane.setDividerLocation(0.3);
+    }
+    
     public void displayMetadataSet(String metadata_path){
 	open_prompt.openMetadataSet(metadata_path);
@@ -312,67 +317,5 @@
 	mem.removeAllMetadataElementListeners();
     }
-
-
-   public void createAttributePopupMenu() {
-        JMenuItem menuItem;
-
-        //Create the popup menu.
-        JPopupMenu popup = new JPopupMenu();
-        menuItem = new JMenuItem(Dictionary.get("GEMS.Popup.AddAttribute"));
-        menuItem.addActionListener(meta_element_table);
-        menuItem.setActionCommand(GEMSConstants.ADD_ATTRIBUTE);
-        popup.add(menuItem);
-        menuItem = new JMenuItem(Dictionary.get("GEMS.Popup.DeleteAttribute"));
-        menuItem.addActionListener(meta_element_table);
-	menuItem.setActionCommand(GEMSConstants.DELETE_ATTRIBUTE);
-        popup.add(menuItem);
-
-        //Add listener to the text area so the popup menu can come up.
-        MouseListener popupListener = new PopupListener(popup);
-        meta_element_table.addMouseListener(popupListener);
-               
-    }
-
-  public void createLanguageDependAttributePopupMenu() {
-        JMenuItem menuItem;
-
-        //Create the popup menu.
-        JPopupMenu popup = new JPopupMenu();
-        //menuItem = new JMenuItem(Dictionary.get("GEMS.Popup.AddAttribute"));
-        //menuItem.addActionListener(lang_element_table);
-        //menuItem.setActionCommand(GEMSConstants.ADD_ATTRIBUTE);
-        //popup.add(menuItem);
-        menuItem = new JMenuItem(Dictionary.get("GEMS.Popup.DeleteAttribute"));
-        menuItem.addActionListener(lang_element_table);
-	menuItem.setActionCommand(GEMSConstants.DELETE_ATTRIBUTE);
-        popup.add(menuItem);
-
-        //Add listener to the text area so the popup menu can come up.
-        MouseListener popupListener = new PopupListener(popup);
-        lang_element_table.addMouseListener(popupListener);
-         
-    }
-
-
-
-      public void createElementPopupMenu() {
-        JMenuItem menuItem;
-	//Create the popup menu.
-        JPopupMenu popup = new JPopupMenu();
-        menuItem = new JMenuItem(Dictionary.get("GEMS.Popup.AddElement"));
-        menuItem.addActionListener(meta_set_tree);
-        menuItem.setActionCommand(GEMSConstants.ADD_ELEMENT);
-        popup.add(menuItem);
-        menuItem = new JMenuItem(Dictionary.get("GEMS.Popup.DeleteElement"));
-        menuItem.addActionListener(meta_set_tree);
-	menuItem.setActionCommand(GEMSConstants.DELETE_ELEMENT);
-        popup.add(menuItem);
-	
-        //Add listener to the text area so the popup menu can come up.
-        MouseListener popupListener = new PopupListener(popup);
-        meta_set_tree.addMouseListener(popupListener); 
-        
-      }
- 
+    
     public void windowGainedFocus(WindowEvent e) {
 	//System.out.println("windowGainedFocus.");
@@ -397,4 +340,5 @@
 	public JMenuItem file_new    = null;
 	public JMenuItem file_open   = null;
+	public JMenuItem file_close   = null;
 	public JMenuItem file_save   = null;
 	public JMenuItem edit_copy   = null;
@@ -409,5 +353,5 @@
 	    file.setText(Dictionary.get("Menu.File"));
 	    
-	    file_exit = new JMenuItem(Dictionary.get("Menu.File_Close"));
+	    file_exit = new JMenuItem(Dictionary.get("Menu.File_Exit"));
 	    file_exit.addActionListener(this);
 	    
@@ -418,4 +362,7 @@
 	    file_open.addActionListener(this);
 	    
+	    file_close = new JMenuItem(Dictionary.get("Menu.File_Close"));
+	    file_close.addActionListener(this);
+
 	    file_save = new JMenuItem(Dictionary.get("Menu.File_Save"));
 	    file_save.addActionListener(this);
@@ -430,9 +377,10 @@
 	    file.add(file_new);
 	    file.add(file_open);
+	    file.add(file_close);
 	    file.add(file_save);
             file.add(file_delete);
 	    file.add(new JSeparator());
             //file.add(file_preferences);
-            file.add(new JSeparator());
+            //file.add(new JSeparator());
 	    file.add(file_exit);
             
@@ -481,4 +429,8 @@
 	    }
 
+	    // File -> Close
+	    if (event_source == file_close) {
+		
+	    }
               // File -> Delete
 	    if (event_source == file_delete) {               
@@ -561,91 +513,3 @@
     }
 
-
-   
- class PopupListener extends MouseAdapter {
-        JPopupMenu popup;
-
-        PopupListener(JPopupMenu popupMenu) {
-            popup = popupMenu;
-        }
-
-        public void mousePressed(MouseEvent e) {
-            maybeShowPopup(e);
-        }
-
-        public void mouseReleased(MouseEvent e) {
-            maybeShowPopup(e);
-        }
-
-        private void maybeShowPopup(MouseEvent e) {
-            Component source = (Component)e.getSource();
-            boolean show = false;
-
-	    if (source instanceof JTable){
-                show = true;
-		JTable table = (JTable)source;
-		JMenuItem item = null;
-                if (table.getSelectedRow() !=-1){
-		    
-		    if(popup.getComponentCount() >1){
-			item = (JMenuItem)popup.getComponent(1);
-		    }
-		    else{
-			item = (JMenuItem)popup.getComponent(0);
-		    } 
-		 
-		    item.setEnabled(true);
-		}
-		else{//disable the delete item if no row is selected
-		    if(popup.getComponentCount() >1){
-			item = (JMenuItem)popup.getComponent(1);
-		    }
-		    else{
-			item = (JMenuItem)popup.getComponent(0);
-		    }
-		    item.setEnabled(false);
-		}
-	    }              
-
-            if (source instanceof JTree){
-		
-		JTree tree = (JTree)source;
-		TreePath tse = tree.getSelectionPath();
-		if (tse ==null) return;
-		DefaultMutableTreeNode snode= (DefaultMutableTreeNode)tse.getLastPathComponent();
-			  
-		Object data = snode.getUserObject();
-                // don't allow the root element deletion	      
-		if (data instanceof MetadataElementModel){                
-		    JMenuItem item = (JMenuItem)popup.getComponent(1);
-                    item.setEnabled(true);
-		}
-		else{
-		    JMenuItem item = (JMenuItem)popup.getComponent(1);
-                    item.setEnabled(false);
-		}
-                
-		
-		// don't allow to add elements two levels deep	      
-		if (tse.getPath().length > 2){                
-		    JMenuItem item = (JMenuItem)popup.getComponent(0);
-                    item.setEnabled(false);
-		}
-		else{
-		    JMenuItem item = (JMenuItem)popup.getComponent(0);
-                    item.setEnabled(true);
-		}
-
-
-		show = true;
-	    }              
-
-            
-
-            if (e.isPopupTrigger() && show) {
-                popup.show(e.getComponent(),
-                           e.getX(), e.getY());
-            }
-        }
-   }
 }
