JAL-793 added ability to visualise raw BioJSON in the exported HTML using facebox
[jalview.git] / src / jalview / util / BrowserLauncher.java
index 5ea4588..cd9c969 100755 (executable)
@@ -1,20 +1,22 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
- * This program 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 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
  * 
- * This program 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.
+ * 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.
+ *  
+ * 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 this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.util;
 
@@ -89,8 +91,8 @@ public class BrowserLauncher
    * Caches whether any classes, methods, and fields that are not part of the
    * JDK and need to be dynamically loaded at runtime loaded successfully.
    * <p>
-   * Note that if this is <code>false</code>, <code>openURL()</code> will
-   * always return an IOException.
+   * Note that if this is <code>false</code>, <code>openURL()</code> will always
+   * return an IOException.
    */
   private static boolean loadedWithoutErrors;
 
@@ -234,7 +236,16 @@ public class BrowserLauncher
     if (osName.startsWith("Mac OS"))
     {
       String mrjVersion = System.getProperty("mrj.version");
-      String majorMRJVersion = mrjVersion.substring(0, 3);
+      String majorMRJVersion;
+      if (mrjVersion == null)
+      {
+        // must be on some later build with mrj support
+        majorMRJVersion = "3.1";
+      }
+      else
+      {
+        majorMRJVersion = mrjVersion.substring(0, 3);
+      }
 
       try
       {
@@ -305,8 +316,8 @@ public class BrowserLauncher
    * Called by a static initializer to load any classes, fields, and methods
    * required at runtime to locate the user's web browser.
    * 
-   * @return <code>true</code> if all intialization succeeded
-   *         <code>false</code> if any portion of the initialization failed
+   * @return <code>true</code> if all intialization succeeded <code>false</code>
+   *         if any portion of the initialization failed
    */
   private static boolean loadClasses()
   {
@@ -683,22 +694,22 @@ public class BrowserLauncher
    * Attempts to open the default web browser to the given URL.
    * 
    * @param url
-   *                The URL to open
+   *          The URL to open
    * @throws IOException
-   *                 If the web browser could not be located or does not run
+   *           If the web browser could not be located or does not run
    */
   public static void openURL(String url) throws IOException
   {
     if (!loadedWithoutErrors)
     {
-      throw new IOException("Exception in finding browser: " + errorMessage);
+      throw new IOException(MessageManager.formatMessage("exception.browser_not_found", new String[]{errorMessage}));
     }
 
     Object browser = locateBrowser();
 
     if (browser == null)
     {
-      throw new IOException("Unable to locate browser: " + errorMessage);
+        throw new IOException(MessageManager.formatMessage("exception.browser_unable_to_locate", new String[]{errorMessage}));
     }
 
     switch (jvm)
@@ -717,19 +728,13 @@ public class BrowserLauncher
         {});
       } catch (InvocationTargetException ite)
       {
-        throw new IOException(
-                "InvocationTargetException while creating AEDesc: "
-                        + ite.getMessage());
+        throw new IOException(MessageManager.formatMessage("exception.invocation_target_exception_creating_aedesc", new String[]{ite.getMessage()}));
       } catch (IllegalAccessException iae)
       {
-        throw new IOException(
-                "IllegalAccessException while building AppleEvent: "
-                        + iae.getMessage());
+         throw new IOException(MessageManager.formatMessage("exception.illegal_access_building_apple_evt", new String[]{iae.getMessage()}));
       } catch (InstantiationException ie)
       {
-        throw new IOException(
-                "InstantiationException while creating AEDesc: "
-                        + ie.getMessage());
+         throw new IOException(MessageManager.formatMessage("exception.illegal_access_building_apple_evt", new String[]{ie.getMessage()}));
       } finally
       {
         aeDesc = null; // Encourage it to get disposed if it was created
@@ -767,13 +772,12 @@ public class BrowserLauncher
         }
         else
         {
-          throw new IOException("Unable to launch URL: " + result);
+          throw new IOException(MessageManager.formatMessage("exception.unable_to_launch_url", new String[]{Integer.valueOf(result).toString()}));
         }
       }
       else
       {
-        throw new IOException(
-                "Unable to create an Internet Config instance: " + result);
+        throw new IOException(MessageManager.formatMessage("exception.unable_to_create_internet_config", new String[]{Integer.valueOf(result).toString()}));
       }
 
       break;
@@ -786,14 +790,10 @@ public class BrowserLauncher
         { url });
       } catch (InvocationTargetException ite)
       {
-        throw new IOException(
-                "InvocationTargetException while calling openURL: "
-                        + ite.getMessage());
+        throw new IOException(MessageManager.formatMessage("exception.invocation_target_calling_url", new String[]{ite.getMessage()}));
       } catch (IllegalAccessException iae)
       {
-        throw new IOException(
-                "IllegalAccessException while calling openURL: "
-                        + iae.getMessage());
+          throw new IOException(MessageManager.formatMessage("exception.illegal_access_calling_url", new String[]{iae.getMessage()}));
       }
 
       break;
@@ -818,9 +818,7 @@ public class BrowserLauncher
         process.exitValue();
       } catch (InterruptedException ie)
       {
-        throw new IOException(
-                "InterruptedException while launching browser: "
-                        + ie.getMessage());
+          throw new IOException(MessageManager.formatMessage("exception.interrupted_launching_browser", new String[]{ie.getMessage()}));
       }
 
       break;
@@ -859,9 +857,7 @@ public class BrowserLauncher
         }
       } catch (InterruptedException ie)
       {
-        throw new IOException(
-                "InterruptedException while launching browser: "
-                        + ie.getMessage());
+          throw new IOException(MessageManager.formatMessage("exception.interrupted_launching_browser", new String[]{ie.getMessage()}));
       }
 
       break;