Index: /trunk/gli/src/org/greenstone/gatherer/gui/PreviewPane.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gui/PreviewPane.java	(revision 4310)
+++ /trunk/gli/src/org/greenstone/gatherer/gui/PreviewPane.java	(revision 4311)
@@ -56,4 +56,5 @@
 	 private JButton reload = null;
 	 private JLabel status      = null;
+	 private Observer observer = null;
 	 private String args[]      = null;
 	 private String current_url = null;
@@ -80,5 +81,5 @@
 
 		  CalHTMLPreferences prefs = new CalHTMLPreferences();
-		  Observer observer = new Observer();
+		  observer = new Observer();
 		  view = new CalHTMLPane(prefs, observer, "Default");
 		  //view.setSize(new Dimension(770, 440));
@@ -88,6 +89,15 @@
 	 
 	 public void collectionChanged(boolean ready) {
+		  /**
 		  if(ready && Gatherer.c_man.built()) {
-				String url = Gatherer.config.exec_path + "?a=p&p=about&c=" + Gatherer.c_man.getCollection().getName();
+				// If no address is set yet then its time to load the local library.
+
+				// Ask library to rebuild if necessary.
+				String url = Gatherer.config.exec_address + "?a=config&cmd=add-collection&c=" + Gatherer.c_man.getCollection().getName();
+				Gatherer.println("Reset library: " + url);
+				observer.state = CalCons.PRE_CONNECT;
+				view.showHTMLDocument((new GURL(url)).getURL());
+				// Display page.
+				url = Gatherer.config.exec_path + "?a=p&p=about&c=" + Gatherer.c_man.getCollection().getName();
 				Gatherer.println("Loading " + url);
 				args = new String[1];
@@ -98,4 +108,5 @@
 		  }
 		  validate();
+		  */
 	 }
 
@@ -129,4 +140,6 @@
 				}
 				else {
+					 String url = Gatherer.config.exec_address + "?a=config&cmd=add-collection&c=" + Gatherer.c_man.getCollection().getName();
+
 					 Gatherer.println("Loading " + url);
 					 args = new String[1];
@@ -177,4 +190,22 @@
 	 }
 
+	 /** This method performs nominally the same as a showHTMLDocument call expect that it blocks until some final loading state is reached, good or bad. */
+	 private void showAndWait(URL url) {
+		  try {
+				// Send url to CalPane
+				
+				// Wait until state is preconnect
+				while(observer.state != CalCons.PRE_CONNECT) {
+					 wait(100); // 10th of a second
+				}
+				// Now wait until state is final state
+				while(observer.state != CalCons.DOC_LOADED) {
+					 wait(100); // 10th of a second
+				}
+		  }
+		  catch (InterruptedException error) {
+		  }
+	 }
+
 	 private class BackListener 
 		  implements ActionListener {
@@ -217,4 +248,5 @@
 	 private class Observer
 		  extends DefaultCalHTMLObserver {
+		  public int state = CalCons.DOC_LOADED;
 		  public void linkActivatedUpdate(CalHTMLPane pane, URL url, String target_frame, String j_name) {
 				if(!url.toString().equals(current_url)) {
@@ -232,6 +264,18 @@
 		  }
 		  public void statusUpdate(CalHTMLPane pane, int state, URL url, int value, String message) {
+				this.state = state;
 				switch(state) {
-				case 11:
+					 // The Pane is attempting to connect to the given URL to receive data.
+				case CalCons.PRE_CONNECT:
+					 System.err.println("Preconnect: " + value + " - " + message);
+					 break;
+					 // The Pane was unable to connect to the given URL or was unable to parse the content. Most likely this will be due to an incorrectly specified URL. The message argument may contain further details of the reason for failure.
+				case CalCons.PARSE_FAILED:
+					 System.err.println("Parse Failed: " + value + " - " + message);
+					 status.setText(get("CannotConnect") + message);
+					 break;
+					 // The Pane has established a connection to the given URL and is receiving any content.
+				case CalCons.CONNECTED:
+					 System.err.println("Connected: " + value + " - " + message);
 					 args = new String[1];
 					 args[0] = url.toString();
@@ -239,6 +283,24 @@
 					 args = null;
 					 break;
-				case 14:
-					 // Rendering complete.
+					 // The size of the content at the given URL is known and is contained in the value argument.
+				case CalCons.DOC_LENGTH:
+					 System.err.println("Doc Length: " + value + " - " + message);
+					 break;
+					 // The title of the document for the given URL is known and is contained in the message argument. Only the title of a document in the Pane's top level frame will be sent to this method. If the document has no name, the message will be null, unless the document is a Frameset document in which case the message "Frameset" will be sent.
+				case CalCons.TITLE:
+					 System.err.println("Title: " + value + " - " + message);
+					 break;
+					 // An exception has been thrown during parsing of the data from the URL. This will most likely be an IOException such as a server time-out.
+				case CalCons.PARSE_FAILED_POST_CONNECT:
+					 System.err.println("Parse Failed Post Connect: " + value + " - " + message);
+					 status.setText(get("TimedOut") + message);
+					 break;
+					 // The document has been parsed but formatting cannot be completed because the document contains images of unspecified size. The parsing thread is waiting for image updates to give it the information it needs to format and display the document. 
+				case CalCons.WAITING_FOR_IMAGES:
+					 System.err.println("Waiting For Images: " + value + " - " + message);
+					 break;
+					 // All text and image data has been received, parsed and the document structure determined.
+				case CalCons.DOC_LOADED:
+					 System.err.println("Doc Loaded: " + value + " - " + message);
 					 status.setText(get("Ready"));
 					 break;
