j2sNative references moved to Platform
[jalview.git] / src / jalview / util / Platform.java
index 1f03f88..0a788d9 100644 (file)
@@ -22,6 +22,7 @@ package jalview.util;
 
 import java.awt.Toolkit;
 import java.awt.event.MouseEvent;
+import java.io.File;
 
 import javax.swing.SwingUtilities;
 
@@ -59,12 +60,14 @@ public class Platform
   }
 
   /**
+   * Answers true if Jalview is running as Javascript, else false. The value is
+   * set at compile time.
    * 
-   * @return true if HTML5 JavaScript
+   * @return
    */
   public static boolean isJS()
   {
-       return isJS;
+    return /** @j2sNative true || */ false;
   }
 
   /**
@@ -219,5 +222,74 @@ public class Platform
                  break;
          }
   }
+
+public static void cacheFileData(String path, byte[] data) {
+       if (!isJS())
+               return;
+         /**
+          * @j2sNative 
+          *   
+          *   swingjs.JSUtil.cacheFileData$S$O(path, data);
+          * 
+          */
+}
+
+public static byte[] getFileBytes(File f) {
+       return /** @j2sNative   f && f._bytes || */null;
+}
+
+public static byte[] getFileAsBytes(String fileStr) {
+    // BH 2018 hack for no support for access-origin
+               return /** @j2sNative swingjs.JSUtil.getFileAsBytes$O(fileStr) || */ null;
+}
+
+public static String getFileAsString(String data) {
+       return /** @j2sNative swingjs.JSUtil.getFileAsString$S(data) || */ null;
+}
+
+public static boolean setFileBytes(File f, String urlstring) {
+       if (!isJS()) 
+               return false;
+       @SuppressWarnings("unused")
+       byte[] bytes = getFileAsBytes(urlstring);
+                   /** @j2sNative 
+                    * f._bytes = bytes; 
+                    */
+       return true;
+}
+
    
+public static void addJ2SBinaryType(String ext)
+{
+  ext = "." + ext + "?";
+
+  /**
+   * @j2sNative
+   * 
+   *            J2S._binaryTypes.push(ext);
+   * 
+   */
+}
+
+public static String encodeURI(String value) {
+    /**
+     * @j2sNative
+     * return encodeURIComponent(value);
+     */
+       return value;
+}
+
+public static boolean openURL(String url) {
+       if (!isJS()) 
+               return false;
+               /**
+                * @j2sNative
+                * 
+                * 
+                *                      window.open(url);
+                */
+       return true;
+}
+
+
 }