import jalview.javascript.json.JSON;
-import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import com.stevesoft.pat.Regex;
+import swingjs.api.JSUtilI;
+
/**
* System platform information used by Applet and Application
*
private static Boolean isNoJSMac = null, isNoJSWin = null, isMac = null,
isWin = null;
+ private static swingjs.api.JSUtilI jsutil;
+
+ static {
+ if (isJS) {
+ try
+ {
+ jsutil = ((JSUtilI) Class.forName("swingjs.JSUtil").newInstance());
+ } catch (InstantiationException | IllegalAccessException
+ | ClassNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
// private static Boolean isHeadless = null;
/**
{
return;
}
- /**
- * @j2sNative
- *
- * swingjs.JSUtil.cacheFileData$S$O(path, data);
- *
- */
+ jsutil.cachePathData(path, data);
}
public static void cacheFileData(File file)
public static byte[] getFileBytes(File f)
{
- // TODO temporary doubling of 秘bytes and _bytes;
- // just remove _bytes when new transpiler has been installed
- return /** @j2sNative f && (f.秘bytes || f._bytes) || */
- null;
+ // JavaScript only
+ return jsutil.getBytes(f);
}
public static byte[] getFileAsBytes(String fileStr)
{
- byte[] bytes = null;
- // BH 2018 hack for no support for access-origin
- /**
- * @j2sNative bytes = swingjs.JSUtil.getFileAsBytes$O(fileStr)
- */
+ byte[] bytes = (byte[]) jsutil.getFile(fileStr, false);
cacheFileData(fileStr, bytes);
return bytes;
}
@SuppressWarnings("unused")
public static String getFileAsString(String url)
{
- String ret = null;
- /**
- * @j2sNative
- *
- * ret = swingjs.JSUtil.getFileAsString$S(url);
- *
- *
- */
+ String ret = (String) jsutil.getFile(url, true);
cacheFileData(url, ret);
return ret;
}
}
@SuppressWarnings("unused")
byte[] bytes = getFileAsBytes(urlstring);
- // TODO temporary doubling of 秘bytes and _bytes;
- // just remove _bytes when new transpiler has been installed
- /**
- * @j2sNative f.秘bytes = f._bytes = bytes;
- */
+ jsutil.setFileBytes(f, bytes);
return true;
}
public static void addJ2SBinaryType(String ext)
{
+
/**
* @j2sNative
*