Merge branch 'develop' into releases/Release_2_11_2_Branch
authorJim Procter <j.procter@dundee.ac.uk>
Tue, 8 Mar 2022 20:40:15 +0000 (20:40 +0000)
committerJim Procter <j.procter@dundee.ac.uk>
Tue, 8 Mar 2022 20:40:15 +0000 (20:40 +0000)
16 files changed:
README
build.gradle
help/help/html/features/preferences.html
help/help/html/releases.html
resources/lang/Messages.properties
resources/lang/Messages_es.properties
src/jalview/bin/Jalview.java
src/jalview/ext/ensembl/EnsemblRestClient.java
src/jalview/ext/ensembl/Species.java
src/jalview/gui/Help.java
src/jalview/gui/Preferences.java
src/jalview/gui/StructureViewerBase.java
src/jalview/io/HTMLOutput.java
src/jalview/jbgui/GPreferences.java
src/jalview/util/BrowserLauncher.java [changed mode: 0755->0644]
test/jalview/ext/ensembl/EnsemblGeneTest.java

diff --git a/README b/README
index b374479..f121a93 100644 (file)
--- a/README
+++ b/README
@@ -1,5 +1,34 @@
-Please see doc/building.md for up to date build and running instructions for the Java desktop application.
+Jalview README
+==============
 
-JalviewJS.
-See  README_GRADLE_JALVIEWJS-2019-10-22.md  for build instructions for JalviewJS.
-This is a little sparse but enough to do the transpilation.
+Welcome !  
+
+Jalview is free (GPLv3 licensed) software for creation, interactive
+visualisation and analysis of alignments of biological sequences. It
+was developed by Michele Clamp in 1996, and now maintained by the
+Jalview Development team in the Barton group at the University of
+Dundee.
+
+If you'd like to help out please check out the website
+(www.jalview.org) and get in touch. See CITATION for the canonical
+reference if you need to cite Jalview.
+
+To build the Jalview Desktop application and JalviewJS, the JavaScript
+transpiled version (with the help of java2script, courtesy of Bob
+Hanson), you will need a Java 11 JDK and a recent version of
+Gradle. For development we recommend Eclipse - you should be able to
+import Jalview as a Gradle project with the Buildship plugin.
+
+Most likely you'll want to take a look at doc/building.md to find out
+exactly what is needed. If you already have Java 11 and Gradle, then
+the tldr:
+
+gradle test # run functional test suite
+
+gradle shadowJar # build a single executable Jar under build/lib/
+
+gradle jalviewjs # builds JalviewJS under build/jalviewjs  
+
+If you want to build JalviewJS then you will also need to download
+Eclipse for your platform, since transpilation requires an Eclipse
+plugin.
index d51382e..9b1eb69 100644 (file)
@@ -1607,7 +1607,9 @@ task getdownWebsite() {
         codeFiles += f
       }
     }
-    codeFiles.sort().each{f ->
+    def jalviewJar = jar.archiveFileName.getOrNull()
+    // put jalview.jar first for CLASSPATH and .properties files reasons
+    codeFiles.sort{a, b -> ( a.getName() == jalviewJar ? -1 : ( b.getName() == jalviewJar ? 1 : a <=> b ) ) }.each{f ->
       def name = f.getName()
       def line = "code = ${getdownAppDistDir}/${name}\n"
       getdownTextString += line
index a33a076..25d59bf 100755 (executable)
@@ -50,7 +50,7 @@
     </li>
     <li>The <a href="#connections"><strong>&quot;Connections&quot;</strong>
         Preferences</a> tab allows you to configure Jalview's internet
-      settings and specify your default web browser.
+      settings.
     </li>
     <li>The <a href="#links"><strong>&quot;Links&quot;</strong>
         Preferences</a> tab shows the currently configured <em>URL
index e3a2a05..e02d472 100755 (executable)
@@ -59,7 +59,7 @@ li:before {
     <tr>
       <td width="60" align="center" nowrap><strong><a
           id="Jalview.2.11.2">2.11.2</a><a id="Jalview.2.11.2.0">.0</a><br />
-          <em>3/03/2022</em></strong></td>
+          <em>8/03/2022</em></strong></td>
       <td align="left" valign="top">
         <ul>
           <li>
@@ -68,6 +68,10 @@ li:before {
             Chimera.
           </li>
           <li>
+            <!-- JAL-3871 JAL-3874 -->Upgraded bundled version of Jmol
+            to 14.31.53
+          </li>
+          <li>
             <!-- JAL-3829 -->Discover 3D structure data for sequences
             with Uniprot references via 3D-Beacons
           </li>
@@ -100,6 +104,12 @@ li:before {
             <!-- JAL-3863 -->Support for Canonical Uniprot IDs
           </li>
           <li>
+            <!-- JAL-3018 -->Updated Ensembl REST Client compatibility
+            to 15.2 and revised model organism names (rat, xenopus,
+            dmelanogaster now rattus_norvegicus, xenopus_tropicalis,
+            drosophila_melanogaster)
+          </li>
+          <li>
             <!-- JAL-3881 -->Sequence IDs split on '_' as well as other
             non-alphanumerics when discovering database references with
             'Fetch DB Refs'
@@ -133,11 +143,14 @@ li:before {
             proxies that require authentication
           </li>
           <li>
+            <!-- JAL-3103 -->New mechanism for opening URLs with system
+            default browser (works on OSX and Linux as well as Windows)
+          </li>
+          <li>
             <!-- JAL-3837 -->GPL license info on splash screen and About
             text
           </li>
-        </ul>
-        <em>Jalview Native App</em>
+        </ul> <em>Jalview Native App</em>
         <ul>
           <li>
             <!-- JAL- -->New Jalview Develop app - making it even easier
@@ -153,18 +166,24 @@ li:before {
             than anonymous 'Java' icons
           </li>
           <li>
-            <!-- JAL-3608 -->Options to allow user to choose the (Swing) Look and Feel (LaF) used by Jalview
+            <!-- JAL-3608 -->Options to allow user to choose the (Swing)
+            Look and Feel (LaF) used by Jalview
           </li>
           <li>
-            <!-- JAL-3552, JAL-3609 -->Metal LaF used to improved operation on Linux Ubuntu with
-            HiDPI display in Java 11 (still known issues with HiDPI screens in java
-            8 and 11. see <a
-            href="https://issues.jalview.org/browse/JAL-3137">JAL-3137</a>)
+            <!-- JAL-3552, JAL-3609 -->Metal LaF used to improved
+            operation on Linux Ubuntu with HiDPI display in Java 11
+            (still known issues with HiDPI screens in java 8 and 11. see
+            <a href="https://issues.jalview.org/browse/JAL-3137">JAL-3137</a>)
           </li>
           <li>
-            <!-- JAL-3830 -->New command line launcher scripts (.sh, .ps1, .bat) usable on
-            macOS, Linux/Unix, Windows and documentation in Help.  Installer wizard has option
-            to add this to PATH, or link to it in your PATH.
+            <!-- JAL-3830 -->New command line launcher scripts (.sh,
+            .ps1, .bat) usable on macOS, Linux/Unix, Windows and
+            documentation in Help. Installer wizard has option to add
+            this to PATH, or link to it in your PATH.<br /> <em>This
+              is the recommended workaround for known issue about
+              working directory preservation when running native
+              application from command line. <!-- JAL-3523 -->
+          </em>
           </li>
           <li>
             <!-- JAL-3633 -->Getdown launcher inherits HTTP/S proxy
@@ -173,11 +192,12 @@ li:before {
         </ul> <em>JalviewJS</em>
         <ul>
           <li>
-            <!-- JAL-3624 -->PDB structures mapped to Uniprot Sequences with
-            SIFTS
+            <!-- JAL-3624 -->PDB structures mapped to Uniprot Sequences
+            with SIFTS
           </li>
           <li>
-            <!-- JAL-3208 -->setprop commandline argument reinstated for JalviewJS only 
+            <!-- JAL-3208 -->setprop commandline argument reinstated for
+            JalviewJS only
           </li>
           <li>
             <!-- JAL-3163 -->Missing message bundle keys are only
@@ -188,7 +208,14 @@ li:before {
             <!-- JAL-3168 -->Feature type is included in the title of
             the Feature Settings' Colour Chooser dialog
           </li>
-          <li></li>
+          <li>
+            <!-- JAL-3279 -->Build details reported in About window
+          </li>
+          <li>
+            <!-- JAL-3038 JAL-3071 JAL-3263 JAL-3084 -->Numerous minor
+            GUI additions and improvements in sync with Java
+            application.
+          </li>
         </ul> <em>Development</em>
         <ul>
           <li>
@@ -217,9 +244,7 @@ li:before {
             <!-- JAL-3907 -->Improved compatibility of Jalview build
             with Java 17 (next LTS target)
           </li>
-
         </ul>
-
       </td>
       <td>
         <ul>
@@ -235,7 +260,6 @@ li:before {
           <li>
             <!-- JAL-3779 -->Annotation file: PROPERTIES apply only to
             the first SEQUENCE_GROUP defined
-
           </li>
 
           <li>
@@ -281,23 +305,22 @@ li:before {
             <!-- JAL-3949 -->Standard out logging broken: messages only
             routing to stderr and appear as a raw template
           </li>
-        </ul> <em>JalviewJS</em>
-        <ul>
-          <li>
-            <!-- JAL-3202 -->Consensus profile may include zero (rounded
-            down) percentage values causing a divide by zero
-          </li>
           <li>
-            <!-- -->
+            <!-- JAL-3739 -->Entering web service parameter values in
+            numerical field doesn't update the value of the parameter
+            until return is pressed.
           </li>
           <li>
-            <!-- -->
-          </li>
-          <li>
-            <!-- -->
+            <!-- JAL-3749 -->Resolved known issue (from 2.11.1.1)
+            concerning duplicate CDS sequences generated when protein
+            products for certain ENA records are repeatedly shown via
+            Calculate-&gt;Show Cross Refs
           </li>
+        </ul> <em>JalviewJS</em>
+        <ul>
           <li>
-            <!-- -->
+            <!-- JAL-3202 -->Consensus profile may include zero (rounded
+            down) percentage values causing a divide by zero
           </li>
           <li>
             <!-- JAL-3762 -->JalviewJS doesn't honour arguments passed
@@ -322,13 +345,13 @@ li:before {
             </ul>
           </li>
 
-        </ul>
-        <em>Known Issues</em>
+        </ul> <em>Known Issues</em>
         <ul>
           <li>
             <!-- JAL-3764 -->Display of RESNUM sequence features are not
             suppressed when structures associated with a sequence are
-            viewed with an external viewer (Regression from 2.11.1 series)
+            viewed with an external viewer (Regression from 2.11.1
+            series)
           </li>
         </ul>
       </td>
index 023f591..9ce5a63 100644 (file)
@@ -587,7 +587,7 @@ label.nuc_alignment_colour = Nucleotide Alignment Colour
 label.address = Address
 label.host = Host
 label.port = Port
-label.default_browser_unix = Default Browser (Unix)
+label.default_browser_unix_windows = Default Browser (Unix, Windows)
 label.send_usage_statistics = Send usage statistics
 label.check_for_questionnaires = Check for questionnaires
 label.check_for_latest_version = Check for latest version
@@ -1048,7 +1048,9 @@ exception.unknown_annotation_detected = Unknown annotation detected: {0} {1}
 exception.couldnt_store_sequence_mappings = Couldn''t store sequence mappings for {0}
 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.  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 49e05e3..fb87f7d 100644 (file)
@@ -534,7 +534,7 @@ label.gap_symbol = S
 label.address = Dirección
 label.host = Host
 label.port = Puerto
-label.default_browser_unix = Navegador por defecto (Unix)
+label.default_browser_unix_windows = Navegador por defecto (Unix, Windows)
 label.send_usage_statistics = Enviar estadísticas de uso
 label.check_for_questionnaires = Comprobar los cuestionarios
 label.check_for_latest_version = Comprobar la Ãºltima versión
@@ -966,7 +966,9 @@ exception.unknown_annotation_detected = Anotaci
 exception.couldnt_store_sequence_mappings = No es posible almacenar los mapeos de secuencia para {0}
 exception.matrix_too_many_iteration = Demasiadas iteraciones en {0} (el máximo es {1})
 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.  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 357f0e4..fc4c821 100755 (executable)
@@ -49,6 +49,7 @@ import javax.swing.UIManager.LookAndFeelInfo;
 
 import com.threerings.getdown.util.LaunchUtil;
 
+//import edu.stanford.ejalbert.launching.IBrowserLaunching;
 import groovy.lang.Binding;
 import groovy.util.GroovyScriptEngine;
 import jalview.ext.so.SequenceOntology;
@@ -482,7 +483,7 @@ public class Jalview
         }
 
         if (!aparser.contains("nohtmltemplates")
-              || Cache.getProperty("NOHTMLTEMPLATES") == null)
+                || Cache.getProperty("NOHTMLTEMPLATES") == null)
         {
           BioJsHTMLOutput.updateBioJS();
         }
@@ -1121,7 +1122,8 @@ public class Jalview
               @Override
               public void run()
               {
-                Console.debug("Initialising googletracker for usage stats.");
+                Console.debug(
+                        "Initialising googletracker for usage stats.");
                 Cache.initGoogleTracker();
                 Console.debug("Tracking enabled.");
               }
index 59c568b..4a5544e 100644 (file)
@@ -69,9 +69,9 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher
    * @see https://github.com/Ensembl/ensembl-rest/wiki/Change-log
    * @see http://rest.ensembl.org/info/rest?content-type=application/json
    */
-  private static final String LATEST_ENSEMBLGENOMES_REST_VERSION = "13.0";
+  private static final String LATEST_ENSEMBLGENOMES_REST_VERSION = "15.2";
 
-  private static final String LATEST_ENSEMBL_REST_VERSION = "13.0";
+  private static final String LATEST_ENSEMBL_REST_VERSION = "15.2";
 
   private static final String REST_CHANGE_LOG = "https://github.com/Ensembl/ensembl-rest/wiki/Change-log";
 
index cc5465e..3feea05 100644 (file)
@@ -36,10 +36,10 @@ enum Species
    * valid species parameters to Ensembl REST services where applicable
    */
   human(true), mouse(true), s_cerevisiae(true), cow(false), pig(false),
-  rat(true), celegans(true), sheep(false), horse(false), gorilla(false),
-  rabbit(false), gibbon(false), dog(false), orangutan(false), xenopus(true),
+  rattus_norvegicus(true), celegans(true), sheep(false), horse(false), gorilla(false),
+  rabbit(false), gibbon(false), dog(false), orangutan(false), xenopus_tropicalis(true),
   chimpanzee(false), cat(false), zebrafish(true), chicken(true),
-  dmelanogaster(true);
+  drosophila_melanogaster(true);
 
   static Set<Species> modelOrganisms = new HashSet<>();
 
index 8bd01ea..658b34f 100644 (file)
  */
 package jalview.gui;
 
-import jalview.util.BrowserLauncher;
-import jalview.util.Platform;
-
 import java.awt.Point;
-import java.io.IOException;
 import java.net.URL;
 
 import javax.help.BadIDException;
@@ -32,6 +28,9 @@ import javax.help.HelpBroker;
 import javax.help.HelpSet;
 import javax.help.HelpSetException;
 
+import jalview.util.BrowserLauncher;
+import jalview.util.Platform;
+
 /**
  * Utility class to show the help documentation window
  * 
@@ -42,18 +41,22 @@ public class Help
   private static final String HELP_PAGE_ROOT = "http://www.jalview.org/help/";
 
   /**
-   * Defines selected help targets with links to inbuilt (Java) help page target,
-   * and externally hosted help page. Will need to be maintained manually if help
-   * pages are reorganised in future.
+   * Defines selected help targets with links to inbuilt (Java) help page
+   * target, and externally hosted help page. Will need to be maintained
+   * manually if help pages are reorganised in future.
    */
   public enum HelpId
   {
-    Home("home", "help.html"), SequenceFeatureSettings("seqfeatures.settings", "html/features/featuresettings.html"),
-    StructureViewer("viewingpdbs", "html/features/viewingpdbs.html"), PdbFts("pdbfts", "html/features/pdbsequencefetcher.html#pdbfts"),
-    UniprotFts("uniprotfts", "html/features/uniprotsequencefetcher.html#uniprotfts");
+    Home("home", "help.html"),
+    SequenceFeatureSettings("seqfeatures.settings",
+            "html/features/featuresettings.html"),
+    StructureViewer("viewingpdbs", "html/features/viewingpdbs.html"),
+    PdbFts("pdbfts", "html/features/pdbsequencefetcher.html#pdbfts"),
+    UniprotFts("uniprotfts",
+            "html/features/uniprotsequencefetcher.html#uniprotfts");
 
     private String id;
-    
+
     private String path;
 
     private HelpId(String hepLoc, String htmlPath)
@@ -94,12 +97,16 @@ public class Help
   {
     if (Platform.isJS())
     {
+      /*
       try
       {
-        BrowserLauncher.openURL(HELP_PAGE_ROOT + id.getPath());
+      */
+      BrowserLauncher.openURL(HELP_PAGE_ROOT + id.getPath());
+      /*
       } catch (IOException e)
       {
       }
+      */
     }
     else
     /**
index b9f30e3..06d3a60 100755 (executable)
@@ -27,7 +27,6 @@ import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.awt.event.MouseEvent;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
@@ -35,7 +34,6 @@ import java.util.concurrent.CompletableFuture;
 
 import javax.help.HelpSetException;
 import javax.swing.JComboBox;
-import javax.swing.JFileChooser;
 import javax.swing.JInternalFrame;
 import javax.swing.JPanel;
 import javax.swing.ListSelectionModel;
@@ -51,6 +49,7 @@ import javax.swing.table.TableColumn;
 import javax.swing.table.TableModel;
 import javax.swing.table.TableRowSorter;
 
+//import edu.stanford.ejalbert.launching.IBrowserLaunching;
 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.bin.Cache;
@@ -148,10 +147,10 @@ public class Preferences extends GPreferences
 
   /**
    * Holds name and link separated with | character. Sequence IDS and Sequences
-   * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and $SEQUENCES$
-   * or $SEQUENCES=/.possible | chars ./=$ and separation character for first and
-   * second token specified after a pipe character at end |,|. (TODO: proper
-   * escape for using | to separate ids or sequences
+   * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
+   * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
+   * for first and second token specified after a pipe character at end |,|.
+   * (TODO: proper escape for using | to separate ids or sequences
    */
 
   public static List<String> groupURLLinks;
@@ -447,26 +446,27 @@ public class Preferences extends GPreferences
         if (validateViewerPath())
         {
           String path = structureViewerPath.getText();
-          try {
-          ViewerType type = ViewerType.valueOf(viewerType);
-          switch (type)
+          try
+          {
+            ViewerType type = ViewerType.valueOf(viewerType);
+            switch (type)
+            {
+            case JMOL:
+              break;
+            case CHIMERA:
+              Cache.setProperty(CHIMERA_PATH, path);
+              break;
+            case CHIMERAX:
+              Cache.setProperty(CHIMERAX_PATH, path);
+              break;
+            case PYMOL:
+              Cache.setProperty(PYMOL_PATH, path);
+              break;
+            }
+          } catch (IllegalArgumentException x)
           {
-          case JMOL:
-            break;
-          case CHIMERA:
-            Cache.setProperty(CHIMERA_PATH, path);
-            break;
-          case CHIMERAX:
-            Cache.setProperty(CHIMERAX_PATH, path);
-            break;
-          case PYMOL:
-            Cache.setProperty(PYMOL_PATH, path);
-            break;
+            Console.error("Failed to set path - unknown viewer type", x);
           }
-        } catch (IllegalArgumentException x)
-        {
-          Console.error("Failed to set path - unknown viewer type",x);
-        }
         }
       }
     });
@@ -638,8 +638,6 @@ public class Preferences extends GPreferences
     setCustomProxyEnabled();
     applyProxyButtonEnabled(false);
 
-    defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
-
     usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
     // note antisense here: default is true
     questionnaire
@@ -886,10 +884,6 @@ public class Preferences extends GPreferences
      */
     // Proxy settings set first (to catch web services)
 
-    Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
-
-    jalview.util.BrowserLauncher.resetBrowser();
-
     // save user-defined and selected links
     String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
     if (menuLinks.isEmpty())
@@ -1052,8 +1046,8 @@ public class Preferences extends GPreferences
   }
 
   /**
-   * Do any necessary validation before saving settings. Return focus to the first
-   * tab which fails validation.
+   * Do any necessary validation before saving settings. Return focus to the
+   * first tab which fails validation.
    * 
    * @return
    */
@@ -1107,7 +1101,7 @@ public class Preferences extends GPreferences
    * DOCUMENT ME!
    * 
    * @param e
-   *            DOCUMENT ME!
+   *          DOCUMENT ME!
    */
   @Override
   public void cancel_actionPerformed(ActionEvent e)
@@ -1129,7 +1123,7 @@ public class Preferences extends GPreferences
    * DOCUMENT ME!
    * 
    * @param e
-   *            DOCUMENT ME!
+   *          DOCUMENT ME!
    */
   @Override
   public void annotations_actionPerformed(ActionEvent e)
@@ -1254,30 +1248,6 @@ public class Preferences extends GPreferences
     ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
   }
 
-  @Override
-  public void defaultBrowser_mouseClicked(MouseEvent e)
-  {
-    // TODO: JAL-3048 not needed for j2s
-    if (!Platform.isJS()) // BH 2019
-    /**
-     * Java only
-     * 
-     * @j2sIgnore
-     */
-    {
-      JFileChooser chooser = new JFileChooser(".");
-      chooser.setDialogTitle(
-              MessageManager.getString("label.select_default_browser"));
-
-      int value = chooser.showOpenDialog(this);
-
-      if (value == JFileChooser.APPROVE_OPTION)
-      {
-        defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
-      }
-    }
-  }
-
   /*
    * (non-Javadoc)
    * 
@@ -1392,8 +1362,8 @@ public class Preferences extends GPreferences
   }
 
   /**
-   * Returns true if structure viewer path is to a valid executable, else shows an
-   * error dialog. Does nothing if the path is empty, as is the case for Jmol
+   * Returns true if structure viewer path is to a valid executable, else shows
+   * an error dialog. Does nothing if the path is empty, as is the case for Jmol
    * (built in to Jalview) or when Jalview is left to try default paths.
    */
   private boolean validateViewerPath()
@@ -1414,8 +1384,8 @@ public class Preferences extends GPreferences
   }
 
   /**
-   * If Chimera or ChimeraX or Pymol is selected, check it can be found on default
-   * or user-specified path, if not show a warning/help dialog
+   * If Chimera or ChimeraX or Pymol is selected, check it can be found on
+   * default or user-specified path, if not show a warning/help dialog
    */
   @Override
   protected void structureViewer_actionPerformed(String selectedItem)
index 349871d..ec5579c 100644 (file)
@@ -156,9 +156,11 @@ public abstract class StructureViewerBase extends GStructureViewer
   {
     alignAddedStructures = alignAdded;
   }
-  
+
   /**
-   * called by the binding model to indicate when adding structures is happening or has been completed
+   * called by the binding model to indicate when adding structures is happening
+   * or has been completed
+   * 
    * @param addingStructures
    */
   public synchronized void setAddingStructures(boolean addingStructures)
@@ -443,8 +445,9 @@ public abstract class StructureViewerBase extends GStructureViewer
     {
       return;
     }
-    AlignmentPanel alignPanel = (AlignmentPanel) apanel; // Implementation error if this
-                                                 // cast fails
+    AlignmentPanel alignPanel = (AlignmentPanel) apanel; // Implementation error
+                                                         // if this
+    // cast fails
     useAlignmentPanelForSuperposition(alignPanel);
     addStructure(pdbentry, seq, chains, alignPanel.alignFrame);
   }
@@ -581,9 +584,8 @@ public abstract class StructureViewerBase extends GStructureViewer
   public void changeColour_actionPerformed(String colourSchemeName)
   {
     AlignmentI al = getAlignmentPanel().av.getAlignment();
-    ColourSchemeI cs = ColourSchemes.getInstance()
-            .getColourScheme(colourSchemeName, getAlignmentPanel().av, al,
-                    null);
+    ColourSchemeI cs = ColourSchemes.getInstance().getColourScheme(
+            colourSchemeName, getAlignmentPanel().av, al, null);
     getBinding().colourByJalviewColourScheme(cs);
   }
 
@@ -1038,14 +1040,17 @@ public abstract class StructureViewerBase extends GStructureViewer
     {
       return false;
     }
-    int p=0;
-    for (String pdbid:pdbids) {
+    int p = 0;
+    for (String pdbid : pdbids)
+    {
       StructureMapping sm[] = getBinding().getSsm().getMapping(pdbid);
-      if (sm!=null && sm.length>0 && sm[0]!=null) {
+      if (sm != null && sm.length > 0 && sm[0] != null)
+      {
         p++;
       }
     }
-    // only return true if there is a mapping for every structure file we have loaded
+    // only return true if there is a mapping for every structure file we have
+    // loaded
     if (p == 0 || p != pdbids.length)
     {
       return false;
@@ -1137,12 +1142,12 @@ public abstract class StructureViewerBase extends GStructureViewer
   {
     String filePath = null;
     Pdb pdbclient = new Pdb();
-    EBIAlfaFold afclient =  new EBIAlfaFold();
+    EBIAlfaFold afclient = new EBIAlfaFold();
     AlignmentI pdbseq = null;
     String pdbid = processingEntry.getId();
     long handle = System.currentTimeMillis()
             + Thread.currentThread().hashCode();
-  
+
     /*
      * Write 'fetching PDB' progress on AlignFrame as we are not yet visible
      */
@@ -1157,29 +1162,36 @@ public abstract class StructureViewerBase extends GStructureViewer
     {
       if (afclient.isValidReference(pdbid))
       {
-        pdbseq = afclient.getSequenceRecords(pdbid,processingEntry.getRetrievalUrl());
-      } else {
-          if (processingEntry.hasRetrievalUrl())
+        pdbseq = afclient.getSequenceRecords(pdbid,
+                processingEntry.getRetrievalUrl());
+      }
+      else
+      {
+        if (processingEntry.hasRetrievalUrl())
+        {
+          String safePDBId = java.net.URLEncoder.encode(pdbid, "UTF-8")
+                  .replace("%", "__");
+
+          // retrieve from URL to new local tmpfile
+          File tmpFile = File.createTempFile(safePDBId,
+                  "." + (PDBEntry.Type.MMCIF.toString().equals(
+                          processingEntry.getType().toString()) ? "cif"
+                                  : "pdb"));
+          String fromUrl = processingEntry.getRetrievalUrl();
+          UrlDownloadClient.download(fromUrl, tmpFile);
+
+          // may not need this check ?
+          String file = tmpFile.getAbsolutePath();
+          if (file != null)
           {
-            String safePDBId = java.net.URLEncoder.encode(pdbid,"UTF-8").replace("%","__");
-                     
-            // retrieve from URL to new local tmpfile
-            File tmpFile = File.createTempFile(safePDBId,
-                    "." + (PDBEntry.Type.MMCIF.toString().equals(
-                            processingEntry.getType().toString()) ? "cif"
-                                    : "pdb"));
-            String fromUrl = processingEntry.getRetrievalUrl();
-            UrlDownloadClient.download(fromUrl, tmpFile);
-            
-            // may not need this check ?
-            String file = tmpFile.getAbsolutePath();
-            if (file != null)
-            {
-              pdbseq = EBIAlfaFold.importDownloadedStructureFromUrl(fromUrl,tmpFile,pdbid,null,null,null);
-            }
-          } else {
-            pdbseq = pdbclient.getSequenceRecords(pdbid);
+            pdbseq = EBIAlfaFold.importDownloadedStructureFromUrl(fromUrl,
+                    tmpFile, pdbid, null, null, null);
           }
+        }
+        else
+        {
+          pdbseq = pdbclient.getSequenceRecords(pdbid);
+        }
       }
     } catch (Exception e)
     {
@@ -1213,22 +1225,28 @@ public abstract class StructureViewerBase extends GStructureViewer
    */
   public File saveSession()
   {
-    if (getBinding() == null) { return  null;}
+    if (getBinding() == null)
+    {
+      return null;
+    }
     File session = getBinding().saveSession();
     long l = session.length();
-    int wait=50;
-    do {
-      try {
+    int wait = 50;
+    do
+    {
+      try
+      {
         Thread.sleep(5);
-      } catch (InterruptedException e) {
-      } 
+      } catch (InterruptedException e)
+      {
+      }
       long nextl = session.length();
-      if (nextl!=l)
+      if (nextl != l)
       {
         wait = 50;
-        l=nextl;
+        l = nextl;
       }
-    } while (--wait>0);
+    } while (--wait > 0);
     return session;
   }
 
@@ -1284,20 +1302,26 @@ public abstract class StructureViewerBase extends GStructureViewer
   @Override
   public void showHelp_actionPerformed()
   {
+    /*
     try
     {
-      String url = getBinding().getHelpURL();
-      if (url != null)
-      {
-        BrowserLauncher.openURL(url);
-      }
-    } catch (IOException ex)
+    */
+    String url = getBinding().getHelpURL();
+    if (url != null)
+    {
+      BrowserLauncher.openURL(url);
+    }
+    /* 
+    }
+    catch (IOException ex)
     {
       System.err
               .println("Show " + getViewerName() + " failed with: "
                       + ex.getMessage());
     }
+    */
   }
+
   @Override
   public boolean hasViewerActionsMenu()
   {
index 54e7e4b..eb44180 100644 (file)
  */
 package jalview.io;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.Objects;
+
 import jalview.api.AlignExportSettingsI;
 import jalview.bin.Cache;
 import jalview.datamodel.AlignExportSettingsAdapter;
@@ -28,13 +35,6 @@ import jalview.gui.AlignmentPanel;
 import jalview.gui.IProgressIndicator;
 import jalview.util.MessageManager;
 
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.Objects;
-
 public abstract class HTMLOutput implements Runnable
 {
   protected AlignmentPanel ap;
@@ -59,7 +59,7 @@ public abstract class HTMLOutput implements Runnable
    * Constructor given an alignment panel (which should not be null)
    * 
    * @param ap
-   * @param desc 
+   * @param desc
    */
   public HTMLOutput(AlignmentPanel ap, String desc)
   {
@@ -261,14 +261,17 @@ public abstract class HTMLOutput implements Runnable
   {
     if (isLaunchInBrowserAfterExport() && !isHeadless())
     {
+      /*
       try
       {
-        jalview.util.BrowserLauncher
-                .openURL("file:///" + getExportedFile());
+      */
+      jalview.util.BrowserLauncher.openURL("file:///" + getExportedFile());
+      /*
       } catch (IOException e)
       {
         e.printStackTrace();
       }
+      */
     }
   }
 
@@ -301,7 +304,7 @@ public abstract class HTMLOutput implements Runnable
   public void exportHTML(String outputFile)
   {
     setProgressMessage(MessageManager.formatMessage(
-        "status.exporting_alignment_as_x_file", getDescription()));
+            "status.exporting_alignment_as_x_file", getDescription()));
     try
     {
       if (outputFile == null)
@@ -327,7 +330,7 @@ public abstract class HTMLOutput implements Runnable
       return;
     }
     new Thread(this).start();
-  
+
   }
 
   /**
@@ -338,6 +341,6 @@ public abstract class HTMLOutput implements Runnable
    */
   protected final String getDescription()
   {
-       return description;
+    return description;
   }
 }
\ No newline at end of file
index d281c8d..69c0f4d 100755 (executable)
@@ -269,8 +269,6 @@ public class GPreferences extends JPanel
 
   protected JPasswordField proxyAuthPasswordPB = new JPasswordField();
 
-  protected JTextField defaultBrowser = new JTextField();
-
   protected ButtonGroup proxyType = new ButtonGroup();
 
   protected JRadioButton noProxy = new JRadioButton();
@@ -740,44 +738,9 @@ public class GPreferences extends JPanel
     connectTab = new JPanel();
     connectTab.setLayout(new GridBagLayout());
 
-    // Label for browser text box
-    JLabel browserLabel = new JLabel();
-    browserLabel.setFont(LABEL_FONT);
-    browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
-    browserLabel.setText(
-            MessageManager.getString("label.default_browser_unix"));
-    defaultBrowser.setFont(LABEL_FONT);
-    defaultBrowser.setText("");
-    final String tooltip = JvSwingUtils.wrapTooltip(true,
-            MessageManager.getString("label.double_click_to_browse"));
-    defaultBrowser.setToolTipText(tooltip);
-    defaultBrowser.addMouseListener(new MouseAdapter()
-    {
-      @Override
-      public void mouseClicked(MouseEvent e)
-      {
-        if (e.getClickCount() > 1)
-        {
-          defaultBrowser_mouseClicked(e);
-        }
-      }
-    });
-
     JPanel proxyPanel = initConnTabProxyPanel();
     initConnTabCheckboxes();
 
-    // 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);
-    defaultBrowser.setText("");
-
-    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,
             GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
@@ -1818,8 +1781,8 @@ public class GPreferences extends JPanel
   }
 
   /**
-   * Show a dialog for the user to choose a file. Returns the chosen path, or null
-   * on Cancel.
+   * Show a dialog for the user to choose a file. Returns the chosen path, or
+   * null on Cancel.
    * 
    * @return
    */
@@ -3487,7 +3450,7 @@ public class GPreferences extends JPanel
    * DOCUMENT ME!
    * 
    * @param e
-   *            DOCUMENT ME!
+   *          DOCUMENT ME!
    */
   public void ok_actionPerformed(ActionEvent e)
   {
@@ -3497,7 +3460,7 @@ public class GPreferences extends JPanel
    * DOCUMENT ME!
    * 
    * @param e
-   *            DOCUMENT ME!
+   *          DOCUMENT ME!
    */
   public void cancel_actionPerformed(ActionEvent e)
   {
@@ -3507,7 +3470,7 @@ public class GPreferences extends JPanel
    * DOCUMENT ME!
    * 
    * @param e
-   *            DOCUMENT ME!
+   *          DOCUMENT ME!
    */
   public void annotations_actionPerformed(ActionEvent e)
   {
@@ -3535,11 +3498,6 @@ public class GPreferences extends JPanel
 
   }
 
-  public void defaultBrowser_mouseClicked(MouseEvent e)
-  {
-
-  }
-
   public void linkURLList_keyTyped(KeyEvent e)
   {
 
old mode 100755 (executable)
new mode 100644 (file)
index dbd9177..4ff15ff
-/*
- * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
- * Copyright (C) $$Year-Rel$$ 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.
- *  
- * 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 <http://www.gnu.org/licenses/>.
- * The Jalview Authors are detailed in the 'AUTHORS' file.
- */
 package jalview.util;
 
-import jalview.bin.Cache;
-
-import java.io.File;
+import java.awt.Desktop;
 import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import jalview.bin.Cache;
+import jalview.bin.Console;
 
-/**
- * BrowserLauncher is a class that provides one static method, openURL, which
- * opens the default web browser for the current user of the system to the given
- * URL. It may support other protocols depending on the system -- mailto, ftp,
- * etc. -- but that has not been rigorously tested and is not guaranteed to
- * work.
- * <p>
- * Yes, this is platform-specific code, and yes, it may rely on classes on
- * certain platforms that are not part of the standard JDK. What we're trying to
- * do, though, is to take something that's frequently desirable but inherently
- * platform-specific -- opening a default browser -- and allow programmers (you,
- * for example) to do so without worrying about dropping into native code or
- * doing anything else similarly evil.
- * <p>
- * Anyway, this code is completely in Java and will run on all JDK 1.1-compliant
- * systems without modification or a need for additional libraries. All classes
- * that are required on certain platforms to allow this to run are dynamically
- * loaded at runtime via reflection and, if not found, will not cause this to do
- * anything other than returning an error when opening the browser.
- * <p>
- * There are certain system requirements for this class, as it's running through
- * Runtime.exec(), which is Java's way of making a native system call.
- * Currently, this requires that a Macintosh have a Finder which supports the
- * GURL event, which is true for Mac OS 8.0 and 8.1 systems that have the
- * Internet Scripting AppleScript dictionary installed in the Scripting
- * Additions folder in the Extensions folder (which is installed by default as
- * far as I know under Mac OS 8.0 and 8.1), and for all Mac OS 8.5 and later
- * systems. On Windows, it only runs under Win32 systems (Windows 95, 98, and NT
- * 4.0, as well as later versions of all). On other systems, this drops back
- * from the inherently platform-sensitive concept of a default browser and
- * simply attempts to launch Netscape via a shell command.
- * <p>
- * This code is Copyright 1999-2001 by Eric Albert (ejalbert\@cs.stanford.edu)
- * and may be redistributed or modified in any form without restrictions as long
- * as the portion of this comment from this paragraph through the end of the
- * comment is not removed. The author requests that he be notified of any
- * application, applet, or other binary that makes use of this code, but that's
- * more out of curiosity than anything and is not required. This software
- * includes no warranty. The author is not repsonsible for any loss of data or
- * functionality or any adverse or unexpected effects of using this software.
- * <p>
- * Credits: <br>
- * Steven Spencer, JavaWorld magazine
- * (<a href="http://www.javaworld.com/javaworld/javatips/jw-javatip66.html">Java
- * Tip 66</a>) <br>
- * Thanks also to Ron B. Yeh, Eric Shapiro, Ben Engber, Paul Teitlebaum, Andrea
- * Cantatore, Larry Barowski, Trevor Bedzek, Frank Miedrich, and Ron Rabakukk
- * 
- * @author Eric Albert (<a href=
- *         "mailto:ejalbert@cs.stanford.edu">ejalbert@cs.stanford.edu</a>)
- * @version 1.4b1 (Released June 20, 2001)
- */
 public class BrowserLauncher
 {
-  /**
-   * The Java virtual machine that we are running on. Actually, in most cases we
-   * only care about the operating system, but some operating systems require us
-   * to switch on the VM.
-   */
-  private static int jvm;
-
-  /** The browser for the system */
-  private static Object browser;
-
-  /**
-   * 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.
-   */
-  private static boolean loadedWithoutErrors;
-
-  /** The com.apple.mrj.MRJFileUtils class */
-  private static Class mrjFileUtilsClass;
-
-  /** The com.apple.mrj.MRJOSType class */
-  private static Class mrjOSTypeClass;
-
-  /** The com.apple.MacOS.AEDesc class */
-  private static Class aeDescClass;
-
-  /** The &lt;init&gt;(int) method of com.apple.MacOS.AETarget */
-  private static Constructor aeTargetConstructor;
-
-  /** The &lt;init&gt;(int, int, int) method of com.apple.MacOS.AppleEvent */
-  private static Constructor appleEventConstructor;
-
-  /** The &lt;init&gt;(String) method of com.apple.MacOS.AEDesc */
-  private static Constructor aeDescConstructor;
-
-  /** The findFolder method of com.apple.mrj.MRJFileUtils */
-  private static Method findFolder;
-
-  /** The getFileCreator method of com.apple.mrj.MRJFileUtils */
-  private static Method getFileCreator;
-
-  /** The getFileType method of com.apple.mrj.MRJFileUtils */
-  private static Method getFileType;
-
-  /** The openURL method of com.apple.mrj.MRJFileUtils */
-  private static Method openURL;
-
-  /** The makeOSType method of com.apple.MacOS.OSUtils */
-  private static Method makeOSType;
-
-  /** The putParameter method of com.apple.MacOS.AppleEvent */
-  private static Method putParameter;
-
-  /** The sendNoReply method of com.apple.MacOS.AppleEvent */
-  private static Method sendNoReply;
-
-  /** Actually an MRJOSType pointing to the System Folder on a Macintosh */
-  private static Object kSystemFolderType;
-
-  /** The keyDirectObject AppleEvent parameter type */
-  private static Integer keyDirectObject;
-
-  /** The kAutoGenerateReturnID AppleEvent code */
-  private static Integer kAutoGenerateReturnID;
-
-  /** The kAnyTransactionID AppleEvent code */
-  private static Integer kAnyTransactionID;
-
-  /** The linkage object required for JDirect 3 on Mac OS X. */
-  private static Object linkage;
-
-  /** The framework to reference on Mac OS X */
-  private static final String JDirect_MacOSX = "/System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/HIToolbox";
-
-  /** JVM constant for MRJ 2.0 */
-  private static final int MRJ_2_0 = 0;
-
-  /** JVM constant for MRJ 2.1 or later */
-  private static final int MRJ_2_1 = 1;
-
-  /** JVM constant for Java on Mac OS X 10.0 (MRJ 3.0) */
-  private static final int MRJ_3_0 = 3;
-
-  /** JVM constant for MRJ 3.1 */
-  private static final int MRJ_3_1 = 4;
-
-  /** JVM constant for any Windows NT JVM */
-  private static final int WINDOWS_NT = 5;
-
-  /** JVM constant for any Windows 9x JVM */
-  private static final int WINDOWS_9x = 6;
-
-  /** JVM constant for any other platform */
-  private static final int OTHER = -1;
-
-  /**
-   * The file type of the Finder on a Macintosh. Hardcoding "Finder" would keep
-   * non-U.S. English systems from working properly.
-   */
-  private static final String FINDER_TYPE = "FNDR";
-
-  /**
-   * The creator code of the Finder on a Macintosh, which is needed to send
-   * AppleEvents to the application.
-   */
-  private static final String FINDER_CREATOR = "MACS";
-
-  /** The name for the AppleEvent type corresponding to a GetURL event. */
-  private static final String GURL_EVENT = "GURL";
-
-  /**
-   * The first parameter that needs to be passed into Runtime.exec() to open the
-   * default web browser on Windows.
-   */
-  private static final String FIRST_WINDOWS_PARAMETER = "/c";
-
-  /** The second parameter for Runtime.exec() on Windows. */
-  private static final String SECOND_WINDOWS_PARAMETER = "start";
+  private static BrowserLauncher INSTANCE = null;
 
-  /**
-   * The third parameter for Runtime.exec() on Windows. This is a "title"
-   * parameter that the command line expects. Setting this parameter allows URLs
-   * containing spaces to work.
-   */
-  private static final String THIRD_WINDOWS_PARAMETER = "\"\"";
+  private static String preferredBrowser = null;
 
-  /**
-   * The shell parameters for Netscape that opens a given URL in an already-open
-   * copy of Netscape on many command-line systems.
-   */
-  private static final String NETSCAPE_REMOTE_PARAMETER = "-remote";
-
-  private static final String NETSCAPE_OPEN_PARAMETER_START = "openURL(";
-
-  private static final String NETSCAPE_OPEN_NEW_WINDOW = ", new-window";
-
-  private static final String NETSCAPE_OPEN_PARAMETER_END = ")";
-
-  /**
-   * The message from any exception thrown throughout the initialization
-   * process.
-   */
-  private static String errorMessage;
-
-  /**
-   * An initialization block that determines the operating system and loads the
-   * necessary runtime data.
-   */
-  static
+  public static BrowserLauncher getInstance()
   {
-
-    loadedWithoutErrors = true;
-
-    if (!Platform.isJS())
-    /**
-     * Java only
-     * 
-     * @j2sIgnore
-     * 
-     */
-    {
-    String osName = System.getProperty("os.name");
-
-    if (osName.startsWith("Mac OS"))
-    {
-      String mrjVersion = System.getProperty("mrj.version");
-      String majorMRJVersion;
-      if (mrjVersion == null)
-      {
-        // must be on some later build with mrj support
-        majorMRJVersion = "3.1";
-      }
-      else
-      {
-        majorMRJVersion = mrjVersion.substring(0, 3);
-      }
-
-      try
-      {
-        double version = Double.valueOf(majorMRJVersion).doubleValue();
-
-        if (version == 2)
-        {
-          jvm = MRJ_2_0;
-        }
-        else if ((version >= 2.1) && (version < 3))
-        {
-          // Assume that all 2.x versions of MRJ work the same. MRJ 2.1 actually
-          // works via Runtime.exec() and 2.2 supports that but has an openURL()
-          // method
-          // as well that we currently ignore.
-          jvm = MRJ_2_1;
-        }
-        else if (version == 3.0)
-        {
-          jvm = MRJ_3_0;
-        }
-        else if (version >= 3.1)
-        {
-          // Assume that all 3.1 and later versions of MRJ work the same.
-          jvm = MRJ_3_1;
-        }
-        else
-        {
-          loadedWithoutErrors = false;
-          errorMessage = "Unsupported MRJ version: " + version;
-        }
-      } catch (NumberFormatException nfe)
-      {
-        loadedWithoutErrors = false;
-        errorMessage = "Invalid MRJ version: " + mrjVersion;
-      }
-    }
-    else if (osName.startsWith("Windows"))
+    if (INSTANCE != null)
     {
-      if (osName.indexOf("9") != -1)
-      {
-        jvm = WINDOWS_9x;
-      }
-      else
-      {
-        jvm = WINDOWS_NT;
-      }
-    }
-    else
-    {
-      jvm = OTHER;
-    }
-
-    if (loadedWithoutErrors)
-    { // if we haven't hit any errors yet
-      loadedWithoutErrors = loadClasses();
-    }
+      return INSTANCE;
     }
+    INSTANCE = new BrowserLauncher();
+    return INSTANCE;
   }
 
-  /**
-   * This class should be never be instantiated; this just ensures so.
-   */
-  private BrowserLauncher()
+  public static void openURL(String url)
   {
-  }
-
-  /**
-   * 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
-   */
-  private static boolean loadClasses()
-  {
-
-    if (!Platform.isJS())
-    /**
-     * Java only
-     * 
-     * @j2sIgnore
-     * 
-     */
-    {
-    switch (jvm)
+    if (Platform.isJS())
     {
-    case MRJ_2_0:
-
-      try
-      {
-        Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget");
-        Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils");
-        Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent");
-        Class aeClass = Class.forName("com.apple.MacOS.ae");
-        aeDescClass = Class.forName("com.apple.MacOS.AEDesc");
-
-        aeTargetConstructor = aeTargetClass
-                .getDeclaredConstructor(new Class[]
-                { int.class });
-        appleEventConstructor = appleEventClass
-                .getDeclaredConstructor(new Class[]
-                { int.class, int.class, aeTargetClass, int.class,
-                    int.class });
-        aeDescConstructor = aeDescClass
-                .getDeclaredConstructor(new Class[]
-                { String.class });
-
-        makeOSType = osUtilsClass.getDeclaredMethod("makeOSType",
-                new Class[]
-                { String.class });
-        putParameter = appleEventClass.getDeclaredMethod("putParameter",
-                new Class[]
-                { int.class, aeDescClass });
-        sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply",
-                new Class[] {});
-
-        Field keyDirectObjectField = aeClass
-                .getDeclaredField("keyDirectObject");
-        keyDirectObject = (Integer) keyDirectObjectField.get(null);
-
-        Field autoGenerateReturnIDField = appleEventClass
-                .getDeclaredField("kAutoGenerateReturnID");
-        kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField
-                .get(null);
-
-        Field anyTransactionIDField = appleEventClass
-                .getDeclaredField("kAnyTransactionID");
-        kAnyTransactionID = (Integer) anyTransactionIDField.get(null);
-      } catch (ClassNotFoundException cnfe)
-      {
-        errorMessage = cnfe.getMessage();
-
-        return false;
-      } catch (NoSuchMethodException nsme)
-      {
-        errorMessage = nsme.getMessage();
-
-        return false;
-      } catch (NoSuchFieldException nsfe)
-      {
-        errorMessage = nsfe.getMessage();
-
-        return false;
-      } catch (IllegalAccessException iae)
-      {
-        errorMessage = iae.getMessage();
-
-        return false;
-      }
-
-      break;
-
-    case MRJ_2_1:
-
-      try
-      {
-        mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils");
-        mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType");
-
-        Field systemFolderField = mrjFileUtilsClass
-                .getDeclaredField("kSystemFolderType");
-        kSystemFolderType = systemFolderField.get(null);
-        findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder",
-                new Class[]
-                { mrjOSTypeClass });
-        getFileCreator = mrjFileUtilsClass
-                .getDeclaredMethod("getFileCreator", new Class[]
-                { File.class });
-        getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType",
-                new Class[]
-                { File.class });
-      } catch (ClassNotFoundException cnfe)
-      {
-        errorMessage = cnfe.getMessage();
-
-        return false;
-      } catch (NoSuchFieldException nsfe)
-      {
-        errorMessage = nsfe.getMessage();
-
-        return false;
-      } catch (NoSuchMethodException nsme)
-      {
-        errorMessage = nsme.getMessage();
-
-        return false;
-      } catch (SecurityException se)
-      {
-        errorMessage = se.getMessage();
-
-        return false;
-      } catch (IllegalAccessException iae)
-      {
-        errorMessage = iae.getMessage();
-
-        return false;
-      }
-
-      break;
-
-    case MRJ_3_0:
-
-      try
-      {
-        Class linker = Class.forName("com.apple.mrj.jdirect.Linker");
-        Constructor constructor = linker
-                .getConstructor(new Class[]
-                { Class.class });
-        linkage = constructor
-                .newInstance(new Object[]
-                { BrowserLauncher.class });
-      } catch (ClassNotFoundException cnfe)
-      {
-        errorMessage = cnfe.getMessage();
-
-        return false;
-      } catch (NoSuchMethodException nsme)
-      {
-        errorMessage = nsme.getMessage();
-
-        return false;
-      } catch (InvocationTargetException ite)
-      {
-        errorMessage = ite.getMessage();
-
-        return false;
-      } catch (InstantiationException ie)
-      {
-        errorMessage = ie.getMessage();
-
-        return false;
-      } catch (IllegalAccessException iae)
-      {
-        errorMessage = iae.getMessage();
-
-        return false;
-      }
-
-      break;
-
-    case MRJ_3_1:
-
-      try
-      {
-        mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils");
-        openURL = mrjFileUtilsClass.getDeclaredMethod("openURL",
-                new Class[]
-                { String.class });
-      } catch (ClassNotFoundException cnfe)
-      {
-        errorMessage = cnfe.getMessage();
-
-        return false;
-      } catch (NoSuchMethodException nsme)
-      {
-        errorMessage = nsme.getMessage();
-
-        return false;
-      }
-
-      break;
-
-    default:
-      break;
-    }
-
+      Platform.openURL(url);
+      return;
     }
-    return true;
-  }
-
-  /**
-   * Attempts to locate the default web browser on the local system. s results
-   * so it only locates the browser once for each use of this class per JVM
-   * instance.
-   * 
-   * @return The browser for the system. Note that this may not be what you
-   *         would consider to be a standard web browser; instead, it's the
-   *         application that gets called to open the default web browser. In
-   *         some cases, this will be a non-String object that provides the
-   *         means of calling the default browser.
-   */
-  private static Object locateBrowser()
-  {
-    if (!Platform.isJS())
+    else
     /**
      * Java only
      * 
      * @j2sIgnore
-     * 
      */
     {
-    if (browser != null)
-    {
-      return browser;
-    }
-
-    switch (jvm)
-    {
-    case MRJ_2_0:
-
-      try
-      {
-        Integer finderCreatorCode = (Integer) makeOSType.invoke(null,
-                new Object[]
-                { FINDER_CREATOR });
-        Object aeTarget = aeTargetConstructor
-                .newInstance(new Object[]
-                { finderCreatorCode });
-        Integer gurlType = (Integer) makeOSType.invoke(null,
-                new Object[]
-                { GURL_EVENT });
-        Object appleEvent = appleEventConstructor
-                .newInstance(new Object[]
-                { gurlType, gurlType, aeTarget, kAutoGenerateReturnID,
-                    kAnyTransactionID });
-
-        // Don't set browser = appleEvent because then the next time we call
-        // locateBrowser(), we'll get the same AppleEvent, to which we'll
-        // already have
-        // added the relevant parameter. Instead, regenerate the AppleEvent
-        // every time.
-        // There's probably a way to do this better; if any has any ideas,
-        // please let
-        // me know.
-        return appleEvent;
-      } catch (IllegalAccessException iae)
-      {
-        browser = null;
-        errorMessage = iae.getMessage();
-
-        return browser;
-      } catch (InstantiationException ie)
-      {
-        browser = null;
-        errorMessage = ie.getMessage();
-
-        return browser;
-      } catch (InvocationTargetException ite)
-      {
-        browser = null;
-        errorMessage = ite.getMessage();
-
-        return browser;
-      }
-
-    case MRJ_2_1:
-
-      File systemFolder;
-
-      try
-      {
-        systemFolder = (File) findFolder.invoke(null,
-                new Object[]
-                { kSystemFolderType });
-      } catch (IllegalArgumentException iare)
-      {
-        browser = null;
-        errorMessage = iare.getMessage();
-
-        return browser;
-      } catch (IllegalAccessException iae)
-      {
-        browser = null;
-        errorMessage = iae.getMessage();
-
-        return browser;
-      } catch (InvocationTargetException ite)
-      {
-        browser = null;
-        errorMessage = ite.getTargetException().getClass() + ": "
-                + ite.getTargetException().getMessage();
-
-        return browser;
-      }
-
-      String[] systemFolderFiles = systemFolder.list();
-
-      // Avoid a FilenameFilter because that can't be stopped mid-list
-      for (int i = 0; i < systemFolderFiles.length; i++)
+      Desktop d = Desktop.getDesktop();
+      if (d != null && d.isSupported(Desktop.Action.BROWSE))
       {
         try
         {
-          File file = new File(systemFolder, systemFolderFiles[i]);
-
-          if (!file.isFile())
-          {
-            continue;
-          }
-
-          // We're looking for a file with a creator code of 'MACS' and
-          // a type of 'FNDR'. Only requiring the type results in non-Finder
-          // applications being picked up on certain Mac OS 9 systems,
-          // especially German ones, and sending a GURL event to those
-          // applications results in a logout under Multiple Users.
-          Object fileType = getFileType.invoke(null, new Object[] { file });
-
-          if (FINDER_TYPE.equals(fileType.toString()))
-          {
-            Object fileCreator = getFileCreator.invoke(null,
-                    new Object[]
-                    { file });
-
-            if (FINDER_CREATOR.equals(fileCreator.toString()))
-            {
-              browser = file.toString(); // Actually the Finder, but that's OK
-
-              return browser;
-            }
-          }
-        } catch (IllegalArgumentException iare)
+          d.browse(new URI(url));
+        } catch (IOException e)
         {
-          errorMessage = iare.getMessage();
-
-          return null;
-        } catch (IllegalAccessException iae)
+          Console.warn(MessageManager.formatMessage(
+                  "exception.browser_unable_to_launch", url));
+          Console.warn(e.getMessage());
+          Console.debug(Cache.getStackTraceString(e));
+        } catch (URISyntaxException e1)
         {
-          browser = null;
-          errorMessage = iae.getMessage();
-
-          return browser;
-        } catch (InvocationTargetException ite)
-        {
-          browser = null;
-          errorMessage = ite.getTargetException().getClass() + ": "
-                  + ite.getTargetException().getMessage();
-
-          return browser;
+          Console.warn(MessageManager.formatMessage(
+                  "exception.browser_unable_to_launch", url));
+          Console.warn(e1.getMessage());
+          Console.debug(Cache.getStackTraceString(e1));
         }
       }
-
-      browser = null;
-
-      break;
-
-    case MRJ_3_0:
-    case MRJ_3_1:
-      browser = ""; // Return something non-null
-
-      break;
-
-    case WINDOWS_NT:
-      browser = "cmd.exe";
-
-      break;
-
-    case WINDOWS_9x:
-      browser = "command.com";
-
-      break;
-
-    case OTHER:
-    default:
-      browser = Cache.getDefault("DEFAULT_BROWSER", "firefox");
-
-      break;
-    }
-
+      else
+      {
+        Console.warn(MessageManager
+                .formatMessage("exception.browser_os_not_supported", url));
+      }
     }
-
-    return browser;
-
   }
 
-  /**
-   * used to ensure that browser is up-to-date after a configuration change
-   * (Unix DEFAULT_BROWSER property change).
-   */
   public static void resetBrowser()
   {
-    browser = null;
+    resetBrowser(false);
   }
 
-  /**
-   * Attempts to open the default web browser to the given URL.
-   * 
-   * @param url
-   *          The URL to open
-   * @throws IOException
-   *           If the web browser could not be located or does not run
-   */
-  public static void openURL(String url) throws IOException
+  public static void resetBrowser(boolean removeIfNull)
   {
-
-    if (Platform.isJS())
-    {
-      Platform.openURL(url);
-      return;
-    }
-    else
-    /**
-     * Java only
-     * 
-     * @j2sIgnore
-     */
+    String defaultBrowser = Cache.getProperty("DEFAULT_BROWSER");
+    preferredBrowser = defaultBrowser;
+    // System.setProperty(getBrowserSystemProperty(),
+    // Cache.getProperty("DEFAULT_BROWSER"));
+    if (defaultBrowser == null && removeIfNull)
     {
-
-    if (!loadedWithoutErrors)
-    {
-      throw new IOException(MessageManager
-              .formatMessage("exception.browser_not_found", new String[]
-              { errorMessage }));
+      // System.clearProperty(getBrowserSystemProperty());
     }
 
-    Object browser = locateBrowser();
-
-    if (browser == null)
-    {
-      throw new IOException(MessageManager.formatMessage(
-              "exception.browser_unable_to_locate", new String[]
-              { errorMessage }));
-    }
-
-    switch (jvm)
-    {
-    case MRJ_2_0:
-
-      Object aeDesc = null;
-
-      try
-      {
-        aeDesc = aeDescConstructor.newInstance(new Object[] { url });
-        putParameter.invoke(browser,
-                new Object[]
-                { keyDirectObject, aeDesc });
-        sendNoReply.invoke(browser, new Object[] {});
-      } catch (InvocationTargetException ite)
-      {
-        throw new IOException(MessageManager.formatMessage(
-                "exception.invocation_target_exception_creating_aedesc",
-                new String[]
-                { ite.getMessage() }));
-      } catch (IllegalAccessException iae)
-      {
-        throw new IOException(MessageManager.formatMessage(
-                "exception.illegal_access_building_apple_evt", new String[]
-                { iae.getMessage() }));
-      } catch (InstantiationException ie)
-      {
-        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
-        browser = null; // Ditto
-      }
-
-      break;
-
-    case MRJ_2_1:
-      Runtime.getRuntime().exec(new String[] { (String) browser, url });
-
-      break;
-
-    case MRJ_3_0:
-
-      int[] instance = new int[1];
-      int result = ICStart(instance, 0);
-
-      if (result == 0)
-      {
-        int[] selectionStart = new int[] { 0 };
-        byte[] urlBytes = url.getBytes();
-        int[] selectionEnd = new int[] { urlBytes.length };
-        result = ICLaunchURL(instance[0], new byte[] { 0 }, urlBytes,
-                urlBytes.length, selectionStart, selectionEnd);
-
-        if (result == 0)
-        {
-          // Ignore the return value; the URL was launched successfully
-          // regardless of what happens here.
-          ICStop(instance);
-        }
-        else
-        {
-          throw new IOException(MessageManager.formatMessage(
-                  "exception.unable_to_launch_url", new String[]
-                  { Integer.valueOf(result).toString() }));
-        }
-      }
-      else
-      {
-        throw new IOException(MessageManager.formatMessage(
-                "exception.unable_to_create_internet_config", new String[]
-                { Integer.valueOf(result).toString() }));
-      }
-
-      break;
-
-    case MRJ_3_1:
-
-      try
-      {
-        openURL.invoke(null, new Object[] { url });
-      } catch (InvocationTargetException ite)
-      {
-        throw new IOException(MessageManager.formatMessage(
-                "exception.invocation_target_calling_url", new String[]
-                { ite.getMessage() }));
-      } catch (IllegalAccessException iae)
-      {
-        throw new IOException(MessageManager.formatMessage(
-                "exception.illegal_access_calling_url", new String[]
-                { iae.getMessage() }));
-      }
-
-      break;
-
-    case WINDOWS_NT:
-    case WINDOWS_9x:
-
-      // Add quotes around the URL to allow ampersands and other special
-      // characters to work.
-      Process process = Runtime.getRuntime()
-              .exec(new String[]
-              { (String) browser, FIRST_WINDOWS_PARAMETER,
-                  SECOND_WINDOWS_PARAMETER, THIRD_WINDOWS_PARAMETER,
-                  '"' + url + '"' });
-
-      // This avoids a memory leak on some versions of Java on Windows.
-      // That's hinted at in
-      // <http://developer.java.sun.com/developer/qow/archive/68/>.
-      try
-      {
-        process.waitFor();
-        process.exitValue();
-      } catch (InterruptedException ie)
-      {
-        throw new IOException(MessageManager.formatMessage(
-                "exception.interrupted_launching_browser", new String[]
-                { ie.getMessage() }));
-      }
-
-      break;
-
-    case OTHER:
-
-      // Assume that we're on Unix and that Netscape (actually Firefox) is
-      // installed
-      // First, attempt to open the URL in a currently running session of
-      // Netscape
-      // JBPNote log debug
-
-      /*
-       * System.out.println("Executing : "+browser+" "+
-       * NETSCAPE_REMOTE_PARAMETER+" "+ NETSCAPE_OPEN_PARAMETER_START + url +
-       * NETSCAPE_OPEN_NEW_WINDOW + NETSCAPE_OPEN_PARAMETER_END);
-       */
-      process = Runtime.getRuntime()
-              .exec(new String[]
-              { (String) browser, NETSCAPE_REMOTE_PARAMETER,
-
-                  NETSCAPE_OPEN_PARAMETER_START + url
-                          + NETSCAPE_OPEN_NEW_WINDOW
-                          + NETSCAPE_OPEN_PARAMETER_END });
-
-      try
-      {
-        int exitCode = process.waitFor();
-
-        if (exitCode != 0)
-        { // if Netscape was not open
-          Runtime.getRuntime().exec(new String[] { (String) browser, url });
-        }
-      } catch (InterruptedException ie)
-      {
-        throw new IOException(MessageManager.formatMessage(
-                "exception.interrupted_launching_browser", new String[]
-                { ie.getMessage() }));
-      }
-
-      break;
-
-    default:
-
-      // This should never occur, but if it does, we'll try the simplest thing
-      // possible
-      Runtime.getRuntime().exec(new String[] { (String) browser, url });
-
-      break;
-    }
-    }
   }
 
+  public static List<String> getBrowserList()
+  {
+    return new ArrayList<String>();
+  }
 
-  /**
-   * Methods required for Mac OS X. The presence of native methods does not
-   * cause any problems on other platforms.
-   */
-  private native static int ICStart(int[] instance, int signature);
-
-  private native static int ICStop(int[] instance);
+  public static String getBrowserSystemProperty()
+  {
+    // return IBrowserLaunching.BROWSER_SYSTEM_PROPERTY;
+    return "jalview.default.browser";
+  }
 
-  private native static int ICLaunchURL(int instance, byte[] hint,
-          byte[] data, int len, int[] selectionStart, int[] selectionEnd);
-}
+}
\ No newline at end of file
index e16197a..2de08f5 100644 (file)
@@ -317,7 +317,6 @@ public class EnsemblGeneTest
     String ids = "ENSG00000158828 ENST00000321556 P30419 ENST00000592782 BRAF";
     EnsemblGene testee = new EnsemblGene();
     List<String> geneIds = testee.getGeneIds(ids);
-    assertEquals(8, geneIds.size());
     assertTrue(geneIds.contains("ENSG00000158828"));
     assertTrue(geneIds.contains("ENSG00000136448"));
     assertTrue(geneIds.contains("ENSG00000157764")); // BRAF human
@@ -326,5 +325,7 @@ public class EnsemblGeneTest
     assertTrue(geneIds.contains("ENSXETG00000004845")); // xenopus
     assertTrue(geneIds.contains("ENSDARG00000017661")); // zebrafish
     assertTrue(geneIds.contains("ENSGALG00000012865")); // chicken
+    assertEquals(8, geneIds.size());
+    
   }
 }