From: jprocter Date: Thu, 3 Nov 2011 18:14:25 +0000 (+0000) Subject: (JAL-974,JAL-975) new handler for JABAWS sequence and alignment annotation services X-Git-Tag: Jalview_2_9~564^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6709b4d7eaeb41020a0e8101730400507c8005a7;p=jalview.git (JAL-974,JAL-975) new handler for JABAWS sequence and alignment annotation services --- diff --git a/src/jalview/ws/jws2/SequenceAnnotationWSClient.java b/src/jalview/ws/jws2/SequenceAnnotationWSClient.java new file mode 100644 index 0000000..3e4cbe1 --- /dev/null +++ b/src/jalview/ws/jws2/SequenceAnnotationWSClient.java @@ -0,0 +1,144 @@ +/** + * + */ +package jalview.ws.jws2; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +import javax.swing.JMenu; +import javax.swing.JMenuItem; + +import compbio.metadata.Argument; + +import jalview.api.AlignCalcWorkerI; +import jalview.datamodel.AlignmentView; +import jalview.gui.AlignFrame; +import jalview.gui.JvSwingUtils; +import jalview.ws.jws2.jabaws2.Jws2Instance; +import jalview.ws.params.WsParamSetI; + +/** + * @author jimp + * + */ +public class SequenceAnnotationWSClient extends Jws2Client +{ + + /** + * initialise a client so its attachWSMenuEntry method can be called. + */ + public SequenceAnnotationWSClient() + { + // TODO Auto-generated constructor stub + } + + public SequenceAnnotationWSClient(final Jws2Instance sh, + AlignFrame alignFrame, WsParamSetI preset, boolean editParams) + { + super(alignFrame, preset, null); + List clnts = alignFrame.getViewport() + .getCalcManager() + .getRegisteredWorkersOfClass(AAConsClient.class); + if (clnts == null || clnts.size() == 0) + { + if (!processParams(sh, editParams)) + { + return; + } + alignFrame + .getViewport() + .getCalcManager() + .registerWorker( + new AAConsClient(sh, alignFrame, preset, paramset)); + } + else + { + AAConsClient worker = (AAConsClient) clnts.get(0); + if (editParams) + { + paramset = worker.getArguments(); + preset = worker.getPreset(); + } + + if (!processParams(sh, editParams, true)) + return; + // reinstate worker if it was blacklisted (might have happened due to invalid parameters) + alignFrame.getViewport().getCalcManager().workerMayRun(worker); + worker.updateParameters(preset, paramset); + + } + } + + /* + * (non-Javadoc) + * + * @see jalview.ws.jws2.Jws2Client#attachWSMenuEntry(javax.swing.JMenu, + * jalview.ws.jws2.jabaws2.Jws2Instance, jalview.gui.AlignFrame) + */ + public void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service, + final AlignFrame alignFrame) + { + if (service.serviceType.toLowerCase().contains("aaconws")) + { + boolean hasparams = service.hasParameters(); + String calcName = "AACons"; + System.out.println("Making an aacons client!"); + JMenuItem aacons = new JMenuItem("AACons Defaults"); + aacons.addActionListener(new ActionListener() + { + + @Override + public void actionPerformed(ActionEvent e) + { + new SequenceAnnotationWSClient(service, alignFrame, null, false); + } + }); + wsmenu.add(aacons); + if (hasparams) + { + // only add these menu options if the service has user-modifiable + // arguments + aacons = new JMenuItem("Edit settings and run ..."); + aacons.setToolTipText("View and change the parameters before alignment."); + + aacons.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + new SequenceAnnotationWSClient(service, alignFrame, null, true); + } + }); + wsmenu.add(aacons); + List presets = service.getParamStore().getPresets(); + if (presets != null && presets.size() > 0) + { + JMenu presetlist = new JMenu("Run " + calcName + "with preset"); + + for (final WsParamSetI preset : presets) + { + final JMenuItem methodR = new JMenuItem(preset.getName()); + methodR.setToolTipText("

" + + JvSwingUtils.wrapTooltip("" + + (preset.isModifiable() ? "User Preset" + : "Service Preset") + "
" + + preset.getDescription() + "

") + ""); + methodR.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + new SequenceAnnotationWSClient(service, alignFrame, preset, + false); + } + + }); + presetlist.add(methodR); + } + wsmenu.add(presetlist); + } + } + + } + } +}