From 61632514caf99d7897843f8bb3e4378aa715d040 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 7 Oct 2019 09:02:11 +0100 Subject: [PATCH] JAL-3070 JAL-3066 provide standard concrete instances for instantaneous analysis UI settings container --- src/jalview/ws/jws2/Jws2ClientFactory.java | 29 ++++++++++++++++--------- src/jalview/ws/params/AutoCalcSetting.java | 32 +++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/jalview/ws/jws2/Jws2ClientFactory.java b/src/jalview/ws/jws2/Jws2ClientFactory.java index c724c45..6445cd5 100644 --- a/src/jalview/ws/jws2/Jws2ClientFactory.java +++ b/src/jalview/ws/jws2/Jws2ClientFactory.java @@ -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 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, diff --git a/src/jalview/ws/params/AutoCalcSetting.java b/src/jalview/ws/params/AutoCalcSetting.java index 55eeb50..68ec7a6 100644 --- a/src/jalview/ws/params/AutoCalcSetting.java +++ b/src/jalview/ws/params/AutoCalcSetting.java @@ -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 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; -- 1.7.10.2