JAL-1517 update copyright to version 2.8.2
[jalview.git] / src / jalview / bin / JalviewLite.java
index 8fe90f5..c9d08d4 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * 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.
  * 
@@ -14,6 +14,7 @@
  * 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 <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.bin;
 
@@ -40,6 +41,7 @@ import jalview.javascript.JalviewLiteJsApi;
 import jalview.javascript.JsCallBack;
 import jalview.structure.SelectionListener;
 import jalview.structure.StructureSelectionManager;
+import jalview.util.MessageManager;
 
 import java.applet.Applet;
 import java.awt.Button;
@@ -59,6 +61,7 @@ import java.util.Hashtable;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
+import netscape.javascript.JSException;
 import netscape.javascript.JSObject;
 
 /**
@@ -1477,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");
@@ -1496,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
@@ -1610,15 +1645,15 @@ public class JalviewLite extends Applet implements
       g.setColor(Color.cyan);
       g.fillRect(0, 0, getSize().width, getSize().height);
       g.setColor(Color.red);
-      g.drawString("Jalview can't 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("Jalview Applet", 50, getSize().height / 2 - 30);
-      g.drawString("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);
     }
   }
 
@@ -1825,11 +1860,10 @@ public class JalviewLite extends Applet implements
 
         if (protocol == jalview.io.AppletFormatAdapter.PASTE)
         {
-          newAlignFrame.setTitle("Sequences from "
-                  + applet.getDocumentBase());
+          newAlignFrame.setTitle(MessageManager.formatMessage("label.sequences_from", new String[]{applet.getDocumentBase().toString()}));
         }
 
-        newAlignFrame.statusBar.setText("Successfully loaded file " + file);
+        newAlignFrame.statusBar.setText(MessageManager.formatMessage("label.successfully_loaded_file", new String []{file}));
 
         String treeFile = applet.getParameter("tree");
         if (treeFile == null)