2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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 jalview.api.AlignCalcWorkerI;
24 import jalview.gui.AlignFrame;
25 import jalview.gui.Desktop;
26 import jalview.gui.JvSwingUtils;
27 import jalview.util.MessageManager;
28 import jalview.ws.api.ServiceWithParameters;
29 import jalview.ws.jws2.dm.AAConSettings;
30 import jalview.ws.jws2.jabaws2.Jws2Instance;
31 import jalview.ws.params.WsParamSetI;
32 import jalview.ws.uimodel.AlignAnalysisUIText;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.util.List;
38 import javax.swing.JMenu;
39 import javax.swing.JMenuItem;
45 public class SequenceAnnotationWSClient extends Jws2Client
48 * initialise a client so its attachWSMenuEntry method can be called.
50 public SequenceAnnotationWSClient()
52 // TODO Auto-generated constructor stub
55 public SequenceAnnotationWSClient(final Jws2Instance sh,
56 AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
58 super(alignFrame, preset, null);
59 initSequenceAnnotationWSClient(sh, alignFrame, preset, editParams);
62 // dan think. Do I need to change this method to run RNAalifold through the
65 public void initSequenceAnnotationWSClient(final Jws2Instance sh,
66 AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
68 // dan changed! dan test. comment out if conditional
69 // if (alignFrame.getViewport().getAlignment().isNucleotide())
71 // JvOptionPane.showMessageDialog(Desktop.desktop, sh.serviceType
72 // + " can only be used\nfor amino acid alignments.",
73 // "Wrong type of sequences!", JvOptionPane.WARNING_MESSAGE);
77 AlignAnalysisUIText aaui = sh.getAlignAnalysisUI();
80 Class clientClass = aaui.getClient();
82 // Build an AACon style client - take alignment, return annotation for
85 List<AlignCalcWorkerI> clnts = alignFrame.getViewport()
86 .getCalcManager().getRegisteredWorkersOfClass(clientClass);
87 AbstractJabaCalcWorker worker;
88 if (clnts == null || clnts.size() == 0)
90 if (!processParams(sh, editParams))
96 worker = (AbstractJabaCalcWorker) (clientClass
97 .getConstructor(new Class[]
98 { Jws2Instance.class, AlignFrame.class, WsParamSetI.class,
100 .newInstance(new Object[]
101 { sh, alignFrame, this.preset, paramset }));
102 } catch (Exception x)
106 MessageManager.getString("error.implementation_error"),
109 alignFrame.getViewport().getCalcManager().registerWorker(worker);
110 alignFrame.getViewport().getCalcManager().startWorker(worker);
115 worker = (AbstractJabaCalcWorker) clnts.get(0);
118 paramset = worker.getArguments();
119 preset = worker.getPreset();
122 if (!processParams(sh, editParams, true))
126 // reinstate worker if it was blacklisted (might have happened due to
127 // invalid parameters)
128 alignFrame.getViewport().getCalcManager().enableWorker(worker);
129 worker.updateParameters(this.preset, paramset);
132 if (sh.getAction().toLowerCase().contains("disorder"))
134 // build IUPred style client. take sequences, returns annotation per
136 if (!processParams(sh, editParams))
141 alignFrame.getViewport().getCalcManager().startWorker(
142 new AADisorderClient(sh, alignFrame, preset, paramset));
146 public SequenceAnnotationWSClient(AAConSettings fave,
147 AlignFrame alignFrame, boolean b)
149 super(alignFrame, fave.getPreset(), fave.getArgumentSet());
150 initSequenceAnnotationWSClient(fave.getService(), alignFrame,
151 fave.getPreset(), b);
157 * @see jalview.ws.jws2.Jws2Client#attachWSMenuEntry(javax.swing.JMenu,
158 * jalview.ws.jws2.jabaws2.Jws2Instance, jalview.gui.AlignFrame)
161 public void attachWSMenuEntry(JMenu wsmenu,
162 final ServiceWithParameters service,
163 final AlignFrame alignFrame)
165 if (registerAAConWSInstance(wsmenu, service, alignFrame))
167 // Alignment dependent analysis calculation WS gui
170 boolean hasparams = service.hasParameters();
171 // Assume name ends in WS
172 String calcName = service.getName().substring(0,
173 service.getName().length() - 2);
175 JMenuItem annotservice = new JMenuItem(MessageManager.formatMessage(
176 "label.calcname_with_default_settings", new String[]
178 annotservice.addActionListener(new ActionListener()
182 public void actionPerformed(ActionEvent e)
184 new SequenceAnnotationWSClient((Jws2Instance) service, alignFrame,
188 wsmenu.add(annotservice);
191 // only add these menu options if the service has user-modifiable
193 annotservice = new JMenuItem(
194 MessageManager.getString("label.edit_settings_and_run"));
195 annotservice.setToolTipText(MessageManager.getString(
196 "label.view_and_change_parameters_before_running_calculation"));
198 annotservice.addActionListener(new ActionListener()
201 public void actionPerformed(ActionEvent e)
203 new SequenceAnnotationWSClient((Jws2Instance) service, alignFrame,
207 wsmenu.add(annotservice);
208 List<WsParamSetI> presets = service.getParamStore().getPresets();
209 if (presets != null && presets.size() > 0)
211 JMenu presetlist = new JMenu(MessageManager
212 .formatMessage("label.run_with_preset", new String[]
215 for (final WsParamSetI preset : presets)
217 final JMenuItem methodR = new JMenuItem(preset.getName());
218 methodR.setToolTipText(JvSwingUtils.wrapTooltip(true, "<strong>"
219 + (preset.isModifiable()
220 ? MessageManager.getString("label.user_preset")
222 .getString("label.service_preset"))
223 + "</strong><br/>" + preset.getDescription()));
224 methodR.addActionListener(new ActionListener()
227 public void actionPerformed(ActionEvent e)
229 new SequenceAnnotationWSClient((Jws2Instance) service,
235 presetlist.add(methodR);
237 wsmenu.add(presetlist);
243 annotservice = new JMenuItem(
244 MessageManager.getString("label.view_documentation"));
245 if (service != null && service.hasDocumentationUrl())
247 annotservice.addActionListener(new ActionListener()
251 public void actionPerformed(ActionEvent arg0)
253 Desktop.instance.showUrl(service.getDocumentationUrl());
256 annotservice.setToolTipText(
257 JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage(
258 "label.view_service_doc_url", new String[]
259 { service.getDocumentationUrl(),
260 service.getDocumentationUrl() })));
261 wsmenu.add(annotservice);