1 Clazz.declarePackage ("jalview.javascript");
2 Clazz.load (null, "jalview.javascript.JSFunctionExec", ["jalview.bin.JalviewLite", "java.lang.StringBuffer", "$.Thread", "java.net.MalformedURLException", "$.URL", "netscape.javascript.JSException", "$.JSObject"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 this.jsExecQueue = null;
7 Clazz.instantialize (this, arguments);
8 }, jalview.javascript, "JSFunctionExec", null, Runnable);
9 Clazz.makeConstructor (c$,
12 this.jsExecQueue = this.jvlite.getJsExecQueue ();
13 this.jvlite.setExecutor (this);
14 }, "jalview.bin.JalviewLite");
15 Clazz.overrideMethod (c$, "finalize",
19 if (this.jsExecQueue != null) {
20 this.jsExecQueue.clear ();
21 }this.jsExecQueue = null;
23 Clazz.defineMethod (c$, "stopQueue",
25 if (this.jsExecQueue != null) {
29 this.jsExecQueue = null;
31 for (var jx, $jx = q.iterator (); $jx.hasNext () && ((jx = $jx.next ()) || true);) {
34 q.removeAllElements ();
37 }}}this.jvlite = null;
40 Clazz.defineMethod (c$, "run",
42 while (this.jsExecQueue != null) {
43 if (this.jsExecQueue.size () > 0) {
44 var r = this.jsExecQueue.elementAt (0);
45 this.jsExecQueue.removeElementAt (0);
49 if (Clazz.exceptionOf (e$$, Exception)) {
52 ex.printStackTrace ();
54 } else if (Clazz.exceptionOf (e$$, Error)) {
57 ex.printStackTrace ();
66 this.jsExecQueue.wait (1000);
68 if (Clazz.exceptionOf (ex, Exception)) {
75 Clazz.defineMethod (c$, "executeJavascriptFunction",
76 function (_listener, objects) {
77 this.executeJavascriptFunction (false, _listener, objects);
79 Clazz.defineMethod (c$, "executeJavascriptFunction",
80 function (async, _listener, $arguments) {
81 this.executeJavascriptFunction (async, _listener, $arguments, null);
83 Clazz.defineMethod (c$, "executeJavascriptFunction",
84 function (async, _listener, $arguments, dbgMsg) {
85 var objects = new Array ($arguments != null ? $arguments.length : 0);
86 if ($arguments != null) {
87 System.arraycopy ($arguments, 0, objects, 0, $arguments.length);
88 }var jsex = new Array (1);
89 var exec = ((Clazz.isClassDefined ("jalview.javascript.JSFunctionExec$1") ? 0 : jalview.javascript.JSFunctionExec.$JSFunctionExec$1$ ()), Clazz.innerTypeInstance (jalview.javascript.JSFunctionExec$1, this, Clazz.cloneFinals ("dbgMsg", dbgMsg, "_listener", _listener, "objects", objects, "jsex", jsex, "async", async)));
91 if (this.executor == null) {
92 this.executor = new Thread ( new jalview.javascript.JSFunctionExec (this.jvlite));
93 this.executor.start ();
95 this.jsExecQueue.addElement (exec);
96 this.jsExecQueue.notify ();
99 if (jsex[0] != null) {
102 c$.$JSFunctionExec$1$ = function () {
104 c$ = Clazz.declareAnonymous (jalview.javascript, "JSFunctionExec$1", null, Runnable);
105 Clazz.defineMethod (c$, "run",
108 var scriptObject = null;
110 scriptObject = netscape.javascript.JSObject.getWindow (this.b$["jalview.javascript.JSFunctionExec"].jvlite);
112 if (Clazz.exceptionOf (ex, Exception)) {
117 ;if (scriptObject != null) {
118 if (jalview.bin.JalviewLite.debug && this.f$.dbgMsg != null) {
119 System.err.println (this.f$.dbgMsg);
120 }scriptObject.call (this.f$._listener, this.f$.objects);
122 if (Clazz.exceptionOf (jex, Exception)) {
123 if (!(Clazz.instanceOf (jex, java.net.MalformedURLException))) {
124 if (jalview.bin.JalviewLite.debug) {
125 System.err.println (jex);
126 }if (Clazz.instanceOf (jex, netscape.javascript.JSException) && this.b$["jalview.javascript.JSFunctionExec"].jvlite.jsfallbackEnabled) {
127 this.f$.jsex[0] = jex;
128 if (jalview.bin.JalviewLite.debug) {
129 System.err.println ("Falling back to javascript: url call");
130 }var sb = new StringBuffer ("javascript:" + this.f$._listener + "(");
131 for (var i = 0; this.f$.objects != null && i < this.f$.objects.length; i++) {
135 if (this.f$.objects[i] != null && !(this.f$.objects[i].getClass ().getName ().indexOf ("jalview") == 0)) {
136 sb.append (this.f$.objects[i].toString ());
140 if (jalview.bin.JalviewLite.debug) {
141 System.err.println (sb.toString ());
144 url = new java.net.URL (sb.toString ());
145 this.b$["jalview.javascript.JSFunctionExec"].jvlite.getAppletContext ().showDocument (url);
148 if (Clazz.exceptionOf (uex, Exception)) {
156 jex.printStackTrace ();
158 this.f$.jsex[0] = jex;