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.util.MessageManager;
31 import jalview.ws.jws2.dm.JabaWsParamSet;
32 import jalview.ws.jws2.jabaws2.Jws2Instance;
33 import jalview.ws.params.WsParamSetI;
36 * provides metadata for a jabaws2 service instance - resolves names, etc.
41 public abstract class Jws2Client extends jalview.ws.WSClient
43 protected AlignFrame alignFrame;
45 protected WsParamSetI preset;
47 protected List<Argument> paramset;
49 public Jws2Client(AlignFrame _alignFrame, WsParamSetI preset,
50 List<Argument> arguments)
52 alignFrame = _alignFrame;
56 if (!((preset instanceof JabaPreset) || preset instanceof JabaWsParamSet))
59 * { this.preset = ((JabaPreset) preset).p; } else if (preset instanceof
60 * JabaWsParamSet) { List<Argument> newargs = new ArrayList<Argument>();
61 * JabaWsParamSet pset = ((JabaWsParamSet) preset); for (Option opt :
62 * pset.getjabaArguments()) { newargs.add(opt); } if (arguments != null
63 * && arguments.size() > 0) { // merge arguments with preset's own
64 * arguments. for (Argument opt : arguments) { newargs.add(opt); } }
65 * paramset = newargs; } else {
68 "Implementation error: Can only instantiate Jaba parameter sets.");
73 // just provided with a bunch of arguments
74 this.paramset = arguments;
78 boolean processParams(Jws2Instance sh, boolean editParams)
80 return processParams(sh, editParams, false);
83 protected boolean processParams(Jws2Instance sh, boolean editParams,
84 boolean adjustingExisting)
89 if (sh.paramStore == null)
91 sh.paramStore = new JabaParamStore(sh,
92 Desktop.getUserParameterStore());
94 WsJobParameters jobParams = (preset == null && paramset != null && paramset
95 .size() > 0) ? new WsJobParameters(null, sh, null, paramset)
96 : new WsJobParameters(sh, preset);
97 if (adjustingExisting)
99 jobParams.setName(MessageManager.getString("label.adjusting_parameters_for_calculation"));
101 if (!jobParams.showRunDialog())
105 WsParamSetI prset = jobParams.getPreset();
108 paramset = jobParams.isServiceDefaults() ? null : JabaParamStore
109 .getJabafromJwsArgs(jobParams.getJobParams());
114 this.preset = prset; // ((JabaPreset) prset).p;
115 paramset = null; // no user supplied parameters.
124 // anonymous constructor - used for headless method calls only
127 protected WebserviceInfo setWebService(Jws2Instance serv, boolean b)
129 // serviceHandle = serv;
130 String serviceInstance = serv.action; // serv.service.getClass().getName();
131 WebServiceName = serv.serviceType;
132 WebServiceJobTitle = serv.getActionText();
133 WsURL = serv.hosturl;
136 return new WebserviceInfo(WebServiceJobTitle, WebServiceJobTitle
137 + " using service hosted at " + serv.hosturl + "\n"
138 + (serv.description != null ? serv.description : ""));
144 * Jws2Instance serviceHandle; (non-Javadoc)
146 * @see jalview.ws.WSMenuEntryProviderI#attachWSMenuEntry(javax.swing.JMenu,
147 * jalview.gui.AlignFrame)
149 * @Override public void attachWSMenuEntry(JMenu wsmenu, AlignFrame
150 * alignFrame) { if (serviceHandle==null) { throw new
151 * Error("Implementation error: No service handle for this Jws2 service."); }
152 * attachWSMenuEntry(wsmenu, serviceHandle, alignFrame); }
155 * add the menu item for a particular jws2 service instance
161 abstract void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service,
162 final AlignFrame alignFrame);