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.jws2.dm.AAConSettings;
29 import jalview.ws.jws2.jabaws2.Jws2Instance;
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 Jws2Instance 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 Jws2Instance 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.getDesktop(), 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()
85 .getCalcManager().getRegisteredWorkersOfClass(clientClass);
86 AbstractJabaCalcWorker worker;
87 if (clnts == null || clnts.size() == 0)
89 if (!processParams(sh, editParams))
95 worker = (AbstractJabaCalcWorker) (clientClass
96 .getConstructor(new Class[]
97 { Jws2Instance.class, AlignFrame.class, WsParamSetI.class,
99 .newInstance(new Object[]
100 { sh, alignFrame, this.preset, paramset }));
101 } catch (Exception x)
105 MessageManager.getString("error.implementation_error"),
108 alignFrame.getViewport().getCalcManager().registerWorker(worker);
109 alignFrame.getViewport().getCalcManager().startWorker(worker);
114 worker = (AbstractJabaCalcWorker) clnts.get(0);
117 paramset = worker.getArguments();
118 preset = worker.getPreset();
121 if (!processParams(sh, editParams, true))
125 // reinstate worker if it was blacklisted (might have happened due to
126 // invalid parameters)
127 alignFrame.getViewport().getCalcManager().enableWorker(worker);
128 worker.updateParameters(this.preset, paramset);
131 if (sh.action.toLowerCase().contains("disorder"))
133 // build IUPred style client. take sequences, returns annotation per
135 if (!processParams(sh, editParams))
140 alignFrame.getViewport().getCalcManager().startWorker(
141 new AADisorderClient(sh, alignFrame, preset, paramset));
145 public SequenceAnnotationWSClient(AAConSettings fave,
146 AlignFrame alignFrame, boolean b)
148 super(alignFrame, fave.getPreset(), fave.getJobArgset());
149 initSequenceAnnotationWSClient(fave.getService(), alignFrame,
150 fave.getPreset(), b);
156 * @see jalview.ws.jws2.Jws2Client#attachWSMenuEntry(javax.swing.JMenu,
157 * jalview.ws.jws2.jabaws2.Jws2Instance, jalview.gui.AlignFrame)
159 public void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service,
160 final AlignFrame alignFrame)
162 if (registerAAConWSInstance(wsmenu, service, alignFrame))
164 // Alignment dependent analysis calculation WS gui
167 boolean hasparams = service.hasParameters();
168 // Assume name ends in WS
169 String calcName = service.serviceType.substring(0,
170 service.serviceType.length() - 2);
172 JMenuItem annotservice = new JMenuItem(MessageManager.formatMessage(
173 "label.calcname_with_default_settings", new String[]
175 annotservice.addActionListener(new ActionListener()
179 public void actionPerformed(ActionEvent e)
181 new SequenceAnnotationWSClient(service, alignFrame, null, false);
184 wsmenu.add(annotservice);
187 // only add these menu options if the service has user-modifiable
189 annotservice = new JMenuItem(
190 MessageManager.getString("label.edit_settings_and_run"));
191 annotservice.setToolTipText(MessageManager.getString(
192 "label.view_and_change_parameters_before_running_calculation"));
194 annotservice.addActionListener(new ActionListener()
196 public void actionPerformed(ActionEvent e)
198 new SequenceAnnotationWSClient(service, alignFrame, null, true);
201 wsmenu.add(annotservice);
202 List<WsParamSetI> presets = service.getParamStore().getPresets();
203 if (presets != null && presets.size() > 0)
205 JMenu presetlist = new JMenu(MessageManager
206 .formatMessage("label.run_with_preset", new String[]
209 for (final WsParamSetI preset : presets)
211 final JMenuItem methodR = new JMenuItem(preset.getName());
212 methodR.setToolTipText(JvSwingUtils.wrapTooltip(true, "<strong>"
213 + (preset.isModifiable()
214 ? MessageManager.getString("label.user_preset")
216 .getString("label.service_preset"))
217 + "</strong><br/>" + preset.getDescription()));
218 methodR.addActionListener(new ActionListener()
220 public void actionPerformed(ActionEvent e)
222 new SequenceAnnotationWSClient(service, alignFrame, preset,
227 presetlist.add(methodR);
229 wsmenu.add(presetlist);
235 annotservice = new JMenuItem(
236 MessageManager.getString("label.view_documentation"));
237 if (service.docUrl != null)
239 annotservice.addActionListener(new ActionListener()
243 public void actionPerformed(ActionEvent arg0)
245 Desktop.getInstance().showUrl(service.docUrl);
248 annotservice.setToolTipText(
249 JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage(
250 "label.view_service_doc_url", new String[]
251 { service.docUrl, service.docUrl })));
252 wsmenu.add(annotservice);