JAL-3253 preliminary static fixes for JavaScript
authorhansonr <hansonr@STO24954W.ad.stolaf.edu>
Wed, 8 May 2019 11:29:37 +0000 (06:29 -0500)
committerhansonr <hansonr@STO24954W.ad.stolaf.edu>
Wed, 8 May 2019 11:29:37 +0000 (06:29 -0500)
Desktop.instance and Desktop.getInstance()
Jalview.instance and Jalview.getInstance()
AlignmentSorter.instance and AlignmentSorter.getInstance()

ArgsParser static final options

*SoapBindingStub static final _operations

Clean up of headless business
Clean up of ArgsParser options

85 files changed:
doc/parameters.xlsx [new file with mode: 0644]
src/ext/vamsas/JpredSoapBindingStub.java [changed mode: 0755->0644]
src/ext/vamsas/MuscleWSSoapBindingStub.java
src/ext/vamsas/RegistryServiceSoapBindingStub.java
src/ext/vamsas/SeqSearchServiceSoapBindingStub.java
src/ext/vamsas/ServiceHandle.java
src/jalview/analysis/AlignmentSorter.java
src/jalview/analysis/GeneticCodes.java
src/jalview/analysis/scoremodels/ScoreMatrix.java
src/jalview/analysis/scoremodels/ScoreModels.java
src/jalview/bin/ArgsParser.java
src/jalview/bin/Cache.java
src/jalview/bin/Jalview.java
src/jalview/gui/AlignExportOptions.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/AnnotationColourChooser.java
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/AppJmol.java
src/jalview/gui/AssociatePdbFileWithSeq.java
src/jalview/gui/CalculationChooser.java
src/jalview/gui/ChimeraViewFrame.java
src/jalview/gui/ColourMenuHelper.java
src/jalview/gui/CrossRefAction.java
src/jalview/gui/CutAndPasteTransfer.java
src/jalview/gui/Desktop.java
src/jalview/gui/FeatureEditor.java
src/jalview/gui/Finder.java
src/jalview/gui/IdPanel.java
src/jalview/gui/JalviewDialog.java
src/jalview/gui/LineartOptions.java
src/jalview/gui/OOMWarning.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/Preferences.java
src/jalview/gui/PromptUserConfig.java
src/jalview/gui/SequenceFetcher.java
src/jalview/gui/SplashScreen.java
src/jalview/gui/SplitFrame.java
src/jalview/gui/StructureChooser.java
src/jalview/gui/StructureViewerBase.java
src/jalview/gui/UserDefinedColours.java
src/jalview/gui/UserQuestionnaireCheck.java
src/jalview/gui/VamsasApplication.java
src/jalview/gui/WebserviceInfo.java
src/jalview/gui/WsJobParameters.java
src/jalview/gui/WsParamSetManager.java
src/jalview/gui/WsPreferences.java
src/jalview/io/BackupFiles.java
src/jalview/io/FileLoader.java
src/jalview/io/HTMLOutput.java
src/jalview/io/HtmlSvgOutput.java
src/jalview/io/VamsasAppDatastore.java
src/jalview/io/WSWUBlastClient.java
src/jalview/io/vamsas/Sequencemapping.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/jbgui/GDesktop.java
src/jalview/jbgui/GPreferences.java
src/jalview/jbgui/GSequenceLink.java
src/jalview/project/Jalview2XML.java
src/jalview/schemes/ResidueProperties.java
src/jalview/util/Platform.java
src/jalview/ws/jws1/Discoverer.java
src/jalview/ws/jws1/JPredClient.java
src/jalview/ws/jws1/MsaWSClient.java
src/jalview/ws/jws1/SeqSearchWSClient.java
src/jalview/ws/jws2/MsaWSClient.java
src/jalview/ws/jws2/SequenceAnnotationWSClient.java
src/jalview/ws/jws2/jabaws2/Jws2Instance.java
src/jalview/ws/rest/RestClient.java
test/jalview/analysis/DnaTest.java
test/jalview/ext/jmol/JmolViewerTest.java
test/jalview/ext/rbvi/chimera/JalviewChimeraView.java
test/jalview/gui/AlignFrameTest.java
test/jalview/gui/AlignViewportTest.java
test/jalview/gui/FreeUpMemoryTest.java
test/jalview/gui/SeqPanelTest.java
test/jalview/io/AnnotatedPDBFileInputTest.java
test/jalview/io/CrossRef2xmlTests.java
test/jalview/io/FeaturesFileTest.java
test/jalview/io/Jalview2xmlBase.java
test/jalview/io/JalviewExportPropertiesTests.java
test/jalview/project/Jalview2xmlTests.java
test/jalview/schemes/ColourSchemesTest.java
test/jalview/structure/StructureSelectionManagerTest.java

diff --git a/doc/parameters.xlsx b/doc/parameters.xlsx
new file mode 100644 (file)
index 0000000..fcbd0fd
Binary files /dev/null and b/doc/parameters.xlsx differ
old mode 100755 (executable)
new mode 100644 (file)
index cff8081..8345551
@@ -31,7 +31,7 @@ public class JpredSoapBindingStub extends org.apache.axis.client.Stub
 
   private java.util.Vector cachedDeserFactories = new java.util.Vector();
 
-  static org.apache.axis.description.OperationDesc[] _operations;
+  private static org.apache.axis.description.OperationDesc[] _operations;
 
   static
   {
@@ -260,6 +260,7 @@ public class JpredSoapBindingStub extends org.apache.axis.client.Stub
     }
   }
 
+  @Override
   public java.lang.String predict(vamsas.objects.simple.Sequence seq)
           throws java.rmi.RemoteException
   {
@@ -297,6 +298,7 @@ public class JpredSoapBindingStub extends org.apache.axis.client.Stub
     }
   }
 
+  @Override
   public java.lang.String predictOnMsa(
           vamsas.objects.simple.Msfalignment msf)
           throws java.rmi.RemoteException
@@ -335,6 +337,7 @@ public class JpredSoapBindingStub extends org.apache.axis.client.Stub
     }
   }
 
+  @Override
   public vamsas.objects.simple.Secstructpred getpredict(
           java.lang.String job_id) throws java.rmi.RemoteException
   {
@@ -373,6 +376,7 @@ public class JpredSoapBindingStub extends org.apache.axis.client.Stub
     }
   }
 
+  @Override
   public vamsas.objects.simple.JpredResult getresult(java.lang.String job_id)
           throws java.rmi.RemoteException
   {
index 1f8d231..026066c 100755 (executable)
@@ -23,7 +23,7 @@ package ext.vamsas;
 public class MuscleWSSoapBindingStub extends org.apache.axis.client.Stub
         implements ext.vamsas.MuscleWS
 {
-  static org.apache.axis.description.OperationDesc[] _operations;
+  private static final org.apache.axis.description.OperationDesc[] _operations;
 
   static
   {
@@ -296,6 +296,7 @@ public class MuscleWSSoapBindingStub extends org.apache.axis.client.Stub
     }
   }
 
+  @Override
   public vamsas.objects.simple.WsJobId align(
           vamsas.objects.simple.SequenceSet seqSet)
           throws java.rmi.RemoteException
@@ -337,6 +338,7 @@ public class MuscleWSSoapBindingStub extends org.apache.axis.client.Stub
     }
   }
 
+  @Override
   public vamsas.objects.simple.Alignment getalign(java.lang.String job_id)
           throws java.rmi.RemoteException
   {
@@ -378,6 +380,7 @@ public class MuscleWSSoapBindingStub extends org.apache.axis.client.Stub
     }
   }
 
+  @Override
   public vamsas.objects.simple.MsaResult getResult(java.lang.String job_id)
           throws java.rmi.RemoteException
   {
@@ -419,6 +422,7 @@ public class MuscleWSSoapBindingStub extends org.apache.axis.client.Stub
     }
   }
 
+  @Override
   public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId)
           throws java.rmi.RemoteException
   {
index 08b2a6b..f010ee8 100755 (executable)
@@ -31,7 +31,7 @@ public class RegistryServiceSoapBindingStub extends
 
   private java.util.Vector cachedDeserFactories = new java.util.Vector();
 
-  static org.apache.axis.description.OperationDesc[] _operations;
+  private static org.apache.axis.description.OperationDesc[] _operations;
 
   static
   {
@@ -192,6 +192,7 @@ public class RegistryServiceSoapBindingStub extends
     }
   }
 
+  @Override
   public ext.vamsas.ServiceHandles getServices()
           throws java.rmi.RemoteException
   {
index 390ceb6..df0a504 100644 (file)
@@ -31,7 +31,7 @@ public class SeqSearchServiceSoapBindingStub extends
 
   private java.util.Vector cachedDeserFactories = new java.util.Vector();
 
-  static org.apache.axis.description.OperationDesc[] _operations;
+  private static final org.apache.axis.description.OperationDesc[] _operations;
 
   static
   {
@@ -299,6 +299,7 @@ public class SeqSearchServiceSoapBindingStub extends
     }
   }
 
+  @Override
   public java.lang.String getDatabase() throws java.rmi.RemoteException
   {
     if (super.cachedEndpoint == null)
@@ -335,6 +336,7 @@ public class SeqSearchServiceSoapBindingStub extends
     }
   }
 
+  @Override
   public vamsas.objects.simple.SeqSearchResult getResult(
           java.lang.String job_id) throws java.rmi.RemoteException
   {
@@ -373,6 +375,7 @@ public class SeqSearchServiceSoapBindingStub extends
     }
   }
 
+  @Override
   public vamsas.objects.simple.WsJobId psearch(
           vamsas.objects.simple.Alignment al, java.lang.String database)
           throws java.rmi.RemoteException
@@ -412,6 +415,7 @@ public class SeqSearchServiceSoapBindingStub extends
     }
   }
 
+  @Override
   public vamsas.objects.simple.WsJobId search(
           vamsas.objects.simple.Sequence s, java.lang.String database)
           throws java.rmi.RemoteException
@@ -450,6 +454,7 @@ public class SeqSearchServiceSoapBindingStub extends
     }
   }
 
+  @Override
   public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId)
           throws java.rmi.RemoteException
   {
index 83412ea..428b5ea 100755 (executable)
@@ -126,6 +126,7 @@ public class ServiceHandle implements java.io.Serializable
 
   private java.lang.Object __equalsCalc = null;
 
+  @Override
   public synchronized boolean equals(java.lang.Object obj)
   {
     if (obj == null)
@@ -162,6 +163,7 @@ public class ServiceHandle implements java.io.Serializable
 
   private boolean __hashCodeCalc = false;
 
+  @Override
   public synchronized int hashCode()
   {
     if (__hashCodeCalc)
@@ -191,7 +193,7 @@ public class ServiceHandle implements java.io.Serializable
   }
 
   // Type metadata
-  private static org.apache.axis.description.TypeDesc typeDesc = new org.apache.axis.description.TypeDesc(
+  private static final org.apache.axis.description.TypeDesc typeDesc = new org.apache.axis.description.TypeDesc(
           ServiceHandle.class, true);
 
   static
index 7ecce49..e5038ba 100755 (executable)
@@ -29,6 +29,7 @@ import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.SequenceNode;
+import jalview.util.Platform;
 import jalview.util.QuickSort;
 
 import java.util.ArrayList;
@@ -53,38 +54,77 @@ import java.util.List;
  */
 public class AlignmentSorter
 {
+
+  static AlignmentSorter instance;
+
+  public static AlignmentSorter getInstance()
+  {
+
+    // BH 2019.05.08 need to isolate static fields in JavaScript
+
+    AlignmentSorter i = instance;
+    @SuppressWarnings("unused")
+    ThreadGroup g = null;
+    if (Platform.isJS())
+    {
+      g = Thread.currentThread().getThreadGroup();
+      /**
+       * @j2sNative i = g._jalviewScoreModelsInstance;
+       * 
+       */
+    }
+    if (i == null)
+    {
+      i = new AlignmentSorter();
+
+      if (Platform.isJS())
+      {
+        /**
+         * @j2sNative g._jalviewScoreModelsInstance = i;
+         * 
+         */
+      }
+      else
+      {
+        instance = i;
+      }
+    }
+    return i;
+  }
+
   /*
    * todo: refactor searches to follow a basic pattern: (search property, last
    * search state, current sort direction)
    */
-  static boolean sortIdAscending = true;
+  boolean sortIdAscending = true;
 
-  static int lastGroupHash = 0;
+  int lastGroupHash = 0;
 
-  static boolean sortGroupAscending = true;
+  boolean sortGroupAscending = true;
 
-  static AlignmentOrder lastOrder = null;
+  AlignmentOrder lastOrder = null;
 
-  static boolean sortOrderAscending = true;
+  boolean sortOrderAscending = true;
 
-  static TreeModel lastTree = null;
+  TreeModel lastTree = null;
 
-  static boolean sortTreeAscending = true;
+  boolean sortTreeAscending = true;
 
-  /*
+
+  /**
    * last Annotation Label used for sort by Annotation score
    */
-  private static String lastSortByAnnotation;
+  private String lastSortByAnnotation;
 
-  /*
-   * string hash of last arguments to sortByFeature
-   * (sort order toggles if this is unchanged between sorts)
+  /**
+   * string hash of last arguments to sortByFeature (sort order toggles if this
+   * is unchanged between sorts)
    */
-  private static String sortByFeatureCriteria;
+  private String sortByFeatureCriteria;
 
-  private static boolean sortByFeatureAscending = true;
+  private boolean sortByFeatureAscending = true;
 
-  private static boolean sortLengthAscending;
+  private boolean sortLengthAscending;
 
   /**
    * Sorts sequences in the alignment by Percentage Identity with the given
@@ -222,7 +262,8 @@ public class AlignmentSorter
 
     QuickSort.sort(ids, seqs);
 
-    if (sortIdAscending)
+    AlignmentSorter as = getInstance();
+    if (as.sortIdAscending)
     {
       setReverseOrder(align, seqs);
     }
@@ -231,7 +272,7 @@ public class AlignmentSorter
       setOrder(align, seqs);
     }
 
-    sortIdAscending = !sortIdAscending;
+    as.sortIdAscending = !as.sortIdAscending;
   }
 
   /**
@@ -255,7 +296,9 @@ public class AlignmentSorter
 
     QuickSort.sort(length, seqs);
 
-    if (sortLengthAscending)
+    AlignmentSorter as = getInstance();
+
+    if (as.sortLengthAscending)
     {
       setReverseOrder(align, seqs);
     }
@@ -264,7 +307,7 @@ public class AlignmentSorter
       setOrder(align, seqs);
     }
 
-    sortLengthAscending = !sortLengthAscending;
+    as.sortLengthAscending = !as.sortLengthAscending;
   }
 
   /**
@@ -281,14 +324,16 @@ public class AlignmentSorter
     // ORDERS BY GROUP SIZE
     List<SequenceGroup> groups = new ArrayList<>();
 
-    if (groups.hashCode() != lastGroupHash)
+    AlignmentSorter as = getInstance();
+
+    if (groups.hashCode() != as.lastGroupHash)
     {
-      sortGroupAscending = true;
-      lastGroupHash = groups.hashCode();
+      as.sortGroupAscending = true;
+      as.lastGroupHash = groups.hashCode();
     }
     else
     {
-      sortGroupAscending = !sortGroupAscending;
+      as.sortGroupAscending = !as.sortGroupAscending;
     }
 
     // SORTS GROUPS BY SIZE
@@ -328,7 +373,7 @@ public class AlignmentSorter
       }
     }
 
-    if (sortGroupAscending)
+    if (as.sortGroupAscending)
     {
       setOrder(align, seqs);
     }
@@ -401,16 +446,18 @@ public class AlignmentSorter
     // Get an ordered vector of sequences which may also be present in align
     List<SequenceI> tmp = order.getOrder();
 
-    if (lastOrder == order)
+    AlignmentSorter as = getInstance();
+
+    if (as.lastOrder == order)
     {
-      sortOrderAscending = !sortOrderAscending;
+      as.sortOrderAscending = !as.sortOrderAscending;
     }
     else
     {
-      sortOrderAscending = true;
+      as.sortOrderAscending = true;
     }
 
-    if (sortOrderAscending)
+    if (as.sortOrderAscending)
     {
       setOrder(align, tmp);
     }
@@ -473,18 +520,20 @@ public class AlignmentSorter
   {
     List<SequenceI> tmp = getOrderByTree(align, tree);
 
+    AlignmentSorter as = getInstance();
+
     // tmp should properly permute align with tree.
-    if (lastTree != tree)
+    if (as.lastTree != tree)
     {
-      sortTreeAscending = true;
-      lastTree = tree;
+      as.sortTreeAscending = true;
+      as.lastTree = tree;
     }
     else
     {
-      sortTreeAscending = !sortTreeAscending;
+      as.sortTreeAscending = !as.sortTreeAscending;
     }
 
-    if (sortTreeAscending)
+    if (as.sortTreeAscending)
     {
       setOrder(align, tmp);
     }
@@ -658,9 +707,12 @@ public class AlignmentSorter
     }
 
     jalview.util.QuickSort.sort(scores, seqs);
-    if (lastSortByAnnotation != scoreLabel)
+
+    AlignmentSorter as = getInstance();
+
+    if (as.lastSortByAnnotation != scoreLabel)
     {
-      lastSortByAnnotation = scoreLabel;
+      as.lastSortByAnnotation = scoreLabel;
       setOrder(alignment, seqs);
     }
     else
@@ -809,6 +861,8 @@ public class AlignmentSorter
       }
     }
 
+    boolean doSort = false;
+
     if (FEATURE_SCORE.equals(method))
     {
       if (hasScores == 0)
@@ -834,7 +888,7 @@ public class AlignmentSorter
           }
         }
       }
-      QuickSort.sortByDouble(scores, seqs, sortByFeatureAscending);
+      doSort = true;
     }
     else if (FEATURE_DENSITY.equals(method))
     {
@@ -846,9 +900,12 @@ public class AlignmentSorter
         // System.err.println("Sorting on Density: seq "+seqs[i].getName()+
         // " Feats: "+featureCount+" Score : "+scores[i]);
       }
-      QuickSort.sortByDouble(scores, seqs, sortByFeatureAscending);
+      doSort = true;
+    }
+    if (doSort)
+    {
+      QuickSort.sortByDouble(scores, seqs, getInstance().sortByFeatureAscending);
     }
-
     setOrder(alignment, seqs);
   }
 
@@ -883,16 +940,17 @@ public class AlignmentSorter
     /*
      * if resorting on the same criteria, toggle sort order
      */
-    if (sortByFeatureCriteria == null
-            || !scoreCriteria.equals(sortByFeatureCriteria))
+    AlignmentSorter as = getInstance();
+    if (as.sortByFeatureCriteria == null
+            || !scoreCriteria.equals(as.sortByFeatureCriteria))
     {
-      sortByFeatureAscending = true;
+      as.sortByFeatureAscending = true;
     }
     else
     {
-      sortByFeatureAscending = !sortByFeatureAscending;
+      as.sortByFeatureAscending = !as.sortByFeatureAscending;
     }
-    sortByFeatureCriteria = scoreCriteria;
+    as.sortByFeatureCriteria = scoreCriteria;
   }
 
 }
index 137b7f8..69a3846 100644 (file)
@@ -12,13 +12,30 @@ import java.util.Map;
 import java.util.StringTokenizer;
 
 /**
- * A singleton that provides instances of genetic code translation tables
+ * A static class that provides instances of genetic code translation tables
  * 
  * @author gmcarstairs
  * @see https://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi
  */
 public final class GeneticCodes
 {
+
+  /**
+   * As implemented, this has to be the first table defined in the data file.
+   */
+  private static GeneticCodeI standardTable;
+
+  /**
+   * 
+   * @return the standard code table (table 1)
+   */
+  public static GeneticCodeI getStandardCodeTable()
+  {
+    return (standardTable == null
+            ? standardTable = codeTables.values().iterator().next()
+            : standardTable);
+  }
+
   private static final int CODON_LENGTH = 3;
 
   private static final String QUOTE = "\"";
@@ -39,42 +56,31 @@ public final class GeneticCodes
 
   private static final String RESOURCE_FILE = "/GeneticCodes.dat";
 
-  private static GeneticCodes instance = new GeneticCodes();
-
-  private Map<String, String> ambiguityCodes;
+  private static final Map<String, String> ambiguityCodes;
 
   /*
    * loaded code tables, with keys in order of loading 
    */
-  private Map<String, GeneticCodeI> codeTables;
+  private static final Map<String, GeneticCodeI> codeTables;
 
-  /**
-   * Private constructor enforces singleton
-   */
-  private GeneticCodes()
+  static
   {
-    if (instance == null)
-    {
-      ambiguityCodes = new HashMap<>();
+    ambiguityCodes = new HashMap<>();
 
-      /*
-       * LinkedHashMap preserves order of addition of entries,
-       * so we can assume the Standard Code Table is the first
-       */
-      codeTables = new LinkedHashMap<>();
-      loadAmbiguityCodes(AMBIGUITY_CODES_FILE);
-      loadCodes(RESOURCE_FILE);
-    }
+    /*
+     * LinkedHashMap preserves order of addition of entries,
+     * so we can assume the Standard Code Table is the first
+     */
+    codeTables = new LinkedHashMap<>();
+    loadAmbiguityCodes(AMBIGUITY_CODES_FILE);
+    loadCodes(RESOURCE_FILE);
   }
 
   /**
-   * Returns the singleton instance of this class
-   * 
-   * @return
+   * Private constructor enforces no instantiation
    */
-  public static GeneticCodes getInstance()
+  private GeneticCodes()
   {
-    return instance;
   }
 
   /**
@@ -82,41 +88,30 @@ public final class GeneticCodes
    * 
    * @return
    */
-  public Iterable<GeneticCodeI> getCodeTables()
+  public static Iterable<GeneticCodeI> getCodeTables()
   {
     return codeTables.values();
   }
 
   /**
-   * Answers the code table with the given id
+   * Answers the code table with the given id -- test suite only
    * 
    * @param id
    * @return
    */
-  public GeneticCodeI getCodeTable(String id)
+  public static GeneticCodeI getCodeTable(String id)
   {
     return codeTables.get(id);
   }
 
   /**
-   * A convenience method that returns the standard code table (table 1). As
-   * implemented, this has to be the first table defined in the data file.
-   * 
-   * @return
-   */
-  public GeneticCodeI getStandardCodeTable()
-  {
-    return codeTables.values().iterator().next();
-  }
-
-  /**
    * Loads the code tables from a data file
    */
-  protected void loadCodes(String fileName)
+  private static void loadCodes(String fileName)
   {
     try
     {
-      InputStream is = getClass().getResourceAsStream(fileName);
+      InputStream is = GeneticCodes.class.getResourceAsStream(fileName);
       if (is == null)
       {
         System.err.println("Resource file not found: " + fileName);
@@ -163,11 +158,11 @@ public final class GeneticCodes
    * 
    * @param fileName
    */
-  protected void loadAmbiguityCodes(String fileName)
+  private static void loadAmbiguityCodes(String fileName)
   {
     try
     {
-      InputStream is = getClass().getResourceAsStream(fileName);
+      InputStream is = GeneticCodes.class.getResourceAsStream(fileName);
       if (is == null)
       {
         System.err.println("Resource file not found: " + fileName);
@@ -209,7 +204,7 @@ public final class GeneticCodes
    * @return
    * @throws IOException
    */
-  protected String readLine(BufferedReader dataIn) throws IOException
+  private static String readLine(BufferedReader dataIn) throws IOException
   {
     String line = dataIn.readLine();
     while (line != null && line.startsWith("#"))
@@ -247,7 +242,8 @@ public final class GeneticCodes
    * @return
    * @throws IOException
    */
-  protected String loadOneTable(BufferedReader dataIn) throws IOException
+  private static String loadOneTable(BufferedReader dataIn)
+          throws IOException
   {
     String name = null;
     String id = null;
@@ -307,7 +303,7 @@ public final class GeneticCodes
    * @param name
    * @param codons
    */
-  protected void registerCodeTable(final String id, final String name,
+  private static void registerCodeTable(final String id, final String name,
           final Map<String, String> codons)
   {
     codeTables.put(id, new GeneticCodeI()
@@ -365,7 +361,7 @@ public final class GeneticCodes
    * @param codeTable
    * @return
    */
-  protected String getAmbiguousTranslation(String codon,
+  protected static String getAmbiguousTranslation(String codon,
           Map<String, String> ambiguous, GeneticCodeI codeTable)
   {
     if (codon.length() != CODON_LENGTH)
@@ -423,4 +419,5 @@ public final class GeneticCodes
     ambiguous.put(codon, peptide);
     return peptide;
   }
+
 }
index b206339..c53ecdb 100644 (file)
@@ -54,7 +54,8 @@ public class ScoreMatrix extends SimilarityScoreModel
    * score matrix (JAL-2397)
    * Set this flag to true (via Groovy) for 2.10.1 behaviour
    */
-  private static boolean scoreGapAsAny = false;
+  // BH 2019.05.08 was static but not ever set
+  private boolean scoreGapAsAny = false;
 
   public static final short UNMAPPED = (short) -1;
 
index ebc9a26..fd579dc 100644 (file)
@@ -25,6 +25,7 @@ import jalview.api.analysis.ScoreModelI;
 import jalview.io.DataSourceType;
 import jalview.io.FileParse;
 import jalview.io.ScoreMatrixFile;
+import jalview.util.Platform;
 
 import java.io.IOException;
 import java.util.LinkedHashMap;
@@ -43,8 +44,6 @@ public class ScoreModels
 
   private static ScoreModels instance;
 
-  private Map<String, ScoreModelI> models;
-
   /**
    * Answers the singleton instance of this class, with lazy initialisation
    * (built-in score models are loaded on the first call to this method)
@@ -53,13 +52,37 @@ public class ScoreModels
    */
   public static ScoreModels getInstance()
   {
-    if (instance == null)
+    ScoreModels m = instance;
+    @SuppressWarnings("unused")
+    ThreadGroup g = null;
+    if (Platform.isJS())
     {
-      instance = new ScoreModels();
+      g = Thread.currentThread().getThreadGroup();
+      /**
+       * @j2sNative m = g._jalviewScoreModelsInstance;
+       * 
+       */
     }
-    return instance;
+    if (m == null)
+    {
+      m = new ScoreModels();
+      if (Platform.isJS())
+      {
+        /**
+         * @j2sNative g._jalviewScoreModelsInstance = m;
+         * 
+         */
+      }
+      else
+      {
+        instance = m;
+      }
+    }
+    return m;
   }
 
+  private Map<String, ScoreModelI> models;
+
   /**
    * Private constructor to enforce use of singleton. Registers Jalview's
    * "built-in" score models:
index c927f1f..2c6cea7 100644 (file)
@@ -34,11 +34,58 @@ import java.util.Vector;
  */
 public class ArgsParser
 {
-  Vector<String> vargs = null;
+
+  public static final String ANNOTATIONS = "annotations";
+
+  public static final String COLOUR = "colour";
+
+  public static final String FEATURES = "features";
+
+  public static final String GROOVY = "groovy";
+
+  public static final String GROUPS = "groups";
+
+  public static final String HEADLESS = "headless";
+
+  public static final String JABAWS = "jabaws";
+
+  public static final String NOANNOTATION = "no-annotation";
+
+  public static final String NOANNOTATION2 = "noannotation"; // BH 2019.05.07
+
+  public static final String NODISPLAY = "nodisplay";
+
+  public static final String NOGUI = "nogui";
+
+  public static final String NONEWS = "nonews";
+
+  public static final String NOQUESTIONNAIRE = "noquestionnaire";
+
+  public static final String NOSORTBYTREE = "nosortbytree";
+
+  public static final String NOUSAGESTATS = "nousagestats";
+
+  public static final String OPEN = "open";
+
+  public static final String PROPS = "props";
+
+  public static final String QUESTIONNAIRE = "questionnaire";
+
+  public static final String SETPROP = "setprop";
+
+  public static final String SORTBYTREE = "sortbytree";
+
+  public static final String TREE = "tree";
+
+  public static final String VDOC = "vdoc";
+
+  public static final String VSESS = "vsess";
+
+  private Vector<String> vargs = null;
 
   public ArgsParser(String[] args)
   {
-    vargs = new Vector<String>();
+    vargs = new Vector<>();
     for (int i = 0; i < args.length; i++)
     {
       String arg = args[i].trim();
index b6ff253..fe136bc 100755 (executable)
@@ -417,9 +417,9 @@ public class Cache
     }
     if (authorDetails == null)
     {
-        applicationProperties.remove("AUTHORS");
-        applicationProperties.remove("AUTHORFNAMES");
-        applicationProperties.remove("YEAR");
+      applicationProperties.remove("AUTHORS");
+      applicationProperties.remove("AUTHORFNAMES");
+      applicationProperties.remove("YEAR");
     }
 
     // FIND THE VERSION NUMBER AND BUILD DATE FROM jalview.jar
@@ -445,7 +445,7 @@ public class Cache
     }
     if (buildDetails == null)
     {
-        applicationProperties.remove("VERSION");
+      applicationProperties.remove("VERSION");
     }
     String jnlpVersion = System.getProperty("jalview.version");
     String codeVersion = getProperty("VERSION");
@@ -493,9 +493,8 @@ public class Cache
     // "DEFAULT_PDB_FILE_PARSER", DEFAULT_PDB_FILE_PARSER));
     // jnlpVersion will be null if we're using InstallAnywhere
     // Dont do this check if running in headless mode
-    if (jnlpVersion == null && getDefault("VERSION_CHECK", true)
-            && (System.getProperty("java.awt.headless") == null || System
-                    .getProperty("java.awt.headless").equals("false")))
+    if (jnlpVersion == null && !Jalview.isHeadlessMode()
+            && getDefault("VERSION_CHECK", true))
     {
 
       class VersionChecker extends Thread
index 694fe00..fcda026 100755 (executable)
@@ -92,13 +92,58 @@ public class Jalview
     Platform.getURLCommandArguments();
   }
 
-  // singleton instance of this class
+  private boolean headless;
+
+  public static boolean isHeadlessMode()
+  {
+    return getInstance().headless;
+  }
+
+  /**
+   * singleton instance of this class in Java only
+   */
 
   private static Jalview instance;
 
+  public static Jalview getInstance()
+  {
+    Jalview j;
+    @SuppressWarnings("unused")
+    ThreadGroup g = Thread.currentThread().getThreadGroup();
+    /**
+     * @j2sNative j = g._jalviewInstance;
+     */
+    {
+      j = instance;
+    }
+    return j;
+  }
+
+  private static void setInstance(Jalview j)
+  {
+    @SuppressWarnings("unused")
+    ThreadGroup g = Thread.currentThread().getThreadGroup();
+    /**
+     * @j2s g._jalviewInstance = j;
+     */
+    {
+      instance = j;
+    }
+  }
+
   private Desktop desktop;
 
-  public static AlignFrame currentAlignFrame;
+  private AlignFrame currentAlignFrame;
+
+  public static AlignFrame getCurrentAlignFrame()
+  {
+    return getInstance().currentAlignFrame;
+  }
+
+  public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
+  {
+    getInstance().currentAlignFrame = currentAlignFrame;
+  }
 
   static
   {
@@ -110,21 +155,21 @@ public class Jalview
      */
     {
       // grab all the rights we can for the JVM
-           Policy.setPolicy(new Policy()
-           {
-             @Override
-             public PermissionCollection getPermissions(CodeSource codesource)
-             {
-               Permissions perms = new Permissions();
-               perms.add(new AllPermission());
-               return (perms);
-             }
-       
-             @Override
-             public void refresh()
-             {
-             }
-           });
+      Policy.setPolicy(new Policy()
+      {
+        @Override
+        public PermissionCollection getPermissions(CodeSource codesource)
+        {
+          Permissions perms = new Permissions();
+          perms.add(new AllPermission());
+          return (perms);
+        }
+
+        @Override
+        public void refresh()
+        {
+        }
+      });
     }
   }
 
@@ -187,11 +232,6 @@ public class Jalview
 
   }
 
-  public static Jalview getInstance()
-  {
-    return instance;
-  }
-
   /**
    * main class for Jalview application
    * 
@@ -200,23 +240,23 @@ public class Jalview
    */
   public static void main(String[] args)
   {
-//     setLogging(); // BH - for event debugging in JavaScript
-    instance = new Jalview();
-    instance.doMain(args);
-}
+    // setLogging(); // BH - for event debugging in JavaScript
+    setInstance(new Jalview());
+    getInstance().doMain(args);
+  }
 
-  private static void logClass(String name) 
-  {    
-         // BH - for event debugging in JavaScript
-      ConsoleHandler consoleHandler = new ConsoleHandler();
-      consoleHandler.setLevel(Level.ALL);
-      Logger logger = Logger.getLogger(name);
-      logger.setLevel(Level.ALL);
-      logger.addHandler(consoleHandler);
+  private static void logClass(String name)
+  {
+    // BH - for event debugging in JavaScript
+    ConsoleHandler consoleHandler = new ConsoleHandler();
+    consoleHandler.setLevel(Level.ALL);
+    Logger logger = Logger.getLogger(name);
+    logger.setLevel(Level.ALL);
+    logger.addHandler(consoleHandler);
   }
 
   @SuppressWarnings("unused")
-  private static void setLogging() 
+  private static void setLogging()
   {
 
     /**
@@ -227,26 +267,23 @@ public class Jalview
       System.out.println("not in js");
     }
 
-         // BH - for event debugging in JavaScript (Java mode only)
+    // BH - for event debugging in JavaScript (Java mode only)
     if (!Platform.isJS())
     /**
      * Java only
      * 
      * @j2sIgnore
      */
-       {
-               Logger.getLogger("").setLevel(Level.ALL);
-        logClass("java.awt.EventDispatchThread");
-        logClass("java.awt.EventQueue");
-        logClass("java.awt.Component");
-        logClass("java.awt.focus.Component");
-        logClass("java.awt.focus.DefaultKeyboardFocusManager"); 
-       }       
+    {
+      Logger.getLogger("").setLevel(Level.ALL);
+      logClass("java.awt.EventDispatchThread");
+      logClass("java.awt.EventQueue");
+      logClass("java.awt.Component");
+      logClass("java.awt.focus.Component");
+      logClass("java.awt.focus.DefaultKeyboardFocusManager");
+    }
 
   }
-  
-
-  
 
   /**
    * @param args
@@ -266,10 +303,9 @@ public class Jalview
             + System.getProperty("os.version"));
 
     ArgsParser aparser = new ArgsParser(args);
-    boolean headless = false;
 
-    String usrPropsFile = aparser.getValue("props");
-    Cache.loadProperties(usrPropsFile); // must do this before
+    String usrPropsFile = aparser.getValue(ArgsParser.PROPS);
+    Cache.loadProperties(usrPropsFile);
     if (usrPropsFile != null)
     {
       System.out.println(
@@ -288,15 +324,17 @@ public class Jalview
         showUsage();
         System.exit(0);
       }
-      if (aparser.contains("nodisplay") || aparser.contains("nogui")
-              || aparser.contains("headless"))
+      if (aparser.contains(ArgsParser.NODISPLAY)
+              || aparser.contains(ArgsParser.NOGUI)
+              || aparser.contains(ArgsParser.HEADLESS)
+              || "true".equals(System.getProperty("java.awt.headless")))
       {
-        System.setProperty("java.awt.headless", "true");
         headless = true;
       }
+
       // anything else!
 
-      final String jabawsUrl = aparser.getValue("jabaws");
+      final String jabawsUrl = aparser.getValue(ArgsParser.JABAWS);
       if (jabawsUrl != null)
       {
         try
@@ -312,7 +350,8 @@ public class Jalview
       }
 
     }
-    String defs = aparser.getValue("setprop");
+    // check for property setting
+    String defs = aparser.getValue(ArgsParser.SETPROP);
     while (defs != null)
     {
       int p = defs.indexOf('=');
@@ -325,15 +364,10 @@ public class Jalview
         System.out.println("Executing setprop argument: " + defs);
         if (Platform.isJS())
         {
-          Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
+          Cache.setProperty(defs.substring(0, p), defs.substring(p + 1));
         }
       }
-      defs = aparser.getValue("setprop");
-    }
-    if (System.getProperty("java.awt.headless") != null
-            && System.getProperty("java.awt.headless").equals("true"))
-    {
-      headless = true;
+      defs = aparser.getValue(ArgsParser.SETPROP);
     }
     System.setProperty("http.agent",
             "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
@@ -377,8 +411,9 @@ public class Jalview
                   "Failed to set QuaQua look and feel: " + e.toString());
         }
       }
-      if (lookAndFeel == null || !(lookAndFeel.getClass()
-              .isAssignableFrom(UIManager.getLookAndFeel().getClass()))
+      if (lookAndFeel == null
+              || !(lookAndFeel.getClass().isAssignableFrom(
+                      UIManager.getLookAndFeel().getClass()))
               || !UIManager.getLookAndFeel().getClass().toString()
                       .toLowerCase().contains("quaqua"))
       {
@@ -406,16 +441,7 @@ public class Jalview
 
     if (!headless)
     {
-      desktop = new Desktop() 
-//      {
-// // BH testing
-//       @Override
-//       protected void processEvent(AWTEvent e) {
-//               System.out.println("Jalview.java " + e);
-//               super.processEvent(e);
-//       }
-//       }
-      ;
+      desktop = new Desktop();
       desktop.setInBatchMode(true); // indicate we are starting up
       desktop.setVisible(true);
 
@@ -427,7 +453,7 @@ public class Jalview
        */
       {
         desktop.startServiceDiscovery();
-        if (!aparser.contains("nousagestats"))
+        if (!aparser.contains(ArgsParser.NOUSAGESTATS))
         {
           startUsageStats(desktop);
         }
@@ -436,9 +462,9 @@ public class Jalview
           System.err.println("CMD [-nousagestats] executed successfully!");
         }
 
-        if (!aparser.contains("noquestionnaire"))
+        if (!aparser.contains(ArgsParser.NOQUESTIONNAIRE))
         {
-          String url = aparser.getValue("questionnaire");
+          String url = aparser.getValue(ArgsParser.QUESTIONNAIRE);
           if (url != null)
           {
             // Start the desktop questionnaire prompter with the specified
@@ -470,7 +496,7 @@ public class Jalview
                   .println("CMD [-noquestionnaire] executed successfully!");
         }
 
-        if (!aparser.contains("nonews"))
+        if (!aparser.contains(ArgsParser.NONEWS))
         {
           desktop.checkForNews();
         }
@@ -479,24 +505,24 @@ public class Jalview
       }
     }
 
-    String file = null, data = null;
+    String data = null;
     FileFormatI format = null;
     DataSourceType protocol = null;
     FileLoader fileLoader = new FileLoader(!headless);
 
-    String groovyscript = null; // script to execute after all loading is
+    // script to execute after all loading is
     // completed one way or another
     // extract groovy argument and execute if necessary
-    groovyscript = aparser.getValue("groovy", true);
-    file = aparser.getValue("open", true);
+    String groovyscript = aparser.getValue(ArgsParser.GROOVY, true);
+    String file = aparser.getValue(ArgsParser.OPEN, true);
 
     if (file == null && desktop == null)
     {
       System.out.println("No files to open!");
       System.exit(1);
     }
-    String vamsasImport = aparser.getValue("vdoc");
-    String vamsasSession = aparser.getValue("vsess");
+    String vamsasImport = aparser.getValue(ArgsParser.VDOC);
+    String vamsasSession = aparser.getValue(ArgsParser.VSESS);
     if (vamsasImport != null || vamsasSession != null)
     {
       if (desktop == null || headless)
@@ -594,11 +620,12 @@ public class Jalview
       System.out.println("CMD [-open " + file + "] executed successfully!");
 
       if (!Platform.isJS())
-        /**
-         * ignore in JavaScript -- can't just file existence - could load it?
-         * 
-         * @j2sIgnore
-         */
+      /**
+       * ignore in JavaScript -- can't just check file existence - could load
+       * it?
+       * 
+       * @j2sIgnore
+       */
       {
         if (!file.startsWith("http://") && !file.startsWith("https://"))
         // BH 2019 added https check for Java
@@ -614,7 +641,7 @@ public class Jalview
         }
       }
 
-        protocol = AppletFormatAdapter.checkProtocol(file);
+      protocol = AppletFormatAdapter.checkProtocol(file);
 
       try
       {
@@ -633,14 +660,13 @@ public class Jalview
       else
       {
         setCurrentAlignFrame(af);
-        data = aparser.getValue("colour", true);
+        data = aparser.getValue(ArgsParser.COLOUR, true);
         if (data != null)
         {
           data.replaceAll("%20", " ");
 
-          ColourSchemeI cs = ColourSchemeProperty
-                  .getColourScheme(af.getViewport(),
-                          af.getViewport().getAlignment(), data);
+          ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
+                  af.getViewport(), af.getViewport().getAlignment(), data);
 
           if (cs != null)
           {
@@ -651,7 +677,7 @@ public class Jalview
         }
 
         // Must maintain ability to use the groups flag
-        data = aparser.getValue("groups", true);
+        data = aparser.getValue(ArgsParser.GROUPS, true);
         if (data != null)
         {
           af.parseFeaturesFile(data,
@@ -660,7 +686,7 @@ public class Jalview
           System.out.println(
                   "CMD groups[-" + data + "]  executed successfully!");
         }
-        data = aparser.getValue("features", true);
+        data = aparser.getValue(ArgsParser.FEATURES, true);
         if (data != null)
         {
           af.parseFeaturesFile(data,
@@ -670,7 +696,7 @@ public class Jalview
                   "CMD [-features " + data + "]  executed successfully!");
         }
 
-        data = aparser.getValue("annotations", true);
+        data = aparser.getValue(ArgsParser.ANNOTATIONS, true);
         if (data != null)
         {
           af.loadJalviewDataFile(data, null, null, null);
@@ -679,7 +705,7 @@ public class Jalview
                   "CMD [-annotations " + data + "] executed successfully!");
         }
         // set or clear the sortbytree flag.
-        if (aparser.contains("sortbytree"))
+        if (aparser.contains(ArgsParser.SORTBYTREE))
         {
           af.getViewport().setSortByTree(true);
           if (af.getViewport().getSortByTree())
@@ -687,7 +713,8 @@ public class Jalview
             System.out.println("CMD [-sortbytree] executed successfully!");
           }
         }
-        if (aparser.contains("no-annotation"))
+        if (aparser.contains(ArgsParser.NOANNOTATION)
+                || aparser.contains(ArgsParser.NOANNOTATION2))
         {
           af.getViewport().setShowAnnotation(false);
           if (!af.getViewport().isShowAnnotation())
@@ -695,7 +722,7 @@ public class Jalview
             System.out.println("CMD no-annotation executed successfully!");
           }
         }
-        if (aparser.contains("nosortbytree"))
+        if (aparser.contains(ArgsParser.NOSORTBYTREE))
         {
           af.getViewport().setSortByTree(false);
           if (!af.getViewport().getSortByTree())
@@ -704,7 +731,7 @@ public class Jalview
                     .println("CMD [-nosortbytree] executed successfully!");
           }
         }
-        data = aparser.getValue("tree", true);
+        data = aparser.getValue(ArgsParser.TREE, true);
         if (data != null)
         {
           try
@@ -737,6 +764,10 @@ public class Jalview
         String imageName = "unnamed.png";
         while (aparser.getSize() > 1)
         {
+          // PNG filename
+          // SVG filename
+          // HTML filename
+          // biojsmsa filename
           String outputFormat = aparser.nextValue();
           file = aparser.nextValue();
 
@@ -951,8 +982,9 @@ public class Jalview
     /**
      * start a User Config prompt asking if we can log usage statistics.
      */
-    PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
-            "USAGESTATS", "Jalview Usage Statistics",
+    PromptUserConfig prompter = new PromptUserConfig(
+            Desktop.getDesktopPane(), "USAGESTATS",
+            "Jalview Usage Statistics",
             "Do you want to help make Jalview better by enabling "
                     + "the collection of usage statistics with Google Analytics ?"
                     + "\n\n(you can enable or disable usage tracking in the preferences)",
@@ -1095,16 +1127,6 @@ public class Jalview
     }
   }
 
-  public static boolean isHeadlessMode()
-  {
-    String isheadless = System.getProperty("java.awt.headless");
-    if (isheadless != null && isheadless.equalsIgnoreCase("true"))
-    {
-      return true;
-    }
-    return false;
-  }
-
   public AlignFrame[] getAlignFrames()
   {
     return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
@@ -1128,13 +1150,4 @@ public class Jalview
     }
   }
 
-  public static AlignFrame getCurrentAlignFrame()
-  {
-    return Jalview.currentAlignFrame;
-  }
-
-  public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
-  {
-    Jalview.currentAlignFrame = currentAlignFrame;
-  }
 }
index 70601c9..3a8fb7c 100644 (file)
@@ -96,7 +96,7 @@ public class AlignExportOptions extends JPanel
     this.settings = defaults;
     this.isComplexAlignFile = format.isComplexAlignFile();
     init(viewport.hasHiddenRows(), viewport.hasHiddenColumns());
-    dialog = JvOptionPane.newOptionDialog(Desktop.desktop);
+    dialog = JvOptionPane.newOptionDialog(Desktop.getDesktopPane());
   }
 
   /**
index 27a0f76..594319f 100644 (file)
@@ -392,7 +392,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     });
     buildColourMenu();
 
-    if (Desktop.desktop != null)
+    if (Desktop.getDesktopPane() != null)
     {
       this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
       if (!Platform.isJS())
@@ -815,7 +815,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   private void addServiceListeners()
   {
     final java.beans.PropertyChangeListener thisListener;
-    Desktop.instance.addJalviewPropertyChangeListener("services",
+    Desktop.getInstance().addJalviewPropertyChangeListener("services",
             thisListener = new java.beans.PropertyChangeListener()
             {
               @Override
@@ -846,7 +846,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               javax.swing.event.InternalFrameEvent evt)
       {
         // System.out.println("deregistering discoverer listener");
-        Desktop.instance.removeJalviewPropertyChangeListener("services",
+        Desktop.getInstance().removeJalviewPropertyChangeListener("services",
                 thisListener);
         closeMenuItem_actionPerformed(true);
       }
@@ -1027,7 +1027,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   public void addFromFile_actionPerformed(ActionEvent e)
   {
-    Desktop.instance.inputLocalFileMenuItem_actionPerformed(viewport);
+    Desktop.getInstance().inputLocalFileMenuItem_actionPerformed(viewport);
   }
 
   @Override
@@ -1041,7 +1041,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       // file is reloaded.
       if (FileFormat.Jalview.equals(currentFileFormat))
       {
-        JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+        JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
         for (int i = 0; i < frames.length; i++)
         {
           if (frames[i] instanceof AlignFrame && frames[i] != this
@@ -1051,14 +1051,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             try
             {
               frames[i].setSelected(true);
-              Desktop.instance.closeAssociatedWindows();
+              Desktop.getInstance().closeAssociatedWindows();
             } catch (java.beans.PropertyVetoException ex)
             {
             }
           }
 
         }
-        Desktop.instance.closeAssociatedWindows();
+        Desktop.getInstance().closeAssociatedWindows();
 
         FileLoader loader = new FileLoader();
         DataSourceType protocol = fileName.startsWith("http:")
@@ -1116,14 +1116,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   public void addFromText_actionPerformed(ActionEvent e)
   {
-    Desktop.instance
+    Desktop.getInstance()
             .inputTextboxMenuItem_actionPerformed(viewport.getAlignPanel());
   }
 
   @Override
   public void addFromURL_actionPerformed(ActionEvent e)
   {
-    Desktop.instance.inputURLMenuItem_actionPerformed(viewport);
+    Desktop.getInstance().inputURLMenuItem_actionPerformed(viewport);
   }
 
   @Override
@@ -1167,7 +1167,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     // todo is this (2005) test now obsolete - value is never null?
     while (currentFileFormat == null)
     {
-      JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+      JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
               MessageManager
                       .getString("label.select_file_format_before_saving"),
               MessageManager.getString("label.file_format_not_specified"),
@@ -1939,7 +1939,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               .setContents(new StringSelection(""), null);
 
       Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,
-              Desktop.instance);
+              Desktop.getInstance());
     } catch (OutOfMemoryError er)
     {
       new OOMWarning("copying region", er);
@@ -2439,7 +2439,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             + 1) == viewport.getAlignment().getWidth()) ? true : false;
        if (wholeHeight && wholeWidth)
        {
-           JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop);
+           JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.getDesktopPane());
                dialog.setResponseHandler(0, okAction); // 0 = OK_OPTION
            Object[] options = new Object[] { MessageManager.getString("action.ok"),
                    MessageManager.getString("action.cancel") };
@@ -2913,7 +2913,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   public void gatherViews_actionPerformed(ActionEvent e)
   {
-    Desktop.instance.gatherViews(this);
+    Desktop.getInstance().gatherViews(this);
   }
 
   /**
@@ -3690,7 +3690,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       {
         if (_s.getLength() < sg.getEndRes())
         {
-          JvOptionPane.showMessageDialog(Desktop.desktop,
+          JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
                   MessageManager.getString(
                           "label.selected_region_to_tree_may_only_contain_residues_or_gaps"),
                   MessageManager.getString(
@@ -4012,7 +4012,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           viewport.setCurrentTree(showNewickTree(fin, filePath).getTree());
         } catch (Exception ex)
         {
-          JvOptionPane.showMessageDialog(Desktop.desktop, ex.getMessage(),
+          JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), ex.getMessage(),
                   MessageManager
                           .getString("label.problem_reading_tree_file"),
                   JvOptionPane.WARNING_MESSAGE);
@@ -4020,7 +4020,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         }
         if (fin != null && fin.hasWarningMessage())
         {
-          JvOptionPane.showMessageDialog(Desktop.desktop,
+          JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
                   fin.getWarningMessage(),
                   MessageManager.getString(
                           "label.possible_problem_with_tree_file"),
@@ -4400,7 +4400,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       final String errorTitle = MessageManager
               .getString("label.implementation_error")
               + MessageManager.getString("label.translation_failed");
-      JvOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), msg, errorTitle,
               JvOptionPane.ERROR_MESSAGE);
       return;
     }
@@ -4410,7 +4410,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               "label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation");
       final String errorTitle = MessageManager
               .getString("label.translation_failed");
-      JvOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), msg, errorTitle,
               JvOptionPane.WARNING_MESSAGE);
     }
     else
@@ -4626,7 +4626,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                     PDBEntry pe = new AssociatePdbFileWithSeq()
                             .associatePdbWithSeq(fm[0].toString(),
                                     (DataSourceType) fm[1], toassoc, false,
-                                    Desktop.instance);
+                                    Desktop.getInstance());
                     if (pe != null)
                     {
                       System.err.println("Associated file : "
@@ -4737,7 +4737,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             {
               // some problem - if no warning its probable that the ID matching
               // process didn't work
-              JvOptionPane.showMessageDialog(Desktop.desktop,
+              JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
                       tcf.getWarningMessage() == null
                               ? MessageManager.getString(
                                       "label.check_file_matches_sequence_ids_alignment")
@@ -4830,7 +4830,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                       + (format != null
                               ? "(parsing as '" + format + "' file)"
                               : ""),
-              oom, Desktop.desktop);
+              oom, Desktop.getDesktopPane());
     }
   }
 
@@ -5639,7 +5639,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       } catch (Exception ex)
       {
         System.err.println((ex.toString()));
-        JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+        JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
                 MessageManager.getString("label.couldnt_run_groovy_script"),
                 MessageManager.getString("label.groovy_support_failed"),
                 JvOptionPane.ERROR_MESSAGE);
index 7d01222..5f56fd9 100644 (file)
@@ -384,7 +384,7 @@ public class AlignViewport extends AlignmentViewport
     if (align != null)
     {
       StructureSelectionManager ssm = StructureSelectionManager
-              .getStructureSelectionManager(Desktop.instance);
+              .getStructureSelectionManager(Desktop.getInstance());
       ssm.registerMappings(align.getCodonFrames());
     }
 
@@ -406,7 +406,7 @@ public class AlignViewport extends AlignmentViewport
       if (mappings != null)
       {
         StructureSelectionManager ssm = StructureSelectionManager
-                .getStructureSelectionManager(Desktop.instance);
+                .getStructureSelectionManager(Desktop.getInstance());
         for (AlignedCodonFrame acf : mappings)
         {
           if (noReferencesTo(acf))
@@ -532,7 +532,7 @@ public class AlignViewport extends AlignmentViewport
   public void sendSelection()
   {
     jalview.structure.StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance)
+            .getStructureSelectionManager(Desktop.getInstance())
             .sendSelection(new SequenceGroup(getSelectionGroup()),
                     new ColumnSelection(getColumnSelection()),
                     new HiddenColumns(getAlignment().getHiddenColumns()),
@@ -578,7 +578,7 @@ public class AlignViewport extends AlignmentViewport
   public StructureSelectionManager getStructureSelectionManager()
   {
     return StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance);
+            .getStructureSelectionManager(Desktop.getInstance());
   }
 
   @Override
@@ -770,7 +770,7 @@ public class AlignViewport extends AlignmentViewport
      * dialog responses 0, 1, 2 (even though JOptionPane shows them
      * in reverse order)
      */
-    JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop)
+    JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.getDesktopPane())
             .setResponseHandler(0, new Runnable()
             {
               @Override
index 9cb690f..20d06e9 100644 (file)
@@ -1376,8 +1376,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
   {
     int seqPanelWidth = getSeqPanel().seqCanvas.getWidth();
 
-    if (System.getProperty("java.awt.headless") != null
-            && System.getProperty("java.awt.headless").equals("true"))
+    if (Jalview.isHeadlessMode())
     {
       seqPanelWidth = alignFrame.getWidth() - getVisibleIdWidth()
               - vscroll.getPreferredSize().width
index e89c1c2..bd05be1 100644 (file)
@@ -301,7 +301,7 @@ public class AnnotationColourChooser extends AnnotationRowFilter
         updateView();
       }
     };
-    JalviewColourChooser.showColourChooser(Desktop.getDesktop(), ttl,
+    JalviewColourChooser.showColourChooser(Desktop.getDesktopPane(), ttl,
             colourPanel.getBackground(), listener);
   }
 
index a0a0df8..399f70f 100755 (executable)
@@ -971,7 +971,7 @@ public class AnnotationLabels extends JPanel
             seqs, omitHidden, alignmentStartEnd);
 
     Toolkit.getDefaultToolkit().getSystemClipboard()
-            .setContents(new StringSelection(output), Desktop.instance);
+            .setContents(new StringSelection(output), Desktop.getInstance());
 
     HiddenColumns hiddenColumns = null;
 
index 7179a18..b88ac35 100644 (file)
@@ -546,7 +546,7 @@ public class AppJmol extends StructureViewerBase
     }
     if (errormsgs.length() > 0)
     {
-      JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+      JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
               MessageManager.formatMessage(
                       "label.pdb_entries_couldnt_be_retrieved", new String[]
                       { errormsgs.toString() }),
index fe0aedf..154582f 100644 (file)
@@ -65,7 +65,7 @@ public class AssociatePdbFileWithSeq
 
       if (prompt)
       {
-        reply = JvOptionPane.showInternalInputDialog(Desktop.desktop,
+        reply = JvOptionPane.showInternalInputDialog(Desktop.getDesktopPane(),
                 MessageManager
                         .getString("label.couldnt_find_pdb_id_in_file"),
                 MessageManager.getString("label.no_pdb_id_in_file"),
index 097a5a0..093eb48 100644 (file)
@@ -545,7 +545,7 @@ public class CalculationChooser extends JPanel
     SequenceGroup sg = viewport.getSelectionGroup();
     if (sg != null && sg.getSize() < MIN_TREE_SELECTION)
     {
-      JvOptionPane.showMessageDialog(Desktop.desktop,
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
               MessageManager.formatMessage(
                       "label.you_need_at_least_n_sequences",
                       MIN_TREE_SELECTION),
index 9167c00..fff1eed 100644 (file)
@@ -336,7 +336,7 @@ public class ChimeraViewFrame extends StructureViewerBase
 
     if (!jmb.launchChimera())
     {
-      JvOptionPane.showMessageDialog(Desktop.desktop,
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
               MessageManager.getString("label.chimera_failed"),
               MessageManager.getString("label.error_loading_file"),
               JvOptionPane.ERROR_MESSAGE);
@@ -497,7 +497,7 @@ public class ChimeraViewFrame extends StructureViewerBase
     if (errormsgs.length() > 0)
     {
 
-      JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+      JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
               MessageManager.formatMessage(
                       "label.pdb_entries_couldnt_be_retrieved", new Object[]
                       { errormsgs.toString() }),
index 6eab07d..6d0d0c9 100644 (file)
@@ -158,7 +158,7 @@ public class ColourMenuHelper
             ActionListener al = radioItem.getActionListeners()[0];
             radioItem.removeActionListener(al);
             int option = JvOptionPane.showInternalConfirmDialog(
-                    Desktop.desktop,
+                    Desktop.getDesktopPane(),
                     MessageManager
                             .getString("label.remove_from_default_list"),
                     MessageManager
index b5275e8..1feb15a 100644 (file)
@@ -437,7 +437,7 @@ public class CrossRefAction implements Runnable
             .setGapCharacter(alignFrame.viewport.getGapCharacter());
 
     StructureSelectionManager ssm = StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance);
+            .getStructureSelectionManager(Desktop.getInstance());
 
     /*
      * register any new mappings for sequence mouseover etc
index d328a0d..4badcba 100644 (file)
@@ -234,7 +234,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
               .println(MessageManager.getString("label.couldnt_read_data"));
       if (!Jalview.isHeadlessMode())
       {
-        JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+        JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
                 AppletFormatAdapter.getSupportedFormats(),
                 MessageManager.getString("label.couldnt_read_data"),
                 JvOptionPane.WARNING_MESSAGE);
@@ -253,7 +253,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
 
     } catch (IOException ex)
     {
-      JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
+      JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(), MessageManager
               .formatMessage("label.couldnt_read_pasted_text", new String[]
               { ex.toString() }),
               MessageManager.getString("label.error_parsing_text"),
@@ -342,7 +342,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
               .println(MessageManager.getString("label.couldnt_read_data"));
       if (!Jalview.isHeadlessMode())
       {
-        JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+        JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
                 AppletFormatAdapter.getSupportedFormats(),
                 MessageManager.getString("label.couldnt_read_data"),
                 JvOptionPane.WARNING_MESSAGE);
index cd8330a..d2967d7 100644 (file)
@@ -20,8 +20,6 @@
  */
 package jalview.gui;
 
-import static jalview.util.UrlConstants.SEQUENCE_ID;
-
 import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 import jalview.bin.Cache;
@@ -134,26 +132,27 @@ import org.stackoverflowusers.file.WindowsShortcut;
  * @author $author$
  * @version $Revision: 1.155 $
  */
+@SuppressWarnings("serial")
 public class Desktop extends jalview.jbgui.GDesktop
         implements DropTargetListener, ClipboardOwner, IProgressIndicator,
         jalview.api.StructureSelectionManagerProvider
 {
-  private static int DEFAULT_MIN_WIDTH = 300;
+  private final static int DEFAULT_MIN_WIDTH = 300;
 
-  private static int DEFAULT_MIN_HEIGHT = 250;
+  private final static int DEFAULT_MIN_HEIGHT = 250;
 
-  private static int ALIGN_FRAME_DEFAULT_MIN_WIDTH = 600;
+  private final static int ALIGN_FRAME_DEFAULT_MIN_WIDTH = 600;
 
-  private static int ALIGN_FRAME_DEFAULT_MIN_HEIGHT = 70;
+  private final static int ALIGN_FRAME_DEFAULT_MIN_HEIGHT = 70;
 
-  private static final String EXPERIMENTAL_FEATURES = "EXPERIMENTAL_FEATURES";
+  private final static String EXPERIMENTAL_FEATURES = "EXPERIMENTAL_FEATURES";
 
   private JalviewChangeSupport changeSupport = new JalviewChangeSupport();
 
   /**
    * news reader - null if it was never started.
    */
-  private BlogReader jvnews = null;
+  BlogReader jvnews = null;
 
   private File projectFile;
 
@@ -192,16 +191,47 @@ public class Desktop extends jalview.jbgui.GDesktop
             listener);
   }
 
-  /** Singleton Desktop instance */
-  public static Desktop instance;
+  /**
+   * Singleton Desktop instance only in Java;
+   */
+  private static Desktop instance;
 
-  public static MyDesktopPane desktop;
+  public static Desktop getInstance()
+  {
+    Desktop d;
+    @SuppressWarnings("unused")
+    ThreadGroup g = Thread.currentThread().getThreadGroup();
+    /**
+     * @j2sNative d = g._jalviewDesktopInstance;
+     */
+    {
+      d = instance;
+    }
+    return d;
+  }
 
-  public static MyDesktopPane getDesktop()
+  private static void setInstance(Desktop d)
   {
-    // BH 2018 could use currentThread() here as a reference to a
-    // Hashtable<Thread, MyDesktopPane> in JavaScript
-    return desktop;
+    @SuppressWarnings("unused")
+    ThreadGroup g = Thread.currentThread().getThreadGroup();
+    /**
+     * @j2s g._jalviewDesktopInstance = d;
+     */
+    {
+      instance = d;
+    }
+  }
+
+  private MyDesktopPane desktopPane;
+
+  public static MyDesktopPane getDesktopPane()
+  {
+    return getInstance().desktopPane;
+  }
+
+  private void setDesktopPane(MyDesktopPane pane)
+  {
+    getInstance().desktopPane = pane;
   }
 
   static int openFrameCount = 0;
@@ -237,7 +267,7 @@ public class Desktop extends jalview.jbgui.GDesktop
       } catch (NullPointerException npe)
       {
         Point p = getMousePosition();
-        instance.showPasteMenu(p.x, p.y);
+        getInstance().showPasteMenu(p.x, p.y);
       }
     }
 
@@ -285,14 +315,14 @@ public class Desktop extends jalview.jbgui.GDesktop
     public void endDraggingFrame(JComponent f)
     {
       delegate.endDraggingFrame(f);
-      desktop.repaint();
+      getDesktopPane().repaint();
     }
 
     @Override
     public void endResizingFrame(JComponent f)
     {
       delegate.endResizingFrame(f);
-      desktop.repaint();
+      getDesktopPane().repaint();
     }
 
     @Override
@@ -352,7 +382,7 @@ public class Desktop extends jalview.jbgui.GDesktop
      * block are spawned off as threads rather than waited for during this
      * constructor.
      */
-    instance = this;
+    setInstance(this);
     if (!Platform.isJS())
     {
       doVamsasClientCheck();
@@ -365,10 +395,10 @@ public class Desktop extends jalview.jbgui.GDesktop
             false);
     boolean showjconsole = jalview.bin.Cache.getDefault("SHOW_JAVA_CONSOLE",
             false);
-    desktop = new MyDesktopPane(selmemusage);
+    setDesktopPane(new MyDesktopPane(selmemusage));
 
     showMemusage.setSelected(selmemusage);
-    desktop.setBackground(Color.white);
+    getDesktopPane().setBackground(Color.white);
     getContentPane().setLayout(new BorderLayout());
     // alternate config - have scrollbars - see notes in JAL-153
     // JScrollPane sp = new JScrollPane();
@@ -381,17 +411,17 @@ public class Desktop extends jalview.jbgui.GDesktop
       getRootPane().putClientProperty("swingjs.overflow.hidden", "false");
     }
 
-    getContentPane().add(desktop, BorderLayout.CENTER);
-    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
+    getContentPane().add(getDesktopPane(), BorderLayout.CENTER);
+    getDesktopPane().setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
 
     // This line prevents Windows Look&Feel resizing all new windows to maximum
     // if previous window was maximised
-    desktop.setDesktopManager(new MyDesktopManager(
+    getDesktopPane().setDesktopManager(new MyDesktopManager(
             (Platform.isWindowsAndNotJS() ? new DefaultDesktopManager()
                     : Platform.isAMacAndNotJS()
                             ? new AquaInternalFrameManager(
-                                    desktop.getDesktopManager())
-                            : desktop.getDesktopManager())));
+                                    getDesktopPane().getDesktopManager())
+                            : getDesktopPane().getDesktopManager())));
 
     Rectangle dims = getLastKnownDimensions("");
     if (dims != null)
@@ -480,7 +510,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 
     }
 
-    this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this));
+    this.setDropTarget(new java.awt.dnd.DropTarget(getDesktopPane(), this));
 
     this.addWindowListener(new WindowAdapter()
     {
@@ -512,7 +542,7 @@ public class Desktop extends jalview.jbgui.GDesktop
         }
       }
     });
-    desktop.addMouseListener(ma);
+    getDesktopPane().addMouseListener(ma);
 
   }
 
@@ -577,10 +607,10 @@ public class Desktop extends jalview.jbgui.GDesktop
       public void run()
       {
         Cache.log.debug("Downloading data from identifiers.org");
-        UrlDownloadClient client = new UrlDownloadClient();
+        // UrlDownloadClient client = new UrlDownloadClient();
         try
         {
-          client.download(IdOrgSettings.getUrl(),
+          UrlDownloadClient.download(IdOrgSettings.getUrl(),
                   IdOrgSettings.getDownloadLocation());
         } catch (IOException e)
         {
@@ -598,7 +628,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     showNews(showNews.isSelected());
   }
 
-  void showNews(boolean visible)
+  protected void showNews(boolean visible)
   {
     Cache.log.debug((visible ? "Showing" : "Hiding") + " news.");
     showNews.setSelected(visible);
@@ -610,10 +640,10 @@ public class Desktop extends jalview.jbgui.GDesktop
         public void run()
         {
           long now = System.currentTimeMillis();
-          Desktop.instance.setProgressBar(
+          Desktop.getInstance().setProgressBar(
                   MessageManager.getString("status.refreshing_news"), now);
           jvnews.refreshNews();
-          Desktop.instance.setProgressBar(null, now);
+          Desktop.getInstance().setProgressBar(null, now);
           jvnews.showNews();
         }
       }).start();
@@ -718,7 +748,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     }
   }
 
-  void showPasteMenu(int x, int y)
+  protected void showPasteMenu(int x, int y)
   {
     JPopupMenu popup = new JPopupMenu();
     JMenuItem item = new JMenuItem(
@@ -860,8 +890,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     // A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN
     // IF JALVIEW IS RUNNING HEADLESS
     // ///////////////////////////////////////////////
-    if (instance == null || (System.getProperty("java.awt.headless") != null
-            && System.getProperty("java.awt.headless").equals("true")))
+    if (instance == null || Jalview.isHeadlessMode())
     {
       return;
     }
@@ -901,13 +930,13 @@ public class Desktop extends jalview.jbgui.GDesktop
      * add an entry for the new frame in the Window menu 
      * (and remove it when the frame is closed)
      */
-    final JMenuItem menuItem = new JMenuItem(title);
+    JMenuItem menuItem = new JMenuItem(title);
     frame.addInternalFrameListener(new InternalFrameAdapter()
     {
       @Override
       public void internalFrameActivated(InternalFrameEvent evt)
       {
-        JInternalFrame itf = desktop.getSelectedFrame();
+        JInternalFrame itf = getDesktopPane().getSelectedFrame();
         if (itf != null)
         {
           if (itf instanceof AlignFrame)
@@ -939,7 +968,7 @@ public class Desktop extends jalview.jbgui.GDesktop
         {
           menuItem.removeActionListener(menuItem.getActionListeners()[0]);
         }
-        windowMenu.remove(menuItem);
+        getInstance().windowMenu.remove(menuItem);
       };
     });
 
@@ -961,9 +990,9 @@ public class Desktop extends jalview.jbgui.GDesktop
 
     setKeyBindings(frame);
 
-    desktop.add(frame);
+    getDesktopPane().add(frame);
 
-    windowMenu.add(menuItem);
+    getInstance().windowMenu.add(menuItem);
 
     frame.toFront();
     try
@@ -988,7 +1017,6 @@ public class Desktop extends jalview.jbgui.GDesktop
    */
   private static void setKeyBindings(JInternalFrame frame)
   {
-    @SuppressWarnings("serial")
     final Action closeAction = new AbstractAction()
     {
       @Override
@@ -1256,7 +1284,8 @@ public class Desktop extends jalview.jbgui.GDesktop
           {
             String msg = MessageManager
                     .formatMessage("label.couldnt_locate", url);
-            JvOptionPane.showInternalMessageDialog(Desktop.desktop, msg,
+            JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
+                    msg,
                     MessageManager.getString("label.url_not_found"),
                     JvOptionPane.WARNING_MESSAGE);
 
@@ -1277,7 +1306,8 @@ public class Desktop extends jalview.jbgui.GDesktop
     };
     String dialogOption = MessageManager
             .getString("label.input_alignment_from_url");
-    JvOptionPane.newOptionDialog(desktop).setResponseHandler(0, action)
+    JvOptionPane.newOptionDialog(getDesktopPane())
+            .setResponseHandler(0, action)
             .showInternalDialog(panel, dialogOption,
                     JvOptionPane.YES_NO_CANCEL_OPTION,
                     JvOptionPane.PLAIN_MESSAGE, null, options,
@@ -1363,7 +1393,7 @@ public class Desktop extends jalview.jbgui.GDesktop
   public void aboutMenuItem_actionPerformed(ActionEvent e)
   {
     // StringBuffer message = getAboutMessage(false);
-    // JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+    // JvOptionPane.showInternalMessageDialog(Desktop.getDesktop(),
     //
     // message.toString(), "About Jalview", JvOptionPane.INFORMATION_MESSAGE);
     new Thread(new Runnable()
@@ -1473,7 +1503,7 @@ public class Desktop extends jalview.jbgui.GDesktop
   public void closeAll_actionPerformed(ActionEvent e)
   {
     // TODO show a progress bar while closing?
-    JInternalFrame[] frames = desktop.getAllFrames();
+    JInternalFrame[] frames = getDesktopPane().getAllFrames();
     for (int i = 0; i < frames.length; i++)
     {
       try
@@ -1544,7 +1574,7 @@ public class Desktop extends jalview.jbgui.GDesktop
   @Override
   protected void showMemusage_actionPerformed(ActionEvent e)
   {
-    desktop.showMemoryUsage(showMemusage.isSelected());
+    getDesktopPane().showMemoryUsage(showMemusage.isSelected());
   }
 
   /*
@@ -1581,7 +1611,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 
   void reorderAssociatedWindows(boolean minimize, boolean close)
   {
-    JInternalFrame[] frames = desktop.getAllFrames();
+    JInternalFrame[] frames = getDesktopPane().getAllFrames();
     if (frames == null || frames.length < 1)
     {
       return;
@@ -1765,7 +1795,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     saveState_actionPerformed(true);
   }
 
-  private void setProjectFile(File choice)
+  protected void setProjectFile(File choice)
   {
     this.projectFile = choice;
   }
@@ -1815,7 +1845,7 @@ public class Desktop extends jalview.jbgui.GDesktop
                {
                  Cache.log.error(
                          "Problems whilst loading project from " + choice, ex);
-                 JvOptionPane.showMessageDialog(Desktop.desktop,
+              JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
                          MessageManager.formatMessage(
                                  "label.error_whilst_loading_project_from",
                                new Object[]
@@ -1925,7 +1955,7 @@ public class Desktop extends jalview.jbgui.GDesktop
    */
   public static AlignmentPanel[] getAlignmentPanels(String alignmentId)
   {
-    if (Desktop.desktop == null)
+    if (Desktop.getDesktopPane() == null)
     {
       // no frames created and in headless mode
       // TODO: verify that frames are recoverable when in headless mode
@@ -1967,7 +1997,7 @@ public class Desktop extends jalview.jbgui.GDesktop
   public static AlignmentViewport[] getViewports(String sequenceSetId)
   {
     List<AlignmentViewport> viewp = new ArrayList<>();
-    if (desktop != null)
+    if (getDesktopPane() != null)
     {
       AlignFrame[] frames = Desktop.getAlignFrames();
 
@@ -2053,7 +2083,7 @@ public class Desktop extends jalview.jbgui.GDesktop
   {
     source.viewport.setGatherViewsHere(true);
     source.viewport.setExplodedGeometry(source.getBounds());
-    JInternalFrame[] frames = desktop.getAllFrames();
+    JInternalFrame[] frames = getDesktopPane().getAllFrames();
     String viewId = source.viewport.getSequenceSetId();
 
     for (int t = 0; t < frames.length; t++)
@@ -2110,7 +2140,7 @@ public class Desktop extends jalview.jbgui.GDesktop
         String fle = chooser.getSelectedFile().toString();
         if (!vamsasImport(chooser.getSelectedFile()))
         {
-          JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+          JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
                   MessageManager.formatMessage(
                           "label.couldnt_import_as_vamsas_session",
                           new Object[]
@@ -2411,7 +2441,7 @@ public class Desktop extends jalview.jbgui.GDesktop
         removeProgressPanel(progpanel);
         if (warnmsg != null)
         {
-          JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+          JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
 
                   warnmsg, warnttl, JvOptionPane.ERROR_MESSAGE);
         }
@@ -2448,7 +2478,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 
   public JInternalFrame[] getAllFrames()
   {
-    return desktop.getAllFrames();
+    return getDesktopPane().getAllFrames();
   }
 
   /**
@@ -2487,7 +2517,7 @@ public class Desktop extends jalview.jbgui.GDesktop
           while (li.hasNext())
           {
             String link = li.next();
-            if (link.contains(SEQUENCE_ID)
+            if (link.contains(UrlConstants.SEQUENCE_ID)
                     && !UrlConstants.isDefaultString(link))
             {
               check = true;
@@ -2534,7 +2564,7 @@ public class Desktop extends jalview.jbgui.GDesktop
           });
           msgPanel.add(jcb);
 
-          JvOptionPane.showMessageDialog(Desktop.desktop, msgPanel,
+          JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), msgPanel,
                   MessageManager
                           .getString("label.SEQUENCE_ID_no_longer_used"),
                   JvOptionPane.WARNING_MESSAGE);
@@ -2649,11 +2679,11 @@ public class Desktop extends jalview.jbgui.GDesktop
   {
     if (Jalview.isHeadlessMode())
     {
-      // Desktop.desktop is null in headless mode
-      return new AlignFrame[] { Jalview.currentAlignFrame };
+      // Desktop.getDesktop() is null in headless mode
+      return new AlignFrame[] { Jalview.getCurrentAlignFrame() };
     }
 
-    JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+    JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
 
     if (frames == null)
     {
@@ -2698,7 +2728,7 @@ public class Desktop extends jalview.jbgui.GDesktop
    */
   public GStructureViewer[] getJmols()
   {
-    JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+    JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
 
     if (frames == null)
     {
@@ -2734,7 +2764,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     } catch (Exception ex)
     {
       jalview.bin.Cache.log.error("Groovy Shell Creation failed.", ex);
-      JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+      JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
 
               MessageManager.getString("label.couldnt_create_groovy_shell"),
               MessageManager.getString("label.groovy_support_failed"),
@@ -2745,7 +2775,7 @@ public class Desktop extends jalview.jbgui.GDesktop
   /**
    * Open the Groovy console
    */
-  void openGroovyConsole()
+  private void openGroovyConsole()
   {
     if (groovyConsole == null)
     {
@@ -2931,7 +2961,7 @@ public class Desktop extends jalview.jbgui.GDesktop
    */
   public static AlignFrame getAlignFrameFor(AlignViewportI viewport)
   {
-    if (desktop != null)
+    if (getDesktopPane() != null)
     {
       AlignmentPanel[] aps = getAlignmentPanels(
               viewport.getSequenceSetId());
@@ -2993,7 +3023,7 @@ public class Desktop extends jalview.jbgui.GDesktop
       if (discoverer == null)
       {
         discoverer = new jalview.ws.jws1.Discoverer();
-        // register PCS handler for desktop.
+        // register PCS handler for getDesktop().
         discoverer.addPropertyChangeListener(changeSupport);
       }
       // JAL-940 - disabled JWS1 service configuration - always start discoverer
@@ -3075,7 +3105,7 @@ public class Desktop extends jalview.jbgui.GDesktop
                  * 
                  * jd.waitForInput();
                  */
-                JvOptionPane.showConfirmDialog(Desktop.desktop,
+                JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(),
                         new JLabel("<html><table width=\"450\"><tr><td>"
                                 + ermsg + "</td></tr></table>"
                                 + "<p>It may be that you have invalid JABA URLs<br/>in your web service preferences,"
@@ -3101,7 +3131,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     }
   }
 
-  private Runnable serviceChangedDialog = null;
+  Runnable serviceChangedDialog = null;
 
   /**
    * start a thread to open a URL in the configured browser. Pops up a warning
@@ -3112,7 +3142,7 @@ public class Desktop extends jalview.jbgui.GDesktop
    */
   public static void showUrl(final String url)
   {
-    showUrl(url, Desktop.instance);
+    showUrl(url, Desktop.getInstance());
   }
 
   /**
@@ -3141,7 +3171,7 @@ public class Desktop extends jalview.jbgui.GDesktop
           jalview.util.BrowserLauncher.openURL(url);
         } catch (Exception ex)
         {
-          JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+          JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
                   MessageManager
                           .getString("label.web_browser_not_found_unix"),
                   MessageManager.getString("label.web_browser_not_found"),
@@ -3157,15 +3187,16 @@ public class Desktop extends jalview.jbgui.GDesktop
     }).start();
   }
 
-  public static WsParamSetManager wsparamManager = null;
+  private WsParamSetManager wsparamManager = null;
 
   public static ParamManager getUserParameterStore()
   {
-    if (wsparamManager == null)
+    Desktop d = getInstance();
+    if (d.wsparamManager == null)
     {
-      wsparamManager = new WsParamSetManager();
+      d.wsparamManager = new WsParamSetManager();
     }
-    return wsparamManager;
+    return d.wsparamManager;
   }
 
   /**
@@ -3210,12 +3241,12 @@ public class Desktop extends jalview.jbgui.GDesktop
   /**
    * flag indicating if dialogExecutor should try to acquire a permit
    */
-  private volatile boolean dialogPause = true;
+  volatile boolean dialogPause = true;
 
   /**
    * pause the queue
    */
-  private java.util.concurrent.Semaphore block = new Semaphore(0);
+  java.util.concurrent.Semaphore block = new Semaphore(0);
 
   private static groovy.ui.Console groovyConsole;
 
@@ -3241,7 +3272,7 @@ public class Desktop extends jalview.jbgui.GDesktop
           }
           ;
         }
-        if (instance == null)
+        if (getInstance() == null)
         {
           return;
         }
@@ -3405,7 +3436,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     String topViewId = myTopFrame.viewport.getSequenceSetId();
     String bottomViewId = myBottomFrame.viewport.getSequenceSetId();
 
-    JInternalFrame[] frames = desktop.getAllFrames();
+    JInternalFrame[] frames = getDesktopPane().getAllFrames();
     for (JInternalFrame frame : frames)
     {
       if (frame instanceof SplitFrame && frame != source)
@@ -3468,6 +3499,7 @@ public class Desktop extends jalview.jbgui.GDesktop
    *          - the payload from the drop event
    * @throws Exception
    */
+  @SuppressWarnings("unchecked")
   public static void transferFromDropTarget(List<Object> files,
           List<DataSourceType> protocols, DropTargetDropEvent evt,
           Transferable t) throws Exception
@@ -3538,7 +3570,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     {
       // Works on Windows and MacOSX
       Cache.log.debug("Drop handled as javaFileListFlavor");
-      for (Object file : (List) t
+      for (Object file : (List<Object>) t
               .getTransferData(DataFlavor.javaFileListFlavor))
       {
         files.add(file);
@@ -3702,7 +3734,7 @@ public class Desktop extends jalview.jbgui.GDesktop
           Class<? extends StructureViewerBase> structureViewerClass)
   {
     List<StructureViewerBase> result = new ArrayList<>();
-    JInternalFrame[] frames = Desktop.instance.getAllFrames();
+    JInternalFrame[] frames = Desktop.getInstance().getAllFrames();
 
     for (JInternalFrame frame : frames)
     {
@@ -3721,4 +3753,5 @@ public class Desktop extends jalview.jbgui.GDesktop
     }
     return result;
   }
+
 }
index d547c58..a02ec36 100644 (file)
@@ -222,7 +222,7 @@ public class FeatureEditor
               updateColourButton(mainPanel, colour, featureColour);
             };
           };
-          JalviewColourChooser.showColourChooser(Desktop.getDesktop(),
+          JalviewColourChooser.showColourChooser(Desktop.getDesktopPane(),
                   title, featureColour.getColour(), listener);
         }
         else
@@ -412,7 +412,7 @@ public class FeatureEditor
      * set dialog action handlers for OK (create/Amend) and Cancel options
      * also for Delete if applicable (when amending features)
      */
-    JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop)
+    JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.getDesktopPane())
             .setResponseHandler(0, okAction).setResponseHandler(2, cancelAction);
     if (!forCreate)
     {
index a1693f7..2a6adda 100755 (executable)
@@ -176,7 +176,7 @@ public class Finder extends GFinder
    */
   boolean getFocusedViewport()
   {
-    if (focusfixed || Desktop.desktop == null)
+    if (focusfixed || Desktop.getDesktopPane() == null)
     {
       if (ap != null && av != null)
       {
@@ -187,7 +187,7 @@ public class Finder extends GFinder
     }
     // now checks further down the window stack to fix bug
     // https://mantis.lifesci.dundee.ac.uk/view.php?id=36008
-    JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+    JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
     for (int f = 0; f < frames.length; f++)
     {
       JInternalFrame alignFrame = frames[f];
index 6b312ad..dc94dee 100755 (executable)
@@ -246,7 +246,7 @@ public class IdPanel extends JPanel
       jalview.util.BrowserLauncher.openURL(url);
     } catch (Exception ex)
     {
-      JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+      JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
               MessageManager.getString("label.web_browser_not_found_unix"),
               MessageManager.getString("label.web_browser_not_found"),
               JvOptionPane.WARNING_MESSAGE);
index 1d7bf3d..0ff5606 100644 (file)
@@ -78,11 +78,11 @@ public abstract class JalviewDialog extends JPanel
           boolean block, String title, int width, int height)
   {
 
-    frame = new JDialog(Desktop.instance, modal);
+    frame = new JDialog(Desktop.getInstance(), modal);
     frame.setTitle(title);
-    if (Desktop.instance != null)
+    if (Desktop.getInstance() != null)
     {
-      Rectangle deskr = Desktop.instance.getBounds();
+      Rectangle deskr = Desktop.getInstance().getBounds();
       frame.setBounds(new Rectangle((int) (deskr.getCenterX() - width / 2),
               (int) (deskr.getCenterY() - height / 2), width, height));
     }
index d55733c..fc6fd23 100644 (file)
@@ -86,7 +86,7 @@ public class LineartOptions extends JPanel
       ex.printStackTrace();
     }
 
-    dialog = JvOptionPane.newOptionDialog(Desktop.desktop);
+    dialog = JvOptionPane.newOptionDialog(Desktop.getDesktopPane());
   }
 
   /**
index 02c8fe1..dc5d0f5 100644 (file)
@@ -72,7 +72,7 @@ public class OOMWarning implements Runnable
 
   public OOMWarning(String string, OutOfMemoryError oomerror)
   {
-    this(string, oomerror, Desktop.desktop);
+    this(string, oomerror, Desktop.getDesktopPane());
   }
 
   @Override
index ad33110..a356def 100644 (file)
@@ -307,7 +307,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
       jalview.util.BrowserLauncher.openURL(url);
     } catch (Exception ex)
     {
-      JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+      JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
               MessageManager.getString("label.web_browser_not_found_unix"),
               MessageManager.getString("label.web_browser_not_found"),
               JvOptionPane.WARNING_MESSAGE);
@@ -1985,7 +1985,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
         refresh();
       };
     };
-    JalviewColourChooser.showColourChooser(Desktop.getDesktop(),
+    JalviewColourChooser.showColourChooser(Desktop.getDesktopPane(),
             title, Color.BLUE, listener);
   }
 
index 9d5596e..cc2961f 100755 (executable)
@@ -857,7 +857,7 @@ public class Preferences extends GPreferences
             Integer.toString(getComboIntStringKey(backupfilesPresetsCombo)));
 
     Cache.saveProperties();
-    Desktop.instance.doConfigureStructurePrefs();
+    Desktop.getInstance().doConfigureStructurePrefs();
     try
     {
       frame.setClosed(true);
@@ -968,7 +968,7 @@ public class Preferences extends GPreferences
     boolean valid = false;
     while (!valid)
     {
-      if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
+      if (JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(), link,
               MessageManager.getString("label.new_sequence_url_link"),
               JvOptionPane.OK_CANCEL_OPTION, -1,
               null) == JvOptionPane.OK_OPTION)
@@ -1020,7 +1020,7 @@ public class Preferences extends GPreferences
     boolean valid = false;
     while (!valid)
     {
-      if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
+      if (JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(), link,
               MessageManager.getString("label.edit_sequence_url_link"),
               JvOptionPane.OK_CANCEL_OPTION, -1,
               null) == JvOptionPane.OK_OPTION)
@@ -1193,7 +1193,7 @@ public class Preferences extends GPreferences
     } catch (NumberFormatException x)
     {
       userIdWidth.setText("");
-      JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+      JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
               MessageManager
                       .getString("warn.user_defined_width_requirements"),
               MessageManager.getString("label.invalid_id_column_width"),
@@ -1219,7 +1219,7 @@ public class Preferences extends GPreferences
       File f = new File(chimeraPath.getText());
       if (!f.canExecute())
       {
-        JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+        JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
                 MessageManager.getString("label.invalid_chimera_path"),
                 MessageManager.getString("label.invalid_name"),
                 JvOptionPane.ERROR_MESSAGE);
@@ -1258,7 +1258,7 @@ public class Preferences extends GPreferences
     if (!found)
     {
       String[] options = { "OK", "Help" };
-      int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
+      int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.getDesktopPane(),
               JvSwingUtils.wrapTooltip(true,
                       MessageManager.getString("label.chimera_missing")),
               "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
index cb59452..77d83a8 100644 (file)
@@ -200,7 +200,7 @@ public class PromptUserConfig implements Runnable
     }
     try
     {
-      int reply = JvOptionPane.showConfirmDialog(Desktop.desktop, // component,
+      int reply = JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(), // component,
               dialogText, dialogTitle,
               (allowCancel) ? JvOptionPane.YES_NO_CANCEL_OPTION
                       : JvOptionPane.YES_NO_OPTION,
index 646a7f1..7b408a4 100755 (executable)
@@ -860,7 +860,7 @@ public class SequenceFetcher extends JPanel implements Runnable
       @Override
       public void run()
       {
-        JvOptionPane.showInternalMessageDialog(Desktop.desktop, error,
+        JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(), error,
                 MessageManager.getString("label.error_retrieving_data"),
                 JvOptionPane.WARNING_MESSAGE);
       }
index 2b87e10..98b24d1 100755 (executable)
@@ -160,7 +160,7 @@ public class SplashScreen extends JPanel
             System.err.println("Error when loading images!");
           }
         } while (!mt.checkAll());
-        Desktop.instance.setIconImage(logo);
+        Desktop.getInstance().setIconImage(logo);
       }
     } catch (Exception ex)
     {
@@ -191,7 +191,7 @@ public class SplashScreen extends JPanel
     }
     add(authlist, BorderLayout.CENTER);
     authlist.addMouseListener(closer);
-    Desktop.desktop.add(iframe);
+    Desktop.getDesktopPane().add(iframe);
     refreshText();
   }
 
@@ -203,7 +203,7 @@ public class SplashScreen extends JPanel
   @SuppressWarnings("unused")
   protected boolean refreshText()
   {
-    String newtext = Desktop.instance.getAboutMessage(true).toString();
+    String newtext = Desktop.getInstance().getAboutMessage(true).toString();
     // System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
     if (oldtext != newtext.length())
     {
@@ -236,8 +236,8 @@ public class SplashScreen extends JPanel
       authlist.setSize(new Dimension(750, 375));
       add(authlist, BorderLayout.CENTER);
       revalidate();
-      iframe.setBounds((Desktop.instance.getWidth() - 750) / 2,
-              (Desktop.instance.getHeight() - 375) / 2, 750,
+      iframe.setBounds((Desktop.getInstance().getWidth() - 750) / 2,
+              (Desktop.getInstance().getHeight() - 375) / 2, 750,
               authlist.getHeight() + iconimg.getHeight());
       iframe.validate();
       iframe.setVisible(true);
@@ -287,7 +287,7 @@ public class SplashScreen extends JPanel
     }
 
     closeSplash();
-    Desktop.instance.startDialogQueue();
+    Desktop.getInstance().startDialogQueue();
   }
 
   /**
index e066c75..55a9c61 100644 (file)
@@ -132,7 +132,7 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
     // allow about 65 pixels for Desktop decorators on Windows
 
     int newHeight = Math.min(height,
-            Desktop.instance.getHeight() - DESKTOP_DECORATORS_HEIGHT);
+            Desktop.getInstance().getHeight() - DESKTOP_DECORATORS_HEIGHT);
     if (newHeight != height)
     {
       int oldDividerLocation = getDividerLocation();
@@ -150,7 +150,7 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
     // TODO if CommandListener is only ever 1:1 for complementary views,
     // may change broadcast pattern to direct messaging (more efficient)
     final StructureSelectionManager ssm = StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance);
+            .getStructureSelectionManager(Desktop.getInstance());
     ssm.addCommandListener(((AlignFrame) getTopFrame()).getViewport());
     ssm.addCommandListener(((AlignFrame) getBottomFrame()).getViewport());
   }
@@ -556,7 +556,7 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
     adjustLayout();
 
     final StructureSelectionManager ssm = StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance);
+            .getStructureSelectionManager(Desktop.getInstance());
     ssm.addCommandListener(newTopPanel.av);
     ssm.addCommandListener(newBottomPanel.av);
   }
@@ -683,7 +683,7 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
    */
   protected void expandViews_actionPerformed()
   {
-    Desktop.instance.explodeViews(this);
+    Desktop.getInstance().explodeViews(this);
   }
 
   /**
@@ -692,7 +692,7 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
    */
   protected void gatherViews_actionPerformed()
   {
-    Desktop.instance.gatherViews(this);
+    Desktop.getInstance().gatherViews(this);
   }
 
   /**
index 23b7fcf..5b15ef1 100644 (file)
@@ -148,7 +148,7 @@ public class StructureChooser extends GStructureChooser
    */
   private void discoverStructureViews()
   {
-    if (Desktop.instance != null)
+    if (Desktop.getInstance() != null)
     {
       targetView.removeAllItems();
       if (lastTargetedView != null && !lastTargetedView.isVisible())
@@ -156,7 +156,7 @@ public class StructureChooser extends GStructureChooser
         lastTargetedView = null;
       }
       int linkedViewsAt = 0;
-      for (StructureViewerBase view : Desktop.instance
+      for (StructureViewerBase view : Desktop.getInstance()
               .getStructureViewers(null, null))
       {
         StructureViewer viewHandler = (lastTargetedView != null
@@ -998,7 +998,7 @@ public class StructureChooser extends GStructureChooser
           PDBEntry fileEntry = new AssociatePdbFileWithSeq()
                   .associatePdbWithSeq(selectedPdbFileName,
                           DataSourceType.FILE, selectedSequence, true,
-                          Desktop.instance);
+                          Desktop.getInstance());
 
           sViewer = launchStructureViewer(
                   ssm, new PDBEntry[]
index 418a84d..af48093 100644 (file)
@@ -407,7 +407,7 @@ public abstract class StructureViewerBase extends GStructureViewer
    */
   protected List<StructureViewerBase> getViewersFor(AlignmentPanel alp)
   {
-    return Desktop.instance.getStructureViewers(alp, this.getClass());
+    return Desktop.getInstance().getStructureViewers(alp, this.getClass());
   }
 
   @Override
index 4846049..2f18f43 100755 (executable)
@@ -448,7 +448,7 @@ public class UserDefinedColours extends GUserDefinedColours
   {
     if (isNoSelectionMade())
     {
-      JvOptionPane.showMessageDialog(Desktop.desktop,
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
               MessageManager
                       .getString("label.no_colour_selection_in_scheme"),
               MessageManager.getString("label.no_colour_selection_warn"),
@@ -503,7 +503,7 @@ public class UserDefinedColours extends GUserDefinedColours
         String[] options = new String[] { title,
             MessageManager.getString("label.dont_save_changes"), };
         final String question = JvSwingUtils.wrapTooltip(true, message);
-        int response = JvOptionPane.showOptionDialog(Desktop.desktop,
+        int response = JvOptionPane.showOptionDialog(Desktop.getDesktopPane(),
                 question, title, JvOptionPane.DEFAULT_OPTION,
                 JvOptionPane.PLAIN_MESSAGE, null, options, options[0]);
 
@@ -557,7 +557,7 @@ public class UserDefinedColours extends GUserDefinedColours
   {
     if (isNoSelectionMade())
     {
-      JvOptionPane.showMessageDialog(Desktop.desktop,
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
               MessageManager
                       .getString("label.no_colour_selection_in_scheme"),
               MessageManager.getString("label.no_colour_selection_warn"),
@@ -741,7 +741,7 @@ public class UserDefinedColours extends GUserDefinedColours
     String name = schemeName.getText().trim();
     if (name.length() < 1)
     {
-      JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+      JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
               MessageManager
                       .getString("label.user_colour_scheme_must_have_name"),
               MessageManager.getString("label.no_name_colour_scheme"),
@@ -756,7 +756,7 @@ public class UserDefinedColours extends GUserDefinedColours
        * @j2sIgnore
        */
       {
-        int reply = JvOptionPane.showInternalConfirmDialog(Desktop.desktop,
+        int reply = JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(),
                 MessageManager.formatMessage(
                         "label.colour_scheme_exists_overwrite", new Object[]
                         { name, name }),
index ef86756..e12586a 100644 (file)
@@ -141,7 +141,7 @@ public class UserQuestionnaireCheck implements Runnable
                 + qid + "&rid=" + rid;
         jalview.bin.Cache.log
                 .info("Prompting user for questionnaire at " + qurl);
-        int reply = JvOptionPane.showInternalConfirmDialog(Desktop.desktop,
+        int reply = JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(),
                 MessageManager.getString("label.jalview_new_questionnaire"),
                 MessageManager.getString("label.jalview_user_survey"),
                 JvOptionPane.YES_NO_OPTION, JvOptionPane.QUESTION_MESSAGE);
index c094b1c..2053fb2 100644 (file)
@@ -173,7 +173,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
           }
         } catch (InvalidSessionDocumentException e)
         {
-          JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+          JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
 
                   MessageManager.getString(
                           "label.vamsas_doc_couldnt_be_opened_as_new_session"),
@@ -455,7 +455,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
     VamsasAppDatastore vds = new VamsasAppDatastore(doc, vobj2jv, jv2vobj,
             baseProvEntry(), alRedoState);
     // wander through frames
-    JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+    JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
 
     if (frames == null)
     {
@@ -660,7 +660,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
                   Cache.log.debug(
                           "Asking user if the vamsas session should be stored.");
                   int reply = JvOptionPane.showInternalConfirmDialog(
-                          Desktop.desktop,
+                          Desktop.getDesktopPane(),
                           "The current VAMSAS session has unsaved data - do you want to save it ?",
                           "VAMSAS Session Shutdown",
                           JvOptionPane.YES_NO_OPTION,
@@ -669,7 +669,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
                   if (reply == JvOptionPane.YES_OPTION)
                   {
                     Cache.log.debug("Prompting for vamsas store filename.");
-                    Desktop.instance.vamsasSave_actionPerformed(null);
+                    Desktop.getInstance().vamsasSave_actionPerformed(null);
                     Cache.log
                             .debug("Finished attempt at storing document.");
                   }
@@ -688,7 +688,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
 
   public void disableGui(boolean b)
   {
-    Desktop.instance.setVamsasUpdate(b);
+    Desktop.getInstance().setVamsasUpdate(b);
   }
 
   Hashtable _backup_vobj2jv;
@@ -763,7 +763,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
       {
         final IPickManager pm = vclient.getPickManager();
         final StructureSelectionManager ssm = StructureSelectionManager
-                .getStructureSelectionManager(Desktop.instance);
+                .getStructureSelectionManager(Desktop.getInstance());
         final VamsasApplication me = this;
         pm.registerMessageHandler(new IMessageHandler()
         {
index c6137cc..ae013ec 100644 (file)
@@ -711,7 +711,7 @@ public class WebserviceInfo extends GWebserviceInfo
       @Override
       public void run()
       {
-        JvOptionPane.showInternalMessageDialog(Desktop.desktop, message,
+        JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(), message,
                 title, JvOptionPane.WARNING_MESSAGE);
 
       }
index 976e551..da00a25 100644 (file)
@@ -215,12 +215,12 @@ public class WsJobParameters extends JPanel implements ItemListener,
   public boolean showRunDialog()
   {
 
-    frame = new JDialog(Desktop.instance, true);
+    frame = new JDialog(Desktop.getInstance(), true);
 
     frame.setTitle(MessageManager.formatMessage("label.edit_params_for",
             new String[]
             { service.getActionText() }));
-    Rectangle deskr = Desktop.instance.getBounds();
+    Rectangle deskr = Desktop.getInstance().getBounds();
     Dimension pref = this.getPreferredSize();
     frame.setBounds(
             new Rectangle((int) (deskr.getCenterX() - pref.width / 2),
@@ -436,8 +436,8 @@ public class WsJobParameters extends JPanel implements ItemListener,
     dialogpanel.add(canceljob);
     // JAL-1580: setMaximumSize() doesn't work, so just size for the worst case:
     // check for null is for JUnit usage
-    final int windowHeight = Desktop.instance == null ? 540
-            : Desktop.instance.getHeight();
+    final int windowHeight = Desktop.getInstance() == null ? 540
+            : Desktop.getInstance().getHeight();
     setPreferredSize(new Dimension(540, windowHeight));
     add(dialogpanel, BorderLayout.SOUTH);
     validate();
index bb5d996..0f315eb 100644 (file)
@@ -203,7 +203,7 @@ public class WsParamSetManager implements ParamManager
       chooser.setDialogTitle(MessageManager
               .getString("label.choose_filename_for_param_file"));
       chooser.setToolTipText(MessageManager.getString("action.save"));
-      int value = chooser.showSaveDialog(Desktop.instance);
+      int value = chooser.showSaveDialog(Desktop.getInstance());
       if (value == JalviewFileChooser.APPROVE_OPTION)
       {
         outfile = chooser.getSelectedFile();
@@ -311,7 +311,7 @@ public class WsParamSetManager implements ParamManager
       File pfile = new File(filename);
       if (pfile.exists() && pfile.canWrite())
       {
-        if (JvOptionPane.showConfirmDialog(Desktop.instance,
+        if (JvOptionPane.showConfirmDialog(Desktop.getInstance(),
                 "Delete the preset's file, too ?", "Delete User Preset ?",
                 JvOptionPane.OK_CANCEL_OPTION) == JvOptionPane.OK_OPTION)
         {
index 850ef21..9966c02 100644 (file)
@@ -454,7 +454,7 @@ public class WsPreferences extends GWsPreferences
     boolean valid = false;
     int resp = JvOptionPane.CANCEL_OPTION;
     while (!valid && (resp = JvOptionPane.showInternalConfirmDialog(
-            Desktop.desktop, panel, title,
+            Desktop.getDesktopPane(), panel, title,
             JvOptionPane.OK_CANCEL_OPTION)) == JvOptionPane.OK_OPTION)
     {
       try
@@ -472,13 +472,13 @@ public class WsPreferences extends GWsPreferences
       } catch (Exception e)
       {
         valid = false;
-        JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+        JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
                 MessageManager.getString("label.invalid_url"));
       }
     }
     if (valid && resp == JvOptionPane.OK_OPTION)
     {
-      int validate = JvOptionPane.showInternalConfirmDialog(Desktop.desktop,
+      int validate = JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(),
               MessageManager.getString("info.validate_jabaws_server"),
               MessageManager.getString("label.test_server"),
               JvOptionPane.YES_NO_OPTION);
@@ -491,7 +491,7 @@ public class WsPreferences extends GWsPreferences
         }
         else
         {
-          int opt = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
+          int opt = JvOptionPane.showInternalOptionDialog(Desktop.getDesktopPane(),
                   "The Server  '" + foo.toString()
                           + "' failed validation,\ndo you want to add it anyway? ",
                   "Server Validation Failed", JvOptionPane.YES_NO_OPTION,
@@ -502,7 +502,7 @@ public class WsPreferences extends GWsPreferences
           }
           else
           {
-            JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+            JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
                     MessageManager.getString(
                             "warn.server_didnt_pass_validation"));
           }
@@ -595,7 +595,7 @@ public class WsPreferences extends GWsPreferences
           if (lastrefresh != update)
           {
             lastrefresh = update;
-            Desktop.instance.startServiceDiscovery(true); // wait around for all
+            Desktop.getInstance().startServiceDiscovery(true); // wait around for all
                                                           // threads to complete
             updateList();
 
@@ -616,15 +616,15 @@ public class WsPreferences extends GWsPreferences
         public void run()
         {
           long ct = System.currentTimeMillis();
-          Desktop.instance.setProgressBar(MessageManager
+          Desktop.getInstance().setProgressBar(MessageManager
                   .getString("status.refreshing_web_service_menus"), ct);
           if (lastrefresh != update)
           {
             lastrefresh = update;
-            Desktop.instance.startServiceDiscovery(true);
+            Desktop.getInstance().startServiceDiscovery(true);
             updateList();
           }
-          Desktop.instance.setProgressBar(null, ct);
+          Desktop.getInstance().setProgressBar(null, ct);
         }
 
       }).start();
index dae1c02..c697a99 100644 (file)
@@ -539,7 +539,7 @@ public class BackupFiles
           MessageManager.getString("label.delete"),
           MessageManager.getString("label.rename") };
 
-      confirmButton = JvOptionPane.showOptionDialog(Desktop.desktop,
+      confirmButton = JvOptionPane.showOptionDialog(Desktop.getDesktopPane(),
               messageSB.toString(),
               MessageManager.getString("label.backupfiles_confirm_delete"),
               JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
@@ -559,7 +559,7 @@ public class BackupFiles
           MessageManager.getString("label.delete"),
           MessageManager.getString("label.keep") };
 
-      confirmButton = JvOptionPane.showOptionDialog(Desktop.desktop,
+      confirmButton = JvOptionPane.showOptionDialog(Desktop.getDesktopPane(),
               messageSB.toString(),
               MessageManager.getString("label.backupfiles_confirm_delete"),
               JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
@@ -594,7 +594,7 @@ public class BackupFiles
                       Long.toString(df.length()) }));
         }
 
-        int confirmButton = JvOptionPane.showConfirmDialog(Desktop.desktop,
+        int confirmButton = JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(),
                 messageSB.toString(),
                 MessageManager
                         .getString("label.backupfiles_confirm_delete"),
@@ -683,7 +683,7 @@ public class BackupFiles
                 "label.backupfiles_confirm_save_new_saved_file_not_ok"));
       }
 
-      int confirmButton = JvOptionPane.showConfirmDialog(Desktop.desktop,
+      int confirmButton = JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(),
               messageSB.toString(),
               MessageManager
                       .getString("label.backupfiles_confirm_save_file"),
index 95f85e6..0d46e76 100755 (executable)
@@ -278,9 +278,9 @@ public class FileLoader implements Runnable
     Runtime rt = Runtime.getRuntime();
     try
     {
-      if (Desktop.instance != null)
+      if (Desktop.getInstance() != null)
       {
-        Desktop.instance.startLoading(file);
+        Desktop.getInstance().startLoading(file);
       }
       if (format == null)
       {
@@ -302,12 +302,12 @@ public class FileLoader implements Runnable
 
       if (format == null)
       {
-        Desktop.instance.stopLoading();
+        Desktop.getInstance().stopLoading();
         System.err.println("The input file \"" + file
                 + "\" has null or unidentifiable data content!");
         if (!Jalview.isHeadlessMode())
         {
-          JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+          JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
                   MessageManager.getString("label.couldnt_read_data")
                           + " in " + file + "\n"
                           + AppletFormatAdapter.getSupportedFormats(),
@@ -318,7 +318,7 @@ public class FileLoader implements Runnable
       }
       // TODO: cache any stream datasources as a temporary file (eg. PDBs
       // retrieved via URL)
-      if (Desktop.desktop != null && Desktop.desktop.isShowMemoryUsage())
+      if (Desktop.getDesktopPane() != null && Desktop.getDesktopPane().isShowMemoryUsage())
       {
         System.gc();
         memused = (rt.maxMemory() - rt.totalMemory() + rt.freeMemory()); // free
@@ -411,7 +411,7 @@ public class FileLoader implements Runnable
                 // register PDB entries with desktop's structure selection
                 // manager
                 StructureSelectionManager
-                        .getStructureSelectionManager(Desktop.instance)
+                        .getStructureSelectionManager(Desktop.getInstance())
                         .registerPDBEntry(pdbe);
               }
             }
@@ -500,23 +500,23 @@ public class FileLoader implements Runnable
         }
         else
         {
-          if (Desktop.instance != null)
+          if (Desktop.getInstance() != null)
           {
-            Desktop.instance.stopLoading();
+            Desktop.getInstance().stopLoading();
           }
 
           final String errorMessage = MessageManager.getString(
                   "label.couldnt_load_file") + " " + title + "\n" + error;
           // TODO: refactor FileLoader to be independent of Desktop / Applet GUI
           // bits ?
-          if (raiseGUI && Desktop.desktop != null)
+          if (raiseGUI && Desktop.getDesktopPane() != null)
           {
             javax.swing.SwingUtilities.invokeLater(new Runnable()
             {
               @Override
               public void run()
               {
-                JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+                JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
                         errorMessage,
                         MessageManager
                                 .getString("label.error_loading_file"),
@@ -544,7 +544,7 @@ public class FileLoader implements Runnable
           @Override
           public void run()
           {
-            JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+            JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
                     MessageManager.formatMessage(
                             "label.problems_opening_file", new String[]
                             { file }),
@@ -566,7 +566,7 @@ public class FileLoader implements Runnable
           @Override
           public void run()
           {
-            JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+            JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
                     MessageManager.formatMessage(
                             "warn.out_of_memory_loading_file", new String[]
                             { file }),
@@ -588,7 +588,7 @@ public class FileLoader implements Runnable
     // memory
     // after
     // load
-    if (Desktop.desktop != null && Desktop.desktop.isShowMemoryUsage())
+    if (Desktop.getDesktopPane() != null && Desktop.getDesktopPane().isShowMemoryUsage())
     {
       if (alignFrame != null)
       {
@@ -610,9 +610,9 @@ public class FileLoader implements Runnable
       }
     }
     // remove the visual delay indicator
-    if (Desktop.instance != null)
+    if (Desktop.getInstance() != null)
     {
-      Desktop.instance.stopLoading();
+      Desktop.getInstance().stopLoading();
     }
 
   }
index 54e7e4b..6b6dc24 100644 (file)
@@ -22,6 +22,7 @@ package jalview.io;
 
 import jalview.api.AlignExportSettingsI;
 import jalview.bin.Cache;
+import jalview.bin.Jalview;
 import jalview.datamodel.AlignExportSettingsAdapter;
 import jalview.datamodel.AlignmentExportData;
 import jalview.gui.AlignmentPanel;
@@ -231,7 +232,7 @@ public abstract class HTMLOutput implements Runnable
 
   protected void setProgressMessage(String message)
   {
-    if (pIndicator != null && !isHeadless())
+    if (pIndicator != null && !Jalview.isHeadlessMode())
     {
       pIndicator.setProgressBar(message, pSessionId);
     }
@@ -241,16 +242,16 @@ public abstract class HTMLOutput implements Runnable
     }
   }
 
-  /**
-   * Answers true if HTML export is invoke in headless mode or false otherwise
-   * 
-   * @return
-   */
-  protected boolean isHeadless()
-  {
-    return System.getProperty("java.awt.headless") != null
-            && System.getProperty("java.awt.headless").equals("true");
-  }
+  // /**
+  // * Answers true if HTML export is invoke in headless mode or false otherwise
+  // *
+  // * @return
+  // */
+  // protected boolean isHeadless()
+  // {
+  // return System.getProperty("java.awt.headless") != null
+  // && System.getProperty("java.awt.headless").equals("true");
+  // }
 
   /**
    * This method provides implementation of consistent behaviour which should
@@ -259,7 +260,7 @@ public abstract class HTMLOutput implements Runnable
    */
   protected void exportCompleted()
   {
-    if (isLaunchInBrowserAfterExport() && !isHeadless())
+    if (isLaunchInBrowserAfterExport() && !Jalview.isHeadlessMode())
     {
       try
       {
index b8241c8..d4a4651 100644 (file)
@@ -21,6 +21,7 @@
 package jalview.io;
 
 import jalview.bin.Cache;
+import jalview.bin.Jalview;
 import jalview.gui.AlignmentPanel;
 import jalview.gui.LineartOptions;
 import jalview.gui.OOMWarning;
@@ -223,7 +224,8 @@ public class HtmlSvgOutput extends HTMLOutput
       /*
        * Prompt for character rendering style if preference is not set
        */
-      if (renderStyle.equalsIgnoreCase("Prompt each time") && !isHeadless())
+      if (renderStyle.equalsIgnoreCase("Prompt each time")
+              && !Jalview.isHeadlessMode())
       {
         LineartOptions svgOption = new LineartOptions("HTML", textOption);
         svgOption.setResponseAction(1, new Runnable()
index adf4447..c2954f0 100644 (file)
@@ -720,9 +720,9 @@ public class VamsasAppDatastore
       // /SAVE THE TREES
       // /////////////////////////////////
       // FIND ANY ASSOCIATED TREES
-      if (Desktop.desktop != null)
+      if (Desktop.getDesktopPane() != null)
       {
-        javax.swing.JInternalFrame[] frames = Desktop.instance
+        javax.swing.JInternalFrame[] frames = Desktop.getInstance()
                 .getAllFrames();
 
         for (int t = 0; t < frames.length; t++)
@@ -1479,7 +1479,7 @@ public class VamsasAppDatastore
           if (mappings != null)
           {
             jalview.structure.StructureSelectionManager
-                    .getStructureSelectionManager(Desktop.instance)
+                    .getStructureSelectionManager(Desktop.getInstance())
                     .registerMappings(mappings);
           }
         }
index 63b78b2..e24c2f3 100755 (executable)
@@ -150,7 +150,7 @@ public class WSWUBlastClient
   {
     // This must be outside the run() body as java 1.5
     // will not return any value from the OptionPane to the expired thread.
-    int reply = JvOptionPane.showConfirmDialog(Desktop.desktop,
+    int reply = JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(),
             "Automatically update suggested ids?",
             "Auto replace sequence ids", JvOptionPane.YES_NO_OPTION);
 
index 0a582e5..402ffdf 100644 (file)
@@ -365,7 +365,7 @@ public class Sequencemapping extends Rangetype
     }
     bindjvvobj(mapping, sequenceMapping);
     jalview.structure.StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance)
+            .getStructureSelectionManager(Desktop.getInstance())
             .registerMapping(acf);
     // Try to link up any conjugate database references in the two sequences
     // matchConjugateDBRefs(from, to, mapping);
index 8bbfb8d..de20556 100755 (executable)
@@ -1242,8 +1242,7 @@ public class GAlignFrame extends JInternalFrame
     showTranslation
             .setText(MessageManager.getString("label.translate_cDNA"));
     boolean first = true;
-    for (final GeneticCodeI table : GeneticCodes.getInstance()
-            .getCodeTables())
+    for (final GeneticCodeI table : GeneticCodes.getCodeTables())
     {
       JMenuItem item = new JMenuItem(table.getId() + " " + table.getName());
       showTranslation.add(item);
index 2ea3774..943e705 100755 (executable)
@@ -37,16 +37,14 @@ import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
 
 /**
- * DOCUMENT ME!
+ * abstract class super to jalview.gui.Desktop
  * 
- * @author $author$
- * @version $Revision$
  */
 @SuppressWarnings("serial")
-public class GDesktop extends JFrame
+public abstract class GDesktop extends JFrame
 {
 
-  protected static JMenu windowMenu = new JMenu();
+  public JMenu windowMenu = new JMenu(); // BH 2019.05.07 was static
 
   JMenuBar desktopMenubar = new JMenuBar();
 
@@ -110,7 +108,7 @@ public class GDesktop extends JFrame
 
   protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem();
 
-  protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem();
+  public JCheckBoxMenuItem showNews = new JCheckBoxMenuItem();
 
   protected JMenuItem snapShotWindow = new JMenuItem();
 
@@ -119,7 +117,6 @@ public class GDesktop extends JFrame
    */
   public GDesktop()
   {
-    super();
     try
     {
       jbInit();
index 3c35e4e..5fbc3d7 100755 (executable)
@@ -2193,7 +2193,7 @@ public class GPreferences extends JPanel
     boolean ret = false;
     String warningMessage = MessageManager
             .getString("label.warning_confirm_change_reverse");
-    int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
+    int confirm = JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(),
             warningMessage,
             MessageManager.getString("label.change_increment_decrement"),
             JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
index a43e504..2ec7051 100755 (executable)
@@ -219,7 +219,7 @@ public class GSequenceLink extends JPanel
       return true;
     }
 
-    JvOptionPane.showInternalMessageDialog(jalview.gui.Desktop.desktop,
+    JvOptionPane.showInternalMessageDialog(jalview.gui.Desktop.getDesktopPane(),
             MessageManager.getString("warn.url_must_contain"),
             MessageManager.getString("label.invalid_url"),
             JvOptionPane.WARNING_MESSAGE);
@@ -228,7 +228,7 @@ public class GSequenceLink extends JPanel
 
   public void notifyDuplicate()
   {
-    JvOptionPane.showInternalMessageDialog(jalview.gui.Desktop.desktop,
+    JvOptionPane.showInternalMessageDialog(jalview.gui.Desktop.getDesktopPane(),
             MessageManager.getString("warn.name_cannot_be_duplicate"),
             MessageManager.getString("label.invalid_name"),
             JvOptionPane.WARNING_MESSAGE);
index 4d772a1..1aac037 100644 (file)
@@ -1081,7 +1081,7 @@ public class Jalview2XML
            * only view *should* be coped with sensibly.
            */
           // This must have been loaded, is it still visible?
-          JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+          JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
           String matchedFile = null;
           for (int f = frames.length - 1; f > -1; f--)
           {
@@ -1233,9 +1233,9 @@ public class Jalview2XML
     {
       // FIND ANY ASSOCIATED TREES
       // NOT IMPLEMENTED FOR HEADLESS STATE AT PRESENT
-      if (Desktop.desktop != null)
+      if (Desktop.getDesktopPane() != null)
       {
-        JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+        JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
 
         for (int t = 0; t < frames.length; t++)
         {
@@ -1279,9 +1279,9 @@ public class Jalview2XML
     /*
      * save PCA viewers
      */
-    if (!storeDS && Desktop.desktop != null)
+    if (!storeDS && Desktop.getDesktopPane() != null)
     {
-      for (JInternalFrame frame : Desktop.desktop.getAllFrames())
+      for (JInternalFrame frame : Desktop.getDesktopPane().getAllFrames())
       {
         if (frame instanceof PCAPanel)
         {
@@ -1919,11 +1919,11 @@ public class Jalview2XML
           final SequenceI jds, List<String> viewIds, AlignmentPanel ap,
           boolean storeDataset)
   {
-    if (Desktop.desktop == null)
+    if (Desktop.getDesktopPane() == null)
     {
       return;
     }
-    JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+    JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
     for (int f = frames.length - 1; f > -1; f--)
     {
       if (frames[f] instanceof AppVarna)
@@ -2915,9 +2915,9 @@ public class Jalview2XML
       {
         // used to attempt to parse as V1 castor-generated xml
       }
-      if (Desktop.instance != null)
+      if (Desktop.getInstance() != null)
       {
-        Desktop.instance.stopLoading();
+        Desktop.getInstance().stopLoading();
       }
       if (af != null)
       {
@@ -2945,7 +2945,7 @@ public class Jalview2XML
      */
     for (AlignFrame fr : gatherToThisFrame.values())
     {
-      Desktop.instance.gatherViews(fr);
+      Desktop.getInstance().gatherViews(fr);
     }
 
     restoreSplitFrames();
@@ -2954,7 +2954,7 @@ public class Jalview2XML
       if (ds.getCodonFrames() != null)
       {
         StructureSelectionManager
-                .getStructureSelectionManager(Desktop.instance)
+                .getStructureSelectionManager(Desktop.getInstance())
                 .registerMappings(ds.getCodonFrames());
       }
     }
@@ -2963,9 +2963,9 @@ public class Jalview2XML
       reportErrors();
     }
 
-    if (Desktop.instance != null)
+    if (Desktop.getInstance() != null)
     {
-      Desktop.instance.stopLoading();
+      Desktop.getInstance().stopLoading();
     }
 
     return af;
@@ -3046,7 +3046,7 @@ public class Jalview2XML
      */
     for (SplitFrame sf : gatherTo)
     {
-      Desktop.instance.gatherViews(sf);
+      Desktop.getInstance().gatherViews(sf);
     }
 
     splitFrameCandidates.clear();
@@ -3105,7 +3105,7 @@ public class Jalview2XML
           @Override
           public void run()
           {
-            JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+            JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
                     finalErrorMessage,
                     "Error " + (saving ? "saving" : "loading")
                             + " Jalview file",
@@ -3576,7 +3576,7 @@ public class Jalview2XML
               entry.setProperty(prop.getName(), prop.getValue());
             }
             StructureSelectionManager
-                    .getStructureSelectionManager(Desktop.instance)
+                    .getStructureSelectionManager(Desktop.getInstance())
                     .registerPDBEntry(entry);
             // adds PDBEntry to datasequence's set (since Jalview 2.10)
             if (al.getSequenceAt(i).getDatasetSequence() != null)
@@ -4294,7 +4294,7 @@ public class Jalview2XML
             int height = safeInt(structureState.getHeight());
 
             // Probably don't need to do this anymore...
-            // Desktop.desktop.getComponentAt(x, y);
+            // Desktop.getDesktop().getComponentAt(x, y);
             // TODO: NOW: check that this recovers the PDB file correctly.
             String pdbFile = loadPDBFile(jprovider, pdbid.getId(),
                     pdbid.getFile());
@@ -4778,7 +4778,7 @@ public class Jalview2XML
     {
       try
       {
-        frames = Desktop.desktop.getAllFrames();
+        frames = Desktop.getDesktopPane().getAllFrames();
       } catch (ArrayIndexOutOfBoundsException e)
       {
         // occasional No such child exceptions are thrown here...
index 5f84ca0..5bbe46d 100755 (executable)
@@ -896,8 +896,7 @@ public class ResidueProperties
 
   public static String codonTranslate(String lccodon)
   {
-    String peptide = GeneticCodes.getInstance().getStandardCodeTable()
-            .translate(lccodon);
+    String peptide = GeneticCodes.getStandardCodeTable().translate(lccodon);
     if ("*".equals(peptide))
     {
       return "STOP";
index f9eb2a6..523f816 100644 (file)
@@ -54,7 +54,7 @@ public class Platform
   private static Boolean isNoJSMac = null, isNoJSWin = null, isMac = null,
           isWin = null;
 
-  private static Boolean isHeadless = null;
+  // private static Boolean isHeadless = null;
 
   /**
    * added to group mouse events into Windows and nonWindows (mac, unix, linux)
@@ -111,18 +111,18 @@ public class Platform
     return (isNoJSWin == null ? (isNoJSWin = !isJS && isWin()) : isNoJSWin);
   }
 
-  /**
-   * 
-   * @return true if we are running in non-interactive no UI mode
-   */
-  public static boolean isHeadless()
-  {
-    if (isHeadless == null)
-    {
-      isHeadless = "true".equals(System.getProperty("java.awt.headless"));
-    }
-    return isHeadless;
-  }
+  // /**
+  // *
+  // * @return true if we are running in non-interactive no UI mode
+  // */
+  // public static boolean isHeadless()
+  // {
+  // if (isHeadless == null)
+  // {
+  // isHeadless = "true".equals(System.getProperty("java.awt.headless"));
+  // }
+  // return isHeadless;
+  // }
 
   /**
    * 
index bee9fad..ec8c89c 100644 (file)
@@ -246,9 +246,9 @@ public class Discoverer implements Runnable
       // JBPNote - should do this a better way!
       if (f.getFaultReason().indexOf("(407)") > -1)
       {
-        if (jalview.gui.Desktop.desktop != null)
+        if (jalview.gui.Desktop.getDesktopPane() != null)
         {
-          JvOptionPane.showMessageDialog(jalview.gui.Desktop.desktop,
+          JvOptionPane.showMessageDialog(jalview.gui.Desktop.getDesktopPane(),
                   MessageManager.getString("label.set_proxy_settings"),
                   MessageManager
                           .getString("label.proxy_authorization_failed"),
index 3b7bdb6..3dd8104 100644 (file)
@@ -323,7 +323,7 @@ public class JPredClient extends WS1Client
 
     } catch (Exception ex)
     {
-      JvOptionPane.showMessageDialog(Desktop.desktop,
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
               MessageManager.formatMessage(
                       "label.secondary_structure_prediction_service_couldnt_be_located",
                       new String[]
index 4a09625..e97d309 100644 (file)
@@ -78,7 +78,7 @@ public class MsaWSClient extends WS1Client
     alignFrame = _alignFrame;
     if (!sh.getAbstractName().equals("MsaWS"))
     {
-      JvOptionPane.showMessageDialog(Desktop.desktop,
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
               MessageManager.formatMessage(
                       "label.service_called_is_not_msa_service",
                       new String[]
@@ -91,7 +91,7 @@ public class MsaWSClient extends WS1Client
 
     if ((wsInfo = setWebService(sh)) == null)
     {
-      JvOptionPane.showMessageDialog(Desktop.desktop, MessageManager
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), MessageManager
               .formatMessage("label.msa_service_is_unknown", new String[]
               { sh.getName() }),
               MessageManager.getString("label.internal_jalview_error"),
index 53338d3..cb965f0 100644 (file)
@@ -84,7 +84,7 @@ public class SeqSearchWSClient extends WS1Client
     // name to service client name
     if (!sh.getAbstractName().equals(this.getServiceActionKey()))
     {
-      JvOptionPane.showMessageDialog(Desktop.desktop,
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
               MessageManager.formatMessage(
                       "label.service_called_is_not_seq_search_service",
                       new String[]
@@ -97,7 +97,7 @@ public class SeqSearchWSClient extends WS1Client
 
     if ((wsInfo = setWebService(sh)) == null)
     {
-      JvOptionPane.showMessageDialog(Desktop.desktop,
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
               MessageManager.formatMessage(
                       "label.seq_search_service_is_unknown", new String[]
                       { sh.getName() }),
index 23c6949..319252a 100644 (file)
@@ -107,7 +107,7 @@ public class MsaWSClient extends Jws2Client
     if (!(sh.service instanceof MsaWS))
     {
       // redundant at mo - but may change
-      JvOptionPane.showMessageDialog(Desktop.desktop,
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
               MessageManager.formatMessage(
                       "label.service_called_is_not_msa_service",
                       new String[]
@@ -120,7 +120,7 @@ public class MsaWSClient extends Jws2Client
     server = (MsaWS) sh.service;
     if ((wsInfo = setWebService(sh, false)) == null)
     {
-      JvOptionPane.showMessageDialog(Desktop.desktop, MessageManager
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), MessageManager
               .formatMessage("label.msa_service_is_unknown", new String[]
               { sh.serviceType }),
               MessageManager.getString("label.internal_jalview_error"),
index 45bddac..9358c76 100644 (file)
@@ -67,7 +67,7 @@ public class SequenceAnnotationWSClient extends Jws2Client
     // dan changed! dan test. comment out if conditional
     // if (alignFrame.getViewport().getAlignment().isNucleotide())
     // {
-    // JvOptionPane.showMessageDialog(Desktop.desktop, sh.serviceType
+    // JvOptionPane.showMessageDialog(Desktop.getDesktop(), sh.serviceType
     // + " can only be used\nfor amino acid alignments.",
     // "Wrong type of sequences!", JvOptionPane.WARNING_MESSAGE);
     // return;
@@ -242,7 +242,7 @@ public class SequenceAnnotationWSClient extends Jws2Client
           @Override
           public void actionPerformed(ActionEvent arg0)
           {
-            Desktop.instance.showUrl(service.docUrl);
+            Desktop.getInstance().showUrl(service.docUrl);
           }
         });
         annotservice.setToolTipText(
index 2f3c298..a4e2e75 100644 (file)
@@ -186,7 +186,7 @@ public class Jws2Instance
       try
       {
         paramStore = new JabaParamStore(this,
-                (Desktop.instance != null ? Desktop.getUserParameterStore()
+                (Desktop.getInstance() != null ? Desktop.getUserParameterStore()
                         : null));
       } catch (Exception ex)
       {
index a71b70d..08f137d 100644 (file)
@@ -329,7 +329,7 @@ public class RestClient extends WSClient
     else
     {
       // TODO: try to tell the user why the job couldn't be started.
-      JvOptionPane.showMessageDialog(Desktop.desktop,
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
               (jobsthread.hasWarnings() ? jobsthread.getWarnings()
                       : MessageManager.getString(
                               "label.job_couldnt_be_started_check_input")),
index 27ae8cd..631b535 100644 (file)
@@ -139,8 +139,8 @@ public class DnaTest
     Iterator<int[]> contigs = cs.getVisContigsIterator(0, alf.getWidth(),
             false);
     Dna dna = new Dna(av, contigs);
-    AlignmentI translated = dna.translateCdna(GeneticCodes.getInstance()
-            .getStandardCodeTable());
+    AlignmentI translated = dna
+            .translateCdna(GeneticCodes.getStandardCodeTable());
     assertNotNull("Couldn't do a full width translation of test data.",
             translated);
   }
@@ -171,8 +171,8 @@ public class DnaTest
               alf.getWidth(), false);
       AlignViewportI av = new AlignViewport(alf, cs);
       Dna dna = new Dna(av, vcontigs);
-      AlignmentI transAlf = dna.translateCdna(GeneticCodes.getInstance()
-              .getStandardCodeTable());
+      AlignmentI transAlf = dna
+              .translateCdna(GeneticCodes.getStandardCodeTable());
 
       assertTrue("Translation failed (ipos=" + ipos
               + ") No alignment data.", transAlf != null);
@@ -199,8 +199,8 @@ public class DnaTest
     Iterator<int[]> contigs = cs.getVisContigsIterator(0, alf.getWidth(),
             false);
     Dna dna = new Dna(av, contigs);
-    AlignmentI translated = dna.translateCdna(GeneticCodes.getInstance()
-            .getStandardCodeTable());
+    AlignmentI translated = dna
+            .translateCdna(GeneticCodes.getStandardCodeTable());
     String aa = translated.getSequenceAt(0).getSequenceAsString();
     assertEquals(
             "AAAACCDDEEFFGGGGHHIIIKKLLLLLLMNNPPPPQQRRRRRRSSSSSSTTTTVVVVWYY***",
@@ -225,8 +225,8 @@ public class DnaTest
     Iterator<int[]> contigs = cs.getVisContigsIterator(0, alf.getWidth(),
             false);
     Dna dna = new Dna(av, contigs);
-    AlignmentI translated = dna.translateCdna(GeneticCodes.getInstance()
-            .getStandardCodeTable());
+    AlignmentI translated = dna
+            .translateCdna(GeneticCodes.getStandardCodeTable());
     String aa = translated.getSequenceAt(0).getSequenceAsString();
     assertEquals("AACDDGGGGHHIIIKKLLLLLLMNNPPPPQQRRRRRRSSSSSSTTTTVVVVW", aa);
   }
@@ -313,8 +313,8 @@ public class DnaTest
     Iterator<int[]> contigs = cs.getVisContigsIterator(0, cdna.getWidth(),
             false);
     Dna dna = new Dna(av, contigs);
-    AlignmentI translated = dna.translateCdna(GeneticCodes.getInstance()
-            .getStandardCodeTable());
+    AlignmentI translated = dna
+            .translateCdna(GeneticCodes.getStandardCodeTable());
 
     /*
      * Jumble the cDNA sequences and translate.
@@ -330,8 +330,8 @@ public class DnaTest
     av = new AlignViewport(cdnaReordered, cs);
     contigs = cs.getVisContigsIterator(0, cdna.getWidth(), false);
     dna = new Dna(av, contigs);
-    AlignmentI translated2 = dna.translateCdna(GeneticCodes.getInstance()
-            .getStandardCodeTable());
+    AlignmentI translated2 = dna
+            .translateCdna(GeneticCodes.getStandardCodeTable());
 
     /*
      * Check translated sequences are the same in both alignments.
index e451ed2..7ef0d16 100644 (file)
@@ -74,7 +74,7 @@ public class JmolViewerTest
   @AfterClass(alwaysRun = true)
   public static void tearDownAfterClass() throws Exception
   {
-    jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
+    jalview.gui.Desktop.getInstance().closeAll_actionPerformed(null);
   }
 
   @Test(groups = { "Functional" })
index 734f7eb..194d34a 100644 (file)
@@ -95,7 +95,7 @@ public class JalviewChimeraView
   @AfterClass(alwaysRun = true)
   public static void tearDownAfterClass() throws Exception
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
   }
 
   @AfterMethod(alwaysRun = true)
index 454ff61..fd10d99 100644 (file)
@@ -164,7 +164,7 @@ public class AlignFrameTest
   @AfterMethod(alwaysRun = true)
   public void tearDown()
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
   }
 
   /**
index 959abb0..75e8065 100644 (file)
@@ -80,7 +80,7 @@ public class AlignViewportTest
      * remove any sequence mappings left lying around by other tests
      */
     StructureSelectionManager ssm = StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance);
+            .getStructureSelectionManager(Desktop.getInstance());
     ssm.resetAll();
   }
 
@@ -128,7 +128,7 @@ public class AlignViewportTest
      * mappings
      */
     StructureSelectionManager ssm = StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance);
+            .getStructureSelectionManager(Desktop.getInstance());
     List<AlignedCodonFrame> sequenceMappings = ssm.getSequenceMappings();
     assertEquals(2, sequenceMappings.size());
     assertTrue(sequenceMappings.contains(acf1));
@@ -150,10 +150,10 @@ public class AlignViewportTest
   @Test(groups = { "Functional" })
   public void testDeregisterMapping_withNoReference()
   {
-    Desktop d = Desktop.instance;
+    Desktop d = Desktop.getInstance();
     assertNotNull(d);
     StructureSelectionManager ssm = StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance);
+            .getStructureSelectionManager(Desktop.getInstance());
     ssm.resetAll();
 
     AlignFrame af1 = new FileLoader().LoadFileWaitTillLoaded(
@@ -213,10 +213,10 @@ public class AlignViewportTest
   @Test(groups = { "Functional" })
   public void testDeregisterMapping_withReference()
   {
-    Desktop d = Desktop.instance;
+    Desktop d = Desktop.getInstance();
     assertNotNull(d);
     StructureSelectionManager ssm = StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance);
+            .getStructureSelectionManager(Desktop.getInstance());
     ssm.resetAll();
 
     AlignFrame af1 = new FileLoader().LoadFileWaitTillLoaded(
index 9b21274..ee2b898 100644 (file)
@@ -70,7 +70,7 @@ public class FreeUpMemoryTest
 
     doStuffInJalview(f);
 
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
 
     checkUsedMemory(35L);
   }
@@ -109,7 +109,7 @@ public class FreeUpMemoryTest
      * sanity check - fails if any frame was added after
      * closeAll_actionPerformed
      */
-    assertEquals(Desktop.instance.getAllFrames().length, 0);
+    assertEquals(Desktop.getInstance().getAllFrames().length, 0);
 
     /*
      * if this assertion fails
index 6783514..54c967f 100644 (file)
@@ -252,7 +252,7 @@ public class SeqPanelTest
   @AfterMethod(alwaysRun = true)
   public void tearDown()
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
   }
 
   @Test(groups = "Functional")
index 8eb3796..b8ac0fa 100644 (file)
@@ -207,7 +207,7 @@ public class AnnotatedPDBFileInputTest
   @AfterClass(alwaysRun = true)
   public static void tearDownAfterClass() throws Exception
   {
-    jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
+    jalview.gui.Desktop.getInstance().closeAll_actionPerformed(null);
 
   }
 
index 6e4593d..daadfa5 100644 (file)
@@ -135,7 +135,7 @@ public class CrossRef2xmlTests extends Jalview2xmlBase
       {
         // retrieve dbref
 
-        SequenceFetcher sf = new SequenceFetcher(Desktop.instance,
+        SequenceFetcher sf = new SequenceFetcher(Desktop.getInstance(),
                 forSource, forAccession);
         sf.run();
         AlignFrame[] afs = Desktop.getAlignFrames();
@@ -162,7 +162,7 @@ public class CrossRef2xmlTests extends Jalview2xmlBase
       }
       else
       {
-        Desktop.instance.closeAll_actionPerformed(null);
+        Desktop.getInstance().closeAll_actionPerformed(null);
         // recover stored project
         af = new FileLoader(false).LoadFileWaitTillLoaded(
                 savedProjects.get(first).toString(), DataSourceType.FILE);
@@ -229,7 +229,7 @@ public class CrossRef2xmlTests extends Jalview2xmlBase
           }
           else
           {
-            Desktop.instance.closeAll_actionPerformed(null);
+            Desktop.getInstance().closeAll_actionPerformed(null);
             pass3 = 0;
             // recover stored project
             File storedProject = savedProjects.get(nextxref);
@@ -340,7 +340,7 @@ public class CrossRef2xmlTests extends Jalview2xmlBase
                 }
                 else
                 {
-                  Desktop.instance.closeAll_actionPerformed(null);
+                  Desktop.getInstance().closeAll_actionPerformed(null);
                   // recover stored project
                   File storedProject = savedProjects.get(nextnextxref);
                   if (storedProject == null)
index 77c18db..fdef53d 100644 (file)
@@ -71,7 +71,7 @@ public class FeaturesFileTest
      * remove any sequence mappings created so they don't pollute other tests
      */
     StructureSelectionManager ssm = StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance);
+            .getStructureSelectionManager(Desktop.getInstance());
     ssm.resetAll();
   }
 
index fbdd782..3a0560c 100644 (file)
@@ -70,16 +70,16 @@ public class Jalview2xmlBase
   @AfterClass(alwaysRun = true)
   public static void tearDownAfterClass() throws Exception
   {
-    jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
+    jalview.gui.Desktop.getInstance().closeAll_actionPerformed(null);
   }
 
   @BeforeTest(alwaysRun = true)
   public static void clearDesktop()
   {
-    if (Desktop.instance != null && Desktop.getFrames() != null
+    if (Desktop.getInstance() != null && Desktop.getFrames() != null
             && Desktop.getFrames().length > 0)
     {
-      Desktop.instance.closeAll_actionPerformed(null);
+      Desktop.getInstance().closeAll_actionPerformed(null);
     }
   }
 
index 06d177d..1614453 100644 (file)
@@ -63,7 +63,7 @@ public class JalviewExportPropertiesTests
   @AfterClass(alwaysRun = true)
   public static void tearDownAfterClass() throws Exception
   {
-    jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
+    jalview.gui.Desktop.getInstance().closeAll_actionPerformed(null);
 
   }
 
index e9221e0..830a759 100644 (file)
@@ -405,7 +405,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" }, enabled = true)
   public void testStoreAndRecoverExpandedviews() throws Exception
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
 
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/exampleFile_2_7.jar", DataSourceType.FILE);
@@ -433,7 +433,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the expanded view state", e);
     }
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     if (Desktop.getAlignFrames() != null)
     {
       Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@@ -459,7 +459,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverReferenceSeqSettings() throws Exception
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/exampleFile_2_7.jar", DataSourceType.FILE);
     assertNotNull(af, "Didn't read in the example file correctly.");
@@ -498,7 +498,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the expanded view state", e);
     }
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     if (Desktop.getAlignFrames() != null)
     {
       Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@@ -592,7 +592,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverGroupRepSeqs() throws Exception
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/uniref50.fa", DataSourceType.FILE);
     assertNotNull(af, "Didn't read in the example file correctly.");
@@ -667,7 +667,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the expanded view state", e);
     }
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     if (Desktop.getAlignFrames() != null)
     {
       Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@@ -712,7 +712,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverPDBEntry() throws Exception
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     String exampleFile = "examples/3W5V.pdb";
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(exampleFile,
             DataSourceType.FILE);
@@ -761,7 +761,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the state", e);
     }
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     if (Desktop.getAlignFrames() != null)
     {
       Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@@ -812,7 +812,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverColourThresholds() throws IOException
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/uniref50.fa", DataSourceType.FILE);
 
@@ -872,7 +872,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
             ".jvp");
     tfile.deleteOnExit();
     new Jalview2XML(false).saveState(tfile);
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
             DataSourceType.FILE);
     Assert.assertNotNull(af, "Failed to reload project");
@@ -1081,7 +1081,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testMergeDatasetsforManyViews() throws IOException
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
 
     // complex project - one dataset, several views on several alignments
     AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
@@ -1125,7 +1125,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = "Functional")
   public void testPcaViewAssociation() throws IOException
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     final String PCAVIEWNAME = "With PCA";
     // create a new tempfile
     File tempfile = File.createTempFile("jvPCAviewAssoc", "jvp");
@@ -1159,10 +1159,10 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     }
 
     // load again.
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             tempfile.getCanonicalPath(), DataSourceType.FILE);
-    JInternalFrame[] frames = Desktop.instance.getAllFrames();
+    JInternalFrame[] frames = Desktop.getInstance().getAllFrames();
     // PCA and the tabbed alignment view should be the only two windows on the
     // desktop
     assertEquals(frames.length, 2,
index 5db3743..06be31e 100644 (file)
@@ -172,7 +172,7 @@ public class ColourSchemesTest
   @AfterClass(alwaysRun = true)
   public static void tearDownAfterClass() throws Exception
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
   }
 
   @Test(groups = "Functional")
index e59648f..dab692f 100644 (file)
@@ -199,7 +199,7 @@ public class StructureSelectionManagerTest extends Jalview2xmlBase
   {
     // for some reason 'BeforeMethod' (which should be inherited from
     // Jalview2XmlBase isn't always called)...
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     try { 
       Thread.sleep(200);
     } catch (Exception foo) {};