2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ws.jws2;
23 import java.util.List;
25 import javax.swing.JMenu;
27 import compbio.metadata.Argument;
29 import jalview.gui.AlignFrame;
30 import jalview.gui.Desktop;
31 import jalview.gui.WebserviceInfo;
32 import jalview.gui.WsJobParameters;
33 import jalview.util.MessageManager;
34 import jalview.ws.jws2.dm.JabaWsParamSet;
35 import jalview.ws.jws2.jabaws2.Jws2Instance;
36 import jalview.ws.params.WsParamSetI;
39 * provides metadata for a jabaws2 service instance - resolves names, etc.
44 public abstract class Jws2Client extends jalview.ws.WSClient
46 protected AlignFrame alignFrame;
48 protected WsParamSetI preset;
50 protected List<Argument> paramset;
52 public Jws2Client(AlignFrame _alignFrame, WsParamSetI preset,
53 List<Argument> arguments)
55 alignFrame = _alignFrame;
59 if (!((preset instanceof JabaPreset) || preset instanceof JabaWsParamSet))
62 * { this.preset = ((JabaPreset) preset).p; } else if (preset instanceof
63 * JabaWsParamSet) { List<Argument> newargs = new ArrayList<Argument>();
64 * JabaWsParamSet pset = ((JabaWsParamSet) preset); for (Option opt :
65 * pset.getjabaArguments()) { newargs.add(opt); } if (arguments != null
66 * && arguments.size() > 0) { // merge arguments with preset's own
67 * arguments. for (Argument opt : arguments) { newargs.add(opt); } }
68 * paramset = newargs; } else {
71 "Implementation error: Can only instantiate Jaba parameter sets.");
76 // just provided with a bunch of arguments
77 this.paramset = arguments;
81 boolean processParams(Jws2Instance sh, boolean editParams)
83 return processParams(sh, editParams, false);
86 protected boolean processParams(Jws2Instance sh, boolean editParams,
87 boolean adjustingExisting)
92 if (sh.paramStore == null)
94 sh.paramStore = new JabaParamStore(sh,
95 Desktop.getUserParameterStore());
97 WsJobParameters jobParams = (preset == null && paramset != null && paramset
98 .size() > 0) ? new WsJobParameters(null, sh, null, paramset)
99 : new WsJobParameters(sh, preset);
100 if (adjustingExisting)
102 jobParams.setName(MessageManager
103 .getString("label.adjusting_parameters_for_calculation"));
105 if (!jobParams.showRunDialog())
109 WsParamSetI prset = jobParams.getPreset();
112 paramset = jobParams.isServiceDefaults() ? null : JabaParamStore
113 .getJabafromJwsArgs(jobParams.getJobParams());
118 this.preset = prset; // ((JabaPreset) prset).p;
119 paramset = null; // no user supplied parameters.
128 // anonymous constructor - used for headless method calls only
131 protected WebserviceInfo setWebService(Jws2Instance serv, boolean b)
133 // serviceHandle = serv;
134 String serviceInstance = serv.action; // serv.service.getClass().getName();
135 WebServiceName = serv.serviceType;
136 WebServiceJobTitle = serv.getActionText();
137 WsURL = serv.hosturl;
140 return new WebserviceInfo(WebServiceJobTitle, WebServiceJobTitle
141 + " using service hosted at " + serv.hosturl + "\n"
142 + (serv.description != null ? serv.description : ""));
148 * Jws2Instance serviceHandle; (non-Javadoc)
150 * @see jalview.ws.WSMenuEntryProviderI#attachWSMenuEntry(javax.swing.JMenu,
151 * jalview.gui.AlignFrame)
153 * @Override public void attachWSMenuEntry(JMenu wsmenu, AlignFrame
154 * alignFrame) { if (serviceHandle==null) { throw new
155 * Error("Implementation error: No service handle for this Jws2 service."); }
156 * attachWSMenuEntry(wsmenu, serviceHandle, alignFrame); }
159 * add the menu item for a particular jws2 service instance
165 abstract void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service,
166 final AlignFrame alignFrame);