merge from 2_4_Release branch
[jalview.git] / src / jalview / gui / VamsasApplication.java
index 121a200..5988bb8 100644 (file)
@@ -1,5 +1,20 @@
-/**
- *
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
+ * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
 package jalview.gui;
 
@@ -164,25 +179,31 @@ public class VamsasApplication
 
   private void setVclientConfig()
   {
-    if (vclient==null)
+    if (vclient == null)
     {
       return;
     }
-    try {
+    try
+    {
       if (vclient instanceof uk.ac.vamsas.client.simpleclient.SimpleClient)
       {
-        uk.ac.vamsas.client.simpleclient.SimpleClientConfig cfg = ((uk.ac.vamsas.client.simpleclient.SimpleClient)  vclient).getSimpleClientConfig();
+        uk.ac.vamsas.client.simpleclient.SimpleClientConfig cfg = ((uk.ac.vamsas.client.simpleclient.SimpleClient) vclient)
+                .getSimpleClientConfig();
         cfg._validatemergedroots = false;
-        cfg._validateupdatedroots= true; //we may write rubbish otherwise. 
+        cfg._validateupdatedroots = true; // we may write rubbish otherwise.
       }
-    }
-    catch (Error e)
+    } catch (Error e)
     {
-      Cache.log.warn("Probable SERIOUS VAMSAS client incompatibility - carrying on regardless",e);
-    }
-    catch (Exception e)
+      Cache.log
+              .warn(
+                      "Probable SERIOUS VAMSAS client incompatibility - carrying on regardless",
+                      e);
+    } catch (Exception e)
     {
-      Cache.log.warn("Probable VAMSAS client incompatibility - carrying on regardless",e);
+      Cache.log
+              .warn(
+                      "Probable VAMSAS client incompatibility - carrying on regardless",
+                      e);
     }
   }
 
@@ -223,7 +244,7 @@ public class VamsasApplication
     Cache.log
             .debug("Jalview loading the Vamsas Session for the first time.");
     dealWithDocumentUpdate(false); // we don't push an update out to the
-                                    // document yet.
+    // document yet.
     Cache.log.debug("... finished update for the first time.");
   }
 
@@ -263,17 +284,18 @@ public class VamsasApplication
 
   public void push_update()
   {
-    Thread udthread = new Thread(new Runnable() {
+    Thread udthread = new Thread(new Runnable()
+    {
 
       public void run()
       {
         Cache.log.info("Jalview updating to the Vamsas Session.");
-    
+
         dealWithDocumentUpdate(true);
         /*
          * IClientDocument cdoc=null; try { cdoc = vclient.getClientDocument(); }
-         * catch (Exception e) { Cache.log.error("Failed to get client document for
-         * update."); // RAISE A WARNING DIALOG disableGui(false); return; }
+         * catch (Exception e) { Cache.log.error("Failed to get client document
+         * for update."); // RAISE A WARNING DIALOG disableGui(false); return; }
          * updateVamsasDocument(cdoc); updateJalviewGui();
          * cdoc.setVamsasRoots(cdoc.getVamsasRoots()); // propagate update flags
          * back vclient.updateDocument(cdoc);
@@ -281,7 +303,7 @@ public class VamsasApplication
         Cache.log.info("Jalview finished updating to the Vamsas Session.");
         // TODO Auto-generated method stub
       }
-      
+
     });
     udthread.start();
   }
@@ -342,7 +364,9 @@ public class VamsasApplication
   IdentityHashMap jv2vobj = null;
 
   Hashtable vobj2jv = null;
+
   Hashtable alRedoState = null;
+
   public void updateVamsasDocument(IClientDocument doc)
   {
     ensureJvVamsas();
@@ -482,27 +506,35 @@ public class VamsasApplication
   private void addStoreDocumentHandler()
   {
     final VamsasApplication client = this;
-    vclient.addVorbaEventHandler(uk.ac.vamsas.client.Events.DOCUMENT_REQUESTTOCLOSE, new PropertyChangeListener()
-    {
-      public void propertyChange(PropertyChangeEvent evt)
-      {
-        Cache.log.debug("Asking user if the vamsas session should be stored.");
-        int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
-                "The current VAMSAS session has unsaved data - do you want to save it ?",
-            "VAMSAS Session Shutdown",
-            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
-        
-            if(reply==JOptionPane.YES_OPTION)
+    vclient.addVorbaEventHandler(
+            uk.ac.vamsas.client.Events.DOCUMENT_REQUESTTOCLOSE,
+            new PropertyChangeListener()
             {
-              Cache.log.debug("Prompting for vamsas store filename.");
-              Desktop.instance.vamsasSave_actionPerformed(null);
-              Cache.log.debug("Finished attempt at storing document.");
-            } 
-            Cache.log.debug("finished dealing with REQUESTTOCLOSE event.");
-      }
-    });
+              public void propertyChange(PropertyChangeEvent evt)
+              {
+                Cache.log
+                        .debug("Asking user if the vamsas session should be stored.");
+                int reply = JOptionPane
+                        .showInternalConfirmDialog(
+                                Desktop.desktop,
+                                "The current VAMSAS session has unsaved data - do you want to save it ?",
+                                "VAMSAS Session Shutdown",
+                                JOptionPane.YES_NO_OPTION,
+                                JOptionPane.QUESTION_MESSAGE);
+
+                if (reply == JOptionPane.YES_OPTION)
+                {
+                  Cache.log.debug("Prompting for vamsas store filename.");
+                  Desktop.instance.vamsasSave_actionPerformed(null);
+                  Cache.log.debug("Finished attempt at storing document.");
+                }
+                Cache.log
+                        .debug("finished dealing with REQUESTTOCLOSE event.");
+              }
+            });
     Cache.log.debug("Added Jalview handler for vamsas document updates.");
   }
+
   public void disableGui(boolean b)
   {
     Desktop.instance.setVamsasUpdate(b);