Index: trunk/gli/src/org/greenstone/gatherer/cdm/MetadataSetView.java
===================================================================
--- trunk/gli/src/org/greenstone/gatherer/cdm/MetadataSetView.java	(revision 12131)
+++ 	(revision )
@@ -1,370 +1,0 @@
-/**
- *#########################################################################
- *
- * 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.*;
-import java.awt.event.*;
-import java.io.File;
-import java.util.*;
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.filechooser.*;
-import org.greenstone.gatherer.Configuration;
-import org.greenstone.gatherer.DebugStream;
-import org.greenstone.gatherer.Dictionary;
-import org.greenstone.gatherer.Gatherer;
-import org.greenstone.gatherer.gui.DesignPaneHeader;
-import org.greenstone.gatherer.gui.GLIButton;
-import org.greenstone.gatherer.gui.MetadataElementListCellRenderer;
-import org.greenstone.gatherer.metadata.MetadataElement;
-import org.greenstone.gatherer.metadata.MetadataSet;
-import org.greenstone.gatherer.metadata.MetadataSetManager;
-import org.greenstone.gatherer.metadata.MetadataTools;
-import org.greenstone.gatherer.metadata.MetadataXMLFileManager;
-
-
-/** This class only knows how to produce a simple visual representation of the currently imported metadata sets. It is also read-only, so should be fairly straight forward.
- * @author John Thompson, Greenstone Digital Library, University of Waikato
- * @version 2.3d
- */
-public class MetadataSetView
-    extends DynamicListModel {
-
-    /** The visual contols used to review the metadata sets. */
-    private Control controls = null;
-    /** A reference to ourselves so our inner classes can refer to us. */
-    private DynamicListModel model = null;
-
-
-    public MetadataSetView()
-    {
-	model = this;
-
-	// Initialise the model
-	refreshModel();
-
-	// Build the controls
-	controls = new MetadataSetViewControls();
-    }
-
-
-    public void destroy()
-    {
-	controls.destroy();
-	controls = null;
-	model = null;
-    }
-
-
-    /** A method for retrieve the controls for this manager.
-     */
-    public Control getControls() {
-	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) {
-
-    }
-
-    public void refreshModel()
-    {
-	// Remove any metadata sets from the model that are no longer loaded
-	ArrayList loaded_metadata_sets = MetadataSetManager.getMetadataSets();
-	for (int i = size() - 1; i >= 0; i--) {
-	    MetadataSet metadata_set = (MetadataSet) get(i);
-	    if (loaded_metadata_sets.contains(metadata_set) == false) {
-		// System.err.println("Metadata set in list no longer loaded...removing.");
-		remove(i);
-	    }
-	}
-
-	// Add any metadata sets that are loaded but not in the model
-	for (int i = 0; i < loaded_metadata_sets.size(); i++) {
-	    MetadataSet loaded_metadata_set = (MetadataSet) loaded_metadata_sets.get(i);
-	    boolean in_model = false;
-	    for (int j = 0; j < size(); j++) {
-		MetadataSet metadata_set = (MetadataSet) get(j);
-		if (metadata_set.equals(loaded_metadata_set)) {
-		    in_model = true;
-		    break;
-		}
-	    }
-
-	    if (in_model == false) {
-		// System.err.println("Metadata set loaded but not in list...adding.");
-		addElement(loaded_metadata_set);
-	    }
-	}
-    }
-
-
-    /** This class creates and lays-out the various controls for reviewing the metadata sets, and their commands as they would appear in the collection configuration file. */
-    private class MetadataSetViewControls
-	extends JPanel
-	implements Control {
-	/** Adds a new set to the collection*/
-	private JButton add_button;
-	/** Will eventually launch GEMS for editing the selected set, for now just gives a message */
-	private JButton edit_button;
-	/** REmoves a set from the collection */
-	private JButton remove_button;
-	/** The label denoting the element list. */
-	private JLabel element_label = null;
-	/** The label denoting the set list. */
-	private JLabel set_label = null;
-	/** The list of elements for the choosen set. */
-	private JList element_list = null;
-	/** The list of sets in this collection. */
-	private JList set_list = null;
-	/** The panel onto which all other panels will be placed. */
-	private JPanel central_pane = null;
-	/** The panel onto which the element list will be placed. */
-	private JPanel element_pane = null;
-	/** The panel containing the set list. */
-	private JPanel set_pane = null;
-
-	private JScrollPane element_list_scroll_pane;
-
-	private MetadataElementListCellRenderer element_list_cell_renderer;
-	private MetadataSetListSelectionListener list_listener;
-
-	/* Constructor.
-	 * @see org.greenstone.gatherer.Dictionary
-	 * @see org.greenstone.gatherer.cdm.MetadataSetView.ListListener
-	 */
-	public MetadataSetViewControls()
-	{
-	    // Create visual components
-	    central_pane = new JPanel();
-	    element_label = new JLabel(Dictionary.get("CDM.MetadataSetManager.Elements"));
-	    element_label.setOpaque(true);
-	    
-	    element_list = new JList();
-	    element_list_scroll_pane = new JScrollPane();
-	    element_list_scroll_pane.setViewportView(element_list);
-	    element_list_cell_renderer = new MetadataElementListCellRenderer();
-	    element_list.setCellRenderer(element_list_cell_renderer);
-	    element_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-	    element_pane = new JPanel();
-
-	    JPanel header_pane = new DesignPaneHeader("CDM.GUI.MetadataSets", "metadatasets");
-	    set_label = new JLabel(Dictionary.get("CDM.MetadataSetManager.Sets"));
-	    set_label.setOpaque(true);
-	    
-	    set_list = new JList(model);
-	    set_list.setCellRenderer(new MetadataSetListCellRenderer());
-	    set_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-
-	    set_pane = new JPanel();
-
-	    JPanel button_pane = new JPanel();
-	    add_button = new GLIButton(Dictionary.get("CDM.MetadataSetManager.Add"), Dictionary.get("CDM.MetadataSetManager.Add_Tooltip"));
-	    add_button.setEnabled(true);
-	    
-	    edit_button = new GLIButton(Dictionary.get("CDM.MetadataSetManager.Edit"), Dictionary.get("CDM.MetadataSetManager.Edit_Tooltip"));
-	    edit_button.setEnabled(false);
-	    	    
-	    remove_button = new GLIButton(Dictionary.get("CDM.MetadataSetManager.Remove"), Dictionary.get("CDM.MetadataSetManager.Remove_Tooltip"));
-	    remove_button.setEnabled(false);
-	    
-	    list_listener = new MetadataSetListSelectionListener();
-
-	    // Add listeners
-	    add_button.addActionListener(new AddButtonListener());
-	    edit_button.addActionListener(new EditButtonListener());
-	    remove_button.addActionListener(new RemoveButtonListener());
-	    set_list.addListSelectionListener(list_listener);
-	    // Layout
-
-	    set_pane.setLayout(new BorderLayout());
-	    set_pane.add(set_label, BorderLayout.NORTH);
-	    set_pane.add(new JScrollPane(set_list), BorderLayout.CENTER);
-
-	    element_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
-	    element_pane.setLayout(new BorderLayout());
-	    element_pane.add(element_label, BorderLayout.NORTH);
-	    element_pane.add(element_list_scroll_pane, BorderLayout.CENTER);
-
-	    central_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
-	    central_pane.setLayout(new GridLayout(2,1));
-	    central_pane.add(set_pane);
-	    central_pane.add(element_pane);
-	    
-	    button_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
-	    button_pane.setLayout(new GridLayout(1,3,0,0));
-	    button_pane.add(add_button);
-	    button_pane.add(edit_button);
-	    button_pane.add(remove_button);
-
-	    setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
-	    setLayout(new BorderLayout());
-	    add(header_pane, BorderLayout.NORTH);
-	    add(central_pane, BorderLayout.CENTER);
-	    add(button_pane, BorderLayout.SOUTH);
-	}
-
-
-	public void destroy() { }
-
-
-	public void gainFocus()
-	{
-
-	    // If no current selection, select first available set
-	    if (set_list.isSelectionEmpty() && set_list.getModel().getSize() > 0) {
-		set_list.setSelectedIndex(0);
-		list_listener.valueChanged(new ListSelectionEvent(set_list, 0, 0, true));
-	    }
-	    if (!set_list.isSelectionEmpty()) {
-		edit_button.setEnabled(true);
-		remove_button.setEnabled(true);
-	    } else {
-		edit_button.setEnabled(false);
-		remove_button.setEnabled(false);
-	    }
-		
-	}
-
-
-	public void loseFocus() { }
-
-
-	/** Listens for clicks on the add button. */
-	private class AddButtonListener
-	    implements ActionListener {
-
-	    /** Called when the add button is clicked.
-	     * @param event an ActionEvent containing information about the mouse click
-	     */
-	    public void actionPerformed(ActionEvent event)
-	    {
-		JFileChooser chooser = new JFileChooser(new File(Gatherer.getGLIMetadataDirectoryPath()));
-		chooser.setFileFilter(new MetadataSet.MetadataSetFileFilter());
-		chooser.setDialogTitle(Dictionary.get("CDM.MetadataSetManager.Add"));
-		int return_val = chooser.showDialog(Gatherer.g_man, Dictionary.get("CDM.MetadataSetManager.Chooser.Add"));
-		if (return_val == JFileChooser.APPROVE_OPTION) {
-		    Gatherer.c_man.importMetadataSet(new MetadataSet(chooser.getSelectedFile()));
-		    refreshModel();
-
-		    // The metadata.xml files may possibly contain metadata for this newly added metadata set
-		    // Re-read all the metadata.xml files to account for this case
-		    MetadataXMLFileManager.clearMetadataXMLFiles();
-		    MetadataXMLFileManager.loadMetadataXMLFiles(new File(Gatherer.c_man.getCollectionImportDirectoryPath()));
-		}
-	    }
-	}
-
-
-	/** Listens for clicks on the edit button. */
-	private class EditButtonListener
-	    implements ActionListener {
-
-	    /** Called when the edit button is clicked.
-	     * @param event an ActionEvent containing information about the mouse click
-	     */
-	    public void actionPerformed(ActionEvent event)
-	    {
-		// do a pop up message
-		JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.MetadataSetManager.Edit_Message"), Dictionary.get("CDM.MetadataSetManager.Edit_Message_Title"), JOptionPane.INFORMATION_MESSAGE);
-
-	    }
-	}
-
-
-	private class MetadataSetListCellRenderer
-	    implements ListCellRenderer
-	{
-	    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
-	    {
-		DefaultListCellRenderer default_list_cell_renderer = new DefaultListCellRenderer();
-		JLabel list_cell_label = (JLabel) default_list_cell_renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
-
-		if (value instanceof MetadataSet) {
-		    MetadataSet metadata_set = (MetadataSet) value;
-		    String metadata_set_name = MetadataTools.getMetadataSetAttribute(metadata_set, "Name", Configuration.getLanguage(), "en");
-		    list_cell_label.setText("metadataset " + metadata_set.getNamespace() + " \"" + metadata_set_name + "\"");
-		}
-
-		return list_cell_label;
-	    }
-	}
-
-
-	private class MetadataSetListSelectionListener
-	    implements ListSelectionListener {
-
-	    public void valueChanged(ListSelectionEvent event)
-	    {
-		// Wait until we get a stable event
-		if (event.getValueIsAdjusting()) {
-		    return;
-		}
-
-		// Now we can process it
-		if (!set_list.isSelectionEmpty()) {
-		    MetadataSet metadata_set = (MetadataSet) set_list.getSelectedValue();
-		    element_list.setListData(new Vector(metadata_set.getMetadataSetElements()));
-  		    remove_button.setEnabled(true);
-		    edit_button.setEnabled(true);
-
-  		    // Finally check the directionality and scroll as necessary
-  		    JScrollBar scroll_bar = element_list_scroll_pane.getHorizontalScrollBar();
-  		    if (element_list_cell_renderer.getDirectionality() == Character.DIRECTIONALITY_RIGHT_TO_LEFT) {
-			scroll_bar.setValue(scroll_bar.getMaximum());
-  		    }
-  		    else {
-			scroll_bar.setValue(scroll_bar.getMinimum());
-		    }
-		}
-		else {
-		    remove_button.setEnabled(false);
-		    edit_button.setEnabled(false);
-		}
-	    }
-	}
-
-
-	/** Listens for clicks on the remove button. */
-	private class RemoveButtonListener
-	    implements ActionListener {
-
-	    /** Called when the remove button is clicked.
-	     * @param event an ActionEvent containing information about the mouse click
-	     */
-	    public void actionPerformed(ActionEvent event)
-	    {
-		MetadataSet metadata_set = (MetadataSet) set_list.getSelectedValue();
-		Gatherer.c_man.removeMetadataSet(metadata_set);
-		refreshModel();
-		element_list.setListData(new Vector());
-	    }
-	}
-    }
-}
