Merge remote-tracking branch 'origin/merge/Jalview-JS/develop_feature/JAL-3690_callba...
[jalview.git] / src / jalview / ws / rest / RestClient.java
index d84206f..2d39db5 100644 (file)
@@ -20,6 +20,8 @@
  */
 package jalview.ws.rest;
 
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
 import jalview.bin.Cache;
 import jalview.datamodel.AlignmentView;
 import jalview.gui.AlignFrame;
@@ -48,8 +50,27 @@ import javax.swing.event.MenuListener;
  * 
  */
 public class RestClient extends WSClient
-        implements WSClientI, WSMenuEntryProviderI
+implements WSClientI, WSMenuEntryProviderI, ApplicationSingletonI
 {
+
+  @SuppressWarnings("unused")
+  private RestClient()
+  {
+    // accessed by ApplicationSingletonProvider
+  }
+
+  
+private static RestClient getInstance()
+{
+return (RestClient) ApplicationSingletonProvider.getInstance(RestClient.class);
+}
+
+public static final String RSBS_SERVICES = "RSBS_SERVICES";
+
+
+  protected Vector<String> services = null;
+
+
   RestServiceDescription service;
 
   public RestClient(RestServiceDescription rsd)
@@ -108,7 +129,7 @@ public class RestClient extends WSClient
     if (!headless)
     {
       wsInfo = new WebserviceInfo(WebServiceJobTitle,
-              WebServiceName + "\n" + WebServiceReference, true);
+              WebServiceName + "\n" + WebServiceReference, Desktop.FRAME_MAKE_VISIBLE);
       wsInfo.setRenderAsHtml(true);
     }
 
@@ -328,7 +349,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")),
@@ -358,12 +379,13 @@ public class RestClient extends WSClient
     return true;
   }
 
-  protected static Vector<String> services = null;
-
-  public static final String RSBS_SERVICES = "RSBS_SERVICES";
-
   public static RestClient[] getRestClients()
   {
+    return getInstance().getClients();
+  }
+    
+  private RestClient[] getClients()
+  {
     if (services == null)
     {
       services = new Vector<>();
@@ -417,10 +439,11 @@ public class RestClient extends WSClient
   {
     if (rsbsUrls != null)
     {
+      
       // TODO: consider validating services ?
-      services = new Vector<>(rsbsUrls);
+      getInstance().services = new Vector<String>(rsbsUrls);
       StringBuffer sprop = new StringBuffer();
-      for (String s : services)
+      for (String s : getInstance().services)
       {
         sprop.append(s);
       }