JAL-3761 debugged and working (but not tidied) locateInFrom2/To2
[jalview.git] / src / jalview / util / Platform.java
index e9afb70..2d05a1b 100644 (file)
@@ -52,7 +52,7 @@ public class Platform
           false;
 
   private static Boolean isNoJSMac = null, isNoJSWin = null, isMac = null,
-          isWin = null;
+          isWin = null, isLinux = null;
 
   private static Boolean isHeadless = null;
 
@@ -81,6 +81,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
    */
@@ -337,7 +349,7 @@ public class Platform
 
   public static byte[] getFileBytes(File f)
   {
-    return /** @j2sNative f && swingjs.JSUtil.getFileBytes$O(f) || */
+    return /** @j2sNative f && swingjs.JSUtil.getFileAsBytes$O(f) || */
     null;
   }
 
@@ -430,10 +442,8 @@ public class Platform
 
   public static String getUniqueAppletID()
   {
-    @SuppressWarnings("unused")
-    ThreadGroup g = Thread.currentThread().getThreadGroup();
     /**
-     * @j2sNative return g.getHtmlApplet$()._uniqueId;
+     * @j2sNative return swingjs.JSUtil.getApplet$()._uniqueId;
      *
      */
     return null;
@@ -454,13 +464,11 @@ public class Platform
     {
       return;
     }
-    @SuppressWarnings("unused")
-    ThreadGroup g = Thread.currentThread().getThreadGroup();
     String id = getUniqueAppletID();
     String key = "", value = "";
     /**
-     * @j2sNative var info = g.getHtmlApplet$().__Info || {}; for (var key in
-     *            info) { if (key.indexOf(prefix) == 0) { value = "" +
+     * @j2sNative var info = swingjs.JSUtil.getApplet$().__Info || {}; for (var
+     *            key in info) { if (key.indexOf(prefix) == 0) { value = "" +
      *            info[key];
      */
 
@@ -547,23 +555,22 @@ public class Platform
    * @param is
    * @param outFile
    * @throws IOException
-   *           if the file cannot be created or there is a problem reading the
-   *           input stream.
+   *                       if the file cannot be created or there is a problem
+   *                       reading the input stream.
    */
   public static void streamToFile(InputStream is, File outFile)
           throws IOException
   {
+    if (isJS() && /**
+                   * @j2sNative outFile.setBytes$O && outFile.setBytes$O(is) &&
+                   */
+            true)
+    {
+      return;
+    }
     FileOutputStream fio = new FileOutputStream(outFile);
     try
     {
-      if (isJS()
-              && /**
-                  * @j2sNative outFile.setBytes$O && outFile.setBytes$O(is) &&
-                  */
-              true)
-      {
-        return;
-      }
       byte[] bb = new byte[32 * 1024];
       int l;
       while ((l = is.read(bb)) > 0)
@@ -606,18 +613,21 @@ public class Platform
 
   public static void getURLCommandArguments()
   {
-
-    /**
-     * Retrieve the first query field as command arguments to Jalview. Include
-     * only if prior to "?j2s" or "&j2s" or "#". Assign the applet's __Info.args
-     * element to this value.
-     * 
-     * @j2sNative var a =
-     *            decodeURI((document.location.href.replace("&","?").split("?j2s")[0]
-     *            + "?").split("?")[1].split("#")[0]); a &&
-     *            (J2S.thisApplet.__Info.args = a.split(" "));
-     */
-
+      try {
+      /**
+       * Retrieve the first query field as command arguments to Jalview. Include
+       * only if prior to "?j2s" or "&j2s" or "#". Assign the applet's
+       * __Info.args element to this value.
+       * 
+       * @j2sNative var a =
+       *            decodeURI((document.location.href.replace("&","?").split("?j2s")[0]
+       *            + "?").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)
+    {
+    }
   }
 
   /**