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 java.util.Locale;
25 import jalview.api.AlignCalcWorkerI;
26 import jalview.gui.AlignFrame;
27 import jalview.gui.Desktop;
28 import jalview.gui.JvSwingUtils;
29 import jalview.util.MessageManager;
30 import jalview.ws.jws2.dm.AAConSettings;
31 import jalview.ws.jws2.jabaws2.Jws2Instance;
32 import jalview.ws.params.WsParamSetI;
33 import jalview.ws.uimodel.AlignAnalysisUIText;
35 import java.awt.event.ActionEvent;
36 import java.awt.event.ActionListener;
37 import java.util.List;
39 import javax.swing.JMenu;
40 import javax.swing.JMenuItem;
46 public class SequenceAnnotationWSClient extends Jws2Client
49 * initialise a client so its attachWSMenuEntry method can be called.
51 public SequenceAnnotationWSClient()
53 // TODO Auto-generated constructor stub
56 public SequenceAnnotationWSClient(final Jws2Instance sh,
57 AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
59 super(alignFrame, preset, null);
60 initSequenceAnnotationWSClient(sh, alignFrame, preset, editParams);
63 // dan think. Do I need to change this method to run RNAalifold through the
66 public void initSequenceAnnotationWSClient(final Jws2Instance sh,
67 AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
69 // dan changed! dan test. comment out if conditional
70 // if (alignFrame.getViewport().getAlignment().isNucleotide())
72 // JvOptionPane.showMessageDialog(Desktop.desktop, sh.serviceType
73 // + " can only be used\nfor amino acid alignments.",
74 // "Wrong type of sequences!", JvOptionPane.WARNING_MESSAGE);
78 AlignAnalysisUIText aaui = sh.getAlignAnalysisUI();
81 Class clientClass = aaui.getClient();
83 // Build an AACon style client - take alignment, return annotation for
86 List<AlignCalcWorkerI> clnts = alignFrame.getViewport()
87 .getCalcManager().getRegisteredWorkersOfClass(clientClass);
88 AbstractJabaCalcWorker worker;
89 if (clnts == null || clnts.size() == 0)
91 if (!processParams(sh, editParams))
97 worker = (AbstractJabaCalcWorker) (clientClass
98 .getConstructor(new Class[]
99 { Jws2Instance.class, AlignFrame.class, WsParamSetI.class,
101 .newInstance(new Object[]
102 { sh, alignFrame, this.preset, paramset }));
103 } catch (Exception x)
107 MessageManager.getString("error.implementation_error"),
110 alignFrame.getViewport().getCalcManager().registerWorker(worker);
111 alignFrame.getViewport().getCalcManager().startWorker(worker);
116 worker = (AbstractJabaCalcWorker) clnts.get(0);
119 paramset = worker.getArguments();
120 preset = worker.getPreset();
123 if (!processParams(sh, editParams, true))
127 // reinstate worker if it was blacklisted (might have happened due to
128 // invalid parameters)
129 alignFrame.getViewport().getCalcManager().enableWorker(worker);
130 worker.updateParameters(this.preset, paramset);
133 if (sh.action.toLowerCase(Locale.ROOT).contains("disorder"))
135 // build IUPred style client. take sequences, returns annotation per
137 if (!processParams(sh, editParams))
142 alignFrame.getViewport().getCalcManager().startWorker(
143 new AADisorderClient(sh, alignFrame, preset, paramset));
147 public SequenceAnnotationWSClient(AAConSettings fave,
148 AlignFrame alignFrame, boolean b)
150 super(alignFrame, fave.getPreset(), fave.getJobArgset());
151 initSequenceAnnotationWSClient(fave.getService(), alignFrame,
152 fave.getPreset(), b);
158 * @see jalview.ws.jws2.Jws2Client#attachWSMenuEntry(javax.swing.JMenu,
159 * jalview.ws.jws2.jabaws2.Jws2Instance, jalview.gui.AlignFrame)
161 public void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service,
162 final AlignFrame alignFrame)
164 if (registerAAConWSInstance(wsmenu, service, alignFrame))
166 // Alignment dependent analysis calculation WS gui
169 boolean hasparams = service.hasParameters();
170 // Assume name ends in WS
171 String calcName = service.serviceType.substring(0,
172 service.serviceType.length() - 2);
174 JMenuItem annotservice = new JMenuItem(MessageManager.formatMessage(
175 "label.calcname_with_default_settings", new String[]
177 annotservice.addActionListener(new ActionListener()
181 public void actionPerformed(ActionEvent e)
183 new SequenceAnnotationWSClient(service, alignFrame, null, false);
186 wsmenu.add(annotservice);
189 // only add these menu options if the service has user-modifiable
191 annotservice = new JMenuItem(
192 MessageManager.getString("label.edit_settings_and_run"));
193 annotservice.setToolTipText(MessageManager.getString(
194 "label.view_and_change_parameters_before_running_calculation"));
196 annotservice.addActionListener(new ActionListener()
198 public void actionPerformed(ActionEvent e)
200 new SequenceAnnotationWSClient(service, alignFrame, null, true);
203 wsmenu.add(annotservice);
204 List<WsParamSetI> presets = service.getParamStore().getPresets();
205 if (presets != null && presets.size() > 0)
207 JMenu presetlist = new JMenu(MessageManager
208 .formatMessage("label.run_with_preset", new String[]
211 for (final WsParamSetI preset : presets)
213 final JMenuItem methodR = new JMenuItem(preset.getName());
214 methodR.setToolTipText(JvSwingUtils.wrapTooltip(true, "<strong>"
215 + (preset.isModifiable()
216 ? MessageManager.getString("label.user_preset")
218 .getString("label.service_preset"))
219 + "</strong><br/>" + preset.getDescription()));
220 methodR.addActionListener(new ActionListener()
222 public void actionPerformed(ActionEvent e)
224 new SequenceAnnotationWSClient(service, alignFrame, preset,
229 presetlist.add(methodR);
231 wsmenu.add(presetlist);
237 annotservice = new JMenuItem(
238 MessageManager.getString("label.view_documentation"));
239 if (service.docUrl != null)
241 annotservice.addActionListener(new ActionListener()
245 public void actionPerformed(ActionEvent arg0)
247 Desktop.instance.showUrl(service.docUrl);
250 annotservice.setToolTipText(
251 JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage(
252 "label.view_service_doc_url", new String[]
253 { service.docUrl, service.docUrl })));
254 wsmenu.add(annotservice);