X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalviewLite.java;h=ef1e16e17d7ae1d3519146f2326af57390a234ed;hb=9493ac8f3b6a02d3cf9747ed6c0d6cf407d284e8;hp=c3e56c67fbb7368e473829deefaaf70cfcb88958;hpb=21c29b20790ac555b2e2a124a034f6c6b4486270;p=jalview.git diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index c3e56c6..ef1e16e 100644 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -1,19 +1,22 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8) - * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.bin; @@ -60,6 +63,7 @@ import java.util.Hashtable; import java.util.StringTokenizer; import java.util.Vector; +import netscape.javascript.JSException; import netscape.javascript.JSObject; /** @@ -1388,8 +1392,7 @@ public class JalviewLite extends Applet implements } else { - throw new Error( - "Invalid separator parameter - must be non-zero length"); + throw new Error(MessageManager.getString("error.invalid_separator_parameter")); } } int r = 255; @@ -1479,6 +1482,43 @@ public class JalviewLite extends Applet implements } } + 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"); @@ -1497,6 +1537,9 @@ public class JalviewLite extends Applet implements { } ; + // try really hard to let the browser plugin know we want liveconnect + initLiveConnect(); + if (scriptObject != null) { try @@ -1611,15 +1654,19 @@ public class JalviewLite extends Applet implements g.setColor(Color.cyan); g.fillRect(0, 0, getSize().width, getSize().height); g.setColor(Color.red); - g.drawString(MessageManager.getString("label.jalview_cannot_open_file"), 5, 15); + g.drawString( + MessageManager.getString("label.jalview_cannot_open_file"), + 5, 15); g.drawString("\"" + file + "\"", 5, 30); } else if (embedded) { g.setColor(Color.black); g.setFont(new Font("Arial", Font.BOLD, 24)); - g.drawString(MessageManager.getString("label.jalview_applet"), 50, getSize().height / 2 - 30); - g.drawString(MessageManager.getString("label.loading_data") + "...", 50, getSize().height / 2); + g.drawString(MessageManager.getString("label.jalview_applet"), 50, + getSize().height / 2 - 30); + g.drawString(MessageManager.getString("label.loading_data") + "...", + 50, getSize().height / 2); } } @@ -1826,10 +1873,14 @@ public class JalviewLite extends Applet implements if (protocol == jalview.io.AppletFormatAdapter.PASTE) { - newAlignFrame.setTitle(MessageManager.formatMessage("label.sequences_from", new String[]{applet.getDocumentBase().toString()})); + newAlignFrame.setTitle(MessageManager.formatMessage( + "label.sequences_from", new String[] + { applet.getDocumentBase().toString() })); } - newAlignFrame.statusBar.setText(MessageManager.formatMessage("label.successfully_loaded_file", new String []{file})); + newAlignFrame.statusBar.setText(MessageManager.formatMessage( + "label.successfully_loaded_file", new String[] + { file })); String treeFile = applet.getParameter("tree"); if (treeFile == null)