debug comment out
[jalview.git] / src / jalview / bin / Jalview.java
index bb2038e..fae2b75 100755 (executable)
@@ -20,6 +20,7 @@
  */
 package jalview.bin;
 
+import jalview.api.AlignCalcWorkerI;
 import jalview.api.AlignFrameI;
 import jalview.api.AlignViewportI;
 import jalview.api.JalviewApp;
@@ -83,9 +84,6 @@ import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.Vector;
-import java.util.logging.ConsoleHandler;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 import javax.swing.LookAndFeel;
 import javax.swing.UIManager;
@@ -146,6 +144,30 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
 
   protected JSFunctionExec jsFunctionExec;
 
+  private boolean noCalculation, noMenuBar, noStatus;
+
+  private boolean noAnnotation;
+
+  public boolean getStartCalculations()
+  {
+    return !noCalculation;
+  }
+
+  public boolean getAllowMenuBar()
+  {
+    return !noMenuBar;
+  }
+
+  public boolean getShowStatus()
+  {
+    return !noStatus;
+  }
+
+  public boolean getShowAnnotation()
+  {
+    return !noAnnotation;
+  }
+
   public static AlignFrame getCurrentAlignFrame()
   {
     return getInstance().currentAlignFrame;
@@ -251,71 +273,12 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
    */
   public static void main(String[] args)
   {
-    // setLogging(); // BH - for event debugging in JavaScript
+    // Platform.startJavaLogging();
     getInstance().doMain(args);
   }
 
-  /**
-   * Allow an outside entity to initiate the second half of argument parsing
-   * (only).
-   * 
-   * @param args
-   * @return null is good
-   */
-  @Override
-  public Object parseArguments(String[] args)
-  {
-
-    try
-    {
-      ArgsParser aparser = new ArgsParser(args);
-      return parseArguments(aparser, false);
-    } catch (Throwable t)
-    {
-      return t;
-    }
-  }
-
-  private static void logClass(String name)
-  {
-    // BH - for event debugging in JavaScript
-    ConsoleHandler consoleHandler = new ConsoleHandler();
-    consoleHandler.setLevel(Level.ALL);
-    Logger logger = Logger.getLogger(name);
-    logger.setLevel(Level.ALL);
-    logger.addHandler(consoleHandler);
-  }
 
   @SuppressWarnings("unused")
-  private static void setLogging()
-  {
-
-    /**
-     * @j2sIgnore
-     * 
-     */
-    {
-      System.out.println("not in js");
-    }
-
-    // BH - for event debugging in JavaScript (Java mode only)
-    if (!Platform.isJS())
-    /**
-     * Java only
-     * 
-     * @j2sIgnore
-     */
-    {
-      Logger.getLogger("").setLevel(Level.ALL);
-      logClass("java.awt.EventDispatchThread");
-      logClass("java.awt.EventQueue");
-      logClass("java.awt.Component");
-      logClass("java.awt.focus.Component");
-      logClass("java.awt.focus.DefaultKeyboardFocusManager");
-    }
-
-  }
-
   /**
    * @param args
    */
@@ -323,7 +286,11 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
   {
 
     boolean isJS = Platform.isJS();
-    if (!isJS)
+    if (isJS)
+    {
+      Platform.setAppClass(this);
+    }
+    else
     {
       System.setSecurityManager(null);
     }
@@ -553,6 +520,33 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
     parseArguments(aparser, true);
   }
 
+  /**
+   * Allow an outside entity to initiate the second half of argument parsing
+   * (only).
+   * 
+   * @param args
+   * @return null is good
+   */
+  @Override
+  public Object parseArguments(String[] args)
+  {
+
+    try
+    {
+      ArgsParser aparser = new ArgsParser(args);
+      return parseArguments(aparser, false);
+    } catch (Throwable t)
+    {
+      return t;
+    }
+  }
+
+  /**
+   * 
+   * @param aparser
+   * @param isStartup
+   * @return
+   */
   private Object parseArguments(ArgsParser aparser, boolean isStartup)
   {
     boolean isJS = Platform.isJS();
@@ -569,7 +563,6 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
     String fileFormat = (isJavaAppletTag
             ? aparser.getAppletValue("format", null)
             : null);
-
     FileFormatI format = null;
     DataSourceType protocol = null;
 
@@ -597,8 +590,11 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
       }
     }
 
+    String data;
+
     if (file != null)
     {
+
       if (!headless)
       {
         desktop.setProgressBar(
@@ -645,6 +641,30 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
         // TODO ?
       }
 
+      if (aparser.contains(ArgsParser.NOMENUBAR))
+      {
+        noMenuBar = true;
+        System.out.println("CMD [nomenu] executed successfully!");
+      }
+
+      if (aparser.contains(ArgsParser.NOSTATUS))
+      {
+        noStatus = true;
+        System.out.println("CMD [nostatus] executed successfully!");
+      }
+
+      if (aparser.contains(ArgsParser.NOANNOTATION)
+              || aparser.contains(ArgsParser.NOANNOTATION2))
+      {
+        noAnnotation = true;
+        System.out.println("CMD no-annotation executed successfully!");
+      }
+      if (aparser.contains(ArgsParser.NOCALCULATION))
+      {
+        noCalculation = true;
+        System.out.println("CMD [nocalculation] executed successfully!");
+      }
+
       AlignFrame af = new FileLoader(!headless).loadFileWaitTillLoaded(file,
               protocol, format);
       if (af == null)
@@ -686,7 +706,7 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
 
         // TODO: file2 How to implement file2 for the applet spit screen?
 
-        String data = aparser.getValue(ArgsParser.COLOUR, true);
+        data = aparser.getValue(ArgsParser.COLOUR, true);
         if (data != null)
         {
           data.replaceAll("%20", " ");
@@ -730,6 +750,13 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
           System.out.println(
                   "CMD [-annotations " + data + "] executed successfully!");
         }
+
+        if (aparser.contains(ArgsParser.SHOWOVERVIEW))
+        {
+          af.overviewMenuItem_actionPerformed(null);
+          System.out.println("CMD [showoverview] executed successfully!");
+        }
+
         // set or clear the sortbytree flag.
         if (aparser.contains(ArgsParser.SORTBYTREE))
         {
@@ -739,18 +766,30 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
             System.out.println("CMD [-sortbytree] executed successfully!");
           }
         }
-        
+
         boolean doUpdateAnnotation = false;
-        
 
-        if (aparser.contains(ArgsParser.NOANNOTATION)
-                || aparser.contains(ArgsParser.NOANNOTATION2))
+        /**
+         * we do this earlier in JalviewJS because of a complication with
+         * SHOWOVERVIEW
+         * 
+         * For now, just fixing this in JalviewJS.
+         *
+         * 
+         * @j2sIgnore
+         * 
+         */
         {
-          af.getViewport().setShowAnnotation(false);
-          if (!af.getViewport().isShowAnnotation())
+          if (aparser.contains(ArgsParser.NOANNOTATION)
+                  || aparser.contains(ArgsParser.NOANNOTATION2))
           {
-            doUpdateAnnotation = true;
-            System.out.println("CMD no-annotation executed successfully!");
+            af.getViewport().setShowAnnotation(false);
+            if (!af.getViewport().isShowAnnotation())
+            {
+              doUpdateAnnotation = true;
+              System.out
+                      .println("CMD no-annotation executed successfully!");
+            }
           }
         }
         if (aparser.contains(ArgsParser.NOSORTBYTREE))
@@ -2005,4 +2044,17 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
 
   }
 
+  @Override
+  public void showOverview()
+  {
+    currentAlignFrame.overviewMenuItem_actionPerformed(null);
+  }
+
+  public void notifyWorker(AlignCalcWorkerI worker, String status)
+  {
+    // System.out.println("Jalview worker " + worker.getClass().getSimpleName()
+    // + " " + status);
+  }
+
 }
+