2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.ws.jws2;
20 import java.util.List;
22 import javax.swing.JMenu;
24 import compbio.metadata.Argument;
26 import jalview.gui.AlignFrame;
27 import jalview.gui.Desktop;
28 import jalview.gui.WebserviceInfo;
29 import jalview.gui.WsJobParameters;
30 import jalview.ws.jws2.dm.JabaWsParamSet;
31 import jalview.ws.jws2.jabaws2.Jws2Instance;
32 import jalview.ws.params.WsParamSetI;
35 * provides metadata for a jabaws2 service instance - resolves names, etc.
40 public abstract class Jws2Client extends jalview.ws.WSClient
42 protected AlignFrame alignFrame;
44 protected WsParamSetI preset;
46 protected List<Argument> paramset;
48 public Jws2Client(AlignFrame _alignFrame, WsParamSetI preset,
49 List<Argument> arguments)
51 alignFrame = _alignFrame;
55 if (!((preset instanceof JabaPreset) || preset instanceof JabaWsParamSet))
58 * { this.preset = ((JabaPreset) preset).p; } else if (preset instanceof
59 * JabaWsParamSet) { List<Argument> newargs = new ArrayList<Argument>();
60 * JabaWsParamSet pset = ((JabaWsParamSet) preset); for (Option opt :
61 * pset.getjabaArguments()) { newargs.add(opt); } if (arguments != null
62 * && arguments.size() > 0) { // merge arguments with preset's own
63 * arguments. for (Argument opt : arguments) { newargs.add(opt); } }
64 * paramset = newargs; } else {
67 "Implementation error: Can only instantiate Jaba parameter sets.");
72 // just provided with a bunch of arguments
73 this.paramset = arguments;
77 boolean processParams(Jws2Instance sh, boolean editParams)
79 return processParams(sh, editParams, false);
82 protected boolean processParams(Jws2Instance sh, boolean editParams,
83 boolean adjustingExisting)
88 if (sh.paramStore == null)
90 sh.paramStore = new JabaParamStore(sh,
91 Desktop.getUserParameterStore());
93 WsJobParameters jobParams = (preset == null && paramset != null && paramset
94 .size() > 0) ? new WsJobParameters(null, sh, null, paramset)
95 : new WsJobParameters(sh, preset);
96 if (adjustingExisting)
98 jobParams.setName("Adjusting parameters for existing Calculation");
100 if (!jobParams.showRunDialog())
104 WsParamSetI prset = jobParams.getPreset();
107 paramset = jobParams.isServiceDefaults() ? null : JabaParamStore
108 .getJabafromJwsArgs(jobParams.getJobParams());
113 this.preset = prset; // ((JabaPreset) prset).p;
114 paramset = null; // no user supplied parameters.
123 // anonymous constructor - used for headless method calls only
126 protected WebserviceInfo setWebService(Jws2Instance serv, boolean b)
128 // serviceHandle = serv;
129 String serviceInstance = serv.action; // serv.service.getClass().getName();
130 WebServiceName = serv.serviceType;
131 WebServiceJobTitle = serv.getActionText();
132 WsURL = serv.hosturl;
135 return new WebserviceInfo(WebServiceJobTitle, WebServiceJobTitle
136 + " using service hosted at " + serv.hosturl + "\n"
137 + (serv.description != null ? serv.description : ""));
143 * Jws2Instance serviceHandle; (non-Javadoc)
145 * @see jalview.ws.WSMenuEntryProviderI#attachWSMenuEntry(javax.swing.JMenu,
146 * jalview.gui.AlignFrame)
148 * @Override public void attachWSMenuEntry(JMenu wsmenu, AlignFrame
149 * alignFrame) { if (serviceHandle==null) { throw new
150 * Error("Implementation error: No service handle for this Jws2 service."); }
151 * attachWSMenuEntry(wsmenu, serviceHandle, alignFrame); }
154 * add the menu item for a particular jws2 service instance
160 abstract void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service,
161 final AlignFrame alignFrame);