From 4edc470836068d06d8033a849f7eec780d39eb99 Mon Sep 17 00:00:00 2001
From: jprocter <Jim Procter>
Date: Wed, 6 Dec 2006 17:29:52 +0000
Subject: [PATCH] type change

---
 src/jalview/gui/VamsasClient.java |  180 ++++++++++++++++++-------------------
 1 file changed, 87 insertions(+), 93 deletions(-)

diff --git a/src/jalview/gui/VamsasClient.java b/src/jalview/gui/VamsasClient.java
index df6dbdd..b97e181 100755
--- a/src/jalview/gui/VamsasClient.java
+++ b/src/jalview/gui/VamsasClient.java
@@ -31,46 +31,46 @@ import org.vamsas.test.simpleclient.ClientDoc;
  *
  */
 public class VamsasClient extends ArchiveClient {
-	// Cache.preferences for vamsas client session arena
-	// preferences for check for default session at startup.
-	// user and organisation stuff.
-	public VamsasClient(Desktop jdesktop,
-			File sessionPath) {
-		super(System.getProperty("user.name"),System.getProperty("host.name"), "jalview","2.7",
-				sessionPath);
-	}
-	public void initial_update() {
-		Cache.log.info("Jalview loading the Vamsas Session.");
-		// load in the vamsas archive for the first time
-		ClientDoc cdoc = this.getUpdateable();
-		updateJalview(cdoc);
+  // Cache.preferences for vamsas client session arena
+  // preferences for check for default session at startup.
+  // user and organisation stuff.
+  public VamsasClient(Desktop jdesktop,
+      File sessionPath) {
+    super(System.getProperty("user.name"),System.getProperty("host.name"), "jalview","2.7",
+        sessionPath);
+  }
+  public void initial_update() {
+    Cache.log.info("Jalview loading the Vamsas Session.");
+    // load in the vamsas archive for the first time
+    ClientDoc cdoc = this.getUpdateable();
+    updateJalview(cdoc);
     JInternalFrame[] frames = Desktop.desktop.getAllFrames();
 
     if (frames == null)
     {
-        return;
+      return;
     }
 
     try
     {
       //REVERSE ORDER
-        for (int i = frames.length - 1; i > -1; i--)
+      for (int i = frames.length - 1; i > -1; i--)
+      {
+        if (frames[i] instanceof AlignFrame)
         {
-            if (frames[i] instanceof AlignFrame)
-            {
-              AlignFrame af = (AlignFrame) frames[i];
-              af.alignPanel.alignmentChanged();
-            }
+          AlignFrame af = (AlignFrame) frames[i];
+          af.alignPanel.alignmentChanged();
         }
+      }
     } catch (Exception e) {
       Cache.log.warn("Exception whilst refreshing jalview windows after a vamsas document update.", e);
     }
     doUpdate(cdoc);
     cdoc.closeDoc();
   }
- 	/**
-	 * this will close all windows currently in Jalview.
-	 *
+  /**
+   * this will close all windows currently in Jalview.
+   *
 
 	protected void closeWindows() {
 		JInternalFrame[] frames = Desktop.desktop.getAllFrames();
@@ -95,10 +95,10 @@ public class VamsasClient extends ArchiveClient {
 		// Close windows - load update.
 		Cache.log.info("Jalview updating from Vamsas Session.");
 	}
-  */
+   */
   VamsasClientWatcher watcher=null;
-	public void push_update() {
-	  watchForChange=false;
+  public void push_update() {
+    watchForChange=false;
     try {
       Thread.sleep(WATCH_SLEEP);
     } catch (Exception e) {
@@ -111,20 +111,14 @@ public class VamsasClient extends ArchiveClient {
     cdoc=null;
     watchForChange=true;
     if (watcher!=null) {
-      Thread wthread = new Thread() {
-        public void run() {
-          watcher.run();
-        }
-      };
-      wthread.start();
-
+      watcher.start();
     }
-		// collect all uncached alignments and put them into the vamsas dataset.
-		// store them.
-		Cache.log.info("Jalview updating the Vamsas Session.");
-	}
-	public void end_session() {
-	  //   stop any update/watcher thread.
+    // collect all uncached alignments and put them into the vamsas dataset.
+    // store them.
+    Cache.log.info("Jalview updating the Vamsas Session.");
+  }
+  public void end_session() {
+    //   stop any update/watcher thread.
     watchForChange=false; // this makes any watch(long) loops return.
     // we should also wait arount for this.WATCH_SLEEP to really make sure the watcher thread has stopped.
     try {
@@ -133,90 +127,90 @@ public class VamsasClient extends ArchiveClient {
 
     };
     Cache.log.info("Jalview disconnecting from the Vamsas Session.");
-	}
-	public void updateJalview(ClientDoc cdoc) {
-		ensureJvVamsas();
+  }
+  public void updateJalview(ClientDoc cdoc) {
+    ensureJvVamsas();
     VamsasDatastore vds = new VamsasDatastore(cdoc, vobj2jv, jv2vobj, baseProvEntry());
     vds.updateToJalview();
-	}
-	private void ensureJvVamsas() {
+  }
+  private void ensureJvVamsas() {
     if (jv2vobj==null) {
       jv2vobj = new IdentityHashMap();
       vobj2jv = new Hashtable();
     }
-	}
-	/**
-	 * jalview object binding to VorbaIds
-	 */
-	IdentityHashMap jv2vobj = null;
-	Hashtable vobj2jv = null;
-	public void updateVamsasDocument(ClientDoc doc) {
-	  ensureJvVamsas();
+  }
+  /**
+   * jalview object binding to VorbaIds
+   */
+  IdentityHashMap jv2vobj = null;
+  Hashtable vobj2jv = null;
+  public void updateVamsasDocument(ClientDoc doc) {
+    ensureJvVamsas();
     VamsasDatastore vds = new VamsasDatastore(doc, vobj2jv, jv2vobj, baseProvEntry());
     // wander through frames
-		JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+    JInternalFrame[] frames = Desktop.desktop.getAllFrames();
 
-        if (frames == null)
-        {
-            return;
-        }
+    if (frames == null)
+    {
+      return;
+    }
 
-        try
+    try
+    {
+      //REVERSE ORDER
+      for (int i = frames.length - 1; i > -1; i--)
+      {
+        if (frames[i] instanceof AlignFrame)
         {
-        	//REVERSE ORDER
-            for (int i = frames.length - 1; i > -1; i--)
-            {
-                if (frames[i] instanceof AlignFrame)
-                {
-                	AlignFrame af = (AlignFrame) frames[i];
-
-                	// update alignment and root from frame.
-                	vds.storeVAMSAS(af.getViewport(), af.getTitle());
-                }
-            }
-        }
-        catch (Exception e) {
-        	Cache.log.error("Vamsas Document store exception",e);
+          AlignFrame af = (AlignFrame) frames[i];
+
+          // update alignment and root from frame.
+          vds.storeVAMSAS(af.getViewport(), af.getTitle());
         }
-	}
-	private Entry baseProvEntry() {
+      }
+    }
+    catch (Exception e) {
+      Cache.log.error("Vamsas Document store exception",e);
+    }
+  }
+  private Entry baseProvEntry() {
     org.vamsas.objects.core.Entry pentry = new org.vamsas.objects.core.Entry();
     pentry.setUser(this.getProvenanceUser());
     pentry.setApp(this.getClientHandle().getClientName());
     pentry.setDate(new org.exolab.castor.types.Date(new java.util.Date()));
     pentry.setAction("created");
     return pentry;
-	}
-  protected class VamsasClientWatcher extends Thread implements Runnable {
-		/* (non-Javadoc)
-		 * @see java.lang.Thread#run()
-		 */
-		VamsasClient client=null;
-		VamsasClientWatcher(VamsasClient client) {
-			this.client = client;
-		}
+  }
+  protected class VamsasClientWatcher extends Thread {
+    /* (non-Javadoc)
+     * @see java.lang.Thread#run()
+     */
+    VamsasClient client=null;
+    VamsasClientWatcher(VamsasClient client) {
+      this.client = client;
+    }
     boolean running=false;
-		public void run() {
-		  running=true;
-			while (client.watchForChange) {
-			  ClientDoc docio = client.watch(0);
-			  if (docio!=null) {
+    public void run() {
+      running=true;
+      while (client.watchForChange) {
+        ClientDoc docio = client.watch(0);
+        if (docio!=null) {
           client.disableGui(true);
           Cache.log.debug("Updating jalview from changed vamsas document.");
-			    client.updateJalview(docio);
+          client.updateJalview(docio);
           Cache.log.debug("Finished updating from document change.");
           docio.closeDoc();
           docio=null;
           client.disableGui(false);
-			  }
+        }
       }
       running=false;
 
-		}
+    }
 
-	}
+  }
   public void disableGui(boolean b) {
-      Desktop.instance.setVamsasUpdate(b);
+    Desktop.instance.setVamsasUpdate(b);
   }
   public void startWatcher() {
     if (watcher==null)
-- 
1.7.10.2