private static boolean propsAreReadOnly = Platform.isJS();
+ private static String JS_PROPERTY_PREFIX = "jalview_";
+
public static void initLogger()
{
if (log != null)
propsAreReadOnly = true;
}
- if (propertiesFile != null) {
+ if (propertiesFile == null)
+ { // BH 2019
+ Platform.readInfoProperties(JS_PROPERTY_PREFIX , applicationProperties);
+ } else {
try
{
InputStream fis;
*/
public static String getProperty(String key)
{
- return applicationProperties.getProperty(key);
+
+ String prop = applicationProperties.getProperty(key);
+ if (prop == null && Platform.isJS())
+ {
+ prop = applicationProperties.getProperty(Platform.getUniqueAppletID() + "_" + JS_PROPERTY_PREFIX + key);
+ }
+
+ return prop;
}
/**
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.io.File;
+import java.util.Properties;
import javax.swing.SwingUtilities;
}
}
-public static void cacheFileData(String path, byte[] data) {
+ public static void cacheFileData(String path, byte[] data)
+ {
if (!isJS())
return;
/**
* swingjs.JSUtil.cacheFileData$S$O(path, data);
*
*/
-}
+ }
-public static byte[] getFileBytes(File f) {
+ public static byte[] getFileBytes(File f)
+ {
return /** @j2sNative f && f._bytes || */null;
-}
+ }
-public static byte[] getFileAsBytes(String fileStr) {
+ public static byte[] getFileAsBytes(String fileStr)
+ {
// BH 2018 hack for no support for access-origin
- return /** @j2sNative swingjs.JSUtil.getFileAsBytes$O(fileStr) || */ null;
-}
+ return /** @j2sNative swingjs.JSUtil.getFileAsBytes$O(fileStr) || */ null;
+ }
-public static String getFileAsString(String data) {
+ public static String getFileAsString(String data)
+ {
return /** @j2sNative swingjs.JSUtil.getFileAsString$S(data) || */ null;
-}
+ }
-public static boolean setFileBytes(File f, String urlstring) {
+ public static boolean setFileBytes(File f, String urlstring)
+ {
if (!isJS())
return false;
@SuppressWarnings("unused")
* f._bytes = bytes;
*/
return true;
-}
+ }
-public static void addJ2SBinaryType(String ext)
-{
- ext = "." + ext + "?";
-
+ public static void addJ2SBinaryType(String ext)
+ {
/**
* @j2sNative
*
- * J2S._binaryTypes.push(ext);
+ * J2S._binaryTypes.push("." + ext + "?");
*
*/
-}
+ }
-public static String encodeURI(String value) {
+ public static String encodeURI(String value)
+ {
/**
* @j2sNative
* return encodeURIComponent(value);
*/
return value;
-}
+ }
-public static boolean openURL(String url) {
+ public static boolean openURL(String url)
+ {
if (!isJS())
return false;
/**
* window.open(url);
*/
return true;
-}
+ }
+
+ public static String getUniqueAppletID() {
+ @SuppressWarnings("unused")
+ ThreadGroup g = Thread.currentThread().getThreadGroup();
+ /**
+ * @j2sNative return g.html5Applet._uniqueId;
+ *
+ */
+ return null;
+
+ }
+ /**
+ * Read the Info block for this applet.
+ *
+ * @param prefix "jalview_"
+ * @param p
+ * @return unique id for this applet
+ */
+ public static void readInfoProperties(String prefix, Properties p)
+ {
+ @SuppressWarnings("unused")
+ ThreadGroup g = Thread.currentThread().getThreadGroup();
+ String id = getUniqueAppletID();
+ String key = "", value = "";
+ /**
+ * @j2sNative
+ var info = g.html5Applet.__Info || {};
+ for (var key in info) {
+ if (key.indexOf(prefix) == 0) {
+ value = "" + info[key];
+ */
+
+ p.put(id + "_" + key, value);
+
+ /**
+ * @j2sNative
+
+
+ }
+ }
+ */
+ }
}