JAL-3446 from JAL-3253-applet Desktop and Jws2Discoverer getInstance()
authorBobHanson <hansonr@stolaf.edu>
Tue, 2 Jun 2020 21:54:57 +0000 (16:54 -0500)
committerBobHanson <hansonr@stolaf.edu>
Tue, 2 Jun 2020 21:54:57 +0000 (16:54 -0500)
src/jalview/bin/Jalview.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AnnotationColourChooser.java
src/jalview/gui/Desktop.java
src/jalview/gui/FeatureEditor.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/WsJobParameters.java
src/jalview/gui/WsPreferences.java
src/jalview/ws/jws2/Jws2Client.java
src/jalview/ws/jws2/Jws2Discoverer.java

index e98ea63..f23ebfa 100755 (executable)
@@ -361,7 +361,7 @@ public class Jalview implements JalviewJSApi
       {
         try
         {
-          Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
+          Jws2Discoverer.getInstance().setPreferredUrl(jabawsUrl);
           System.out.println(
                   "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
         } catch (MalformedURLException e)
index 29f6a2e..a7018c3 100644 (file)
@@ -4260,7 +4260,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                 boolean new_sspred = false;
                 if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
                 {
-                  Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
+                  Jws2Discoverer jws2servs = Jws2Discoverer.getInstance();
                   if (jws2servs != null)
                   {
                     if (jws2servs.hasServices())
index e89c1c2..bd05be1 100644 (file)
@@ -301,7 +301,7 @@ public class AnnotationColourChooser extends AnnotationRowFilter
         updateView();
       }
     };
-    JalviewColourChooser.showColourChooser(Desktop.getDesktop(), ttl,
+    JalviewColourChooser.showColourChooser(Desktop.getDesktopPane(), ttl,
             colourPanel.getBackground(), listener);
   }
 
index 1b85dd5..a894910 100644 (file)
@@ -216,13 +216,19 @@ public class Desktop extends jalview.jbgui.GDesktop
 
   public static MyDesktopPane desktop;
 
-  public static MyDesktopPane getDesktop()
+  public static MyDesktopPane getDesktopPane()
   {
     // BH 2018 could use currentThread() here as a reference to a
     // Hashtable<Thread, MyDesktopPane> in JavaScript
     return desktop;
   }
 
+  public static StructureSelectionManager getStructureSelectionManager()
+  {
+    return StructureSelectionManager
+            .getStructureSelectionManager(getInstance());
+  }
+
   static int openFrameCount = 0;
 
   static final int xOffset = 30;
@@ -2658,7 +2664,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 
     if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
     {
-      t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
+      t2 = jalview.ws.jws2.Jws2Discoverer.getInstance()
               .startDiscoverer(changeSupport);
     }
     Thread t3 = null;
@@ -2691,7 +2697,7 @@ public class Desktop extends jalview.jbgui.GDesktop
   {
     if (evt.getNewValue() == null || evt.getNewValue() instanceof Vector)
     {
-      final String ermsg = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
+      final String ermsg = jalview.ws.jws2.Jws2Discoverer.getInstance()
               .getErrorMessages();
       if (ermsg != null)
       {
index d547c58..57e2915 100644 (file)
@@ -222,7 +222,7 @@ public class FeatureEditor
               updateColourButton(mainPanel, colour, featureColour);
             };
           };
-          JalviewColourChooser.showColourChooser(Desktop.getDesktop(),
+          JalviewColourChooser.showColourChooser(Desktop.getDesktopPane(),
                   title, featureColour.getColour(), listener);
         }
         else
index 2a7fb9f..87912ab 100644 (file)
@@ -2083,7 +2083,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
         refresh();
       }
     };
-    JalviewColourChooser.showColourChooser(Desktop.getDesktop(),
+    JalviewColourChooser.showColourChooser(Desktop.getDesktopPane(),
             title, Color.BLUE, listener);
   }
 
index 976e551..2ee3629 100644 (file)
@@ -963,13 +963,13 @@ public class WsJobParameters extends JPanel implements ItemListener,
   public static void main(String[] args)
   {
     jalview.ws.jws2.Jws2Discoverer disc = jalview.ws.jws2.Jws2Discoverer
-            .getDiscoverer();
+            .getInstance();
     int p = 0;
     if (args.length > 0)
     {
       Vector<String> services = new Vector<>();
       services.addElement(args[p++]);
-      Jws2Discoverer.getDiscoverer().setServiceUrls(services);
+      Jws2Discoverer.getInstance().setServiceUrls(services);
     }
     try
     {
index 5186a26..fd6114b 100644 (file)
@@ -65,7 +65,7 @@ public class WsPreferences extends GWsPreferences
   private void initFromPreferences()
   {
 
-    wsUrls = Jws2Discoverer.getDiscoverer().getServiceUrls();
+    wsUrls = Jws2Discoverer.getInstance().getServiceUrls();
     if (!wsUrls.isEmpty())
     {
       oldUrls = new Vector<String>(wsUrls);
@@ -122,7 +122,7 @@ public class WsPreferences extends GWsPreferences
     int r = 0;
     for (String url : wsUrls)
     {
-      int status = Jws2Discoverer.getDiscoverer().getServerStatusFor(url);
+      int status = Jws2Discoverer.getInstance().getServerStatusFor(url);
       tdat[r][1] = Integer.valueOf(status);
       tdat[r++][0] = url;
     }
@@ -241,7 +241,7 @@ public class WsPreferences extends GWsPreferences
 
   private void updateServiceList()
   {
-    Jws2Discoverer.getDiscoverer().setServiceUrls(wsUrls);
+    Jws2Discoverer.getInstance().setServiceUrls(wsUrls);
   }
 
   private void updateRsbsServiceList()
@@ -646,8 +646,8 @@ public class WsPreferences extends GWsPreferences
   @Override
   protected void resetWs_actionPerformed(ActionEvent e)
   {
-    Jws2Discoverer.getDiscoverer().setServiceUrls(null);
-    List<String> nwsUrls = Jws2Discoverer.getDiscoverer().getServiceUrls();
+    Jws2Discoverer.getInstance().setServiceUrls(null);
+    List<String> nwsUrls = Jws2Discoverer.getInstance().getServiceUrls();
     if (!wsUrls.equals(nwsUrls))
     {
       update++;
index 0f1a25e..62f2a03 100644 (file)
@@ -398,7 +398,7 @@ public abstract class Jws2Client extends jalview.ws.WSClient
       {
         // check service is actually in the list of currently avaialable
         // services
-        if (!Jws2Discoverer.getDiscoverer().getServices().contains(service))
+        if (!Jws2Discoverer.getInstance().getServices().contains(service))
         {
           // it isn't ..
           service = null;
@@ -408,7 +408,7 @@ public abstract class Jws2Client extends jalview.ws.WSClient
     if (service == null)
     {
       // get the default service for AACon
-      service = Jws2Discoverer.getDiscoverer().getPreferredServiceFor(null,
+      service = Jws2Discoverer.getInstance().getPreferredServiceFor(null,
               aaui.getServiceType());
     }
     if (service == null)
index 516a719..c3b0b30 100644 (file)
@@ -74,6 +74,20 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
    */
   private static Jws2Discoverer discoverer;
 
+  /**
+   * Returns the singleton instance of this class.
+   * 
+   * @return
+   */
+  public static Jws2Discoverer getInstance()
+  {
+    if (discoverer == null)
+    {
+      discoverer = new Jws2Discoverer();
+    }
+    return discoverer;
+  }
+
   /*
    * Override for testing only
    */
@@ -591,19 +605,19 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
         testUrls.add(url);
       }
     }
-    Thread runner = getDiscoverer()
+    Thread runner = getInstance()
             .startDiscoverer(new PropertyChangeListener()
             {
 
               @Override
               public void propertyChange(PropertyChangeEvent evt)
               {
-                if (getDiscoverer().services != null)
+                if (getInstance().services != null)
                 {
                   System.out.println("Changesupport: There are now "
-                          + getDiscoverer().services.size() + " services");
+                          + getInstance().services.size() + " services");
                   int i = 1;
-                  for (Jws2Instance instance : getDiscoverer().services)
+                  for (Jws2Instance instance : getInstance().services)
                   {
                     System.out.println("Service " + i++ + " "
                             + instance.getClass() + "@" + instance.getHost()
@@ -630,19 +644,6 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
     }
   }
 
-  /**
-   * Returns the singleton instance of this class.
-   * 
-   * @return
-   */
-  public static Jws2Discoverer getDiscoverer()
-  {
-    if (discoverer == null)
-    {
-      discoverer = new Jws2Discoverer();
-    }
-    return discoverer;
-  }
 
   public boolean hasServices()
   {