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 = new AbstractJabaCalcWorker(sh, alignFrame, this.preset,
102 MessageManager.getString("error.implementation_error"),
105 alignFrame.getViewport().getCalcManager().registerWorker(worker);
106 alignFrame.getViewport().getCalcManager().startWorker(worker);
111 worker = (AbstractJabaCalcWorker) clnts.get(0);
114 paramset = worker.getArguments();
115 preset = worker.getPreset();
118 if (!processParams(sh, editParams, true))
122 // reinstate worker if it was blacklisted (might have happened due to
123 // invalid parameters)
124 alignFrame.getViewport().getCalcManager().enableWorker(worker);
125 worker.updateParameters(this.preset, paramset);
128 if (sh.getAction().toLowerCase().contains("disorder"))
130 // build IUPred style client. take sequences, returns annotation per
132 if (!processParams(sh, editParams))
137 alignFrame.getViewport().getCalcManager().startWorker(
138 new AbstractJabaCalcWorker(sh, alignFrame, preset, paramset));
142 public SequenceAnnotationWSClient(AAConSettings fave,
143 AlignFrame alignFrame, boolean b)
145 super(alignFrame, fave.getPreset(), fave.getArgumentSet());
146 initSequenceAnnotationWSClient(fave.getService(), alignFrame,
147 fave.getPreset(), b);
153 * @see jalview.ws.jws2.Jws2Client#attachWSMenuEntry(javax.swing.JMenu,
154 * jalview.ws.jws2.jabaws2.Jws2Instance, jalview.gui.AlignFrame)
157 public void attachWSMenuEntry(JMenu wsmenu,
158 final ServiceWithParameters service,
159 final AlignFrame alignFrame)
161 if (Jws2ClientFactory.registerAAConWSInstance(wsmenu, service,
164 // Alignment dependent analysis calculation WS gui
167 boolean hasparams = service.hasParameters();
168 // Assume name ends in WS
169 String calcName = service.getName().substring(0,
170 service.getName().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((Jws2Instance) service, alignFrame,
185 wsmenu.add(annotservice);
188 // only add these menu options if the service has user-modifiable
190 annotservice = new JMenuItem(
191 MessageManager.getString("label.edit_settings_and_run"));
192 annotservice.setToolTipText(MessageManager.getString(
193 "label.view_and_change_parameters_before_running_calculation"));
195 annotservice.addActionListener(new ActionListener()
198 public void actionPerformed(ActionEvent e)
200 new SequenceAnnotationWSClient((Jws2Instance) service, alignFrame,
204 wsmenu.add(annotservice);
205 List<WsParamSetI> presets = service.getParamStore().getPresets();
206 if (presets != null && presets.size() > 0)
208 JMenu presetlist = new JMenu(MessageManager
209 .formatMessage("label.run_with_preset", new String[]
212 for (final WsParamSetI preset : presets)
214 final JMenuItem methodR = new JMenuItem(preset.getName());
215 methodR.setToolTipText(JvSwingUtils.wrapTooltip(true, "<strong>"
216 + (preset.isModifiable()
217 ? MessageManager.getString("label.user_preset")
219 .getString("label.service_preset"))
220 + "</strong><br/>" + preset.getDescription()));
221 methodR.addActionListener(new ActionListener()
224 public void actionPerformed(ActionEvent e)
226 new SequenceAnnotationWSClient((Jws2Instance) service,
232 presetlist.add(methodR);
234 wsmenu.add(presetlist);
240 annotservice = new JMenuItem(
241 MessageManager.getString("label.view_documentation"));
242 if (service != null && service.hasDocumentationUrl())
244 annotservice.addActionListener(new ActionListener()
248 public void actionPerformed(ActionEvent arg0)
250 Desktop.instance.showUrl(service.getDocumentationUrl());
253 annotservice.setToolTipText(
254 JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage(
255 "label.view_service_doc_url", new String[]
256 { service.getDocumentationUrl(),
257 service.getDocumentationUrl() })));
258 wsmenu.add(annotservice);