Index: /trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java	(revision 12249)
+++ /trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java	(revision 12250)
@@ -408,5 +408,6 @@
 	for(int i = 0; i < library_size; i++) {
 	    Plugin plugin = (Plugin) library.get(i);
-	    if(!plugin.isAbstract()) {
+	    String plugin_name = plugin.getName();
+	    if(!plugin.isAbstract() && !plugin_name.equals(StaticStrings.ARCPLUG_STR) && !plugin_name.equals(StaticStrings.RECPLUG_STR)) {
 		available.add(plugin);
 	    }
@@ -414,5 +415,8 @@
 	}
 	// Now go through the assigned plugins, and remove any that match.
-	available.removeAll(children());
+	// only for < lib sys specialist mode
+	if (Configuration.getMode()<=Configuration.SYSTEMS_MODE) {
+	    available.removeAll(children());
+	}
 	//DebugStream.println("There are a total of " + library.size() + " plugins in the library.");
 	//DebugStream.println("However " + children().size() + " are in use,");
@@ -438,5 +442,5 @@
      * @param plugin The plugin <strong>File</strong> you wish to load.
      */
-    private void loadPlugin(String plugin, String lang) {
+    private void loadPlugin(String plugin, String lang, String collection_name) {
 	Document document = null;
 	InputStream input_stream = null;
@@ -450,31 +454,20 @@
 	    }
 	    else {
-		String args[] = null;
-		if(Utility.isWindows()) {
-		    args = new String[6];
-		    if(Configuration.perl_path != null) {
-			args[0] = Configuration.perl_path;
-		    }
-		    else {
-			args[0] = "Perl.exe";
-		    }
-		    args[1] = LocalGreenstone.getBinScriptDirectoryPath() + "pluginfo.pl";
-		    args[2] = "-xml";
-		    args[3] = "-language";
-		    args[4] = lang;
-		    args[5] = getPluginName(plugin);
-		}
-		else {
-		    args = new String[5];
-		    args[0] = "pluginfo.pl";
-		    args[1] = "-xml";
-		    args[2] = "-language";
-		    args[3] = lang;
-		    args[4] = getPluginName(plugin);
-		}
+		ArrayList args = new ArrayList();
+		if (Utility.isWindows()) {
+		    args.add(Configuration.perl_path);
+		    args.add("-S");
+		}
+		args.add(LocalGreenstone.getBinScriptDirectoryPath() + "pluginfo.pl");
+		args.add("-xml");
+		args.add("-language");
+		args.add(lang);
+		args.add("-collect");
+		args.add(collection_name);
+		args.add(getPluginName(plugin));
 
 		// Create the process.
 		Runtime runtime = Runtime.getRuntime();
-		Process process = runtime.exec(args);
+		Process process = runtime.exec((String[])args.toArray(new String [0]));
 		input_stream = process.getErrorStream();
 		xml = XMLTools.readXMLStream(input_stream);
@@ -524,9 +517,52 @@
 		String directory = LocalGreenstone.getDirectoryPath();
 		directory = directory + "perllib" + File.separator + "plugins" + File.separator;
-		loadPlugins(new File(directory));
-	    }
-	}
-    }
-
+		String current_lang = Configuration.getLanguage();
+		String collection_name = Gatherer.c_man.getCollection().getName();
+
+		boolean is_windows = Utility.isWindows();
+		boolean is_mac = Utility.isMac();
+	
+		File files[] = (new File(directory)).listFiles();
+		File coll_files[] = (new File(Gatherer.c_man.getCollectionPluginsDirectoryPath())).listFiles();
+		int num_files = 0;
+		if (files != null) {
+		    num_files += files.length;
+		}
+		if (coll_files != null) {
+		    num_files += coll_files.length;
+		}
+		if(num_files > 0) {
+		
+		    // Create a progress indicator.
+		    ParsingProgress progress = new ParsingProgress(Dictionary.get("CDM.PlugInManager.Parsing.Title"), Dictionary.get("CDM.PlugInManager.Parsing.Message"), num_files);
+		    if (coll_files != null) {
+			for (int i=0; i<coll_files.length; i++) {   
+			    if(coll_files[i].getName().endsWith(".pm")) {
+				loadPlugin(coll_files[i].getName(), current_lang, collection_name);
+			    }
+			    progress.inc();
+			}
+		    }
+
+		    if (files != null) {
+			for(int i = 0; i < files.length; i++) {
+			    // We only want to check Perl Modules.
+			    if(files[i].getName().endsWith(".pm")) {
+				if (files[i].getName().equals("GMLPlug.pm") || ((is_windows || is_mac) && files[i].getName().equals("DBPlug.pm"))) {
+				    // don't load GMLPlug or DBPlug for windows
+				} else {
+				    loadPlugin(files[i].getName(), current_lang, collection_name);
+				}
+			    }
+			    progress.inc();
+			}
+		    }
+		    progress.dispose();
+		    progress.destroy();
+		    progress = null;
+		}   
+	    }
+	}
+    }
 
 
@@ -565,4 +601,5 @@
 
 	String current_lang = Configuration.getLanguage();
+	String collection_name = Gatherer.c_man.getCollection().getName();
 	if (num_plugins>0) {
 	    // Create a progress indicator.
@@ -574,5 +611,5 @@
 		    // don't load GMLPlug or DBPlug for windows
 		} else {
-		    loadPlugin(plugin, current_lang);
+		    loadPlugin(plugin, current_lang, collection_name);
 		}
 		
@@ -585,32 +622,4 @@
     }
 
-
-    /** Method to load plug-in information from a specified directory. Of course no plug-ins may be found at this location.
-     * @param directory A <strong>File</strong> indicating the directory to be scanned for plug-ins.
-     */
-    private void loadPlugins(File directory) {
-	File files[] = directory.listFiles();
-	boolean is_windows = Utility.isWindows();
-	boolean is_mac = Utility.isMac();
-	String current_lang = Configuration.getLanguage();
-	if(files != null) {
-	    // Create a progress indicator.
-	    ParsingProgress progress = new ParsingProgress(Dictionary.get("CDM.PlugInManager.Parsing.Title"), Dictionary.get("CDM.PlugInManager.Parsing.Message"), files.length);
-	    for(int i = 0; i < files.length; i++) {
-		// We only want to check Perl Modules.
-		if(files[i].getName().endsWith(".pm")) {
-		    if (files[i].getName().equals("GMLPlug.pm") || ((is_windows || is_mac) && files[i].getName().equals("DBPlug.pm"))) {
-			// don't load GMLPlug or DBPlug for windows
-		    } else {
-			loadPlugin(files[i].getName(), current_lang);
-		    }
-		}
-		progress.inc();
-	    }
-	    progress.dispose();
-	    progress.destroy();
-	    progress = null;
-	}
-    }
 
     private Plugin parseXML(Node root) {
@@ -679,5 +688,5 @@
 	private JButton remove = null;
 	/** A combobox containing all of the known plugins, including those that may have already been assigned. */
-	private GComboBox plugin = null;
+	private JComboBox plugin_combobox = null;
 	/** The label next to the plugin combobox. */
 	private JLabel plugin_label = null;
@@ -719,11 +728,7 @@
 
 	    PluginComboboxListener picl = new PluginComboboxListener();
-	    plugin = new GComboBox(getAvailable());
-	    plugin.setBackgroundNonSelectionColor(Configuration.getColor("coloring.editable_background", false));
-	    plugin.setBackgroundSelectionColor(Configuration.getColor("coloring.collection_selection_background", false));
-	    plugin.setEditable(true);
-	    plugin.setTextNonSelectionColor(Configuration.getColor("coloring.workspace_tree_foreground", false));
-	    plugin.setTextSelectionColor(Configuration.getColor("coloring.collection_selection_foreground", false));
-	    picl.itemStateChanged(new ItemEvent(plugin, 0, null, ItemEvent.SELECTED));
+	    plugin_combobox = new JComboBox(getAvailable());
+	    plugin_combobox.setEditable(false);
+	    picl.itemStateChanged(new ItemEvent(plugin_combobox, 0, null, ItemEvent.SELECTED));
 
 	    plugin_label = new JLabel(Dictionary.get("CDM.PlugInManager.PlugIn"));
@@ -750,5 +755,5 @@
 	    move_up_button.addActionListener(ml);
 	    move_up_button.addActionListener(CollectionDesignManager.all_change_listener);
-	    plugin.addItemListener(picl);
+	    plugin_combobox.addItemListener(picl);
 	    remove.addActionListener(new RemoveListener());
 	    remove.addActionListener(CollectionDesignManager.all_change_listener);
@@ -775,5 +780,5 @@
 	    plugin_pane.setLayout(new BorderLayout(5,0));
 	    plugin_pane.add(plugin_label, BorderLayout.WEST);
-	    plugin_pane.add(plugin, BorderLayout.CENTER);
+	    plugin_pane.add(plugin_combobox, BorderLayout.CENTER);
 
 	    button_pane.setLayout(new GridLayout(1,3));
@@ -841,5 +846,5 @@
 	     */
 	    public void actionPerformed(ActionEvent event) {
-		Object selected_object = plugin.getSelectedItem();
+		Object selected_object = plugin_combobox.getSelectedItem();
 		if(selected_object != null) {
 		    // Retrieve the base plugin if any
@@ -848,34 +853,21 @@
 		    // Create a new element in the DOM
 		    Element element = CollectionDesignManager.collect_config.document.createElement(CollectionConfiguration.PLUGIN_ELEMENT);
-		    // Remember that the plugin supplied might be a custom string rather than a base plugin
-		    Plugin new_plugin = null;
-		    if(base_plugin != null) {
-			//DebugStream.println("New Plugin based on existing Plugin");
-			element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, base_plugin.getName());
-			new_plugin = new Plugin(element, base_plugin);
+		    element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, base_plugin.getName());
+		    Plugin new_plugin = new Plugin(element, base_plugin);
+		    element = null;
+		    
+		    // Automatically chain to configuration. This ensures required arguments are filled out.
+		    ArgumentConfiguration ac = new ArgumentConfiguration(new_plugin);
+		    if(ac.display()) {
+			assignPlugin(new_plugin);
+			plugin_list.setSelectedValue(new_plugin, true);
+			// Since we weren't cancelled, if we are in a low mode, remove the plugin from the available list (except for UnknownPlug
+			if(base_plugin != null && Configuration.getMode() <= Configuration.SYSTEMS_MODE && !base_plugin.getName().equals(StaticStrings.UNKNOWNPLUG_STR)) {
+			    plugin_combobox.removeItem(base_plugin);
+			    plugin_combobox.setSelectedIndex(0);
+			}
 		    }
-		    else {
-			//DebugStream.println("New Custom Plugin");
-			element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, selected_object.toString());
-			new_plugin = new Plugin(element, null);
-		    }
-		    if(!model.contains(new_plugin) || new_plugin.getName().equals(StaticStrings.UNKNOWNPLUG_STR)) {
-			// Automatically chain to configuration. This ensures required arguments are filled out.
-			ArgumentConfiguration ac = new ArgumentConfiguration(new_plugin);
-			if(ac.display()) {
-			    assignPlugin(new_plugin);
-			    plugin_list.setSelectedValue(new_plugin, true);
-			    // Since we weren't cancelled, and if there was a base plugin, ensure it no longer is shown as available, unless it is the UnknownPlugin which can be added several times
-			    if(base_plugin != null && !base_plugin.getName().equals(StaticStrings.UNKNOWNPLUG_STR)) {
-				plugin.removeItem(base_plugin);
-			    }
-			}
-			ac = null;
-			new_plugin = null;
-			plugin.setSelectedIndex(0);
-		    }
-		    else {
-			JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.PlugInManager.PlugIn_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
-		    }
+		    ac = null;
+		    new_plugin = null;
 		    base_plugin = null;
 		}
@@ -1059,12 +1051,12 @@
             if(event.getStateChange() == ItemEvent.SELECTED) {
                 // Retrieve the selected plugin
-                Object current_selection = plugin.getSelectedItem();
+                Object current_selection = plugin_combobox.getSelectedItem();
                 // And reset the tooltip. If the plugin is null or is a string, then go back to the default message
                 if(current_selection == null || current_selection instanceof String) {
-		    plugin.setToolTipText(Dictionary.get("CDM.PlugInManager.PlugIn_Tooltip"));
+		    plugin_combobox.setToolTipText(Dictionary.get("CDM.PlugInManager.PlugIn_Tooltip"));
                 }
                 else {
                     Plugin current_plugin = (Plugin) current_selection;
-		    plugin.setToolTipText(Utility.formatHTMLWidth(current_plugin.getDescription(), 40));
+		    plugin_combobox.setToolTipText(Utility.formatHTMLWidth(current_plugin.getDescription(), 40));
                     current_plugin = null;
                 }
@@ -1118,5 +1110,5 @@
 		    }
 		    // Refresh the available plugins
-		    plugin.setModel(new DefaultComboBoxModel(getAvailable()));
+		    plugin_combobox.setModel(new DefaultComboBoxModel(getAvailable()));
 		}
 		else {
