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.params.AutoCalcSetting;
30 import jalview.ws.params.WsParamSetI;
31 import jalview.ws.uimodel.AlignAnalysisUIText;
33 import java.awt.event.ActionEvent;
34 import java.awt.event.ActionListener;
35 import java.util.List;
37 import javax.swing.JMenu;
38 import javax.swing.JMenuItem;
44 public class SequenceAnnotationWSClient extends Jws2Client
47 * initialise a client so its attachWSMenuEntry method can be called.
49 public SequenceAnnotationWSClient()
51 // TODO Auto-generated constructor stub
54 public SequenceAnnotationWSClient(final ServiceWithParameters sh,
55 AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
57 super(alignFrame, preset, null);
58 initSequenceAnnotationWSClient(sh, alignFrame, preset, editParams);
61 // dan think. Do I need to change this method to run RNAalifold through the
64 public void initSequenceAnnotationWSClient(final ServiceWithParameters sh,
65 AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
67 // dan changed! dan test. comment out if conditional
68 // if (alignFrame.getViewport().getAlignment().isNucleotide())
70 // JvOptionPane.showMessageDialog(Desktop.desktop, sh.serviceType
71 // + " can only be used\nfor amino acid alignments.",
72 // "Wrong type of sequences!", JvOptionPane.WARNING_MESSAGE);
76 AlignAnalysisUIText aaui = sh.getAlignAnalysisUI();
79 Class clientClass = aaui.getClient();
81 // Build an AACon style client - take alignment, return annotation for
84 List<AlignCalcWorkerI> clnts = alignFrame.getViewport()
86 .getWorkersOfClass(SeqAnnotationServiceCalcWorker.class);
88 SeqAnnotationServiceCalcWorker worker = null;
91 for (AlignCalcWorkerI _worker : clnts)
93 worker = (SeqAnnotationServiceCalcWorker) _worker;
94 if (worker.hasService()
95 && worker.getService().getClass().equals(clientClass))
104 if (!processParams(sh, editParams))
110 worker = new SeqAnnotationServiceCalcWorker(sh, alignFrame, this.preset,
112 } catch (Exception x)
116 MessageManager.getString("error.implementation_error"),
119 alignFrame.getViewport().getCalcManager().registerWorker(worker); // also
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(AutoCalcSetting 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 (Jws2ClientFactory.registerAAConWSInstance(wsmenu,
176 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.getInstance().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);