From: BobHanson Date: Sun, 7 Jun 2020 04:05:16 +0000 (-0500) Subject: JAL-3446 JavaScript interface X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6354853222361b71da5f59e53e81624f3b97e871;p=jalview.git JAL-3446 JavaScript interface - testing with two apps on a page - now requires Jalview1.getApp().xxxx, not just Jalview1.app, because a call is needed to ensure that ThreadGroup is set correctly. - still working on this... --- diff --git a/doc/JalviewJS-API.md b/doc/JalviewJS-API.md index 3386b2a..1302021 100644 --- a/doc/JalviewJS-API.md +++ b/doc/JalviewJS-API.md @@ -1,6 +1,6 @@ -## public interface JalviewJSApi +# public interface JalviewJSApi -# full list of available methods (from JalviewLiteJsApi): +## full list of available methods (from JalviewLiteJsApi): public boolean addPdbFile(AlignFrame alFrame, String sequenceId, String pdbEntryString, String pdbFile); public String getAlignment(String format); @@ -67,7 +67,7 @@ public void showOverview(); public void updateForAnnotations(); -# addition available methods (from JalviewLite): +## addition available methods (from JalviewLite): public static String getBuildDate() public static String getInstallation() @@ -75,7 +75,7 @@ -# proposed alias list: +## proposed alias list: - remove overloaded methods - indicate null options diff --git a/doc/JalviewJS-startupParams.md b/doc/JalviewJS-startupParams.md new file mode 100644 index 0000000..9ff3352 --- /dev/null +++ b/doc/JalviewJS-startupParams.md @@ -0,0 +1,92 @@ +## JalviewJS startup parameters + +TODO -- go through these + +# parameters -- from jalview.bin.AppletParams + + private final static String[] params = { + "alignpdbfiles", + "ANNOTATIONCOLOUR_MAX", "ANNOTATIONCOLOUR_MIN", + "annotations", + "APPLICATION_URL", "automaticScrolling", "centrecolumnlabels", + "debug", "defaultColour", "defaultColourNuc", "defaultColourProt", + "embedded", "enableSplitFrame", "externalstructureviewer", "features", + "file", "file2", "format", "heightScale", "hidefeaturegroups", + "jalviewhelpurl", "jnetfile", "jpredfile", "label", "linkLabel_", + "linkLabel_1", "linkURL_", "nojmol", "normaliseLogo", + "normaliseSequenceLogo", "oninit", "PDBFILE", "PDBSEQ", + "relaxedidmatch", "resolvetocodebase", "RGB", "scaleProteinAsCdna", + "scoreFile", "separator", "sequence", "showAnnotation", "showbutton", + "showConsensus", "showConsensusHistogram", "showConservation", + "showfeaturegroups", "showFeatureSettings", "showFullId", + "showGroupConsensus", "showGroupConservation", "showOccupancy", + "showQuality", "showSequenceLogo", "showTreeBootstraps", + "showTreeDistances", "showUnconserved", "showUnlinkedTreeNodes", + "sortBy", "sortByTree", "tree", "treeFile", "upperCase", + "userDefinedColour", "widthScale", "windowHeight", "windowWidth", + "wrap", }; + + + + +# arguments -- from jalview.bin.ArgsParser + + public static final String NOCALCULATION = "nocalculation"; + + public static final String NOMENUBAR = "nomenubar"; + + public static final String NOSTATUS = "nostatus"; + + public static final String SHOWOVERVIEW = "showoverview"; + + // + public static final String ANNOTATIONS = "annotations"; + + public static final String COLOUR = "colour"; + + public static final String FEATURES = "features"; + + public static final String GROOVY = "groovy"; + + public static final String GROUPS = "groups"; + + public static final String HEADLESS = "headless"; + + public static final String JABAWS = "jabaws"; + + public static final String NOANNOTATION = "no-annotation"; + + public static final String NOANNOTATION2 = "noannotation"; // BH 2019.05.07 + + public static final String NODISPLAY = "nodisplay"; + + public static final String NOGUI = "nogui"; + + public static final String NONEWS = "nonews"; + + public static final String NOQUESTIONNAIRE = "noquestionnaire"; + + public static final String NOSORTBYTREE = "nosortbytree"; + + public static final String NOUSAGESTATS = "nousagestats"; + + public static final String OPEN = "open"; + + public static final String OPEN2 = "open2"; // BH added -- for applet + // compatibility; not fully + // implemented + + public static final String PROPS = "props"; + + public static final String QUESTIONNAIRE = "questionnaire"; + + public static final String SETPROP = "setprop"; + + public static final String SORTBYTREE = "sortbytree"; + + public static final String TREE = "tree"; + + public static final String VDOC = "vdoc"; + + public static final String VSESS = "vsess"; + diff --git a/src/jalview/api/JalviewJSApp.java b/src/jalview/api/JalviewJSApp.java index d6c2ec6..5641295 100644 --- a/src/jalview/api/JalviewJSApp.java +++ b/src/jalview/api/JalviewJSApp.java @@ -65,9 +65,17 @@ public class JalviewJSApp implements JalviewJSApi // be '|', but many sequence IDS include // pipes. + /** + * We maintain a pointer to the jalview instance here, because only with that do we have a direct + * connection from the JavaScript "applet" object to the proper instance of Jalview in case there + * are multiple applets on a page. + */ + private Jalview jalview; + - public JalviewJSApp(ArgsParser aparser) + public JalviewJSApp(Jalview jalview, ArgsParser aparser) { + this.jalview = jalview; this.aparser = aparser; Platform.setAppClass(this); } @@ -1397,7 +1405,7 @@ public class JalviewJSApp implements JalviewJSApi try { - Jalview.getInstance().parseArguments(new ArgsParser(args), false); + jalview.parseArguments(new ArgsParser(args), false); return null; } catch (Throwable t) { @@ -1852,7 +1860,7 @@ public class JalviewJSApp implements JalviewJSApi */ public String doSendCallback(Object callback, Object[] data) { - Jalview me = Jalview.getInstance(); + Jalview me = jalview; if (me != null && callback != null) { diff --git a/src/jalview/bin/AppletParams.java b/src/jalview/bin/AppletParams.java index a6c87b1..3abaf72 100644 --- a/src/jalview/bin/AppletParams.java +++ b/src/jalview/bin/AppletParams.java @@ -17,8 +17,9 @@ import jalview.gui.Preferences; public class AppletParams extends HashMap { - private final static String[] params = { "alignpdbfiles", - Preferences.ANNOTATIONCOLOUR_MAX, Preferences.ANNOTATIONCOLOUR_MIN, + private final static String[] params = { + "alignpdbfiles", + "ANNOTATIONCOLOUR_MAX", "ANNOTATIONCOLOUR_MIN", "annotations", "APPLICATION_URL", "automaticScrolling", "centrecolumnlabels", "debug", "defaultColour", "defaultColourNuc", "defaultColourProt", diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index ac44bfe..4819d7a 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -822,7 +822,7 @@ public class Jalview implements ApplicationSingletonI if (isJS) { - jsApp = new JalviewJSApp(aparser); + jsApp = new JalviewJSApp(this, aparser); jsApp.load(af); } else diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index 0a6a5c9..b1b6697 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -808,17 +808,17 @@ public class Platform { if (isJS) { - jsutil.setAppletAttribute("app", j); + jsutil.setAppClass(j); } } /** * - * If this frame ia embedded in a web page, return a known type. + * If this frame is embedded in a web page, return a known type. * * @param frame * a JFrame or JInternalFrame - * @param type + * @param type "name", "node", "init", "dim", or any DOM attribute, such as "id" * @return null if frame is not embedded. */ public static Object getEmbeddedAttribute(Component frame, String type) diff --git a/src/swingjs/api/JSUtilI.java b/src/swingjs/api/JSUtilI.java index cc4f8d4..322ec83 100644 --- a/src/swingjs/api/JSUtilI.java +++ b/src/swingjs/api/JSUtilI.java @@ -348,4 +348,7 @@ public interface JSUtilI { */ Map getAppletInfoAsMap(); + + void setAppClass(Object j); + } diff --git a/swingjs/SwingJS-site.zip b/swingjs/SwingJS-site.zip index 2a6782d..90ec5a2 100644 Binary files a/swingjs/SwingJS-site.zip and b/swingjs/SwingJS-site.zip differ diff --git a/swingjs/timestamp b/swingjs/timestamp index 05d031a..5cb9ccc 100644 --- a/swingjs/timestamp +++ b/swingjs/timestamp @@ -1 +1 @@ -20200605004905 +20200606223527 diff --git a/swingjs/ver/3.2.9-j11/SwingJS-site.zip b/swingjs/ver/3.2.9-j11/SwingJS-site.zip index ea5d1e0..2a6782d 100644 Binary files a/swingjs/ver/3.2.9-j11/SwingJS-site.zip and b/swingjs/ver/3.2.9-j11/SwingJS-site.zip differ diff --git a/swingjs/ver/3.2.9-j11/timestamp b/swingjs/ver/3.2.9-j11/timestamp index b21d6d8..129de41 100644 --- a/swingjs/ver/3.2.9-j11/timestamp +++ b/swingjs/ver/3.2.9-j11/timestamp @@ -1 +1 @@ -20200604081344 +20200606151807 diff --git a/swingjs/ver/3.2.9/SwingJS-site.zip b/swingjs/ver/3.2.9/SwingJS-site.zip index 2a6782d..90ec5a2 100644 Binary files a/swingjs/ver/3.2.9/SwingJS-site.zip and b/swingjs/ver/3.2.9/SwingJS-site.zip differ diff --git a/swingjs/ver/3.2.9/timestamp b/swingjs/ver/3.2.9/timestamp index 05d031a..5cb9ccc 100644 --- a/swingjs/ver/3.2.9/timestamp +++ b/swingjs/ver/3.2.9/timestamp @@ -1 +1 @@ -20200605004905 +20200606223527