Index: main/trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java
===================================================================
--- main/trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java	(revision 29848)
+++ main/trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java	(revision 29972)
@@ -73,5 +73,6 @@
     static final private Dimension LABEL_SIZE = new Dimension(225, 25);
     static final private Dimension TREE_SIZE = new Dimension(150, 500);
-    static final private String CONTENTS[] = { "DOWNLOAD.MODE.WebDownload", "DOWNLOAD.MODE.MediaWikiDownload", "DOWNLOAD.MODE.OAIDownload", "DOWNLOAD.MODE.ZDownload" , "DOWNLOAD.MODE.SRWDownload"};
+    //static final private String CONTENTS[] = { "DOWNLOAD.MODE.WebDownload", "DOWNLOAD.MODE.MediaWikiDownload", "DOWNLOAD.MODE.OAIDownload", "DOWNLOAD.MODE.ZDownload" , "DOWNLOAD.MODE.SRWDownload"};
+    private String CONTENTS[] = null;
 
     private boolean download_button_enabled = false;
@@ -96,5 +97,5 @@
         this.setComponentOrientation(Dictionary.getOrientation());
 	// TODO: Download the WDownload and the download panel fixed!!
-        getter = new DownloadScrollPane();
+	getter = new DownloadScrollPane();
         getter.start();
 	list_scroll = getter.getDownloadJobList();      
@@ -103,9 +104,16 @@
 	String lang = Configuration.getLanguage();
 	download_map = new HashMap();
-	download_map.put("Web", loadDownload("WebDownload",lang));
-	download_map.put("MediaWiki", loadDownload("MediaWikiDownload",lang));
-	download_map.put("OAI", loadDownload("OAIDownload",lang));
-	download_map.put("Z3950", loadDownload("Z3950Download",lang));
-	download_map.put("SRW", loadDownload("SRWDownload",lang));
+
+	ArrayList<String> downloaderNamesList = getDownloads(lang);	
+	int size = downloaderNamesList.size();
+	CONTENTS = new String[size];
+	for(int i = 0; i < size; i++) {
+	    String downloadName = downloaderNamesList.get(i); // e.g. "WebDownload"	    
+	    CONTENTS[i] = "DOWNLOAD.MODE."+downloadName.replace("3950", ""); // A special case is Z3950Download,
+	                                 // which has to be stored in CONTENTS array as DOWNLOAD.MODE.ZDownload
+
+	    String shortName = downloadName.replace("Download", ""); // e.g. "Web"
+	    download_map.put(shortName, loadDownload(downloadName,lang));	    
+	}
 
 	// Creation
@@ -225,8 +233,92 @@
     }
 
+    private ArrayList<String> getDownloads(String lang) {
+	ArrayList downloaders = null;
+	Document document = null;
+	Process process = null;
+	
+	try {
+	    if (Gatherer.isGsdlRemote) {
+		String output = Gatherer.remoteGreenstoneServer.getScriptOptions("downloadinfo.pl", "&listall");
+		Reader reader = new StringReader(output);
+		document = XMLTools.parseXML(reader);
+	    }
+	    else {
+		ArrayList args_list = new ArrayList();
+		String args[] = null;
+		if(Configuration.perl_path != null) {
+		    args_list.add(Configuration.perl_path);
+		} else if(Utility.isWindows()) {
+		    args_list.add("Perl.exe");
+		} else {
+		    args_list.add("perl");
+		}
+		args_list.add("-S");
+		args_list.add(LocalGreenstone.getBinScriptDirectoryPath()+"downloadinfo.pl");
+		args_list.add("-listall");
+		args_list.add("-xml");
+		args_list.add("-language");
+		args_list.add(lang);		
+		
+		// Create the process.
+		args = (String []) args_list.toArray(new String[0]);
+		Runtime runtime = Runtime.getRuntime();
+		DebugStream.println("Getting Download Info: "+args_list);
+		process = runtime.exec(args);
+		
+		InputStream input_stream = process.getErrorStream();
+		document = XMLTools.parseXML(input_stream);
+	    }
+
+            
+	}
+	catch (Exception error) {
+	    System.err.println("Failed when trying to parse downloadinfo.pl -listall");
+	    error.printStackTrace();
+	} 
+	finally {
+	    Utility.closeProcess(process);
+	}
+
+	if(document != null) {
+	    //return parseXML(document.getDocumentElement());
+	    Element downloadList = document.getDocumentElement();
+	    int length = -1;
+	    if(downloadList.hasAttribute("length")) {
+		length = Integer.parseInt(downloadList.getAttribute("length"));
+		downloaders = new ArrayList<String>(length);		
+
+		for (Node node = downloadList.getFirstChild(); node != null; node = node.getNextSibling()) {
+		    // goes through each <DownloadInfo> of listAll
+
+		    String download_name = null;
+
+		    for(Node infoNode = node.getFirstChild(); 
+			infoNode != null; infoNode = infoNode.getNextSibling()) {
+
+			String node_name = infoNode.getNodeName();
+			if(node_name.equalsIgnoreCase("Name")) { // <Name>WebDownload</Name>
+			    download_name = XMLTools.getValue(infoNode);			
+			}
+			// skip all the downloaders that are Abstract, as these are pure superclasses
+			else if(node_name.equalsIgnoreCase("Abstract")) {
+			    String isAbstract = XMLTools.getValue(infoNode);
+			    
+			    if(isAbstract.equalsIgnoreCase("no") && download_name != null) {
+				downloaders.add(download_name);
+			    }
+			}
+		    }
+		}
+	    }
+	}
+
+	return downloaders;
+    }
+
     /** Supporting Functions */
     private Download loadDownload(String download_name, String lang) {
 	Document document = null;
-	
+	Process process = null;
 	try {
 	    if (Gatherer.isGsdlRemote) {
@@ -256,10 +348,9 @@
 		Runtime runtime = Runtime.getRuntime();
 		DebugStream.println("Getting Download Info: "+args_list);
-		Process process = runtime.exec(args);
+		process = runtime.exec(args);
 		
 		InputStream input_stream = process.getErrorStream();
 		document = XMLTools.parseXML(input_stream);
 	    }
-
             
 	}
@@ -267,4 +358,7 @@
 	    System.err.println("Failed when trying to parse: " + download_name);
 	    error.printStackTrace();
+	}
+	finally {
+	    Utility.closeProcess(process);
 	}
 
@@ -462,24 +556,10 @@
 		String type = (String)node.getUserObject();
 		Gatherer.g_man.wait(true);
-		if(type == CONTENTS[0]) {
-		    mode = "Web";
-		    generateOptions(options_pane,(Download)download_map.get(mode));
-		}
-		else if(type == CONTENTS[1]) {
-		    mode = "MediaWiki";
-		    generateOptions(options_pane,(Download)download_map.get(mode));
-		}
-		else if(type == CONTENTS[2]) {
-		    mode = "OAI";
-		    generateOptions(options_pane,(Download)download_map.get(mode));
-		}
-		else if(type == CONTENTS[3]) {
-		    mode = "Z3950";
-		    generateOptions(options_pane,(Download)download_map.get(mode));
-		}
-		else if(type == CONTENTS[4]) {
-		    mode = "SRW";
-		    generateOptions(options_pane,(Download)download_map.get(mode));
-		}
+
+		// type has the value DOWNLOAD.MODE.<downloader>Download,
+		// mode should then be of the form <downloader>
+		mode = type.replace("DOWNLOAD.MODE.", "").replace("Download", "");		
+		generateOptions(options_pane,(Download)download_map.get(mode));
+
 		tree.setSelectionPath(path);
 		previous_path = path;
Index: main/trunk/gli/src/org/greenstone/gatherer/util/Utility.java
===================================================================
--- main/trunk/gli/src/org/greenstone/gatherer/util/Utility.java	(revision 29848)
+++ main/trunk/gli/src/org/greenstone/gatherer/util/Utility.java	(revision 29972)
@@ -584,3 +584,12 @@
 	}
     }
+
+    public static void closeProcess(Process prcs) {
+	if( prcs != null ) { 
+	    closeResource(prcs.getErrorStream()); 
+	    closeResource(prcs.getOutputStream()); 
+	    closeResource(prcs.getInputStream()); 
+	    prcs.destroy(); 
+	} 
+    }
 }
