From: Ben Soares Date: Wed, 22 Nov 2023 20:11:43 +0000 (+0000) Subject: JAL-4059 Send bespoke Info hash parameters into jalview.bin.Jalview instance. Set... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4d5326a24a5d1a5ec45dffbfaf9cb2f63ca14a30;p=jalview.git JAL-4059 Send bespoke Info hash parameters into jalview.bin.Jalview instance. Set 'splash' div exemplified in jalview_bin_Jalview-namespace.html. Add to core_jalview classlist. --- diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 65ffcab..4eed72f 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -40,6 +40,7 @@ import java.security.PermissionCollection; import java.security.Permissions; import java.security.Policy; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -311,7 +312,7 @@ public class Jalview implements JalviewObjectI } else { - setJSNamespace(); + setJSInfo(); } if (args == null || args.length == 0 || (args.length == 1 @@ -2099,52 +2100,76 @@ public class Jalview implements JalviewObjectI } /** - * Namespace (if set) by JalviewJS + * Info dict set by instantiating JalviewJS */ - private String JSNamespace = null; + private Map JSInfo = null; - private void setJSNamespace(String ns) - { - if (!Platform.isJS()) - { - return; - } - Console.outPrintln("JSNamespace set to '" + ns + "'"); - JSNamespace = ns; - } + private final String[] JSSavedKeys = { "main", "core", "width", "height", + "serverURL", "j2sPath", "console" }; - public String getJSNamespace() + private final String JSSavedKeysPrefix = "js_"; + + private final String JSNamespaceKey = JSSavedKeysPrefix + "namespace"; + + public String getJSInfoValue(String key) { - return JSNamespace; + return JSInfo == null ? null : JSInfo.get(key); } - public void setJSNamespace() + public void setJSInfo() { if (!Platform.isJS()) { return; } - String ns = null; + JSInfo = new HashMap<>(); + String key = null; + String val = null; /** - * @j2sNative var namespace = J2S.thisApplet.__Info.namespace; + * @j2sNative if (J2S.thisApplet.__Info !== undefined) { * - * if (namespace === undefined) + * Object.entries(J2S.thisApplet.__Info).forEach( entry => { * - * { - * - * System.out.println("No namespace given"); - * - * } + * key = entry[0]; * - * else - * - * { + * val = entry[1]; + */ + if (key != null && (key.startsWith(JSSavedKeysPrefix) + || Arrays.asList(JSSavedKeys).contains(key))) + { + JSInfo.put(key, val); + + if (key.equals(JSNamespaceKey)) + { + setJSNamespace(val); + } + } + /** + * @j2sNative } * - * ns = namespace; + * ); * * } */ - setJSNamespace(ns); } + /** + * Namespace (if set) by JalviewJS + */ + private String JSNamespace = null; + + private void setJSNamespace(String ns) + { + if (!Platform.isJS()) + { + return; + } + Console.outPrintln("JSNamespace set to '" + ns + "'"); + JSNamespace = ns; + } + + public String getJSNamespace() + { + return JSNamespace; + } } diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index b33c9c7..8211dcb 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -656,45 +656,99 @@ public class Desktop extends jalview.jbgui.GDesktop if (Platform.isJS()) { - String ns = Jalview.getInstance().getJSNamespace(); + final String ns = Jalview.getInstance().getJSNamespace(); if (ns != null) { - - String nsc = ns + (ns.length() > 0 ? ":" : ""); - String splashId = nsc + "jalviewSplash"; + final String jalviewjsDesktopElementId = "testApplet_LayeredPaneUI_10_8div"; + final String nsc = ns + (ns.length() > 0 ? ":" : ""); + final String nsu = ns + (ns.length() > 0 ? "_" : ""); + final String splashId = nsc + "jalviewSplash"; + final String splashClassActive = nsu + "jalviewSplashActive"; + final String splashClassInactive = nsu + "jalviewSplashInactive"; + final String splashClassHidden = nsu + "jalviewSplashHidden"; + final String js_overflow = Jalview.getInstance() + .getJSInfoValue("js_overflow"); /** - * @j2sNative let splash = document.getElementById(splashId); + * @j2sNative // splash element disappearance + * + * var splashElement = document.getElementById(splashId); + * + * if (splashElement !== undefined) { + * + * splashElement.classList.remove(splashClassActive); + * + * splashElement.classList.add(splashClassInactive); * - * if (splash != null) { + * function sleep(ms) { * - * splash.style.display = "none"; + * return new Promise(resolve => setTimeout(resolve, ms)); * * } - */ - - /** - * @j2sNative var overflow = J2S.thisApplet.__Info.overflow; * - * let desktop = - * document.getElementById("jalviewjs_LayeredPaneUI_10_8div"); + * async function hideSplash() { + * + * await sleep(5000); + * + * splashElement.classList.add(splashClassHidden); + * + * } + * + * hideSplash(); + * + * } + * + * // overflow setting + * + * async function changeVisibility() { + * + * var desktopElement = null; * - * if (desktop != null && overflow) { + * var timeCount = 0; * - * System.out.println("###### Setting overflow to true"); + * var setCount = 0; * - * desktop.style.overflow = "visible"; + * var stayedSetCount = 0; + * + * while ((desktopElement == null || setCount < 5) && + * timeCount < 50 && stayedSetCount < 5) { + * + * await sleep(100); + * + * if (desktopElement == null) { + * + * desktopElement = + * document.getElementById(jalviewjsDesktopElementId); + * + * } + * + * if (desktopElement !== undefined && desktopElement !== + * null) { + * + * if (desktopElement.style.overflow == "hidden") { + * + * desktopElement.style.overflow = "visible"; + * + * setCount++; + * + * stayedSetCount = 0; * * } else { * - * System.out.println("###### Setting overflow to false"); + * stayedSetCount++; * - * System.out.println("###### overflow="); + * } + * + * } * - * System.out.println(overflow); + * timeCount++; + * + * } + * + * } * - * System.out.println("###### desktop="); + * if (new String(js_overflow).substring(0,4) === "true") { * - * console.log(desktop); + * changeVisibility(); * * } */ diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index a5c004f..52a1bcf 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -667,7 +667,7 @@ public class Platform * if namespace is not defined then use the old style single first * parameter for arguments * - * @j2sNative var namespace = J2S.thisApplet.__Info.namespace; + * @j2sNative var namespace = J2S.thisApplet.__Info.js_namespace; * * if (namespace === undefined) * @@ -698,9 +698,9 @@ public class Platform * * var nsc = ""; * - * if (J2S.thisApplet.__Info.namespace) { + * if (namespace) { * - * ns = J2S.thisApplet.__Info.namespace; + * ns = namespace; * * nsc = ns + ":"; * diff --git a/utils/jalviewjs/_j2sclasslist.txt b/utils/jalviewjs/_j2sclasslist.txt index 3471709..65d0302 100644 --- a/utils/jalviewjs/_j2sclasslist.txt +++ b/utils/jalviewjs/_j2sclasslist.txt @@ -1347,6 +1347,7 @@ java/util/zip/ZipConstants.js java/util/zip/ZipEntry.js java/util/zip/ZipInputStream.js javajs/api/BytePoster.js +javajs/api/GenericCifDataParser.js javajs/api/GenericLineReader.js javajs/api/GenericOutputChannel.js javajs/api/JSONEncodable.js @@ -1358,6 +1359,7 @@ javajs/util/AjaxURLStreamHandlerFactory.js javajs/util/BS.js javajs/util/Base64.js javajs/util/CU.js +javajs/util/CifDataParser.js javajs/util/DF.js javajs/util/Encoding.js javajs/util/JSThread.js @@ -1629,6 +1631,8 @@ org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl.js org/jibble/epsgraphics/EpsDocument.js org/jibble/epsgraphics/EpsException.js org/jibble/epsgraphics/EpsGraphics2D.js +org/jmol/adapter/readers/cif/CifReader.js +org/jmol/adapter/readers/cif/MMCifReader.js org/jmol/adapter/readers/pdb/PdbReader.js org/jmol/adapter/smarter/Atom.js org/jmol/adapter/smarter/AtomIterator.js diff --git a/utils/jalviewjs/site-resources/images/jalview_logo_small.svg b/utils/jalviewjs/site-resources/images/jalview_logo_small.svg new file mode 100644 index 0000000..494aafc --- /dev/null +++ b/utils/jalviewjs/site-resources/images/jalview_logo_small.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/utils/jalviewjs/site-resources/jalview_bin_Jalview-corenamespace.html b/utils/jalviewjs/site-resources/jalview_bin_Jalview-corenamespace.html new file mode 100644 index 0000000..bfcf8ea --- /dev/null +++ b/utils/jalviewjs/site-resources/jalview_bin_Jalview-corenamespace.html @@ -0,0 +1,38 @@ + + + + +SwingJS test Jalview + + + + + +
+
+
+ +
+
+This is System.out. clear it start/stop profiling
see ___j2sflags.htm for SwingJS URL command-line options
get _j2sClassList.txt +
+ + diff --git a/utils/jalviewjs/site-resources/jalview_bin_Jalview-namespace.html b/utils/jalviewjs/site-resources/jalview_bin_Jalview-namespace.html index 4563a71..cf95a42 100644 --- a/utils/jalviewjs/site-resources/jalview_bin_Jalview-namespace.html +++ b/utils/jalviewjs/site-resources/jalview_bin_Jalview-namespace.html @@ -17,20 +17,47 @@ Info = { j2sPath: 'swingjs/j2s', console:'sysoutdiv', allowjavascript: true, - namespace: "jv" + // all js_... values can be accessed in Jalview.getInstance().getJSInfoValue(key) + js_namespace: "jv", + js_overflow: true } + -
- -
-
+
+
+ +
+
This is System.out. clear it start/stop profiling
see ___j2sflags.htm for SwingJS URL command-line options
get _j2sClassList.txt