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 ServiceWithParameters 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 ServiceWithParameters 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()
87 .getRegisteredWorkersOfClass(SeqAnnotationServiceCalcWorker.class);
89 SeqAnnotationServiceCalcWorker worker = null;
92 for (AlignCalcWorkerI _worker : clnts)
94 worker = (SeqAnnotationServiceCalcWorker) _worker;
95 if (worker.hasService()
96 && worker.getService().getClass().equals(clientClass))
105 if (!processParams(sh, editParams))
111 worker = new SeqAnnotationServiceCalcWorker(sh, alignFrame, this.preset,
113 } catch (Exception x)
117 MessageManager.getString("error.implementation_error"),
120 alignFrame.getViewport().getCalcManager().registerWorker(worker);
121 alignFrame.getViewport().getCalcManager().startWorker(worker);
128 paramset = worker.getArguments();
129 preset = worker.getPreset();
132 if (!processParams(sh, editParams, true))
136 // reinstate worker if it was blacklisted (might have happened due to
137 // invalid parameters)
138 alignFrame.getViewport().getCalcManager().enableWorker(worker);
139 worker.updateParameters(this.preset, paramset);
142 if (!sh.isInteractiveUpdate())
144 // build IUPred style client. take sequences, returns annotation per
146 if (!processParams(sh, editParams))
151 alignFrame.getViewport().getCalcManager().startWorker(
152 new SeqAnnotationServiceCalcWorker(sh, alignFrame, preset, paramset));
156 public SequenceAnnotationWSClient(AAConSettings fave,
157 AlignFrame alignFrame, boolean b)
159 super(alignFrame, fave.getPreset(), fave.getArgumentSet());
160 initSequenceAnnotationWSClient(fave.getService(), alignFrame,
161 fave.getPreset(), b);
167 * @see jalview.ws.jws2.Jws2Client#attachWSMenuEntry(javax.swing.JMenu,
168 * jalview.ws.jws2.jabaws2.Jws2Instance, jalview.gui.AlignFrame)
171 public void attachWSMenuEntry(JMenu wsmenu,
172 final ServiceWithParameters service,
173 final AlignFrame alignFrame)
175 if (service instanceof Jws2Instance
176 && Jws2ClientFactory.registerAAConWSInstance(wsmenu, (Jws2Instance) service, alignFrame))
178 // Alignment dependent analysis calculation WS gui
181 boolean hasparams = service.hasParameters();
182 String calcName = service.getName();
183 if (calcName.endsWith("WS"))
185 // Remove "WS" suffix
186 calcName = calcName.substring(0, calcName.length() - 2);
189 JMenuItem annotservice = new JMenuItem(MessageManager.formatMessage(
190 "label.calcname_with_default_settings", new String[]
192 annotservice.addActionListener(new ActionListener()
196 public void actionPerformed(ActionEvent e)
198 new SequenceAnnotationWSClient(service, alignFrame,
202 wsmenu.add(annotservice);
205 // only add these menu options if the service has user-modifiable
207 annotservice = new JMenuItem(
208 MessageManager.getString("label.edit_settings_and_run"));
209 annotservice.setToolTipText(MessageManager.getString(
210 "label.view_and_change_parameters_before_running_calculation"));
212 annotservice.addActionListener(new ActionListener()
215 public void actionPerformed(ActionEvent e)
217 new SequenceAnnotationWSClient(service, alignFrame,
221 wsmenu.add(annotservice);
222 List<WsParamSetI> presets = service.getParamStore().getPresets();
223 if (presets != null && presets.size() > 0)
225 JMenu presetlist = new JMenu(MessageManager
226 .formatMessage("label.run_with_preset", new String[]
229 for (final WsParamSetI preset : presets)
231 final JMenuItem methodR = new JMenuItem(preset.getName());
232 methodR.setToolTipText(JvSwingUtils.wrapTooltip(true, "<strong>"
233 + (preset.isModifiable()
234 ? MessageManager.getString("label.user_preset")
236 .getString("label.service_preset"))
237 + "</strong><br/>" + preset.getDescription()));
238 methodR.addActionListener(new ActionListener()
241 public void actionPerformed(ActionEvent e)
243 new SequenceAnnotationWSClient(service,
249 presetlist.add(methodR);
251 wsmenu.add(presetlist);
257 annotservice = new JMenuItem(
258 MessageManager.getString("label.view_documentation"));
259 if (service != null && service.hasDocumentationUrl())
261 annotservice.addActionListener(new ActionListener()
265 public void actionPerformed(ActionEvent arg0)
267 Desktop.instance.showUrl(service.getDocumentationUrl());
270 annotservice.setToolTipText(
271 JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage(
272 "label.view_service_doc_url", new String[]
273 { service.getDocumentationUrl(),
274 service.getDocumentationUrl() })));
275 wsmenu.add(annotservice);