X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fjws2%2FMsaWSClient.java;h=f3c385aef406f9ca198612b59d042b1f2dbd8a3f;hb=153dd62dc91da13ae732600e6ea55ddbe15eab39;hp=1d9a89c4e5c688f0e7a939f77a53bab0d109ae68;hpb=f7d38a812a5d339f421590c5c78023a6832f98d3;p=jalview.git diff --git a/src/jalview/ws/jws2/MsaWSClient.java b/src/jalview/ws/jws2/MsaWSClient.java index 1d9a89c..f3c385a 100644 --- a/src/jalview/ws/jws2/MsaWSClient.java +++ b/src/jalview/ws/jws2/MsaWSClient.java @@ -1,5 +1,5 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle * * This file is part of Jalview. @@ -19,6 +19,7 @@ package jalview.ws.jws2; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.ArrayList; import java.util.List; import javax.swing.*; @@ -27,9 +28,12 @@ import jalview.datamodel.*; import jalview.gui.*; import compbio.data.msa.MsaWS; import compbio.metadata.Argument; +import compbio.metadata.Option; import compbio.metadata.Preset; import compbio.metadata.PresetManager; import jalview.ws.jws2.Jws2Discoverer.Jws2Instance; +import jalview.ws.jws2.dm.JabaWsParamSet; +import jalview.ws.params.WsParamSetI; /** * DOCUMENT ME! @@ -60,7 +64,7 @@ public class MsaWSClient extends Jws2Client // TODO Auto-generated constructor stub } - public MsaWSClient(Jws2Discoverer.Jws2Instance sh, Preset preset, + public MsaWSClient(Jws2Discoverer.Jws2Instance sh, WsParamSetI preset, String altitle, jalview.datamodel.AlignmentView msa, boolean submitGaps, boolean preserveOrder, Alignment seqdataset, AlignFrame _alignFrame) @@ -86,7 +90,7 @@ public class MsaWSClient extends Jws2Client * DOCUMENT ME! */ - public MsaWSClient(Jws2Discoverer.Jws2Instance sh, Preset preset, + public MsaWSClient(Jws2Discoverer.Jws2Instance sh, WsParamSetI preset, List arguments, boolean editParams, String altitle, jalview.datamodel.AlignmentView msa, boolean submitGaps, boolean preserveOrder, Alignment seqdataset, @@ -108,17 +112,64 @@ public class MsaWSClient extends Jws2Client return; } server = sh.service; - this.preset = preset; - this.paramset = arguments; + if (preset != null) + { + if (preset instanceof JabaPreset) + { + this.preset = ((JabaPreset) preset).p; + } + else if (preset instanceof JabaWsParamSet) + { + List newargs = new ArrayList(); + JabaWsParamSet pset = ((JabaWsParamSet) preset); + for (Option opt : pset.getjabaArguments()) + { + newargs.add(opt); + } + if (arguments != null && arguments.size() > 0) + { + // merge arguments with preset's own arguments. + for (Argument opt : arguments) + { + newargs.add(opt); + } + } + paramset = newargs; + } + else + { + throw new Error( + "Implementation error: Can only instantiate Jaba parameter sets."); + } + } + else + { + // just provided with a bunch of arguments + this.paramset = arguments; + } if (editParams) { + if (sh.paramStore == null) + { + sh.paramStore = new JabaParamStore(sh, + Desktop.getUserParameterStore()); + } WsJobParameters jobParams = new WsJobParameters(sh, preset); if (!jobParams.showRunDialog()) { return; } - preset = null; - paramset = jobParams.getJobParams(); + WsParamSetI prset = jobParams.getPreset(); + if (prset == null) + { + paramset = JabaParamStore.getJabafromJwsArgs(jobParams + .getJobParams()); + } + else + { + this.preset = ((JabaPreset) prset).p; + paramset = null; // no user supplied parameters. + } } if ((wsInfo = setWebService(sh, false)) == null) @@ -211,7 +262,7 @@ public class MsaWSClient extends Jws2Client String svcname = WebServiceName; if (svcname.endsWith("WS")) { - svcname = svcname.substring(0,svcname.length()-2); + svcname = svcname.substring(0, svcname.length() - 2); } String calcName = svcname + " "; if (canSubmitGaps()) @@ -220,17 +271,21 @@ public class MsaWSClient extends Jws2Client rmsawsmenu.add(msawsmenu); calcName = ""; } - + boolean hasparams = service.hasParameters(); do { + String action="Align "; if (submitGaps == true) { - msawsmenu = new JMenu("profile " + svcname); + action="Realign "; + msawsmenu = new JMenu("Realign with " + svcname); + msawsmenu.setToolTipText("Align sequences to an existing alignment"); rmsawsmenu.add(msawsmenu); } final boolean withGaps = submitGaps; + JMenuItem method = new JMenuItem(calcName + "Defaults"); - method.setToolTipText("Align with default settings"); + method.setToolTipText(action+"with default settings"); method.addActionListener(new ActionListener() { @@ -244,45 +299,54 @@ public class MsaWSClient extends Jws2Client } }); msawsmenu.add(method); - method = new JMenuItem(calcName + "Edit and run ..."); - method.setToolTipText("View and change the parameters before alignment."); - - method.addActionListener(new ActionListener() + if (hasparams) { - public void actionPerformed(ActionEvent e) - { - AlignmentView msa = alignFrame.gatherSequencesForAlignment(); - new MsaWSClient(service, null, null, true, alignFrame.getTitle(), - msa, withGaps, true, alignFrame.getViewport() - .getAlignment().getDataset(), alignFrame); + // only add these menu options if the service has user-modifiable arguments + method = new JMenuItem(calcName + "Edit and run ..."); + method.setToolTipText("View and change the parameters before alignment."); - } - }); - msawsmenu.add(method); - PresetManager presets = service.getPresets(); - if (presets != null && presets.getPresets().size() > 0) - { - JMenu presetlist = new JMenu(calcName + "Presets"); + method.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + AlignmentView msa = alignFrame.gatherSequencesForAlignment(); + new MsaWSClient(service, null, null, true, alignFrame + .getTitle(), msa, withGaps, true, alignFrame + .getViewport().getAlignment().getDataset(), alignFrame); - for (final Preset preset : (List) presets.getPresets()) + } + }); + msawsmenu.add(method); + List presets = service.getParamStore().getPresets(); + if (presets != null && presets.size() > 0) { - final JMenuItem methodR = new JMenuItem(preset.getName()); - methodR.setToolTipText("

"+preset.getDescription()+"

"); - methodR.addActionListener(new ActionListener() + JMenu presetlist = new JMenu(calcName + "Presets"); + + for (final WsParamSetI preset : presets) { - public void actionPerformed(ActionEvent e) + final JMenuItem methodR = new JMenuItem(preset.getName()); + methodR.setToolTipText("

" + + JvSwingUtils.wrapTooltip("" + + (preset.isModifiable() ? "User Preset" + : "Service Preset") + "
" + + preset.getDescription() + "

") + ""); + methodR.addActionListener(new ActionListener() { - AlignmentView msa = alignFrame.gatherSequencesForAlignment(); - new MsaWSClient(service, preset, alignFrame.getTitle(), msa, - false, true, alignFrame.getViewport().getAlignment() - .getDataset(), alignFrame); + public void actionPerformed(ActionEvent e) + { + AlignmentView msa = alignFrame + .gatherSequencesForAlignment(); + new MsaWSClient(service, preset, alignFrame.getTitle(), + msa, false, true, alignFrame.getViewport() + .getAlignment().getDataset(), alignFrame); - } + } - }); - presetlist.add(methodR); + }); + presetlist.add(methodR); + } + msawsmenu.add(presetlist); } - msawsmenu.add(presetlist); } if (!submitGaps && canSubmitGaps()) {