Index: gli/branches/rtl-gli/src/org/greenstone/gatherer/file/FileManager.java
===================================================================
--- gli/branches/rtl-gli/src/org/greenstone/gatherer/file/FileManager.java	(revision 18353)
+++ gli/branches/rtl-gli/src/org/greenstone/gatherer/file/FileManager.java	(revision 18354)
@@ -45,4 +45,5 @@
 import org.greenstone.gatherer.collection.CollectionTreeNode;
 import org.greenstone.gatherer.gui.ExplodeMetadataDatabasePrompt;
+import org.greenstone.gatherer.gui.ReplaceSrcDocWithHtmlPrompt; 
 import org.greenstone.gatherer.gui.GProgressBar;
 import org.greenstone.gatherer.gui.NewFolderOrFilePrompt;
@@ -179,10 +180,10 @@
 			    source_files[i] = source_nodes[i].getFile();
 			}
-			RemoteGreenstoneServer.uploadFilesIntoCollection(collection_name, source_files, target_node.getFile());
+			Gatherer.remoteGreenstoneServer.uploadFilesIntoCollection(collection_name, source_files, target_node.getFile());
 		    }
 		    else if (type == FileJob.DELETE) {
 			// Deletes: delete each top-level file/directory one at a time
 			for (int i = 0; i < source_nodes.length; i++) {
-			    RemoteGreenstoneServer.deleteCollectionFile(collection_name, source_nodes[i].getFile());
+			    Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection_name, source_nodes[i].getFile());
 			}
 		    }
@@ -190,5 +191,6 @@
 			// Moves: move each top-level file/directory one at a time
 			for (int i = 0; i < source_nodes.length; i++) {
-			    RemoteGreenstoneServer.moveCollectionFile(collection_name, source_nodes[i].getFile(), target_node.getFile());
+			    Gatherer.remoteGreenstoneServer.moveCollectionFile(
+                                     collection_name, source_nodes[i].getFile(), target_node.getFile());
 			}
 		    }
@@ -201,5 +203,4 @@
     }
 
-
     public void explodeMetadataDatabase(File file)
     {
@@ -208,4 +209,10 @@
     }
 
+    // Works with replace_srcdoc_with_html.pl
+    public void replaceSrcDocWithHtml(File[] files)
+    {
+	// This must go in a separate thread because we need the progress bar to work (remote Greenstone server)
+	new ReplaceSrcDocWithHtmlPromptTask(files).start();
+    }
 
     private class ExplodeMetadataDatabasePromptTask
@@ -222,4 +229,21 @@
 	{
 	    ExplodeMetadataDatabasePrompt emp = new ExplodeMetadataDatabasePrompt(metadata_database_file);
+	}
+    }
+
+    // Works with replace_srcdoc_with_html.pl
+    private class ReplaceSrcDocWithHtmlPromptTask
+	extends Thread
+    {
+	private File[] replace_these_srcdoc_files = null;
+
+	public ReplaceSrcDocWithHtmlPromptTask(File[] replace_these_srcdoc_files)
+	{
+	    this.replace_these_srcdoc_files = replace_these_srcdoc_files;
+	}
+
+	public void run()
+	{
+	    ReplaceSrcDocWithHtmlPrompt prompt = new ReplaceSrcDocWithHtmlPrompt(replace_these_srcdoc_files);
 	}
     }
@@ -249,5 +273,6 @@
 		// ... but only if it is inside the collection and we haven't already downloaded it
 		if (file.getAbsolutePath().startsWith(Gatherer.getCollectDirectoryPath()) && file.length() == 0) {
-		    if (RemoteGreenstoneServer.downloadCollectionFile(CollectionManager.getLoadedCollectionName(), file).equals("")) {
+		    if (Gatherer.remoteGreenstoneServer.downloadCollectionFile(
+                                 CollectionManager.getLoadedCollectionName(), file).equals("")) {
 			// Something has gone wrong downloading the file
 			return;
@@ -324,5 +349,6 @@
 			    folder_file.createNewFile();
 			    if (Gatherer.isGsdlRemote) {
-				RemoteGreenstoneServer.uploadCollectionFile(CollectionManager.getLoadedCollectionName(), folder_file);
+				Gatherer.remoteGreenstoneServer.uploadCollectionFile(
+                                         CollectionManager.getLoadedCollectionName(), folder_file);
 			    }
 			}
@@ -330,5 +356,6 @@
 			    folder_file.mkdirs();
 			    if (Gatherer.isGsdlRemote) {
-				RemoteGreenstoneServer.newCollectionDirectory(CollectionManager.getLoadedCollectionName(), folder_file);
+				Gatherer.remoteGreenstoneServer.newCollectionDirectory(
+                                         CollectionManager.getLoadedCollectionName(), folder_file);
 			    }
 			}
@@ -390,5 +417,6 @@
 		file_queue.addJob(System.currentTimeMillis(), collection_tree, new FileNode[] { collection_tree_node }, collection_tree, new_collection_tree_node, FileJob.RENAME);
 		if (Gatherer.isGsdlRemote) {
-		    RemoteGreenstoneServer.moveCollectionFile(CollectionManager.getLoadedCollectionName(), collection_file, new_collection_file);
+		    Gatherer.remoteGreenstoneServer.moveCollectionFile(
+                             CollectionManager.getLoadedCollectionName(), collection_file, new_collection_file);
 		}
 	    }
@@ -439,5 +467,6 @@
 	    file_queue.addJob(System.currentTimeMillis(), Gatherer.g_man.gather_pane.workspace_tree, new FileNode[] { source_node }, collection_tree, (FileNode)collection_tree_node.getParent(),  FileJob.COPY_FILE_ONLY);
 	    if (Gatherer.isGsdlRemote) {
-		RemoteGreenstoneServer.uploadFilesIntoCollection(CollectionManager.getLoadedCollectionName(), new File[] { new_file }, target_directory);
+		Gatherer.remoteGreenstoneServer.uploadFilesIntoCollection(
+                         CollectionManager.getLoadedCollectionName(), new File[] { new_file }, target_directory);
 	    }
 	    // do a replace of old file with new file
Index: gli/branches/rtl-gli/src/org/greenstone/gatherer/file/FileNode.java
===================================================================
--- gli/branches/rtl-gli/src/org/greenstone/gatherer/file/FileNode.java	(revision 18353)
+++ gli/branches/rtl-gli/src/org/greenstone/gatherer/file/FileNode.java	(revision 18354)
@@ -20,4 +20,6 @@
     protected FileSystemModel model = null;
     protected MutableTreeNode parent = null;
+    /** The string that is displayed as the filename. Attempts to be in the correct encoding. */
+    protected String displayFileName = null;
 
 
@@ -27,11 +29,49 @@
 
 	// Files cannot have children
-	if (file != null && file.isFile()) {
+	if (file != null && !file.isDirectory()) { //file.isFile()) {
 	    // Cache this result to prevent unceasing missing disk messages being thrown if the
 	    // removable media was, um, removed after directory mapped
 	    this.allows_children = false;
-	}
-    }
-
+	    displayFileName = calcDisplayString();
+	}	
+    }
+
+
+     /** This method returns a string representation of the filenodes in the Collection
+     * Tree, that can then be displayed in the tree. 
+     * We'll initially assume that the filenames are utf8 encoded and so convert the
+     * filename into utf8 for proper presentation in the Collection tree pane.
+     * If the filenames are not utf8, then the conversion would have introduced funny
+     * characters. Therefore, when converting to utf8, if the converted filename 
+     * contains the special character '\ufffd', then we know the conversion did not work
+     * and we return the original string which may or may not be properly presented by
+     * default.
+     * See http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/CharsetDecoder.html
+     * which says "How a decoding error is handled depends upon the action requested for 
+     * that type of error, which is described by an instance of the CodingErrorAction class.
+     * The possible error actions are to ignore the erroneous input, report the error to
+     * the invoker via the returned CoderResult object, or replace the erroneous input with
+     * the current value of the replacement string. The replacement has the initial value 
+     * "\uFFFD"; its value may be changed via the replaceWith method."
+     * The following made me think that String(byte[], String charsetName) constructor may
+     * use the replacement value \uFFFD.
+     * http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20512969.html
+     * mentions the following which made me think of this: 
+     * convertedStr = convertedStr.replace('\ufffd', ' ');
+     */
+    protected String calcDisplayString() {
+	String filename = file.getName();
+	try{
+	    String utf8filename = new String(filename.getBytes(), "UTF8");
+	    if(utf8filename.indexOf('\ufffd') == -1) {
+		return utf8filename;
+	    } else { // contains the character indicating that it's invalid utf8
+		// return the original string
+		return filename;
+	    }
+	} catch(java.io.UnsupportedEncodingException e) {
+	    return filename;
+	}
+    }
 
     /** Returns the children of the node as an Enumeration. */
@@ -312,5 +352,8 @@
 	}
 	else {
-	    return file.getName();
+	    if(displayFileName == null) {    
+		displayFileName = calcDisplayString();
+	    }
+	    return displayFileName; //return file.getName();	    
 	}
     }
