JAL-3103 Remove BrowserLauncher2 and use Desktop.browse(url) with wrapper methods
authorBen Soares <b.soares@dundee.ac.uk>
Tue, 8 Mar 2022 12:03:11 +0000 (12:03 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Tue, 8 Mar 2022 12:03:11 +0000 (12:03 +0000)
12 files changed:
THIRDPARTYLIBS
j11lib/BrowserLauncher2-1_3.jar [deleted file]
j8lib/BrowserLauncher2-1_3.jar [deleted file]
resources/edu/stanford/ejalbert/launching/misc/linuxUnixConfig.properties [deleted file]
resources/edu/stanford/ejalbert/launching/misc/sunOSConfig.properties [deleted file]
resources/edu/stanford/ejalbert/launching/windows/windowsConfig.properties [deleted file]
resources/lang/Messages.properties
resources/lang/Messages_es.properties
src/jalview/bin/Jalview.java
src/jalview/gui/Preferences.java
src/jalview/jbgui/GPreferences.java
src/jalview/util/BrowserLauncher.java

index 848573e..a202e97 100644 (file)
@@ -20,7 +20,6 @@ apache-mime4j-0.6.jar
 axis.jar
 biojava-core-4.1.0.jar LGPLv2.1 - latest license at https://github.com/biojava/biojava/blob/master/LICENSE
 biojava-ontology-4.1.0.jar     LGPLv2.1 - latest license at https://github.com/biojava/biojava/blob/master/LICENSE
-BrowserLauncher2-1_3.jar LGPLv2.1
 commons-codec-1.3.jar
 commons-logging-1.1.1.jar
 getdown-core.jar       Getdown license - https://github.com/threerings/getdown/blob/master/LICENSE
diff --git a/j11lib/BrowserLauncher2-1_3.jar b/j11lib/BrowserLauncher2-1_3.jar
deleted file mode 100644 (file)
index ceeab7e..0000000
Binary files a/j11lib/BrowserLauncher2-1_3.jar and /dev/null differ
diff --git a/j8lib/BrowserLauncher2-1_3.jar b/j8lib/BrowserLauncher2-1_3.jar
deleted file mode 100644 (file)
index ceeab7e..0000000
Binary files a/j8lib/BrowserLauncher2-1_3.jar and /dev/null differ
diff --git a/resources/edu/stanford/ejalbert/launching/misc/linuxUnixConfig.properties b/resources/edu/stanford/ejalbert/launching/misc/linuxUnixConfig.properties
deleted file mode 100644 (file)
index c7f3f8c..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-# ************************************************
-#    Copyright 2006,2007 Jeff Chapman
-#
-#    This file is part of BrowserLauncher2.
-#
-#    BrowserLauncher2 is free software; you can redistribute it and/or modify
-#    it under the terms of the GNU Lesser General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or
-#    (at your option) any later version.
-#
-#    BrowserLauncher2 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 Lesser General Public License for more details.
-#
-#    You should have received a copy of the GNU Lesser General Public License
-#    along with BrowserLauncher2; if not, write to the Free Software
-#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-# ************************************************
-# $Id: linuxUnixConfig.properties,v 1.3 2007/06/13 19:25:54 jchapman0 Exp $
-
-# delimiter for browser listing
-delimchar=;
-
-# list of browsers and arguments for using them
-# display name | executable name | start browser args | invoke already started browser | force new window
-browser.mozilla=Mozilla;mozilla;<browser> <url>;<browser> -remote openURL(<url>)
-browser.netscape=Netscape;netscape;<browser> <url>;<browser> -remote openURL(<url>)
-browser.firefox=Firefox;firefox;<browser> <url>;<browser> -new-tab <url>;<browser> -new-window <url>
-browser.mozilla-firefox=Firefox;mozilla-firefox;<browser> <url>;<browser> -remote openURL(<url>);<browser> -new-window <url>
-browser.konqueror=Konqueror;kfmclient;<browser> openURL <url>;<browser> newTab <url>;<browser> openURL <url>
-browser.opera=Opera;opera;<browser> <url>;<browser> -newpage <url>;<browser> -newwindow <url>
-browser.epiphany=Epiphany;epiphany;<browser> <url>;<browser> --new-tab <url>
-browser.chrome=Google Chrome;google-chrome;<browser> <url>;<browser> <url>;<browser> --new-window <url>
-browser.chrome-stable=Google Chrome;google-chrome-stable;<browser> <url>;<browser> <url>;<browser> --new-window <url>
diff --git a/resources/edu/stanford/ejalbert/launching/misc/sunOSConfig.properties b/resources/edu/stanford/ejalbert/launching/misc/sunOSConfig.properties
deleted file mode 100644 (file)
index af32b42..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-# ************************************************
-#    Copyright 2006 Jeff Chapman
-#
-#    This file is part of BrowserLauncher2.
-#
-#    BrowserLauncher2 is free software; you can redistribute it and/or modify
-#    it under the terms of the GNU Lesser General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or
-#    (at your option) any later version.
-#
-#    BrowserLauncher2 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 Lesser General Public License for more details.
-#
-#    You should have received a copy of the GNU Lesser General Public License
-#    along with BrowserLauncher2; if not, write to the Free Software
-#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-# ************************************************
-# $Id: sunOSConfig.properties,v 1.2 2006/09/12 15:40:34 jchapman0 Exp $
-
-# delimiter for browser listing
-delimchar=;
-
-# list of browsers and arguments for using them
-# display name | executable name | start browser args | invoke already started browser
-browser.sdtwebclient=Default;sdtwebclient;<browser> <url>;<browser> -remote openURL(<url>)
-browser.mozilla=Mozilla;mozilla;<browser> <url>;<browser> -remote openURL(<url>)
-browser.netscape=Netscape;netscape;<browser> <url>;<browser> -remote openURL(<url>)
-browser.firefox=FireFox;firefox;<browser> <url>;<browser> -remote openURL(<url>);<browser> -new-window <url>
-browser.opera=Opera;opera;<browser> <url>;<browser> -newpage <url>;<browser> -newwindow <url>
-
diff --git a/resources/edu/stanford/ejalbert/launching/windows/windowsConfig.properties b/resources/edu/stanford/ejalbert/launching/windows/windowsConfig.properties
deleted file mode 100644 (file)
index c4e0f2b..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-# ************************************************
-#    Copyright 2006,2007 Jeff Chapman
-#
-#    This file is part of BrowserLauncher2.
-#
-#    BrowserLauncher2 is free software; you can redistribute it and/or modify
-#    it under the terms of the GNU Lesser General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or
-#    (at your option) any later version.
-#
-#    BrowserLauncher2 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 Lesser General Public License for more details.
-#
-#    You should have received a copy of the GNU Lesser General Public License
-#    along with BrowserLauncher2; if not, write to the Free Software
-#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-# ************************************************
-# $Id: windowsConfig.properties,v 1.6 2007/08/30 19:38:09 jchapman0 Exp $
-
-# delimiter for browser listing
-delimchar=;
-
-# windows versions and arguments for launching a browser
-# default (will be used for Win10 and Win11) is winNT
-# command for starting default browser | command for starting a specific browser | use registry
-windows.winVista=cmd.exe /c start "" "<url>";"<path><browser>.exe" <args> "<url>";true
-windows.win2000=cmd.exe /c start "" "<url>";"<path><browser>.exe" <args> "<url>";true
-windows.win9x=command.com /c start "<url>";"<path><browser>.exe" <args> "<url>";true
-windows.winNT=cmd.exe /c start "" "<url>";"<path><browser>.exe" <args> "<url>";true
-
-# properties used to find browsers in program files folder
-program.files.template={0}:\\Program Files
-# drive letters to try when looking for Program Files folder
-drive.letters=C;D;E
-
-#windows.win2000=cmd.exe /c start "" "<url>";cmd.exe /c start <browser> <args> "<url>"
-#windows.win9x=command.com /c start "<url>";command.com /c start <browser> <args> "<url>"
-#windows.winNT=cmd.exe /c start "" "<url>";cmd.exe /c start <browser> <args> "<url>"
-
-# list of browsers and arguments for using them and discovering them
-# browser display name | browser exe name | new window argument | directory containing exe
-browser.mozilla=Mozilla;mozilla;;mozilla.org
-browser.netscape=Netscape;netscape;;Netscape
-browser.mozilla-firefox=Mozilla Firefox;firefox;-new-window;Mozilla Firefox
-browser.firefox=Firefox;firefox;-new-window;Firefox
-browser.opera=Opera;opera;-newwindow;Opera
-browser.edge=Microsoft Edge;msedge;;Microsoft
-browser.kmeleon=K-Meleon;k-meleon;;K-Meleon
-browser.chrome=Google Chrome;chrome;;Google
index fa32f12..6c0ae79 100644 (file)
@@ -1050,7 +1050,7 @@ exception.matrix_too_many_iteration = Too many iterations in {0} (max is {1})
 exception.browser_not_found = Exception in finding browser: {0}
 exception.browser_unable_to_launch = Unable to launch browser: {0}
 exception.browser_unable_to_locate = Unable to locate browser: {0}
-exception.browser_os_not_supported = Launching browser on this operating system not supported: {0}.  Use URL\n{1}
+exception.browser_os_not_supported = Launching browser on this operating system not supported.  Use URL\n{0}
 exception.invocation_target_exception_creating_aedesc = InvocationTargetException while creating AEDesc: {0}
 exception.illegal_access_building_apple_evt= IllegalAccessException while building AppleEvent: {0}
 exception.unable_to_launch_url = Unable to launch URL: {0}
index 9e3c447..fb87f7d 100644 (file)
@@ -968,7 +968,7 @@ exception.matrix_too_many_iteration = Demasiadas iteraciones en {0} (el m
 exception.browser_not_found = Excepción al buscar el navegador: {0}
 exception.browser_unable_to_launch = Imposible iniciar el navegador: {0}
 exception.browser_unable_to_locate = Imposible encontrar el navegador: {0}
-exception.browser_os_not_supported = No se admite el inicio del navegador en este sistema operativo: {0}. Usar URL\n{1}
+exception.browser_os_not_supported = No se admite el inicio del navegador en este sistema operativo.  Usar URL\n{0}
 exception.invocation_target_exception_creating_aedesc = InvocationTargetException mientras se creaba AEDesc: {0}
 exception.illegal_access_building_apple_evt= IllegalAccessException mientras se construía AppleEvent: {0}
 exception.unable_to_launch_url = Imposible lanzar la URL: {0}
index 458e587..4fc7714 100755 (executable)
@@ -49,7 +49,7 @@ import javax.swing.UIManager.LookAndFeelInfo;
 
 import com.threerings.getdown.util.LaunchUtil;
 
-import edu.stanford.ejalbert.launching.IBrowserLaunching;
+//import edu.stanford.ejalbert.launching.IBrowserLaunching;
 import groovy.lang.Binding;
 import groovy.util.GroovyScriptEngine;
 import jalview.ext.so.SequenceOntology;
@@ -514,7 +514,7 @@ public class Jalview
     String defaultBrowser = Cache.getProperty("DEFAULT_BROWSER");
     if (defaultBrowser != null)
     {
-      System.setProperty(IBrowserLaunching.BROWSER_SYSTEM_PROPERTY,
+      System.setProperty(BrowserLauncher.getBrowserSystemProperty(),
               defaultBrowser);
       BrowserLauncher.resetBrowser();
     } // don't clearProperty if DEFAULT_BROWSER is null, might be set by user
index 17f6af6..fe0aea1 100755 (executable)
@@ -51,7 +51,7 @@ import javax.swing.table.TableColumn;
 import javax.swing.table.TableModel;
 import javax.swing.table.TableRowSorter;
 
-import edu.stanford.ejalbert.launching.IBrowserLaunching;
+//import edu.stanford.ejalbert.launching.IBrowserLaunching;
 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.bin.Cache;
@@ -895,16 +895,7 @@ public class Preferences extends GPreferences
 
     Cache.setOrRemove("DEFAULT_BROWSER",
             (String) defaultBrowser.getSelectedItem());
-    if (Cache.getProperty("DEFAULT_BROWSER") != null)
-    {
-      System.setProperty(IBrowserLaunching.BROWSER_SYSTEM_PROPERTY,
-              Cache.getProperty("DEFAULT_BROWSER"));
-    }
-    else
-    {
-      System.clearProperty(IBrowserLaunching.BROWSER_SYSTEM_PROPERTY);
-    }
-    BrowserLauncher.resetBrowser();
+    BrowserLauncher.resetBrowser(true);
 
     // save user-defined and selected links
     String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
index 61b2f24..0d2b623 100755 (executable)
@@ -45,8 +45,6 @@ import javax.swing.AbstractCellEditor;
 import javax.swing.BorderFactory;
 import javax.swing.BoxLayout;
 import javax.swing.ButtonGroup;
-import javax.swing.ComboBoxModel;
-import javax.swing.DefaultComboBoxModel;
 import javax.swing.DefaultListCellRenderer;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
@@ -93,7 +91,6 @@ import jalview.io.BackupFilenameParts;
 import jalview.io.BackupFiles;
 import jalview.io.BackupFilesPresetEntry;
 import jalview.io.IntKeyStringValueEntry;
-import jalview.util.BrowserLauncher;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 import jalview.util.StringUtils;
@@ -770,13 +767,14 @@ public class GPreferences extends JPanel
     JPanel proxyPanel = initConnTabProxyPanel();
     initConnTabCheckboxes();
 
+    /* removing default browser preference and using Desktop.browse()
     // Add default Browser text box
     connectTab.add(browserLabel,
             new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                     GridBagConstraints.WEST, GridBagConstraints.NONE,
                     new Insets(10, 0, 5, 5), 5, 1));
     defaultBrowser.setFont(LABEL_FONT);
-
+    
     ComboBoxModel<String> cbModel = new DefaultComboBoxModel(
             BrowserLauncher.getInstance().getBrowserList().toArray());
     String browserPref = Cache.getProperty("DEFAULT_BROWSER");
@@ -785,10 +783,11 @@ public class GPreferences extends JPanel
       cbModel.setSelectedItem(browserPref);
     }
     defaultBrowser.setModel(cbModel);
-
+    
     connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
             0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
             new Insets(10, 0, 5, 10), 30, 1));
+    */
 
     // Add proxy server panel
     connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
index cddbecb..4ff15ff 100644 (file)
@@ -1,43 +1,31 @@
 package jalview.util;
 
-import edu.stanford.ejalbert.exception.BrowserLaunchingInitializingException;
-import edu.stanford.ejalbert.exception.UnsupportedOperatingSystemException;
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
 import jalview.bin.Cache;
 import jalview.bin.Console;
 
-public class BrowserLauncher extends edu.stanford.ejalbert.BrowserLauncher
+public class BrowserLauncher
 {
   private static BrowserLauncher INSTANCE = null;
 
-  // get singleton BrowserLauncher instance
+  private static String preferredBrowser = null;
+
   public static BrowserLauncher getInstance()
   {
-    if (INSTANCE == null)
+    if (INSTANCE != null)
     {
-      try
-      {
-        INSTANCE = new BrowserLauncher();
-      } catch (BrowserLaunchingInitializingException e)
-      {
-        Console.warn(MessageManager.formatMessage(
-                "exception.browser_unable_to_launch", e.getMessage()));
-      } catch (UnsupportedOperatingSystemException e)
-      {
-        Console.warn(MessageManager.formatMessage("exception."));
-        Console.debug(e.getMessage());
-      }
+      return INSTANCE;
     }
+    INSTANCE = new BrowserLauncher();
     return INSTANCE;
   }
 
-  public BrowserLauncher() throws BrowserLaunchingInitializingException,
-          UnsupportedOperatingSystemException
-  {
-    super();
-  }
-
-  private static String preferredBrowser = null;
-
   public static void openURL(String url)
   {
     if (Platform.isJS())
@@ -52,28 +40,61 @@ public class BrowserLauncher extends edu.stanford.ejalbert.BrowserLauncher
      * @j2sIgnore
      */
     {
-      BrowserLauncher bl = getInstance();
-      if (bl != null)
+      Desktop d = Desktop.getDesktop();
+      if (d != null && d.isSupported(Desktop.Action.BROWSE))
       {
-        if (Platform.isMac() || preferredBrowser == null)
+        try
         {
-          bl.openURLinBrowser(url);
-        }
-        else
+          d.browse(new URI(url));
+        } catch (IOException e)
+        {
+          Console.warn(MessageManager.formatMessage(
+                  "exception.browser_unable_to_launch", url));
+          Console.warn(e.getMessage());
+          Console.debug(Cache.getStackTraceString(e));
+        } catch (URISyntaxException e1)
         {
-          bl.openURLinBrowser(preferredBrowser, url);
+          Console.warn(MessageManager.formatMessage(
+                  "exception.browser_unable_to_launch", url));
+          Console.warn(e1.getMessage());
+          Console.debug(Cache.getStackTraceString(e1));
         }
       }
       else
       {
-        Console.warn("Could not open URL '" + url + "'");
+        Console.warn(MessageManager
+                .formatMessage("exception.browser_os_not_supported", url));
       }
     }
   }
 
   public static void resetBrowser()
   {
+    resetBrowser(false);
+  }
+
+  public static void resetBrowser(boolean removeIfNull)
+  {
     String defaultBrowser = Cache.getProperty("DEFAULT_BROWSER");
     preferredBrowser = defaultBrowser;
+    // System.setProperty(getBrowserSystemProperty(),
+    // Cache.getProperty("DEFAULT_BROWSER"));
+    if (defaultBrowser == null && removeIfNull)
+    {
+      // System.clearProperty(getBrowserSystemProperty());
+    }
+
   }
+
+  public static List<String> getBrowserList()
+  {
+    return new ArrayList<String>();
+  }
+
+  public static String getBrowserSystemProperty()
+  {
+    // return IBrowserLaunching.BROWSER_SYSTEM_PROPERTY;
+    return "jalview.default.browser";
+  }
+
 }
\ No newline at end of file