JAL-3210 Merge branch 'develop' into trialMerge
[jalview.git] / src / jalview / bin / Jalview.java
index 694fe00..521b674 100755 (executable)
@@ -67,6 +67,8 @@ import java.util.logging.Logger;
 import javax.swing.LookAndFeel;
 import javax.swing.UIManager;
 
+import com.threerings.getdown.util.LaunchUtil;
+
 import groovy.lang.Binding;
 import groovy.util.GroovyScriptEngine;
 
@@ -137,8 +139,8 @@ public class Jalview
   class FeatureFetcher
   {
     /*
-     * TODO: generalise to track all jalview events to orchestrate batch
-     * processing events.
+     * TODO: generalise to track all jalview events to orchestrate batch processing
+     * events.
      */
 
     private int queued = 0;
@@ -196,7 +198,7 @@ public class Jalview
    * main class for Jalview application
    * 
    * @param args
-   *          open <em>filename</em>
+   *               open <em>filename</em>
    */
   public static void main(String[] args)
   {
@@ -264,6 +266,8 @@ public class Jalview
     System.out.println(System.getProperty("os.arch") + " "
             + System.getProperty("os.name") + " "
             + System.getProperty("os.version"));
+    // report Jalview version
+    Cache.loadBuildProperties(true);
 
     ArgsParser aparser = new ArgsParser(args);
     boolean headless = false;
@@ -377,8 +381,9 @@ public class Jalview
                   "Failed to set QuaQua look and feel: " + e.toString());
         }
       }
-      if (lookAndFeel == null || !(lookAndFeel.getClass()
-              .isAssignableFrom(UIManager.getLookAndFeel().getClass()))
+      if (lookAndFeel == null
+              || !(lookAndFeel.getClass().isAssignableFrom(
+                      UIManager.getLookAndFeel().getClass()))
               || !UIManager.getLookAndFeel().getClass().toString()
                       .toLowerCase().contains("quaqua"))
       {
@@ -396,10 +401,10 @@ public class Jalview
     }
 
     /*
-     * configure 'full' SO model if preferences say to, 
-     * else use the default (SO Lite)
+     * configure 'full' SO model if preferences say to, else use the default (SO
+     * Lite)
      */
-    if (Cache.getDefault("USE_FULL_SO", false))
+    if (Cache.getDefault("USE_FULL_SO", true))
     {
       SequenceOntologyFactory.setInstance(new SequenceOntology());
     }
@@ -417,6 +422,20 @@ public class Jalview
 //       }
       ;
       desktop.setInBatchMode(true); // indicate we are starting up
+
+      try
+      {
+        JalviewTaskbar.setTaskbar(this);
+      } catch (Exception e)
+      {
+        System.out.println("Cannot set Taskbar");
+        // e.printStackTrace();
+      } catch (Throwable t)
+      {
+        System.out.println("Cannot set Taskbar");
+        // t.printStackTrace();
+      }
+
       desktop.setVisible(true);
 
       if (!Platform.isJS())
@@ -479,6 +498,25 @@ public class Jalview
       }
     }
 
+    // Move any new getdown-launcher-new.jar into place over old
+    // getdown-launcher.jar
+    String appdirString = System.getProperty("getdownappdir");
+    if (appdirString != null && appdirString.length() > 0)
+    {
+      final File appdir = new File(appdirString);
+      new Thread()
+      {
+        @Override
+        public void run()
+        {
+          LaunchUtil.upgradeGetdown(
+                  new File(appdir, "getdown-launcher-old.jar"),
+                  new File(appdir, "getdown-launcher.jar"),
+                  new File(appdir, "getdown-launcher-new.jar"));
+        }
+      }.start();
+    }
+
     String file = null, data = null;
     FileFormatI format = null;
     DataSourceType protocol = null;
@@ -495,91 +533,6 @@ public class Jalview
       System.out.println("No files to open!");
       System.exit(1);
     }
-    String vamsasImport = aparser.getValue("vdoc");
-    String vamsasSession = aparser.getValue("vsess");
-    if (vamsasImport != null || vamsasSession != null)
-    {
-      if (desktop == null || headless)
-      {
-        System.out.println(
-                "Headless vamsas sessions not yet supported. Sorry.");
-        System.exit(1);
-      }
-      // if we have a file, start a new session and import it.
-      boolean inSession = false;
-      if (vamsasImport != null)
-      {
-        try
-        {
-          DataSourceType viprotocol = AppletFormatAdapter
-                  .checkProtocol(vamsasImport);
-          if (viprotocol == DataSourceType.FILE)
-          {
-            inSession = desktop.vamsasImport(new File(vamsasImport));
-          }
-          else if (viprotocol == DataSourceType.URL)
-          {
-            inSession = desktop.vamsasImport(new URL(vamsasImport));
-          }
-
-        } catch (Exception e)
-        {
-          System.err.println("Exeption when importing " + vamsasImport
-                  + " as a vamsas document.");
-          e.printStackTrace();
-        }
-        if (!inSession)
-        {
-          System.err.println("Failed to import " + vamsasImport
-                  + " as a vamsas document.");
-        }
-        else
-        {
-          System.out.println("Imported Successfully into new session "
-                  + desktop.getVamsasApplication().getCurrentSession());
-        }
-      }
-      if (vamsasSession != null)
-      {
-        if (vamsasImport != null)
-        {
-          // close the newly imported session and import the Jalview specific
-          // remnants into the new session later on.
-          desktop.vamsasStop_actionPerformed(null);
-        }
-        // now join the new session
-        try
-        {
-          if (desktop.joinVamsasSession(vamsasSession))
-          {
-            System.out.println(
-                    "Successfully joined vamsas session " + vamsasSession);
-          }
-          else
-          {
-            System.err.println("WARNING: Failed to join vamsas session "
-                    + vamsasSession);
-          }
-        } catch (Exception e)
-        {
-          System.err.println(
-                  "ERROR: Failed to join vamsas session " + vamsasSession);
-          e.printStackTrace();
-        }
-        if (vamsasImport != null)
-        {
-          // the Jalview specific remnants can now be imported into the new
-          // session at the user's leisure.
-          Cache.log.info(
-                  "Skipping Push for import of data into existing vamsas session."); // TODO:
-          // enable
-          // this
-          // when
-          // debugged
-          // desktop.getVamsasApplication().push_update();
-        }
-      }
-    }
     long progress = -1;
     // Finally, deal with the remaining input data.
     if (file != null)
@@ -638,9 +591,8 @@ public class Jalview
         {
           data.replaceAll("%20", " ");
 
-          ColourSchemeI cs = ColourSchemeProperty
-                  .getColourScheme(af.getViewport(),
-                          af.getViewport().getAlignment(), data);
+          ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
+                  af.getViewport(), af.getViewport().getAlignment(), data);
 
           if (cs != null)
           {
@@ -827,16 +779,15 @@ public class Jalview
     // ////////////////////
 
     if (!Platform.isJS() && !headless && file == null
-            && vamsasImport == null
-            && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
+            && Cache.getDefault("SHOW_STARTUP_FILE", true))
     /**
      * Java only
      * 
      * @j2sIgnore
      */
     {
-      file = jalview.bin.Cache.getDefault("STARTUP_FILE",
-              jalview.bin.Cache.getDefault("www.jalview.org",
+      file = Cache.getDefault("STARTUP_FILE",
+              Cache.getDefault("www.jalview.org",
                       "http://www.jalview.org")
                       + "/examples/exampleFile_2_7.jar");
       if (file.equals(
@@ -845,7 +796,7 @@ public class Jalview
         // hardwire upgrade of the startup file
         file.replace("_2_3.jar", "_2_7.jar");
         // and remove the stale setting
-        jalview.bin.Cache.removeProperty("STARTUP_FILE");
+        Cache.removeProperty("STARTUP_FILE");
       }
 
       protocol = DataSourceType.FILE;
@@ -938,10 +889,6 @@ public class Jalview
                     // passed in correctly)"
                     + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
                     + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
-                    // +
-                    // "-vdoc vamsas-document\tImport vamsas document into new
-                    // session or join existing session with same URN\n"
-                    // + "-vses vamsas-session\tJoin session with given URN\n"
                     + "-groovy FILE\tExecute groovy script in FILE, after all other arguments have been processed (if FILE is the text 'STDIN' then the file will be read from STDIN)\n"
                     + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
   }
@@ -981,10 +928,10 @@ public class Jalview
    * Locate the given string as a file and pass it to the groovy interpreter.
    * 
    * @param groovyscript
-   *          the script to execute
+   *                         the script to execute
    * @param jalviewContext
-   *          the Jalview Desktop object passed in to the groovy binding as the
-   *          'Jalview' object.
+   *                         the Jalview Desktop object passed in to the groovy
+   *                         binding as the 'Jalview' object.
    */
   private void executeGroovyScript(String groovyscript, AlignFrame af)
   {
@@ -1071,7 +1018,7 @@ public class Jalview
     }
     try
     {
-      Map<String, Object> vbinding = new HashMap<>();
+      Map<String, java.lang.Object> vbinding = new HashMap<>();
       vbinding.put("Jalview", this);
       if (af != null)
       {
@@ -1113,8 +1060,8 @@ public class Jalview
   }
 
   /**
-   * Quit method delegates to Desktop.quit - unless running in headless mode
-   * when it just ends the JVM
+   * Quit method delegates to Desktop.quit - unless running in headless mode when
+   * it just ends the JVM
    */
   public void quit()
   {