Index: unk/gli/src/org/greenstone/gatherer/gui/CollectionPane.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gui/CollectionPane.java	(revision 6835)
+++ 	(revision )
@@ -1,810 +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.
- *
- * <BR><BR>
- *
- * Author: John Thompson, Greenstone Digital Library, University of Waikato
- *
- * <BR><BR>
- *
- * Copyright (C) 1999 New Zealand Digital Library Project
- *
- * <BR><BR>
- *
- * 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.
- *
- * <BR><BR>
- *
- * 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.
- *
- * <BR><BR>
- *
- * 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.gui;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.io.*;
-import java.util.*;
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.tree.*;
-import org.greenstone.gatherer.Configuration;
-import org.greenstone.gatherer.Dictionary;
-import org.greenstone.gatherer.Gatherer;
-import org.greenstone.gatherer.file.FileNode;
-import org.greenstone.gatherer.file.FileOpenActionListener;
-import org.greenstone.gatherer.file.FileQueue;
-import org.greenstone.gatherer.file.FileSystemModel;
-import org.greenstone.gatherer.gui.Filter;
-import org.greenstone.gatherer.gui.GComboBox;
-import org.greenstone.gatherer.gui.GLIButton;
-import org.greenstone.gatherer.gui.tree.DragTree;
-import org.greenstone.gatherer.gui.tree.WorkspaceTree;
-import org.greenstone.gatherer.undo.UndoManager;
-import org.greenstone.gatherer.util.DragComponent;
-import org.greenstone.gatherer.util.DragGroup;
-import org.greenstone.gatherer.util.TreeSynchronizer;
-import org.greenstone.gatherer.util.Utility;
-
-/** The collection pane is analogous with a file manager. It is there that the user chooses which files to include in their collection and what structure the file hierarchy should take. The later aspect is not important for the Greenstone Suite, but is usefull for grouping files for ease of metadata markup. The view essentially consists of two file trees, one denoting the entire source workspace and the other the files within your collection. The trees themselves have a title bar at the top, a filter control at the bottom, and are coloured to indicate activity (grey for disabled). The remainder of the screen is taken by a status area, to indicate current file job progress during copying etc, and three buttons for controlling features of the view.
- * @author John Thompson, Greenstone Digital Library, University of Waikato
- * @version 2.3
- */
-public class CollectionPane
-	extends JPanel
-	implements ActionListener, FocusListener {
-	/** The group encompassing all of the components available as drop targets for drag and drop actions. Required so that only one component renders the ghost and higlights itself as a target, which the other members are restored to their original, pristine, condition. */
-	private DragGroup group				  =  null;
-	/** The tree showing the files within the collection. */
-	private DragTree collection_tree		 =  null;
-	/** The threaded queue that handles the actually movement of files, so that the gui remains responsive. */
-	private FileQueue file_queue		  =  null;
-	/** The filter currently applied to the collection tree. */
-	private Filter collection_filter = null;
-	/** The filter currently applied to the workspace tree. */
-	private Filter workspace_filter = null;
-	/** The collection model which is used to build, and hold the data of, the collection tree. */
-	private TreeModel collection	= null;
-	/** The Tree model used as the data source for the workspace tree. */
-	private TreeModel workspace		  =  null;
-	/** The button used to cancel all pending file queue jobs. */
-	private JButton stop_action		   =  null;
-	/** The button used to create a new folder in the collection tree. */
-	private JButton new_folder			=  null;
-	/** The label shown at the top of the collection tree. */
-	private JLabel collection_label	   =  null;
-	/** The label shown in the status area explaining the file apon which action is taking place. */
-	private JLabel filename_label		 =  null;
-	/** The label shown explaining the current state of the file queue thread. */
-	private JLabel status_label		   =  null;
-	/** The label at the top of the workspace tree. */
-	private JLabel workspace_label		=  null;
-	/** The panel that contains the collection tree. */
-	private JPanel collection_pane		=  null;
-	/** The panel that contains the various controls including the status area. */
-	private JPanel control_pane		   =  null;
-	/** The panel that contains the workspace tree. */
-	private JPanel workspace_pane		 =  null;
-	/** The scrollable area into which the collection tree is placed. */
-	private JScrollPane collection_scroll =  null;
-	/** The scrollable area into which the workspace tree is placed. */
-	private JScrollPane workspace_scroll  =  null;
-	/** A split pane seperating the two trees, allowing for the screen real-estate for each to be changed. */
-	private JSplitPane tree_pane		  =  null;
-	/** Text fragment arguments used to fill in phrases returned from the dictionary. */
-	private String args[]				 =  null;
-	/** Ensures that expansion and selection events between collection trees based on the same model are synchronized. */
-	private TreeSynchronizer collection_tree_sync = null;
-	/** Ensures that expansion and selection events between workspace trees based on the same model are synchronized. */
-	private TreeSynchronizer workspace_tree_sync = null;
-	/** The button used to delete files, which also doubles as a drop target for files from the Trees. */
-	private UndoManager bin_button			=  null;
-	/** The default size of a label in the interface. */
-	static final private Dimension LABEL_SIZE = new Dimension(100,30);
-	/** The default size of a special mapping dialog. */
-	static final Dimension DIALOG_SIZE = new Dimension(400, 120);
-	/** The minimum size a gui component can become. */
-	static private Dimension MIN_SIZE	= new Dimension( 90,  90);
-	/** The default size of the status area. */
-	static private Dimension STATUS_SIZE = new Dimension(450, 120);
-	/** The initial size of the trees. */
-	static private Dimension TREE_SIZE   = new Dimension(400, 430);
-
-	/** The tree showing the available source workspace. */
-	public WorkspaceTree workspace_tree	 =  null;
-
-    /* Constructor.
-     * @param tree_sync Ensures that expansion events between like trees are synchronized.
-     * @see org.greenstone.gatherer.file.FileManager
-     * @see org.greenstone.gatherer.file.FileQueue
-     */
-    public CollectionPane(TreeSynchronizer workspace_tree_sync, TreeSynchronizer collection_tree_sync) {
-	this.group = new DragGroup();
-	this.file_queue = Gatherer.f_man.getQueue();
-	this.collection_tree_sync = collection_tree_sync;
-	this.workspace_tree_sync = workspace_tree_sync;
-	
-	// Create components.
-	stop_action = new GLIButton();
-	stop_action.addActionListener(this);
-	stop_action.setEnabled(false);
-	stop_action.setMnemonic(KeyEvent.VK_S);
-	file_queue.registerStopButton(stop_action);
-	Dictionary.registerBoth(stop_action, "Collection.Stop", "Collection.Stop_Tooltip");
-	
-	new_folder = new GLIButton(Utility.getImage("folder.gif"));
-	new_folder.addActionListener(this);
-	new_folder.setEnabled(false);
-	new_folder.setMinimumSize(MIN_SIZE);
-	new_folder.setMnemonic(KeyEvent.VK_N);
-	new_folder.setPreferredSize(MIN_SIZE);
-	Dictionary.registerTooltip(new_folder, "Collection.New_Folder_Tooltip");
-    }
-
-	/** Any implementation of ActionListener requires this method so that when an action is performed the appropriate effect can occur. In this case there are three valid possibilities. If the action occured on the recycle bin, then delete the current selection from the collection tree. If the action instead occured on the new folder button, then create a new folder under the current (single) selection in the collection tree. And finally if the cancel button was pressed, cancel the current, and remaining, jobs on the file queue. */
-	public void actionPerformed(ActionEvent event) {
-	// If a user has clicked on the bin button directly remove whatever
-	// files are selected in the active tree.
-	if(event.getSource() == bin_button) {
-		if(!bin_button.ignore()) {
-		// Find the active tree (you've made selections in).
-		DragTree tree = (DragTree) group.getActive();
-		// Fudge things a bit
-		group.setSource(tree);
-		// Determine the selection.
-		TreePath paths[] = tree.getSelectionPaths();
-		if(paths != null) {
-			FileNode[] source_nodes = new FileNode[paths.length];
-			for(int i = 0; i < paths.length; i++) {
-			source_nodes[i] = (FileNode)(paths[i].getLastPathComponent());
-			}
-			Gatherer.f_man.action(tree, source_nodes, bin_button, null);
-		}
-		}
-	}
-	// If a user has clicked on new_folder create a new folder under
-	// whatever node is selected.
-	else if(event.getSource() == new_folder && collection_tree != null) {
-		int count = collection_tree.getSelectionCount();
-		boolean error = false;
-		if(count == 1) {
-		TreePath path = collection_tree.getSelectionPath();
-		FileNode node = (FileNode) path.getLastPathComponent();
-		if(node.getAllowsChildren()) {
-			Gatherer.f_man.newFolder(collection_tree, node);
-		}
-		else {
-			// try the parent
-			FileNode parent = (FileNode)node.getParent();
-			if (parent!=null && parent.getAllowsChildren()) {
-			Gatherer.f_man.newFolder(collection_tree, parent);
-			} else {
-			error = true;
-			}
-		}
-		}
-		else {
-		error = true;
-		}
-		if(error) {
-		// instead of an error, we now create a new folder at the root
-		FileNode node = (FileNode) collection_tree.getModel().getRoot();
-		Gatherer.f_man.newFolder(collection_tree, node);
-		//JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("FileActions.No_Parent_For_New_Folder"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
-		}
-	}
-	else if(event.getSource() == stop_action) {
-		file_queue.cancelAction();
-	}
-	}
-	/** Called whenever a significant change occurs in the current collections state, such as a new collection being loaded or the current one being closed. Several actions must occur in the GUI to indicate this change to the user, such as en/disabling the collection tree.
-	 * @param ready <i>true</i> if a collection is loaded and ready to be modified, <i>false</i> otherwise.
-	 * @see org.greenstone.gatherer.Configuration
-	 * @see org.greenstone.gatherer.Gatherer
-	 * @see org.greenstone.gatherer.collection.CollectionManager
-	 * @see org.greenstone.gatherer.gui.Coloring
-	 * @see org.greenstone.gatherer.gui.Filter
-	 * @see org.greenstone.gatherer.util.TreeSynchronizer
-	 */
-	public void collectionChanged(boolean ready) {
-	// Try to retrieve the collections record set.
-	collection = Gatherer.c_man.getRecordSet();
-	if(collection != null) {
-		//args = new String[1];
-		//args[0] = Gatherer.c_man.getCollection().getName();
-		Dictionary.registerText(collection_label, "Collection.Collection");
-		collection_tree.setModel(collection);
-		collection_tree.repaint();
-		collection_filter.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false));
-	}
-	else {
-		String args[] = new String[1];
-		args[0] = Dictionary.get("Collection.No_Collection");
-		Dictionary.registerText(collection_label, "Collection.Collection", args);
-		args = null;
-		collection_tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Error")));
-		collection_filter.setBackground(Color.lightGray);
-	}
-	collection_tree.setEnabled(ready);
-	collection_filter.setEnabled(ready);
-	collection_filter.setEditable(Gatherer.config.getMode() > Configuration.LIBRARIAN_MODE);
-	Dictionary.registerTooltip(collection_filter.getComboBox(), "Collection.Filter_Tooltip");
-
-	// Change the label at the top of collection tree.
-	setEnabled(collection_label, ready, Gatherer.config.getColor("coloring.collection_heading_foreground", false), Gatherer.config.getColor("coloring.collection_heading_background", false));
-	// Ensure that this tree view of the collection record set is synchronized with any others.
-	collection_tree_sync.add(collection_tree);
-
-	refreshWorkspaceTree(DragTree.LOADED_COLLECTION_CHANGED);
-	refreshCollectionTree(DragTree.LOADED_COLLECTION_CHANGED);
-
-	// Enable or disable the control buttons
-	bin_button.setEnabled(ready);
-	new_folder.setEnabled(ready);
-	}
-
-	/** Generates the pane on controls used to 'collect' files into the collection. Resposible for creating, connecting and laying out these controls. */
-	public void display() {
-	// Create Components.
-	KeyListenerImpl key_listener = new KeyListenerImpl();
-	MouseListenerImpl mouse_listener = new MouseListenerImpl();
-	this.addKeyListener(key_listener);
-
-	// Workspace Tree
-	workspace_pane = new JPanel();
-	workspace_pane.setMinimumSize(MIN_SIZE);
-	workspace_pane.setPreferredSize(TREE_SIZE);
-	workspace_pane.setSize(TREE_SIZE);
-
-	workspace_label = new JLabel();
-	workspace_label.setOpaque(true);
-	workspace_label.setBackground(Gatherer.config.getColor("coloring.workspace_heading_background", false));
-	workspace_label.setForeground(Gatherer.config.getColor("coloring.workspace_heading_foreground", false));
-	Dictionary.registerText(workspace_label, "Collection.Workspace");
-
-	workspace_tree = new WorkspaceTree(Utility.WORKSPACE_TREE);
-	group.add(workspace_tree);
-	workspace_tree.addFocusListener(this);
-	workspace_tree.addKeyListener(key_listener);
-	workspace_tree.addMouseListener(mouse_listener);
-	workspace_tree.addMouseListener(Gatherer.g_man.foa_listener);
-	workspace_tree.addTreeExpansionListener(Gatherer.g_man.foa_listener);
-	workspace_tree.addTreeSelectionListener(file_queue);
-	workspace_tree.putClientProperty("JTree.lineStyle", "Angled");
-	workspace_tree.setBackgroundNonSelectionColor(Gatherer.config.getColor("coloring.workspace_tree_background", false));
-	workspace_tree.setTextNonSelectionColor(Gatherer.config.getColor("coloring.workspace_tree_foreground", false));
-	workspace_tree.setBackgroundSelectionColor(Gatherer.config.getColor("coloring.workspace_selection_background", false));
-	workspace_tree.setTextSelectionColor(Gatherer.config.getColor("coloring.workspace_selection_foreground", false));
-	workspace_tree.setRootVisible(false);
-
-	workspace_scroll = new JScrollPane(workspace_tree);
-
-	workspace_filter = Gatherer.g_man.getFilter(workspace_tree);
-	workspace_filter.setBackground(Gatherer.config.getColor("coloring.workspace_heading_background", false));
-	workspace_filter.setEditable(Gatherer.config.getMode() > Configuration.LIBRARIAN_MODE);
-	Dictionary.registerTooltip(workspace_filter.getComboBox(), "Collection.Filter_Tooltip");
-
-	// Collection Tree
-	collection_pane = new JPanel();
-	collection_pane.setMinimumSize(MIN_SIZE);
-	collection_pane.setPreferredSize(TREE_SIZE);
-	collection_pane.setSize(TREE_SIZE);
-
-	//args = new String[1];
-	//args[0] = Dictionary.get("Collection.No_Collection");
-	collection_label = new JLabel();
-	collection_label.setOpaque(true);
-	Dictionary.registerText(collection_label, "Collection.No_Collection");
-
-	collection = Gatherer.c_man.getRecordSet();
-	if(collection != null) {
-		collection_tree = new DragTree(Utility.COLLECTION_TREE, collection, null, true);
-		collection_tree.setEnabled(true);
-	}
-	else {
-		collection_tree = new DragTree(Utility.COLLECTION_TREE, null, true);
-		collection_tree.setEnabled(false);
-	}
-	group.add(collection_tree);
-	collection_tree.addFocusListener(this);
-	collection_tree.addKeyListener(key_listener);
-	collection_tree.addMouseListener(mouse_listener);
-	collection_tree.addMouseListener(Gatherer.g_man.foa_listener);
-	collection_tree.addTreeSelectionListener(file_queue);
-	collection_tree.addTreeExpansionListener(Gatherer.g_man.foa_listener);
-	collection_tree.putClientProperty("JTree.lineStyle", "Angled");
-	collection_tree.setBackgroundNonSelectionColor(Gatherer.config.getColor("coloring.collection_tree_background", false));
-	collection_tree.setTextNonSelectionColor(Gatherer.config.getColor("coloring.collection_tree_foreground", false));
-	collection_tree.setBackgroundSelectionColor(Gatherer.config.getColor("coloring.collection_selection_background", false));
-	collection_tree.setTextSelectionColor(Gatherer.config.getColor("coloring.collection_selection_foreground", false));
-	collection_tree.setRootVisible(false);
-	//collection_tree.setRootVisible(true);
-
-	collection_scroll = new JScrollPane(collection_tree);
-
-	collection_filter = Gatherer.g_man.getFilter(collection_tree);
-	if(collection != null) {
-		collection_filter.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false));
-	}
-	else {
-		collection_filter.setBackground(Color.lightGray);
-	}
-	// Add a tool tip
-	Dictionary.registerTooltip(collection_filter.getComboBox(), "Collection.Filter_Tooltip");
-
-	tree_pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
-
-	// Status pane
-	control_pane = new JPanel();
-
-	JPanel inner_pane = new JPanel();
-	inner_pane.setSize(STATUS_SIZE);
-
-	JPanel file_pane = new JPanel();
-	//file_pane.setBackground(Color.white);
-	//JPanel job_pane = new JPanel();
-	//job_pane.setBackground(Color.white);
-	JPanel progress_pane = new JPanel();
-	//progress_pane.setBackground(Color.white);
-	JLabel file_status = file_queue.getFileStatus();
-	//JLabel job_status = job_queue.getJobStatus();
-
-	JProgressBar progress = file_queue.getProgress();
-
-	JPanel button_pane = new JPanel();
-
-	bin_button = Gatherer.c_man.undo;
-	bin_button.addActionListener(this);
-	bin_button.setEnabled(false);
-	bin_button.setMinimumSize(MIN_SIZE);
-	bin_button.setPreferredSize(MIN_SIZE);
-	Dictionary.registerTooltip(bin_button, "Collection.Delete_Tooltip");
-	group.add(bin_button);
-
-	// Layout Components.
-	workspace_pane.setLayout(new BorderLayout());
-	workspace_pane.add(workspace_label, BorderLayout.NORTH);
-	workspace_pane.add(workspace_scroll, BorderLayout.CENTER);
-	workspace_pane.add(workspace_filter, BorderLayout.SOUTH);
-
-	collection_pane.setLayout(new BorderLayout());
-	collection_pane.add(collection_label, BorderLayout.NORTH);
-	collection_pane.add(collection_scroll, BorderLayout.CENTER);
-	collection_pane.add(collection_filter, BorderLayout.SOUTH);
-
-	tree_pane.add(workspace_pane, JSplitPane.LEFT);
-	tree_pane.add(collection_pane, JSplitPane.RIGHT);
-	tree_pane.setDividerLocation(TREE_SIZE.width - 10);
-
-	//job_pane.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
-	//job_pane.setLayout(new BorderLayout());
-	//job_pane.add(job_status, BorderLayout.CENTER);
-
-	file_pane.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
-	file_pane.setLayout(new BorderLayout());
-	file_pane.add(file_status, BorderLayout.CENTER);
-	file_pane.add(stop_action, BorderLayout.EAST);
-
-	progress_pane.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
-	progress_pane.setLayout(new BorderLayout());
-	progress_pane.add(progress, BorderLayout.CENTER);
-
-	inner_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(10,10,10,10), BorderFactory.createLoweredBevelBorder()));
-	inner_pane.setLayout(new GridLayout(2,1));
-	//inner_pane.add(job_pane);
-	inner_pane.add(file_pane);
-	inner_pane.add(progress_pane);
-
-	button_pane.add(new_folder);
-	button_pane.add(bin_button);
-
-	control_pane.setLayout(new BorderLayout());
-	//control_pane.add(new_folder, BorderLayout.WEST);
-	control_pane.add(inner_pane, BorderLayout.CENTER);
-	control_pane.add(button_pane, BorderLayout.EAST);
-
-	this.setLayout(new BorderLayout());
-	this.add(tree_pane, BorderLayout.CENTER);
-	this.add(control_pane, BorderLayout.SOUTH);
-	}
-	/** This method ensures that a certain tree path is visible and selected within the collection tree, expanding nodes if necessary. If the method is successful the bounds of the new selection are returned. */
-	public Rectangle expandPath(TreePath path) {
-	collection_tree.setImmediate(true);
-	collection_tree.scrollPathToVisible(path);
-	collection_tree.setSelectionPath(path);
-	collection_tree.setImmediate(false);
-	return collection_tree.getRowBounds(collection_tree.getRowForPath(path));
-	}
-    /** Called whenever this pane gains focus, this method ensures that the various tree renderers are correctly colouring the tree (as these settings sometimes get lost).
-     * @param event A <strong>FocusEvent</strong> containing details about the focus action performed.
-     */
-    public void focusGained(FocusEvent event) {
-	DefaultTreeCellRenderer def = new DefaultTreeCellRenderer();
-	DefaultTreeCellRenderer w = (DefaultTreeCellRenderer)workspace_tree.getCellRenderer();
-	DefaultTreeCellRenderer c = (DefaultTreeCellRenderer)collection_tree.getCellRenderer();
-	if(event.getSource() == workspace_tree) {
-	    w.setBackgroundSelectionColor(def.getBackgroundSelectionColor());
-	    c.setBackgroundSelectionColor(Color.lightGray);
-	}
-	else if(event.getSource() == collection_tree) {
-	    c.setBackgroundSelectionColor(def.getBackgroundSelectionColor());
-	    w.setBackgroundSelectionColor(Color.lightGray);
-	}
-	repaint();
-    }
-    /** Implementation side-effect, not used in any way.
-     * @param event A <strong>FocusEvent</strong> containing details about the focus action performed.
-     */
-    public void focusLost(FocusEvent event) {
-    }
-
-    /** Called to inform this control panel that it has just gained focus as an effect of the user clicking on its tab.
-     * @see org.greenstone.gatherer.gui.tree.DragTree
-     */
-    public void gainFocus() {
-	// Update the menubar's idea of whats been selected
-	if (collection_tree != null) {
-	    if (collection_tree.isSelectionEmpty()) {
-		Gatherer.g_man.menu_bar.setMetaAuditSuffix(null);
-	    }
-	    else {
-		Gatherer.g_man.menu_bar.setMetaAuditSuffix(collection_tree.getSelectionDetails());
-	    }
-	}
-	// Update the meta-audit view to show the current selection, if any.
-	Gatherer.g_man.meta_audit.setRecords(getSelected());
-    }
-    
-    /** Retrieve a list of the currently selected file records in the active tree. */
-    public FileNode[] getSelected() {
-	TreePath paths[] = collection_tree.getSelectionPaths();
-	FileNode records[] = null;
-	if(paths != null) {
-	    records = new FileNode[paths.length];
-	    for(int i = 0; i < records.length; i++) {
-		records[i] = (FileNode) paths[i].getLastPathComponent();
-	    }
-	}
-	return records;
-    }
-    
-    public String getSelectionDetails() {
-	return collection_tree.getSelectionDetails();
-    }
-    
-    /** Called whenever the detail mode changes to ensure the filters are at an appropriate level (ie only editable by those that understand regular expression matching)
-     * @param mode the mode level as an int
-     */
-    public void modeChanged(int mode) {
-	collection_filter.setEditable(mode > Configuration.LIBRARIAN_MODE);
-	workspace_filter.setEditable(mode > Configuration.LIBRARIAN_MODE);
-    }
-
-    public void refreshCollectionTree(int refresh_reason) {
-	collection_tree.refresh(null);
-    }
-    
-
-    public void refreshWorkspaceTree(int refresh_reason) {
-	workspace_tree.refresh(refresh_reason);
-    }
-    
-    
-	/** Used to set the enabled state, and hence the colouring, of the two tree labels.
-	 * @param label The <strong>JLabel</strong> to be affected.
-	 * @param state <i>true</i> for enabled, i.e. when a collection is ready, <i>false</i> otherwise.
-	 * @param foreground The <strong>Color</strong> to make the foreground text of the label when enabled.
-	 * @param background The <strong>Color</strong> to make the background of the label when enabled.
-	 */
-	private void setEnabled(JLabel label, boolean state, Color foreground, Color background) {
-	///ystem.err.println("Setting the label color to state " + state);
-	if(state) {
-		label.setBackground(background);
-		label.setForeground(foreground);
-	}
-	else {
-		label.setBackground(Color.lightGray);
-		label.setForeground(Color.black);
-	}
-	label.repaint();
-	///ystem.err.println("Color is now " + label.getBackground());
-	}
-
-		/** When a user right-clicks within the trees on the collection pane view they are presented with a small popup menu of context based options. This class provides such functionality.
-		 */
-		private class GPopupMenu
-			extends JPopupMenu
-			implements ActionListener {
-
-			/** The tree over which the right click action occured. */
-			private DragTree tree = null;
-			/** The file record over which the right click action occured, if any. */
-			private FileNode node = null;
-			private JMenuItem collapse_expand_folder_menuitem;
-			/** A menu item enabled if a delete action is appropriate in the menus current context. */
-			private JMenuItem delete = null;
-			/** A menu item enabled if a special directory mapping is appropriate in the menus current context. */
-			private JMenuItem map = null;
-			/** A menu item enabled if a new folder action is appropriate in the menus current context. */
-			private JMenuItem new_folder = null;
-			/** A menu item enabled if a show meta-audit dialog action is appropriate in the menus current context. */
-			private JMenuItem show_metaaudit = null;
-			/** A menu item allowing a user to unmap a special directory, if and only if a special directory is selected. */
-			private JMenuItem unmap = null;
-			private TreePath path = null;
-			/** Constructor. */
-			public GPopupMenu(DragTree tree, MouseEvent event) {
-				super();
-				this.tree = tree;
-				this.path = tree.getClosestPathForLocation(event.getX(), event.getY());
-				if(path != null) {
-				node = (FileNode)path.getLastPathComponent();
-					// Any folder node gets a menu item allowing you to collapse or expand it depending on its current status
-					if(!node.isLeaf()) {
-						// Collapse
-						if(tree.isExpanded(path)) {
-							collapse_expand_folder_menuitem = new JMenuItem(Dictionary.get("Menu.Collapse"), KeyEvent.VK_C);
-						}
-						// Expand
-						else {
-							collapse_expand_folder_menuitem = new JMenuItem(Dictionary.get("Menu.Expand"), KeyEvent.VK_O);
-						}
-						collapse_expand_folder_menuitem.addActionListener(this);
-						add(collapse_expand_folder_menuitem);
-					}
-					// Set Options based on selection and tree
-					if(tree.getSelectionCount() != 0 && tree == collection_tree) {
-						String[] args = new String[1];
-						args[0] = collection_tree.getSelectionDetails();
-						show_metaaudit = new JMenuItem(Dictionary.get("Menu.Metadata_View", args), KeyEvent.VK_V);
-						show_metaaudit.addActionListener(this);
-						add(show_metaaudit);
-					}
-					if(tree == collection_tree && node != null && node.getFile() != null && node.getFile().isDirectory() && !node.isReadOnly()) {
-						new_folder = new JMenuItem(Dictionary.get("CollectionPopupMenu.New_Folder"), KeyEvent.VK_N);
-						new_folder.addActionListener(this);
-						add(new_folder);
-						add(new JSeparator());
-					}
-					if(tree == collection_tree && tree.getSelectionCount() != 0 && node != null && !node.isReadOnly()) {
-						delete = new JMenuItem(Dictionary.get("CollectionPopupMenu.Delete"), KeyEvent.VK_D);
-						delete.addActionListener(this);
-						add(delete);
-					}
-					if(tree == workspace_tree && node != null && !node.isLeaf()) {
-						String node_name = node.toString();
-						FileNode root = (FileNode) tree.getModel().getRoot();
-						if(!node_name.equals(Dictionary.get("Tree.World")) && !node_name.equals(Dictionary.get("Tree.Root")) && !node_name.equals(Dictionary.get("Tree.Public")) && !node_name.equals(Dictionary.get("Tree.Private"))) {
-							// You can unmap 1st level nodes.
-							if(root.getIndex(node) != -1) {
-								unmap = new JMenuItem(Dictionary.get("MappingPrompt.Unmap"), KeyEvent.VK_U);
-								unmap.addActionListener(this);
-								add(unmap);
-							}
-							// Or map any other level directories.
-							else {
-								map = new JMenuItem(Dictionary.get("MappingPrompt.Map"), KeyEvent.VK_M);
-								map.addActionListener(this);
-								add(map);
-							}
-						}
-					}
-					show(tree, event.getX(), event.getY());
-				}
-			}
-
-			/** Called whenever one of the menu items is actioned apon, this method then causes the appropriate effect. */
-			public void actionPerformed(ActionEvent event) {
-				Object source = event.getSource();
-				if(source == delete) {
-					// Retrieve the selection. Of course this gets a bit tricky as the user may have right clicked over a node not in the current selection, in which case we remove only that node.
-					TreePath[] selection_paths = tree.getSelectionPaths();
-					if(selection_paths != null) {
-						FileNode[] source_nodes = new FileNode[selection_paths.length];
-						boolean found = false;
-						for(int i = 0; i < selection_paths.length; i++) {
-							source_nodes[i] = (FileNode) selection_paths[i].getLastPathComponent();
-							if(node != null) {
-								found = found || source_nodes[i].equals(node);
-							}
-						}
-						if(node != null && !found) {
-							source_nodes = null;
-							source_nodes = new FileNode[1];
-							source_nodes[0] = node;
-						}
-						// Fire a delete action
-						Gatherer.f_man.action(tree, source_nodes, bin_button, null);
-						source_nodes = null;
-					}
-					selection_paths = null;
-				}
-				else if(source == map && node != null) {
-					MappingPrompt mp = new MappingPrompt(node.getFile());
-					mp.destroy();
-					mp = null;
-				}
-				else if(source == new_folder && node != null) {
-					Gatherer.f_man.newFolder(tree, node);
-				}
-				else if(source == show_metaaudit) {
-					Gatherer.g_man.showMetaAuditBox();
-				}
-				else if(source == unmap && node != null) {
-					Gatherer.c_man.removeDirectoryMapping(node);
-				}
-				else if(source == collapse_expand_folder_menuitem && path != null && node != null && !node.isLeaf()) {
-					// Collapse
-					if(tree.isExpanded(path)) {
-						tree.collapsePath(path);
-					}
-					// Expand
-					else {
-						tree.expandPath(path);
-					}
-				}
-			}
-		}
-
-	/** This class listens for certain key presses, such as [Enter] or [Delete], and responds appropriately. */
-	private class KeyListenerImpl
-	extends KeyAdapter {
-	/** Called whenever a key that was pressed is released, it is this action that will cause the desired effects (this allows for the key event itself to be processed prior to this listener dealing with it). */
-	public void keyReleased(KeyEvent event) {
-				///ystem.err.println("Key Release detected. " + event.getKeyCode());
-		if(event.getKeyCode() == KeyEvent.VK_DELETE) {
-		// Get the selected files from the tree and removal them using the default dnd removal method.
-		// Find the active tree (you've made selections in).
-		DragTree tree = (DragTree) group.getActive();
-		// Fudge things a bit
-		group.setSource(tree);
-		// Determine the selection.
-		TreePath paths[] = tree.getSelectionPaths();
-		if(paths != null) {
-			FileNode[] source_nodes = new FileNode[paths.length];
-			for(int i = 0; i < source_nodes.length; i++) {
-			source_nodes[i] = (FileNode) paths[i].getLastPathComponent();
-			}
-			Gatherer.f_man.action(tree, source_nodes, bin_button, null);
-			source_nodes = null;
-		}
-		}
-		else if(event.getKeyCode() == KeyEvent.VK_ENTER) {
-		// Get the first selected file.
-		DragTree tree = (DragTree)event.getSource();
-		TreePath path = tree.getSelectionPath();
-		if(path != null) {
-			File file = ((FileNode)path.getLastPathComponent()).getFile();
-			if(file != null && file.isFile()) {
-			Gatherer.self.spawnApplication(file);
-			}
-			else {
-			if(!tree.isExpanded(path)) {
-				tree.expandPath(path);
-			}
-			else {
-				tree.collapsePath(path);
-			}
-			}
-		}
-		}
-	}
-	}
-
-	/** This provides a small prompt for gathering addition details about a special directory mapping such as its symbolic name. */
-	private class MappingPrompt
-	extends JDialog
-	implements ActionListener, KeyListener {
-	private boolean cancelled = false;
-	private JButton cancel_button = null;
-	private JButton ok_button = null;
-	private JTextField name_field = null;
-	public MappingPrompt(File file) {
-		super(Gatherer.g_man);
-		setModal(true);
-		setSize(DIALOG_SIZE);
-		Dictionary.setText(this, "MappingPrompt.Title");
-
-		// Creation
-		JPanel content_pane = (JPanel) getContentPane();
-		JPanel center_pane = new JPanel();
-		JPanel file_pane = new JPanel();
-		JLabel file_label = new JLabel();
-		file_label.setPreferredSize(LABEL_SIZE);
-		Dictionary.setText(file_label, "MappingPrompt.File");
-		JLabel file_field = new JLabel(file.getAbsolutePath());
-		JPanel name_pane = new JPanel();
-		JLabel name_label = new JLabel();
-		name_label.setPreferredSize(LABEL_SIZE);
-		Dictionary.setText(name_label, "MappingPrompt.Name");
-		name_field = new JTextField(file.getName());
-		JPanel button_pane = new JPanel();
-		ok_button = new GLIButton();
-		ok_button.setEnabled(name_field.getText().length() > 0);
-		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.Cancel_Tooltip");
-
-		// Connection
-		cancel_button.addActionListener(this);
-		ok_button.addActionListener(this);
-		name_field.addKeyListener(this);
-		// Layout
-		file_pane.setLayout(new BorderLayout());
-		file_pane.add(file_label, BorderLayout.WEST);
-		file_pane.add(file_field, BorderLayout.CENTER);
-
-		name_pane.setLayout(new BorderLayout());
-		name_pane.add(name_label, BorderLayout.WEST);
-		name_pane.add(name_field, BorderLayout.CENTER);
-
-		center_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
-		center_pane.setLayout(new GridLayout(2,1,5,5));
-		center_pane.add(file_pane);
-		center_pane.add(name_pane);
-
-		button_pane.setLayout(new GridLayout(1,2,5,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(center_pane, BorderLayout.CENTER);
-		content_pane.add(button_pane, BorderLayout.SOUTH);
-		// Display
-		Dimension screen_size = Gatherer.config.screen_size;
-		setLocation((screen_size.width - DIALOG_SIZE.width) / 2, (screen_size.height - DIALOG_SIZE.height) / 2);
-		show();
-		// If not cancelled create mapping.
-		if(!cancelled) {
-		Gatherer.c_man.addDirectoryMapping(name_field.getText(), file);
-		}
-	}
-	public void actionPerformed(ActionEvent event) {
-		if(event.getSource() == cancel_button) {
-		cancelled = true;
-		}
-		dispose();
-	}
-	public void destroy() {
-		cancel_button = null;
-		ok_button = null;
-		name_field = null;
-	}
-	public void keyPressed(KeyEvent event) {
-	}
-	public void keyReleased(KeyEvent event) {
-		ok_button.setEnabled(name_field.getText().length() > 0);
-
-	}
-	public void keyTyped(KeyEvent event) {
-	}
-	}
-	/** This class listens for mouse clicks and responds right mouse button clicks (popup menu). */
-	private class MouseListenerImpl
-	extends MouseAdapter {
-	/** Any subclass of MouseAdapter can override this method to respond to mouse click events. In this case we want to open a pop-up menu if we detect a right mouse click over one of our registered components, and start an external application if someone double clicks on a certain file record. */
-	public void mouseClicked(MouseEvent event) {
-		if(SwingUtilities.isRightMouseButton(event)) {
-		new GPopupMenu((DragTree)event.getSource(), event);
-		}
-	}
-	}
-}
