JAL-3446 from JAL-3253 ApplicationSingletonProvider Desktop
authorBobHanson <hansonr@stolaf.edu>
Wed, 3 Jun 2020 00:29:28 +0000 (19:29 -0500)
committerBobHanson <hansonr@stolaf.edu>
Wed, 3 Jun 2020 00:29:28 +0000 (19:29 -0500)
67 files changed:
src/jalview/bin/Jalview.java
src/jalview/datamodel/features/FeatureAttributes.java
src/jalview/datamodel/features/FeatureSources.java
src/jalview/fts/service/pdb/PDBFTSRestClient.java
src/jalview/fts/service/uniprot/UniProtFTSRestClient.java
src/jalview/gui/AlignExportOptions.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/AppJmol.java
src/jalview/gui/AssociatePdbFileWithSeq.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/VamsasAppDatastore.java
src/jalview/io/WSWUBlastClient.java
src/jalview/io/vamsas/Sequencemapping.java
src/jalview/jbgui/GDesktop.java
src/jalview/jbgui/GPreferences.java
src/jalview/jbgui/GSequenceLink.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/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

index a3f934c..963963d 100755 (executable)
@@ -52,6 +52,7 @@ import jalview.api.AlignCalcWorkerI;
 import jalview.api.AlignViewportI;
 import jalview.api.JalviewApp;
 import jalview.api.StructureSelectionManagerProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.PDBEntry;
@@ -105,8 +106,35 @@ import netscape.javascript.JSObject;
  * @author $author$
  * @version $Revision$
  */
-public class Jalview implements JalviewJSApi
+public class Jalview implements ApplicationSingletonI, JalviewJSApi
 {
+
+  // for testing those nasty messages you cannot ever find.
+  // static
+  // {
+  // System.setOut(new PrintStream(new ByteArrayOutputStream())
+  // {
+  // @Override
+  // public void println(Object o)
+  // {
+  // if (o != null)
+  // {
+  // System.err.println(o);
+  // }
+  // }
+  //
+  // });
+  // }
+  public static Jalview getInstance()
+  {
+    return (Jalview) ApplicationSingletonProvider
+            .getInstance(Jalview.class);
+  }
+
+  private Jalview()
+  {
+  }
+
   static
   {
     Platform.getURLCommandArguments();
@@ -114,10 +142,6 @@ public class Jalview implements JalviewJSApi
 
   private boolean headless;
 
-  // singleton instance of this class
-
-  private static Jalview instance;
-
   private Desktop desktop;
 
   public static AlignFrame currentAlignFrame;
@@ -241,12 +265,6 @@ public class Jalview implements JalviewJSApi
 
   }
 
-  public static Jalview getInstance()
-  {
-    return instance;
-  }
-  
-  
   private final static boolean doPlatformLogging = false;
 
   /**
@@ -261,9 +279,7 @@ public class Jalview implements JalviewJSApi
     {
       Platform.startJavaLogging();
     }
-
-    instance = new Jalview();
-    instance.doMain(args);
+    getInstance().doMain(args);
   }
 
   /**
@@ -472,9 +488,8 @@ public class Jalview implements JalviewJSApi
 
     if (!headless)
     {
-      desktop = new Desktop();
+      desktop = Desktop.getInstance();
       desktop.setInBatchMode(true); // indicate we are starting up
-
       try
       {
         JalviewTaskbar.setTaskbar(this);
@@ -482,7 +497,6 @@ public class Jalview implements JalviewJSApi
       {
         System.out.println("Error setting Taskbar: " + t.getMessage());
       }
-
       desktop.setVisible(true);
 
       if (!Platform.isJS())
@@ -819,8 +833,7 @@ public class Jalview implements JalviewJSApi
             }
           }
         }
-        
-        
+
         if (aparser.contains(ArgsParser.NOSORTBYTREE))
         {
           af.getViewport().setSortByTree(false);
@@ -887,8 +900,7 @@ public class Jalview implements JalviewJSApi
         }
       }
     }
-    
-    
+
     AlignFrame startUpAlframe = null;
     // We'll only open the default file if the desktop is visible.
     // And the user
@@ -940,7 +952,7 @@ public class Jalview implements JalviewJSApi
               format);
 
     }
-    
+
     // extract groovy arguments before anything else.
     // Once all other stuff is done, execute any groovy scripts (in order)
     if (groovyscript != null)
@@ -1118,7 +1130,7 @@ public class Jalview implements JalviewJSApi
     /**
      * start a User Config prompt asking if we can log usage statistics.
      */
-    PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
+    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 ?"
@@ -1471,15 +1483,15 @@ public class Jalview implements JalviewJSApi
                 : jsExecQueue);
       }
 
-// AppletContext deprecated 
-//
-//      @Override
-//      public AppletContext getAppletContext()
-//      {
-//        // TODO Auto-generated method stub
-//        return null;
-//      }
-//
+      // AppletContext deprecated
+      //
+      // @Override
+      // public AppletContext getAppletContext()
+      // {
+      // // TODO Auto-generated method stub
+      // return null;
+      // }
+      //
       @Override
       public boolean isJsfallbackEnabled()
       {
index bcf404b..01f04d5 100644 (file)
@@ -29,17 +29,24 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.TreeMap;
 
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
+
 /**
  * A singleton class to hold the set of attributes known for each feature type
  */
-public class FeatureAttributes
+public class FeatureAttributes implements ApplicationSingletonI
 {
   public enum Datatype
   {
     Character, Number, Mixed
   }
 
-  private static FeatureAttributes instance = new FeatureAttributes();
+  public static FeatureAttributes getInstance()
+  {
+    return (FeatureAttributes) ApplicationSingletonProvider
+            .getInstance(FeatureAttributes.class);
+  }
 
   /*
    * map, by feature type, of a map, by attribute name, of
@@ -192,16 +199,6 @@ public class FeatureAttributes
     }
   }
 
-  /**
-   * Answers the singleton instance of this class
-   * 
-   * @return
-   */
-  public static FeatureAttributes getInstance()
-  {
-    return instance;
-  }
-
   private FeatureAttributes()
   {
     attributes = new HashMap<>();
index b316821..4a87349 100644 (file)
@@ -23,6 +23,9 @@ package jalview.datamodel.features;
 import java.util.HashMap;
 import java.util.Map;
 
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
+
 /**
  * A singleton to hold metadata about feature attributes, keyed by a unique
  * feature source identifier
@@ -30,22 +33,17 @@ import java.util.Map;
  * @author gmcarstairs
  *
  */
-public class FeatureSources
+public class FeatureSources implements ApplicationSingletonI
 {
-  private static FeatureSources instance = new FeatureSources();
-
-  private Map<String, FeatureSourceI> sources;
 
-  /**
-   * Answers the singleton instance of this class
-   * 
-   * @return
-   */
   public static FeatureSources getInstance()
   {
-    return instance;
+    return (FeatureSources) ApplicationSingletonProvider
+            .getInstance(FeatureSources.class);
   }
 
+  private Map<String, FeatureSourceI> sources;
+
   private FeatureSources()
   {
     sources = new HashMap<>();
index 22ed591..c6860cc 100644 (file)
@@ -37,6 +37,8 @@ import com.sun.jersey.api.client.ClientResponse;
 import com.sun.jersey.api.client.WebResource;
 import com.sun.jersey.api.client.config.DefaultClientConfig;
 
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
 import jalview.datamodel.SequenceI;
 import jalview.fts.api.FTSData;
 import jalview.fts.api.FTSDataColumnI;
@@ -53,13 +55,16 @@ import jalview.util.Platform;
  * 
  * @author tcnofoegbu
  */
-public class PDBFTSRestClient extends FTSRestClient
+public class PDBFTSRestClient extends FTSRestClient implements ApplicationSingletonI
 {
-
-  private static FTSRestClientI instance = null;
-
   public static final String PDB_SEARCH_ENDPOINT = "https://www.ebi.ac.uk/pdbe/search/pdb/select?";
 
+  public static FTSRestClientI getInstance()
+  {
+    return (FTSRestClientI) ApplicationSingletonProvider
+            .getInstance(PDBFTSRestClient.class);
+  }
+
   protected PDBFTSRestClient()
   {
   }
@@ -458,15 +463,6 @@ public static String parseJsonExceptionString(String jsonErrorResponse)
     return "/fts/pdb_data_columns.txt";
   }
 
-  public static FTSRestClientI getInstance()
-  {
-    if (instance == null)
-    {
-      instance = new PDBFTSRestClient();
-    }
-    return instance;
-  }
-
   private Collection<FTSDataColumnI> allDefaultDisplayedStructureDataColumns;
 
   public Collection<FTSDataColumnI> getAllDefaultDisplayedStructureDataColumns()
index 3f0b8a4..f227d58 100644 (file)
@@ -21,6 +21,8 @@
 
 package jalview.fts.service.uniprot;
 
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
 import jalview.bin.Cache;
 import jalview.fts.api.FTSData;
 import jalview.fts.api.FTSDataColumnI;
@@ -44,7 +46,15 @@ import com.sun.jersey.api.client.WebResource;
 import com.sun.jersey.api.client.config.DefaultClientConfig;
 
 public class UniProtFTSRestClient extends FTSRestClient
+implements ApplicationSingletonI
 {
+
+public static FTSRestClientI getInstance()
+{
+return (FTSRestClientI) ApplicationSingletonProvider
+    .getInstance(UniProtFTSRestClient.class);
+}
+
   private static final String DEFAULT_UNIPROT_DOMAIN = "https://www.uniprot.org";
 
   static
@@ -52,8 +62,6 @@ public class UniProtFTSRestClient extends FTSRestClient
     Platform.addJ2SDirectDatabaseCall(DEFAULT_UNIPROT_DOMAIN);
   }
 
-  private static FTSRestClientI instance = null;
-
   public final String uniprotSearchEndpoint;
 
   public UniProtFTSRestClient()
@@ -347,15 +355,6 @@ public class UniProtFTSRestClient extends FTSRestClient
     };
   }
 
-  public static FTSRestClientI getInstance()
-  {
-    if (instance == null)
-    {
-      instance = new UniProtFTSRestClient();
-    }
-    return instance;
-  }
-
   @Override
   public String getColumnDataConfigFileName()
   {
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 a7018c3..93713d2 100644 (file)
@@ -393,7 +393,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())
@@ -816,7 +816,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
@@ -847,7 +847,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);
       }
@@ -1028,7 +1028,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
@@ -1042,7 +1042,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
@@ -1052,14 +1052,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:")
@@ -1117,14 +1117,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
@@ -1168,7 +1168,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"),
@@ -1943,7 +1943,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);
@@ -2443,7 +2443,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") };
@@ -2917,7 +2917,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   public void gatherViews_actionPerformed(ActionEvent e)
   {
-    Desktop.instance.gatherViews(this);
+    Desktop.getInstance().gatherViews(this);
   }
 
   /**
@@ -3727,7 +3727,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(
@@ -4050,7 +4050,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);
@@ -4058,7 +4058,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"),
@@ -4447,7 +4447,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;
     }
@@ -4457,7 +4457,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
@@ -4673,7 +4673,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 : "
@@ -4784,7 +4784,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")
@@ -4881,7 +4881,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                       + (format != null
                               ? "(parsing as '" + format + "' file)"
                               : ""),
-              oom, Desktop.desktop);
+              oom, Desktop.getDesktopPane());
     }
   }
 
@@ -5756,7 +5756,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 1849447..a5c899a 100644 (file)
@@ -394,7 +394,7 @@ f   */
     if (align != null)
     {
       StructureSelectionManager ssm = StructureSelectionManager
-              .getStructureSelectionManager(Desktop.instance);
+              .getStructureSelectionManager(Desktop.getInstance());
       ssm.registerMappings(align.getCodonFrames());
     }
 
@@ -416,7 +416,7 @@ f   */
       if (mappings != null)
       {
         StructureSelectionManager ssm = StructureSelectionManager
-                .getStructureSelectionManager(Desktop.instance);
+                .getStructureSelectionManager(Desktop.getInstance());
         for (AlignedCodonFrame acf : mappings)
         {
           if (noReferencesTo(acf))
@@ -542,7 +542,7 @@ f   */
   public void sendSelection()
   {
     jalview.structure.StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance)
+            .getStructureSelectionManager(Desktop.getInstance())
             .sendSelection(new SequenceGroup(getSelectionGroup()),
                     new ColumnSelection(getColumnSelection()),
                     new HiddenColumns(getAlignment().getHiddenColumns()),
@@ -588,7 +588,7 @@ f   */
   public StructureSelectionManager getStructureSelectionManager()
   {
     return StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance);
+            .getStructureSelectionManager(Desktop.getInstance());
   }
 
   @Override
@@ -780,7 +780,7 @@ f   */
      * 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(NO_SPLIT, new Runnable()
             {
               @Override
index 5a681f1..27dcebf 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 e13df4a..afb727f 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 c6d6e97..317eff5 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 43d7015..e38b55b 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 2ada4d2..cc25696 100644 (file)
@@ -454,7 +454,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 a894910..5df48a2 100644 (file)
@@ -94,6 +94,9 @@ import org.stackoverflowusers.file.WindowsShortcut;
 
 import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
+import jalview.api.StructureSelectionManagerProvider;
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
 import jalview.bin.Cache;
 import jalview.bin.Jalview;
 import jalview.gui.ImageExporter.ImageWriterI;
@@ -108,6 +111,7 @@ import jalview.io.FormatAdapter;
 import jalview.io.IdentifyFile;
 import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
+import jalview.jbgui.GDesktop;
 import jalview.jbgui.GSplitFrame;
 import jalview.jbgui.GStructureViewer;
 import jalview.project.Jalview2XML;
@@ -130,9 +134,11 @@ import jalview.ws.utils.UrlDownloadClient;
  * @author $author$
  * @version $Revision: 1.155 $
  */
-public class Desktop extends jalview.jbgui.GDesktop
+@SuppressWarnings("serial")
+public class Desktop extends GDesktop
         implements DropTargetListener, ClipboardOwner, IProgressIndicator,
-        jalview.api.StructureSelectionManagerProvider
+        StructureSelectionManagerProvider, ApplicationSingletonI
+
 {
   private static final String CITATION = "<br><br>Development managed by The Barton Group, University of Dundee, Scotland, UK.<br>"
           + "<br><br>For help, see the FAQ at <a href=\"http://www.jalview.org/faq\">www.jalview.org/faq</a> and/or join the jalview-discuss@jalview.org mailing list"
@@ -201,26 +207,26 @@ public class Desktop extends jalview.jbgui.GDesktop
             listener);
   }
 
-  /** Singleton Desktop instance */
-  public static Desktop instance;
+  private MyDesktopPane desktopPane;
+
+  public static MyDesktopPane getDesktopPane()
+  {
+    Desktop desktop = getInstance();
+    return desktop == null ? null : desktop.desktopPane;
+  }
 
   /**
-   * BH TEMPORARY ONLY -- should use ApplicationSingleton
+   * Answers an 'application scope' singleton instance of this class. Separate
+   * SwingJS 'applets' running in the same browser page will each have a
+   * distinct instance of Desktop.
    * 
    * @return
    */
   public static Desktop getInstance()
   {
-    return instance;
-  }
-
-  public static MyDesktopPane desktop;
-
-  public static MyDesktopPane getDesktopPane()
-  {
-    // BH 2018 could use currentThread() here as a reference to a
-    // Hashtable<Thread, MyDesktopPane> in JavaScript
-    return desktop;
+    return Jalview.isHeadlessMode() ? null
+            : (Desktop) ApplicationSingletonProvider
+                    .getInstance(Desktop.class);
   }
 
   public static StructureSelectionManager getStructureSelectionManager()
@@ -262,7 +268,7 @@ public class Desktop extends jalview.jbgui.GDesktop
       } catch (NullPointerException npe)
       {
         Point p = getMousePosition();
-        instance.showPasteMenu(p.x, p.y);
+        showPasteMenu(p.x, p.y);
       }
     }
 
@@ -310,14 +316,14 @@ public class Desktop extends jalview.jbgui.GDesktop
     public void endDraggingFrame(JComponent f)
     {
       delegate.endDraggingFrame(f);
-      desktop.repaint();
+      desktopPane.repaint();
     }
 
     @Override
     public void endResizingFrame(JComponent f)
     {
       delegate.endResizingFrame(f);
-      desktop.repaint();
+      desktopPane.repaint();
     }
 
     @Override
@@ -367,190 +373,195 @@ public class Desktop extends jalview.jbgui.GDesktop
   }
 
   /**
-   * Creates a new Desktop object.
+   * Private constructor enforces singleton pattern. It is called by reflection
+   * from ApplicationSingletonProvider.getInstance().
    */
-  public Desktop()
+  private Desktop()
   {
-    super();
-    /**
-     * A note to implementors. It is ESSENTIAL that any activities that might
-     * block are spawned off as threads rather than waited for during this
-     * constructor.
-     */
-    instance = this;
-
-    doConfigureStructurePrefs();
-    setTitle("Jalview " + Cache.getProperty("VERSION"));
-    /*
-    if (!Platform.isAMac())
-    {
-      // this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
-    }
-    else
-    {
-     this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
-    }
-    */
-
+    Cache.initLogger();
     try
     {
-      APQHandlers.setAPQHandlers(this);
-    } catch (Throwable t)
-    {
-      System.out.println("Error setting APQHandlers: " + t.toString());
-      // t.printStackTrace();
-    }
+      /**
+       * A note to implementors. It is ESSENTIAL that any activities that might
+       * block are spawned off as threads rather than waited for during this
+       * constructor.
+       */
 
-    addWindowListener(new WindowAdapter()
-    {
+      doConfigureStructurePrefs();
+      setTitle("Jalview " + Cache.getProperty("VERSION"));
+      /*
+      if (!Platform.isAMac())
+      {
+      // this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+      }
+      else
+      {
+       this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+      }
+      */
 
-      @Override
-      public void windowClosing(WindowEvent ev)
+      try
       {
-        quit();
+        APQHandlers.setAPQHandlers(this);
+      } catch (Throwable t)
+      {
+        System.out.println("Error setting APQHandlers: " + t.toString());
+        // t.printStackTrace();
       }
-    });
 
-    boolean selmemusage = Cache.getDefault("SHOW_MEMUSAGE",
-            false);
+      addWindowListener(new WindowAdapter()
+      {
 
-    boolean showjconsole = Cache.getDefault("SHOW_JAVA_CONSOLE",
-            false);
-    desktop = new MyDesktopPane(selmemusage);
+        @Override
+        public void windowClosing(WindowEvent ev)
+        {
+          quit();
+        }
+      });
 
-    showMemusage.setSelected(selmemusage);
-    desktop.setBackground(Color.white);
+      boolean selmemusage = Cache.getDefault("SHOW_MEMUSAGE", false);
 
-    getContentPane().setLayout(new BorderLayout());
-    // alternate config - have scrollbars - see notes in JAL-153
-    // JScrollPane sp = new JScrollPane();
-    // sp.getViewport().setView(desktop);
-    // getContentPane().add(sp, BorderLayout.CENTER);
+      boolean showjconsole = Cache.getDefault("SHOW_JAVA_CONSOLE", false);
+      desktopPane = new MyDesktopPane(selmemusage);
 
-    // BH 2018 - just an experiment to try unclipped JInternalFrames.
-    if (Platform.isJS())
-    {
-      getRootPane().putClientProperty("swingjs.overflow.hidden", "false");
-    }
+      showMemusage.setSelected(selmemusage);
+      desktopPane.setBackground(Color.white);
 
-    getContentPane().add(desktop, BorderLayout.CENTER);
-    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
+      getContentPane().setLayout(new BorderLayout());
+      // alternate config - have scrollbars - see notes in JAL-153
+      // JScrollPane sp = new JScrollPane();
+      // sp.getViewport().setView(desktop);
+      // getContentPane().add(sp, BorderLayout.CENTER);
 
-    // This line prevents Windows Look&Feel resizing all new windows to maximum
-    // if previous window was maximised
-    desktop.setDesktopManager(new MyDesktopManager(
-            (Platform.isWindowsAndNotJS() ? new DefaultDesktopManager()
-                    : Platform.isAMacAndNotJS()
-                            ? new AquaInternalFrameManager(
-                                    desktop.getDesktopManager())
-                            : desktop.getDesktopManager())));
+      // BH 2018 - just an experiment to try unclipped JInternalFrames.
+      if (Platform.isJS())
+      {
+        getRootPane().putClientProperty("swingjs.overflow.hidden", "false");
+      }
 
-    Rectangle dims = getLastKnownDimensions("");
-    if (dims != null)
-    {
-      setBounds(dims);
-    }
-    else
-    {
-      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
-      int xPos = Math.max(5, (screenSize.width - 900) / 2);
-      int yPos = Math.max(5, (screenSize.height - 650) / 2);
-      setBounds(xPos, yPos, 900, 650);
-    }
+      getContentPane().add(desktopPane, BorderLayout.CENTER);
+      desktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
 
-    if (!Platform.isJS())
-    /**
-     * Java only
-     * 
-     * @j2sIgnore
-     */
-    {
-      jconsole = new Console(this, showjconsole);
-      jconsole.setHeader(Cache.getVersionDetailsForConsole());
-      showConsole(showjconsole);
+      // This line prevents Windows Look&Feel resizing all new windows to
+      // maximum
+      // if previous window was maximised
+      desktopPane.setDesktopManager(new MyDesktopManager(
+              (Platform.isWindowsAndNotJS() ? new DefaultDesktopManager()
+                      : Platform.isAMacAndNotJS()
+                              ? new AquaInternalFrameManager(
+                                      desktopPane.getDesktopManager())
+                              : desktopPane.getDesktopManager())));
+
+      Rectangle dims = getLastKnownDimensions("");
+      if (dims != null)
+      {
+        setBounds(dims);
+      }
+      else
+      {
+        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+        int xPos = Math.max(5, (screenSize.width - 900) / 2);
+        int yPos = Math.max(5, (screenSize.height - 650) / 2);
+        setBounds(xPos, yPos, 900, 650);
+      }
+
+      if (!Platform.isJS())
+      /**
+       * Java only
+       * 
+       * @j2sIgnore
+       */
+      {
+        jconsole = new Console(this, showjconsole);
+        jconsole.setHeader(Cache.getVersionDetailsForConsole());
+        showConsole(showjconsole);
 
-      showNews.setVisible(false);
+        showNews.setVisible(false);
 
-      experimentalFeatures.setSelected(showExperimental());
+        experimentalFeatures.setSelected(showExperimental());
 
-      getIdentifiersOrgData();
+        getIdentifiersOrgData();
 
-      checkURLLinks();
+        checkURLLinks();
 
-      // Spawn a thread that shows the splashscreen
+        // Spawn a thread that shows the splashscreen
 
-      SwingUtilities.invokeLater(new Runnable()
-      {
-        @Override
-        public void run()
+        SwingUtilities.invokeLater(new Runnable()
         {
-          new SplashScreen(true);
-        }
-      });
+          @Override
+          public void run()
+          {
+            new SplashScreen(true);
+          }
+        });
 
-      // Thread off a new instance of the file chooser - this reduces the time
-      // it
-      // takes to open it later on.
-      new Thread(new Runnable()
-      {
-        @Override
-        public void run()
+        // Thread off a new instance of the file chooser - this reduces the time
+        // it
+        // takes to open it later on.
+        new Thread(new Runnable()
         {
-          Cache.log.debug("Filechooser init thread started.");
-          String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
-          JalviewFileChooser.forRead(Cache.getProperty("LAST_DIRECTORY"),
-                  fileFormat);
-          Cache.log.debug("Filechooser init thread finished.");
-        }
-      }).start();
-      // Add the service change listener
-      changeSupport.addJalviewPropertyChangeListener("services",
-              new PropertyChangeListener()
-              {
-
-                @Override
-                public void propertyChange(PropertyChangeEvent evt)
+          @Override
+          public void run()
+          {
+            Cache.log.debug("Filechooser init thread started.");
+            String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
+            JalviewFileChooser.forRead(Cache.getProperty("LAST_DIRECTORY"),
+                    fileFormat);
+            Cache.log.debug("Filechooser init thread finished.");
+          }
+        }).start();
+        // Add the service change listener
+        changeSupport.addJalviewPropertyChangeListener("services",
+                new PropertyChangeListener()
                 {
-                  Cache.log.debug("Firing service changed event for "
-                          + evt.getNewValue());
-                  JalviewServicesChanged(evt);
-                }
-              });
-    }
 
-    this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this));
-
-    this.addWindowListener(new WindowAdapter()
-    {
-      @Override
-      public void windowClosing(WindowEvent evt)
-      {
-        quit();
+                  @Override
+                  public void propertyChange(PropertyChangeEvent evt)
+                  {
+                    Cache.log.debug("Firing service changed event for "
+                            + evt.getNewValue());
+                    JalviewServicesChanged(evt);
+                  }
+                });
       }
-    });
 
-    MouseAdapter ma;
-    this.addMouseListener(ma = new MouseAdapter()
-    {
-      @Override
-      public void mousePressed(MouseEvent evt)
+      this.setDropTarget(new java.awt.dnd.DropTarget(desktopPane, this));
+
+      this.addWindowListener(new WindowAdapter()
       {
-        if (evt.isPopupTrigger()) // Mac
+        @Override
+        public void windowClosing(WindowEvent evt)
         {
-          showPasteMenu(evt.getX(), evt.getY());
+          quit();
         }
-      }
+      });
 
-      @Override
-      public void mouseReleased(MouseEvent evt)
+      MouseAdapter ma;
+      this.addMouseListener(ma = new MouseAdapter()
       {
-        if (evt.isPopupTrigger()) // Windows
+        @Override
+        public void mousePressed(MouseEvent evt)
         {
-          showPasteMenu(evt.getX(), evt.getY());
+          if (evt.isPopupTrigger()) // Mac
+          {
+            showPasteMenu(evt.getX(), evt.getY());
+          }
         }
-      }
-    });
-    desktop.addMouseListener(ma);
+
+        @Override
+        public void mouseReleased(MouseEvent evt)
+        {
+          if (evt.isPopupTrigger()) // Windows
+          {
+            showPasteMenu(evt.getX(), evt.getY());
+          }
+        }
+      });
+      desktopPane.addMouseListener(ma);
+    } catch (Throwable t)
+    {
+      t.printStackTrace();
+    }
 
   }
 
@@ -574,10 +585,10 @@ public class Desktop extends jalview.jbgui.GDesktop
             .getStructureSelectionManager(this);
     if (Cache.getDefault(Preferences.ADD_SS_ANN, true))
     {
-      ssm.setAddTempFacAnnot(Cache
-              .getDefault(Preferences.ADD_TEMPFACT_ANN, true));
-      ssm.setProcessSecondaryStructure(Cache
-              .getDefault(Preferences.STRUCT_FROM_PDB, true));
+      ssm.setAddTempFacAnnot(
+              Cache.getDefault(Preferences.ADD_TEMPFACT_ANN, true));
+      ssm.setProcessSecondaryStructure(
+              Cache.getDefault(Preferences.STRUCT_FROM_PDB, true));
       ssm.setSecStructServices(
               Cache.getDefault(Preferences.USE_RNAVIEW, true));
     }
@@ -626,7 +637,7 @@ public class Desktop extends jalview.jbgui.GDesktop
         }
       }
     }).start();
-    
+
   }
 
   @Override
@@ -647,10 +658,10 @@ public class Desktop extends jalview.jbgui.GDesktop
         public void run()
         {
           long now = System.currentTimeMillis();
-          Desktop.instance.setProgressBar(
+          setProgressBar(
                   MessageManager.getString("status.refreshing_news"), now);
           jvnews.refreshNews();
-          Desktop.instance.setProgressBar(null, now);
+          setProgressBar(null, now);
           jvnews.showNews();
         }
       }).start();
@@ -671,10 +682,8 @@ public class Desktop extends jalview.jbgui.GDesktop
     Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
     String x = Cache.getProperty(windowName + "SCREEN_X");
     String y = Cache.getProperty(windowName + "SCREEN_Y");
-    String width = Cache
-            .getProperty(windowName + "SCREEN_WIDTH");
-    String height = Cache
-            .getProperty(windowName + "SCREEN_HEIGHT");
+    String width = Cache.getProperty(windowName + "SCREEN_WIDTH");
+    String height = Cache.getProperty(windowName + "SCREEN_HEIGHT");
     if ((x != null) && (y != null) && (width != null) && (height != null))
     {
       int ix = Integer.parseInt(x), iy = Integer.parseInt(y),
@@ -684,10 +693,10 @@ public class Desktop extends jalview.jbgui.GDesktop
         // attempt #1 - try to cope with change in screen geometry - this
         // version doesn't preserve original jv aspect ratio.
         // take ratio of current screen size vs original screen size.
-        double sw = ((1f * screenSize.width) / (1f * Integer.parseInt(
-                Cache.getProperty("SCREENGEOMETRY_WIDTH"))));
-        double sh = ((1f * screenSize.height) / (1f * Integer.parseInt(
-                Cache.getProperty("SCREENGEOMETRY_HEIGHT"))));
+        double sw = ((1f * screenSize.width) / (1f * Integer
+                .parseInt(Cache.getProperty("SCREENGEOMETRY_WIDTH"))));
+        double sh = ((1f * screenSize.height) / (1f * Integer
+                .parseInt(Cache.getProperty("SCREENGEOMETRY_HEIGHT"))));
         // rescale the bounds depending upon the current screen geometry.
         ix = (int) (ix * sw);
         iw = (int) (iw * sw);
@@ -843,6 +852,8 @@ public class Desktop extends jalview.jbgui.GDesktop
           int w, int h, boolean resizable, boolean ignoreMinSize)
   {
 
+
+
     // TODO: allow callers to determine X and Y position of frame (eg. via
     // bounds object).
     // TODO: consider fixing method to update entries in the window submenu with
@@ -857,8 +868,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 (Jalview.isHeadlessMode())
     {
       return;
     }
@@ -904,8 +914,8 @@ public class Desktop extends jalview.jbgui.GDesktop
       @Override
       public void internalFrameActivated(InternalFrameEvent evt)
       {
-        JInternalFrame itf = desktop.getSelectedFrame();
-        if (itf != null)
+        JInternalFrame itf = getDesktopPane().getSelectedFrame();
+       if (itf != null)
         {
           if (itf instanceof AlignFrame)
           {
@@ -936,7 +946,7 @@ public class Desktop extends jalview.jbgui.GDesktop
         {
           menuItem.removeActionListener(menuItem.getActionListeners()[0]);
         }
-        windowMenu.remove(menuItem);
+        getInstance().windowMenu.remove(menuItem);
       }
     });
 
@@ -958,9 +968,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
@@ -978,8 +988,8 @@ public class Desktop extends jalview.jbgui.GDesktop
   }
 
   /**
-   * Add key bindings to a JInternalFrame so that Ctrl-W and Cmd-W will close the
-   * window
+   * Add key bindings to a JInternalFrame so that Ctrl-W and Cmd-W will close
+   * the window
    * 
    * @param frame
    */
@@ -1018,7 +1028,7 @@ public class Desktop extends jalview.jbgui.GDesktop
   {
     if (!internalCopy)
     {
-      Desktop.jalviewClipboard = null;
+      jalviewClipboard = null;
     }
 
     internalCopy = false;
@@ -1063,7 +1073,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 
     try
     {
-      Desktop.transferFromDropTarget(files, protocols, evt, t);
+      transferFromDropTarget(files, protocols, evt, t);
     } catch (Exception e)
     {
       e.printStackTrace();
@@ -1119,8 +1129,9 @@ public class Desktop extends jalview.jbgui.GDesktop
   public void inputLocalFileMenuItem_actionPerformed(AlignViewport viewport)
   {
     String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
-    JalviewFileChooser chooser = JalviewFileChooser
-            .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat, BackupFiles.getEnabled());
+    JalviewFileChooser chooser = JalviewFileChooser.forRead(
+            Cache.getProperty("LAST_DIRECTORY"), fileFormat,
+            BackupFiles.getEnabled());
 
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle(
@@ -1253,7 +1264,7 @@ public class Desktop extends jalview.jbgui.GDesktop
           {
             String msg = MessageManager
                     .formatMessage("label.couldnt_locate", url);
-            JvOptionPane.showInternalMessageDialog(Desktop.desktop, msg,
+            JvOptionPane.showInternalMessageDialog(getDesktopPane(), msg,
                     MessageManager.getString("label.url_not_found"),
                     JvOptionPane.WARNING_MESSAGE);
 
@@ -1274,7 +1285,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     };
     String dialogOption = MessageManager
             .getString("label.input_alignment_from_url");
-    JvOptionPane.newOptionDialog(desktop).setResponseHandler(0, action)
+    JvOptionPane.newOptionDialog(desktopPane).setResponseHandler(0, action)
             .showInternalDialog(panel, dialogOption,
                     JvOptionPane.YES_NO_CANCEL_OPTION,
                     JvOptionPane.PLAIN_MESSAGE, null, options,
@@ -1294,7 +1305,7 @@ public class Desktop extends jalview.jbgui.GDesktop
   {
     CutAndPasteTransfer cap = new CutAndPasteTransfer();
     cap.setForInput(viewPanel);
-    Desktop.addInternalFrame(cap,
+    addInternalFrame(cap,
             MessageManager.getString("label.cut_paste_alignmen_file"), true,
             600, 500);
   }
@@ -1306,10 +1317,8 @@ public class Desktop extends jalview.jbgui.GDesktop
   public void quit()
   {
     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
-    Cache.setProperty("SCREENGEOMETRY_WIDTH",
-            screen.width + "");
-    Cache.setProperty("SCREENGEOMETRY_HEIGHT",
-            screen.height + "");
+    Cache.setProperty("SCREENGEOMETRY_WIDTH", screen.width + "");
+    Cache.setProperty("SCREENGEOMETRY_HEIGHT", screen.height + "");
     storeLastKnownDimensions("", new Rectangle(getBounds().x, getBounds().y,
             getWidth(), getHeight()));
 
@@ -1340,9 +1349,9 @@ public class Desktop extends jalview.jbgui.GDesktop
 
   private void storeLastKnownDimensions(String string, Rectangle jc)
   {
-    Cache.log.debug("Storing last known dimensions for "
-            + string + ": x:" + jc.x + " y:" + jc.y + " width:" + jc.width
-            + " height:" + jc.height);
+    Cache.log.debug("Storing last known dimensions for " + string + ": x:"
+            + jc.x + " y:" + jc.y + " width:" + jc.width + " height:"
+            + jc.height);
 
     Cache.setProperty(string + "SCREEN_X", jc.x + "");
     Cache.setProperty(string + "SCREEN_Y", jc.y + "");
@@ -1453,7 +1462,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 = desktopPane.getAllFrames();
     for (int i = 0; i < frames.length; i++)
     {
       try
@@ -1520,7 +1529,7 @@ public class Desktop extends jalview.jbgui.GDesktop
   @Override
   protected void showMemusage_actionPerformed(ActionEvent e)
   {
-    desktop.showMemoryUsage(showMemusage.isSelected());
+    desktopPane.showMemoryUsage(showMemusage.isSelected());
   }
 
   /*
@@ -1557,7 +1566,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 
   void reorderAssociatedWindows(boolean minimize, boolean close)
   {
-    JInternalFrame[] frames = desktop.getAllFrames();
+    JInternalFrame[] frames = desktopPane.getAllFrames();
     if (frames == null || frames.length < 1)
     {
       return;
@@ -1697,16 +1706,17 @@ public class Desktop extends jalview.jbgui.GDesktop
           setProgressBar(MessageManager.formatMessage(
                   "label.saving_jalview_project", new Object[]
                   { chosenFile.getName() }), chosenFile.hashCode());
-          Cache.setProperty("LAST_DIRECTORY",
-                  chosenFile.getParent());
+          Cache.setProperty("LAST_DIRECTORY", chosenFile.getParent());
           // TODO catch and handle errors for savestate
           // TODO prevent user from messing with the Desktop whilst we're saving
           try
           {
-               boolean doBackup = BackupFiles.getEnabled();
-            BackupFiles backupfiles = doBackup ? new BackupFiles(chosenFile) : null;
+            boolean doBackup = BackupFiles.getEnabled();
+            BackupFiles backupfiles = doBackup ? new BackupFiles(chosenFile)
+                    : null;
 
-            new Jalview2XML().saveState(doBackup ? backupfiles.getTempFile() : chosenFile);
+            new Jalview2XML().saveState(
+                    doBackup ? backupfiles.getTempFile() : chosenFile);
 
             if (doBackup)
             {
@@ -1732,7 +1742,7 @@ public class Desktop extends jalview.jbgui.GDesktop
           setProgressBar(null, chosenFile.hashCode());
         }
       }).start();
-      }
+    }
   }
 
   @Override
@@ -1763,8 +1773,10 @@ public class Desktop extends jalview.jbgui.GDesktop
         "Jalview Project (old)" };
     JalviewFileChooser chooser = new JalviewFileChooser(
             Cache.getProperty("LAST_DIRECTORY"), suffix, desc,
-            "Jalview Project", true, BackupFiles.getEnabled()); // last two booleans: allFiles,
-                                            // allowBackupFiles
+            "Jalview Project", true, BackupFiles.getEnabled()); // last two
+                                                                // booleans:
+                                                                // allFiles,
+    // allowBackupFiles
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle(MessageManager.getString("label.restore_state"));
     chooser.setResponseHandler(0, new Runnable()
@@ -1781,29 +1793,30 @@ public class Desktop extends jalview.jbgui.GDesktop
           @Override
           public void run()
           {
-               try 
+            try
             {
               new Jalview2XML().loadJalviewAlign(selectedFile);
             } catch (OutOfMemoryError oom)
-               {
-                 new OOMWarning("Whilst loading project from " + choice, oom);
-               } catch (Exception ex)
-               {
-                 Cache.log.error(
-                         "Problems whilst loading project from " + choice, ex);
-                 JvOptionPane.showMessageDialog(Desktop.desktop,
-                         MessageManager.formatMessage(
-                                 "label.error_whilst_loading_project_from",
-                               new Object[]
-                                   { choice }),
-                         MessageManager.getString("label.couldnt_load_project"),
-                         JvOptionPane.WARNING_MESSAGE);
-               }
+            {
+              new OOMWarning("Whilst loading project from " + choice, oom);
+            } catch (Exception ex)
+            {
+              Cache.log.error(
+                      "Problems whilst loading project from " + choice, ex);
+              JvOptionPane.showMessageDialog( getDesktopPane(),
+                      MessageManager.formatMessage(
+                              "label.error_whilst_loading_project_from",
+                              new Object[]
+                              { choice }),
+                      MessageManager
+                              .getString("label.couldnt_load_project"),
+                      JvOptionPane.WARNING_MESSAGE);
+            }
           }
         }).start();
       }
     });
-    
+
     chooser.showOpenDialog(this);
   }
 
@@ -1834,7 +1847,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     {
       progressPanel = new JPanel(new GridLayout(1, 1));
       totalProgressCount = 0;
-      instance.getContentPane().add(progressPanel, BorderLayout.SOUTH);
+      getContentPane().add(progressPanel, BorderLayout.SOUTH);
     }
     JPanel thisprogress = new JPanel(new BorderLayout(10, 5));
     JProgressBar progressBar = new JProgressBar();
@@ -1847,7 +1860,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     ((GridLayout) progressPanel.getLayout()).setRows(
             ((GridLayout) progressPanel.getLayout()).getRows() + 1);
     ++totalProgressCount;
-    instance.validate();
+    validate();
     return thisprogress;
   }
 
@@ -1901,7 +1914,7 @@ public class Desktop extends jalview.jbgui.GDesktop
    */
   public static AlignmentPanel[] getAlignmentPanels(String alignmentId)
   {
-    if (Desktop.desktop == null)
+    if (getDesktopPane() == null)
     {
       // no frames created and in headless mode
       // TODO: verify that frames are recoverable when in headless mode
@@ -1943,9 +1956,9 @@ 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();
+      AlignFrame[] frames = getAlignFrames();
 
       for (AlignFrame afr : frames)
       {
@@ -1992,9 +2005,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 
     // FIXME: ideally should use UI interface API
     FeatureSettings viewFeatureSettings = (af.featureSettings != null
-            && af.featureSettings.isOpen())
-            ? af.featureSettings
-            : null;
+            && af.featureSettings.isOpen()) ? af.featureSettings : null;
     Rectangle fsBounds = af.getFeatureSettingsGeometry();
     for (int i = 0; i < size; i++)
     {
@@ -2027,7 +2038,8 @@ public class Desktop extends jalview.jbgui.GDesktop
 
       addInternalFrame(newaf, af.getTitle(), AlignFrame.DEFAULT_WIDTH,
               AlignFrame.DEFAULT_HEIGHT);
-      // and materialise a new feature settings dialog instance for the new alignframe
+      // and materialise a new feature settings dialog instance for the new
+      // alignframe
       // (closes the old as if 'OK' was pressed)
       if (ap == af.alignPanel && newaf.featureSettings != null
               && newaf.featureSettings.isOpen()
@@ -2045,9 +2057,9 @@ public class Desktop extends jalview.jbgui.GDesktop
 
   /**
    * Gather expanded views (separate AlignFrame's) with the same sequence set
-   * identifier back in to this frame as additional views, and close the expanded
-   * views. Note the expanded frames may themselves have multiple views. We take
-   * the lot.
+   * identifier back in to this frame as additional views, and close the
+   * expanded views. Note the expanded frames may themselves have multiple
+   * views. We take the lot.
    * 
    * @param source
    */
@@ -2055,7 +2067,7 @@ public class Desktop extends jalview.jbgui.GDesktop
   {
     source.viewport.setGatherViewsHere(true);
     source.viewport.setExplodedGeometry(source.getBounds());
-    JInternalFrame[] frames = desktop.getAllFrames();
+    JInternalFrame[] frames = desktopPane.getAllFrames();
     String viewId = source.viewport.getSequenceSetId();
     for (int t = 0; t < frames.length; t++)
     {
@@ -2099,8 +2111,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     }
 
     // refresh the feature setting UI for the source frame if it exists
-    if (source.featureSettings != null
-            && source.featureSettings.isOpen())
+    if (source.featureSettings != null && source.featureSettings.isOpen())
     {
       source.showFeatureSettingsUI();
     }
@@ -2108,7 +2119,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 
   public JInternalFrame[] getAllFrames()
   {
-    return desktop.getAllFrames();
+    return desktopPane.getAllFrames();
   }
 
   /**
@@ -2194,7 +2205,7 @@ public class Desktop extends jalview.jbgui.GDesktop
           });
           msgPanel.add(jcb);
 
-          JvOptionPane.showMessageDialog(Desktop.desktop, msgPanel,
+          JvOptionPane.showMessageDialog(desktopPane, msgPanel,
                   MessageManager
                           .getString("label.SEQUENCE_ID_no_longer_used"),
                   JvOptionPane.WARNING_MESSAGE);
@@ -2205,12 +2216,12 @@ public class Desktop extends jalview.jbgui.GDesktop
 
   /**
    * Proxy class for JDesktopPane which optionally displays the current memory
-   * usage and highlights the desktop area with a red bar if free memory runs low.
+   * usage and highlights the desktop area with a red bar if free memory runs
+   * low.
    * 
    * @author AMW
    */
-  public class MyDesktopPane extends JDesktopPane
-          implements Runnable
+  public class MyDesktopPane extends JDesktopPane implements Runnable
   {
     private static final float ONE_MB = 1048576f;
 
@@ -2309,11 +2320,10 @@ public class Desktop extends jalview.jbgui.GDesktop
   {
     if (Jalview.isHeadlessMode())
     {
-      // Desktop.desktop is null in headless mode
       return new AlignFrame[] { Jalview.currentAlignFrame };
     }
 
-    JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+    JInternalFrame[] frames =  getDesktopPane().getAllFrames();
 
     if (frames == null)
     {
@@ -2358,7 +2368,7 @@ public class Desktop extends jalview.jbgui.GDesktop
    */
   public GStructureViewer[] getJmols()
   {
-    JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+    JInternalFrame[] frames = desktopPane.getAllFrames();
 
     if (frames == null)
     {
@@ -2394,7 +2404,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     } catch (Exception ex)
     {
       Cache.log.error("Groovy Shell Creation failed.", ex);
-      JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+      JvOptionPane.showInternalMessageDialog(desktopPane,
 
               MessageManager.getString("label.couldnt_create_groovy_shell"),
               MessageManager.getString("label.groovy_support_failed"),
@@ -2447,14 +2457,17 @@ public class Desktop extends jalview.jbgui.GDesktop
   }
 
   /**
-   * Bind Ctrl/Cmd-Q to Quit - for reset as Groovy Console takes over this binding
-   * when opened
+   * Bind Ctrl/Cmd-Q to Quit - for reset as Groovy Console takes over this
+   * binding when opened
    */
   protected void addQuitHandler()
   {
-    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
-            .put(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
-                    jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()),
+    getRootPane()
+            .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+                    KeyStroke
+                            .getKeyStroke(KeyEvent.VK_Q,
+                                    jalview.util.ShortcutKeyMaskExWrapper
+                                            .getMenuShortcutKeyMaskEx()),
                     "Quit");
     getRootPane().getActionMap().put("Quit", new AbstractAction()
     {
@@ -2583,15 +2596,16 @@ public class Desktop extends jalview.jbgui.GDesktop
   }
 
   /**
-   * This will return the first AlignFrame holding the given viewport instance. It
-   * will break if there are more than one AlignFrames viewing a particular av.
+   * This will return the first AlignFrame holding the given viewport instance.
+   * It will break if there are more than one AlignFrames viewing a particular
+   * av.
    * 
    * @param viewport
    * @return alignFrame for viewport
    */
   public static AlignFrame getAlignFrameFor(AlignViewportI viewport)
   {
-    if (desktop != null)
+    if ( getDesktopPane() != null)
     {
       AlignmentPanel[] aps = getAlignmentPanels(
               viewport.getSequenceSetId());
@@ -2736,7 +2750,7 @@ public class Desktop extends jalview.jbgui.GDesktop
                  * 
                  * jd.waitForInput();
                  */
-                JvOptionPane.showConfirmDialog(Desktop.desktop,
+                JvOptionPane.showConfirmDialog(desktopPane,
                         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,"
@@ -2773,7 +2787,7 @@ public class Desktop extends jalview.jbgui.GDesktop
    */
   public static void showUrl(final String url)
   {
-    showUrl(url, Desktop.instance);
+    showUrl(url, getInstance());
   }
 
   /**
@@ -2802,7 +2816,7 @@ public class Desktop extends jalview.jbgui.GDesktop
           jalview.util.BrowserLauncher.openURL(url);
         } catch (Exception ex)
         {
-          JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+          JvOptionPane.showInternalMessageDialog( getDesktopPane(),
                   MessageManager
                           .getString("label.web_browser_not_found_unix"),
                   MessageManager.getString("label.web_browser_not_found"),
@@ -2842,7 +2856,7 @@ public class Desktop extends jalview.jbgui.GDesktop
       try
       {
         url = e.getURL().toString();
-        Desktop.showUrl(url);
+        showUrl(url);
       } catch (Exception x)
       {
         if (url != null)
@@ -2901,11 +2915,11 @@ public class Desktop extends jalview.jbgui.GDesktop
           {
           }
         }
-        if (instance == null)
+        if (Jalview.isHeadlessMode())
         {
           return;
         }
-        try
+       try
         {
           SwingUtilities.invokeAndWait(prompter);
         } catch (Exception q)
@@ -2961,8 +2975,8 @@ public class Desktop extends jalview.jbgui.GDesktop
 
   /**
    * Explode the views in the given SplitFrame into separate SplitFrame windows.
-   * This respects (remembers) any previous 'exploded geometry' i.e. the size and
-   * location last time the view was expanded (if any). However it does not
+   * This respects (remembers) any previous 'exploded geometry' i.e. the size
+   * and location last time the view was expanded (if any). However it does not
    * remember the split pane divider location - this is set to match the
    * 'exploding' frame.
    * 
@@ -3027,7 +3041,7 @@ public class Desktop extends jalview.jbgui.GDesktop
       {
         splitFrame.setLocation(geometry.getLocation());
       }
-      Desktop.addInternalFrame(splitFrame, sf.getTitle(), -1, -1);
+      addInternalFrame(splitFrame, sf.getTitle(), -1, -1);
     }
 
     /*
@@ -3065,7 +3079,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     String topViewId = myTopFrame.viewport.getSequenceSetId();
     String bottomViewId = myBottomFrame.viewport.getSequenceSetId();
 
-    JInternalFrame[] frames = desktop.getAllFrames();
+    JInternalFrame[] frames = desktopPane.getAllFrames();
     for (JInternalFrame frame : frames)
     {
       if (frame instanceof SplitFrame && frame != source)
@@ -3133,7 +3147,8 @@ public class Desktop extends jalview.jbgui.GDesktop
           Transferable t) throws Exception
   {
 
-    // BH 2018 changed List<String> to List<Object> to allow for File from SwingJS
+    // BH 2018 changed List<String> to List<Object> to allow for File from
+    // SwingJS
 
     // DataFlavor[] flavors = t.getTransferDataFlavors();
     // for (int i = 0; i < flavors.length; i++) {
@@ -3145,7 +3160,8 @@ public class Desktop extends jalview.jbgui.GDesktop
     // byte[] data = getDroppedFileBytes(file);
     // fileName.setText(file.getName() + " - " + data.length + " " +
     // evt.getLocation());
-    // JTextArea target = (JTextArea) ((DropTarget) evt.getSource()).getComponent();
+    // JTextArea target = (JTextArea) ((DropTarget)
+    // evt.getSource()).getComponent();
     // target.setText(new String(data));
     // }
     // dtde.dropComplete(true);
@@ -3345,10 +3361,10 @@ public class Desktop extends jalview.jbgui.GDesktop
   }
 
   /**
-   * Answers a (possibly empty) list of any structure viewer frames (currently for
-   * either Jmol or Chimera) which are currently open. This may optionally be
-   * restricted to viewers of a specified class, or viewers linked to a specified
-   * alignment panel.
+   * Answers a (possibly empty) list of any structure viewer frames (currently
+   * for either Jmol or Chimera) which are currently open. This may optionally
+   * be restricted to viewers of a specified class, or viewers linked to a
+   * specified alignment panel.
    * 
    * @param apanel
    *          if not null, only return viewers linked to this panel
@@ -3361,7 +3377,7 @@ public class Desktop extends jalview.jbgui.GDesktop
           Class<? extends StructureViewerBase> structureViewerClass)
   {
     List<StructureViewerBase> result = new ArrayList<>();
-    JInternalFrame[] frames = Desktop.instance.getAllFrames();
+    JInternalFrame[] frames = getAllFrames();
 
     for (JInternalFrame frame : frames)
     {
index 57e2915..a02ec36 100644 (file)
@@ -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 4b5e9d4..2734b8d 100755 (executable)
@@ -242,7 +242,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 9704b39..62bdd35 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 87912ab..ff70162 100644 (file)
@@ -301,7 +301,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);
index 2354072..ce3c29d 100755 (executable)
@@ -963,7 +963,7 @@ public class Preferences extends GPreferences
             BackupFilesPresetEntry.SAVEDCONFIG, savedBFPE.toString());
 
     Cache.saveProperties();
-    Desktop.instance.doConfigureStructurePrefs();
+    Desktop.getInstance().doConfigureStructurePrefs();
     try
     {
       frame.setClosed(true);
@@ -1110,7 +1110,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)
@@ -1162,7 +1162,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)
@@ -1335,7 +1335,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"),
@@ -1361,7 +1361,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);
@@ -1400,7 +1400,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 8b5d3b7..7c83259 100755 (executable)
@@ -868,7 +868,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 f4b275d..0edede4 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(splashText, BorderLayout.CENTER);
     splashText.addMouseListener(closer);
-    Desktop.desktop.add(iframe);
+    Desktop.getDesktopPane().add(iframe);
     refreshText();
   }
 
@@ -200,7 +200,7 @@ public class SplashScreen extends JPanel
    */
   protected boolean refreshText()
   {
-    String newtext = Desktop.instance.getAboutMessage();
+    String newtext = Desktop.getInstance().getAboutMessage();
     // System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
     if (oldTextLength != newtext.length())
     {
@@ -239,8 +239,8 @@ public class SplashScreen extends JPanel
       splashText.setSize(new Dimension(750, 375));
       add(splashText, 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,
               splashText.getHeight() + iconimg.getHeight());
       iframe.validate();
       iframe.setVisible(true);
@@ -286,7 +286,7 @@ public class SplashScreen extends JPanel
     }
 
     closeSplash();
-    Desktop.instance.startDialogQueue();
+    Desktop.getInstance().startDialogQueue();
   }
 
   /**
index e8f30b7..4c607f6 100644 (file)
@@ -152,7 +152,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();
@@ -170,7 +170,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());
   }
@@ -571,7 +571,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);
   }
@@ -698,7 +698,7 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
    */
   protected void expandViews_actionPerformed()
   {
-    Desktop.instance.explodeViews(this);
+    Desktop.getInstance().explodeViews(this);
   }
 
   /**
@@ -707,7 +707,7 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
    */
   protected void gatherViews_actionPerformed()
   {
-    Desktop.instance.gatherViews(this);
+    Desktop.getInstance().gatherViews(this);
   }
 
   /**
index 4a8a7d8..2af17a9 100644 (file)
@@ -145,7 +145,7 @@ public class StructureChooser extends GStructureChooser
    */
   private void discoverStructureViews()
   {
-    if (Desktop.instance != null)
+    if (Desktop.getInstance() != null)
     {
       targetView.removeAllItems();
       if (lastTargetedView != null && !lastTargetedView.isVisible())
@@ -153,7 +153,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
@@ -1008,7 +1008,7 @@ public class StructureChooser extends GStructureChooser
           PDBEntry fileEntry = new AssociatePdbFileWithSeq()
                   .associatePdbWithSeq(selectedPdbFileName,
                           DataSourceType.FILE, selectedSequence, true,
-                          Desktop.instance);
+                          Desktop.getInstance());
           sViewer = StructureViewer.launchStructureViewer(ap, new PDBEntry[] { fileEntry },
                   new SequenceI[]
                   { selectedSequence }, superimpose, theViewer,
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 0848a4d..2ee3e06 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.");
                   }
@@ -689,7 +689,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
   public void disableGui(boolean b)
   {
     // JAL-3311 TODO: remove this class!
-    // Desktop.instance.setVamsasUpdate(b);
+    // Desktop.getInstance().setVamsasUpdate(b);
   }
 
   Hashtable _backup_vobj2jv;
@@ -764,7 +764,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 25ade21..101acbe 100644 (file)
@@ -746,7 +746,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 2ee3629..45822a3 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 fd6114b..b97a25e 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 0d5f92b..9537442 100644 (file)
@@ -538,7 +538,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,
@@ -558,7 +558,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,
@@ -593,7 +593,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"),
@@ -682,7 +682,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 ac55911..7eda110 100755 (executable)
@@ -275,9 +275,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)
       {
@@ -299,12 +299,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(),
@@ -315,7 +315,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
@@ -408,7 +408,7 @@ public class FileLoader implements Runnable
                 // register PDB entries with desktop's structure selection
                 // manager
                 StructureSelectionManager
-                        .getStructureSelectionManager(Desktop.instance)
+                        .getStructureSelectionManager(Desktop.getInstance())
                         .registerPDBEntry(pdbe);
               }
             }
@@ -501,23 +501,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"),
@@ -545,7 +545,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 }),
@@ -567,7 +567,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 }),
@@ -589,7 +589,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)
       {
@@ -611,9 +611,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 387dbfa..c60fd88 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 6793663..c029bee 100755 (executable)
@@ -46,7 +46,7 @@ import javax.swing.JMenuItem;
 public class GDesktop extends JFrame
 {
 
-  protected static JMenu windowMenu = new JMenu();
+  protected JMenu windowMenu = new JMenu();
 
   JMenuBar desktopMenubar = new JMenuBar();
 
index 60f17ab..08fbea3 100755 (executable)
@@ -2259,7 +2259,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 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..67e3338 100644 (file)
@@ -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 e092192..7954db0 100644 (file)
@@ -186,7 +186,7 @@ public class Jws2Instance implements AutoCloseable
       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 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 00af72d..e51527a 100644 (file)
@@ -75,7 +75,7 @@ public class AlignFrameTest
   @AfterMethod(alwaysRun = true)
   public void tearDown()
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
   }
 
   /**
index 76021ce..8a5ef8c 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 43064a3..66e0d22 100644 (file)
@@ -77,7 +77,7 @@ public class FreeUpMemoryTest
     }
     doStuffInJalview(f);
 
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
 
     checkUsedMemory(expectedMin);
   }
@@ -120,7 +120,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 2fdbe7e..01eec32 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 6ea3883..beeb52f 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 3ca6ed8..59cb3cd 100644 (file)
@@ -184,7 +184,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();
@@ -211,7 +211,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);
@@ -278,7 +278,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);
@@ -389,7 +389,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 b753e94..7b3373c 100644 (file)
@@ -72,7 +72,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 eb66416..e0930c9 100644 (file)
@@ -410,7 +410,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);
@@ -438,7 +438,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);
@@ -464,7 +464,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.");
@@ -503,7 +503,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);
@@ -597,7 +597,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.");
@@ -672,7 +672,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);
@@ -717,7 +717,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);
@@ -766,7 +766,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);
@@ -817,7 +817,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);
 
@@ -880,7 +880,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");
@@ -1089,7 +1089,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(
@@ -1133,7 +1133,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");
@@ -1167,10 +1167,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,
@@ -1200,7 +1200,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverGeneLocus() throws Exception
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     String seqData = ">P30419\nACDE\n>X1235\nGCCTGTGACGAA";
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(seqData,
             DataSourceType.PASTE);
@@ -1236,7 +1236,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the state", e);
     }
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
   
     new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
             DataSourceType.FILE);
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) {};