2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
3 * Copyright (C) 2014 The Jalview Authors
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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.ws.jws2;
21 import java.util.List;
23 import javax.swing.JMenu;
25 import compbio.metadata.Argument;
27 import jalview.gui.AlignFrame;
28 import jalview.gui.Desktop;
29 import jalview.gui.WebserviceInfo;
30 import jalview.gui.WsJobParameters;
31 import jalview.util.MessageManager;
32 import jalview.ws.jws2.dm.JabaWsParamSet;
33 import jalview.ws.jws2.jabaws2.Jws2Instance;
34 import jalview.ws.params.WsParamSetI;
37 * provides metadata for a jabaws2 service instance - resolves names, etc.
42 public abstract class Jws2Client extends jalview.ws.WSClient
44 protected AlignFrame alignFrame;
46 protected WsParamSetI preset;
48 protected List<Argument> paramset;
50 public Jws2Client(AlignFrame _alignFrame, WsParamSetI preset,
51 List<Argument> arguments)
53 alignFrame = _alignFrame;
57 if (!((preset instanceof JabaPreset) || preset instanceof JabaWsParamSet))
60 * { this.preset = ((JabaPreset) preset).p; } else if (preset instanceof
61 * JabaWsParamSet) { List<Argument> newargs = new ArrayList<Argument>();
62 * JabaWsParamSet pset = ((JabaWsParamSet) preset); for (Option opt :
63 * pset.getjabaArguments()) { newargs.add(opt); } if (arguments != null
64 * && arguments.size() > 0) { // merge arguments with preset's own
65 * arguments. for (Argument opt : arguments) { newargs.add(opt); } }
66 * paramset = newargs; } else {
69 "Implementation error: Can only instantiate Jaba parameter sets.");
74 // just provided with a bunch of arguments
75 this.paramset = arguments;
79 boolean processParams(Jws2Instance sh, boolean editParams)
81 return processParams(sh, editParams, false);
84 protected boolean processParams(Jws2Instance sh, boolean editParams,
85 boolean adjustingExisting)
90 if (sh.paramStore == null)
92 sh.paramStore = new JabaParamStore(sh,
93 Desktop.getUserParameterStore());
95 WsJobParameters jobParams = (preset == null && paramset != null && paramset
96 .size() > 0) ? new WsJobParameters(null, sh, null, paramset)
97 : new WsJobParameters(sh, preset);
98 if (adjustingExisting)
100 jobParams.setName(MessageManager.getString("label.adjusting_parameters_for_calculation"));
102 if (!jobParams.showRunDialog())
106 WsParamSetI prset = jobParams.getPreset();
109 paramset = jobParams.isServiceDefaults() ? null : JabaParamStore
110 .getJabafromJwsArgs(jobParams.getJobParams());
115 this.preset = prset; // ((JabaPreset) prset).p;
116 paramset = null; // no user supplied parameters.
125 // anonymous constructor - used for headless method calls only
128 protected WebserviceInfo setWebService(Jws2Instance serv, boolean b)
130 // serviceHandle = serv;
131 String serviceInstance = serv.action; // serv.service.getClass().getName();
132 WebServiceName = serv.serviceType;
133 WebServiceJobTitle = serv.getActionText();
134 WsURL = serv.hosturl;
137 return new WebserviceInfo(WebServiceJobTitle, WebServiceJobTitle
138 + " using service hosted at " + serv.hosturl + "\n"
139 + (serv.description != null ? serv.description : ""));
145 * Jws2Instance serviceHandle; (non-Javadoc)
147 * @see jalview.ws.WSMenuEntryProviderI#attachWSMenuEntry(javax.swing.JMenu,
148 * jalview.gui.AlignFrame)
150 * @Override public void attachWSMenuEntry(JMenu wsmenu, AlignFrame
151 * alignFrame) { if (serviceHandle==null) { throw new
152 * Error("Implementation error: No service handle for this Jws2 service."); }
153 * attachWSMenuEntry(wsmenu, serviceHandle, alignFrame); }
156 * add the menu item for a particular jws2 service instance
162 abstract void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service,
163 final AlignFrame alignFrame);