Merge commit 'alpha/update_2_12_for_2_11_2_series_merge^2' into HEAD
[jalview.git] / src / jalview / util / Platform.java
index daaab3a..7b93fe5 100644 (file)
@@ -23,6 +23,7 @@ package jalview.util;
 import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.GraphicsEnvironment;
+
 import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseEvent;
@@ -61,7 +62,6 @@ import com.stevesoft.pat.Regex;
 import jalview.bin.Jalview;
 import jalview.javascript.json.JSON;
 import swingjs.api.JSUtilI;
-
 /**
  * System platform information used by Applet and Application
  * 
@@ -74,7 +74,10 @@ public class Platform
           false;
 
   private static Boolean isNoJSMac = null, isNoJSWin = null, isMac = null,
-          isWin = null;
+          isWin = null, isLinux = null;
+
+
+  private static Boolean isHeadless = null;
 
   private static swingjs.api.JSUtilI jsutil;
 
@@ -171,6 +174,18 @@ public class Platform
   }
 
   /**
+   * added to check LaF for Linux
+   * 
+   * @return
+   */
+  public static boolean isLinux()
+  {
+    return (isLinux == null
+            ? (isLinux = (System.getProperty("os.name").indexOf("Linux") >= 0))
+            : isLinux);
+  }
+
+  /**
    * 
    * @return true if HTML5 JavaScript
    */
@@ -201,6 +216,18 @@ public class Platform
     return (isNoJSWin == null ? (isNoJSWin = !isJS && isWin()) : isNoJSWin);
   }
 
+  /**
+   * 
+   * @return true if we are running in non-interactive no UI mode
+   */
+  public static boolean isHeadless()
+  {
+    if (isHeadless == null)
+    {
+      isHeadless = "true".equals(System.getProperty("java.awt.headless"));
+    }
+    return isHeadless;
+  }
 
   /**
    * 
@@ -496,6 +523,7 @@ public class Platform
   public static String getUniqueAppletID()
   {
     return (isJS ? (String) jsutil.getAppletAttribute("_uniqueId") : null);
+
   }
 
   /**
@@ -595,6 +623,7 @@ public class Platform
               "StringJS does not support FileReader parsing for JSON -- but it could...");
     }
     return JSON.parse(r);
+
   }
 
   /**
@@ -609,13 +638,11 @@ public class Platform
   public static void streamToFile(InputStream is, File outFile)
           throws IOException
   {
-
     if (isJS)
     {
       jsutil.setFileBytes(outFile, is);
       return;
     }
-
     FileOutputStream fio = new FileOutputStream(outFile);
     try
     {
@@ -648,7 +675,6 @@ public class Platform
     if (isJS)
     {
       jsutil.addDirectDatabaseCall(domain);
-
       System.out.println(
               "Platform adding known access-control-allow-origin * for domain "
                       + domain);
@@ -663,8 +689,7 @@ public class Platform
   public static void getURLCommandArguments()
   {
 
-    try
-    {
+      try {
       /**
        * Retrieve the first query field as command arguments to Jalview. Include
        * only if prior to "?j2s" or "&j2s" or "#". Assign the applet's
@@ -672,14 +697,14 @@ public class Platform
        * 
        * @j2sNative var a =
        *            decodeURI((document.location.href.replace("&","?").split("?j2s")[0]
-       *            + "?").split("?")[1].split("#")[0]); a &&
-       *            (J2S.thisApplet.__Info.args = a.split(" "));
-       * 
-       *            System.out.println("URL arguments: " + a);
+       *            + "?").split("?")[1].split("#")[0]); a && (System.out.println("URL arguments detected were "+a)) &&
+       *            (J2S.thisApplet.__Info.urlargs = a.split(" ")); 
+       *            (!J2S.thisApplet.__Info.args || J2S.thisApplet.__Info.args == "" || J2S.thisApplet.__Info.args == "??") && (J2S.thisApplet.__Info.args = a) && (System.out.println("URL arguments were passed to J2S main."));
        */
     } catch (Throwable t)
     {
     }
+
   }
 
   /**
@@ -704,7 +729,6 @@ public class Platform
     String p2 = path2.replace('\\', '/');
     return p1.equals(p2);
   }
-
   ///////////// JAL-3253 Applet additions //////////////
 
   /**
@@ -1028,5 +1052,4 @@ public class Platform
       }
     }
   }
-
 }