From 117479142a51c5ab468ba4120815cb8436648dfd Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 27 May 2014 16:03:20 +0100 Subject: [PATCH] JAL-1507 added loop to throw dummy javascript calls out to the browser to make sure it wakes up and prompts user to allow LiveConnect --- src/jalview/bin/JalviewLite.java | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index ad09824..631c7fe 100644 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -61,6 +61,7 @@ import java.util.Hashtable; import java.util.StringTokenizer; import java.util.Vector; +import netscape.javascript.JSException; import netscape.javascript.JSObject; /** @@ -1479,7 +1480,36 @@ public class JalviewLite extends Applet implements callInitCallback(); } } - + private void initLiveConnect() + { + // try really hard to get the liveConnect thing working + boolean notFailed=false; + int tries=0; + while (notFailed && tries<10) { + if (tries>0) + { + System.err.println("LiveConnect request thread going to sleep."); + } + try { + Thread.sleep(700*(1+tries)); + } + catch (InterruptedException q) {}; + if (tries++>0) + { + System.err.println("LiveConnect request thread woken up."); + } + try { + JSObject scriptObject = JSObject.getWindow(this); + if (scriptObject.eval("navigator")!=null) + { + notFailed=true; + } + } catch (JSException jsex) + { + System.err.println("Attempt "+tries+" to access LiveConnect javascript failed."); + } + } + } private void callInitCallback() { String initjscallback = getParameter("oninit"); @@ -1498,6 +1528,9 @@ public class JalviewLite extends Applet implements { } ; + // try really hard to let the browser plugin know we want liveconnect + initLiveConnect(); + if (scriptObject != null) { try -- 1.7.10.2