JAL-3070 JAL-3066 provide standard concrete instances for instantaneous analysis...
authorJim Procter <jprocter@issues.jalview.org>
Mon, 7 Oct 2019 08:02:11 +0000 (09:02 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Mon, 7 Oct 2019 08:02:11 +0000 (09:02 +0100)
src/jalview/ws/jws2/Jws2ClientFactory.java
src/jalview/ws/params/AutoCalcSetting.java

index c724c45..6445cd5 100644 (file)
@@ -7,6 +7,7 @@ import jalview.gui.JvSwingUtils;
 import jalview.util.MessageManager;
 import jalview.ws.api.ServiceWithParameters;
 import jalview.ws.jws2.dm.AAConSettings;
+import jalview.ws.jws2.jabaws2.Jws2Instance;
 import jalview.ws.params.AutoCalcSetting;
 import jalview.ws.uimodel.AlignAnalysisUIText;
 
@@ -85,18 +86,23 @@ public class Jws2ClientFactory
         @Override
         public void actionPerformed(ActionEvent arg0)
         {
+
           List<AlignCalcWorkerI> aaconClient = alignFrame.getViewport()
-                  .getCalcManager()
-                  .getRegisteredWorkersOfClass(aaui.getClient());
-          if (aaconClient != null && aaconClient.size() > 0)
-          {
-            removeCurrentAAConWorkerFor(aaui, alignFrame);
-          }
-          else
+                  .getCalcManager().getRegisteredWorkersOfClass(
+                          SeqAnnotationServiceCalcWorker.class);
+          if (aaconClient != null)
           {
-            buildCurrentAAConWorkerFor(aaui, alignFrame);
-
+            for (AlignCalcWorkerI worker : aaconClient)
+            {
+              if (((SeqAnnotationServiceCalcWorker) worker).getService()
+                      .getClass().equals(aaui.getClient()))
+              {
+                removeCurrentAAConWorkerFor(aaui, alignFrame);
+                return;
+              }
+            }
           }
+          buildCurrentAAConWorkerFor(aaui, alignFrame);
         }
 
       });
@@ -142,6 +148,7 @@ public class Jws2ClientFactory
           boolean serviceEnabled = false;
           if (aaconClient != null)
           {
+            // NB code duplicatino again!
             for (AlignCalcWorkerI _worker : aaconClient)
             {
               SeqAnnotationServiceCalcWorker worker = (SeqAnnotationServiceCalcWorker) _worker;
@@ -271,7 +278,9 @@ public class Jws2ClientFactory
       throw new Error(
               MessageManager.getString("error.no_aacon_service_found"));
     }
-    return new AAConSettings(true, service, null, null);
+    return service instanceof Jws2Instance
+            ? new AAConSettings(true, service, null, null)
+            : new AutoCalcSetting(service, null, null, true);
   }
 
   private static void removeCurrentAAConWorkerFor(AlignAnalysisUIText aaui,
index 55eeb50..68ec7a6 100644 (file)
@@ -26,7 +26,7 @@ import jalview.ws.api.ServiceWithParameters;
 import java.util.ArrayList;
 import java.util.List;
 
-public abstract class AutoCalcSetting
+public class AutoCalcSetting
 {
 
   protected boolean autoUpdate;
@@ -99,11 +99,37 @@ public abstract class AutoCalcSetting
   }
 
   /**
+   * default WsParamFile generator method - clients with custom formats should
+   * override and implement their own
    * 
    * @return stringified representation of the parameters for this setting
    */
-  public abstract String getWsParamFile();
-
+  public String getWsParamFile()
+  {
+    List<ArgumentI> opts = null;
+    if (jobArgset != null)
+    {
+      opts = jobArgset;
+    }
+    else
+    {
+      if (preset != null)
+      {
+        opts = preset.getArguments();
+      }
+    }
+    if (opts == null || opts.size() == 0)
+    {
+      return "";
+    }
+    StringBuffer pset = new StringBuffer();
+    for (ArgumentI ps : opts)
+    {
+      pset.append(ps.getName() + "\t" + ps.getValue());
+      pset.append("\n");
+    }
+    return pset.toString();
+  }
   public ServiceWithParameters getService()
   {
     return service;