X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fjws2%2FMsaWSClient.java;h=9ddc69a56f5f7dcca112b0e6ff9fb0584c21e00c;hb=057f733ab390518a3641f1dedebd36c028bf03d6;hp=a557cf79a1ef4080aad567348406b22d185be9d4;hpb=39c0b5e5d2ff4352d36bb6705121dc5ed14ba81b;p=jalview.git diff --git a/src/jalview/ws/jws2/MsaWSClient.java b/src/jalview/ws/jws2/MsaWSClient.java index a557cf7..9ddc69a 100644 --- a/src/jalview/ws/jws2/MsaWSClient.java +++ b/src/jalview/ws/jws2/MsaWSClient.java @@ -1,31 +1,38 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.ws.jws2; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.List; import javax.swing.*; import jalview.datamodel.*; import jalview.gui.*; import compbio.data.msa.MsaWS; -import jalview.ws.jws2.Jws2Discoverer.Jws2Instance; +import compbio.metadata.Argument; +import jalview.util.MessageManager; +import jalview.ws.jws2.jabaws2.Jws2Instance; +import jalview.ws.params.WsParamSetI; /** * DOCUMENT ME! @@ -39,7 +46,26 @@ public class MsaWSClient extends Jws2Client * server is a WSDL2Java generated stub for an archetypal MsaWSI service. */ MsaWS server; - AlignFrame alignFrame; + + public MsaWSClient(Jws2Instance sh, String altitle, + jalview.datamodel.AlignmentView msa, boolean submitGaps, + boolean preserveOrder, Alignment seqdataset, + AlignFrame _alignFrame) + { + this(sh, null, null, false, altitle, msa, submitGaps, preserveOrder, + seqdataset, _alignFrame); + // TODO Auto-generated constructor stub + } + + public MsaWSClient(Jws2Instance sh, WsParamSetI preset, String altitle, + jalview.datamodel.AlignmentView msa, boolean submitGaps, + boolean preserveOrder, Alignment seqdataset, + AlignFrame _alignFrame) + { + this(sh, preset, null, false, altitle, msa, submitGaps, preserveOrder, + seqdataset, _alignFrame); + // TODO Auto-generated constructor stub + } /** * Creates a new MsaWSClient object that uses a service given by an externally @@ -57,33 +83,35 @@ public class MsaWSClient extends Jws2Client * DOCUMENT ME! */ - public MsaWSClient(Jws2Discoverer.Jws2Instance sh, String altitle, + public MsaWSClient(Jws2Instance sh, WsParamSetI preset, + List arguments, boolean editParams, String altitle, jalview.datamodel.AlignmentView msa, boolean submitGaps, boolean preserveOrder, Alignment seqdataset, AlignFrame _alignFrame) { - super(); - alignFrame = _alignFrame; + super(_alignFrame, preset, arguments); + if (!processParams(sh, editParams)) + { + return; + } + if (!(sh.service instanceof MsaWS)) { // redundant at mo - but may change JOptionPane .showMessageDialog( Desktop.desktop, - "The Service called \n" - + sh.serviceType - + "\nis not a \nMultiple Sequence Alignment Service !", - "Internal Jalview Error", JOptionPane.WARNING_MESSAGE); + MessageManager.formatMessage("label.service_called_is_not_msa_service", new String[]{sh.serviceType}), + MessageManager.getString("label.internal_jalview_error"), JOptionPane.WARNING_MESSAGE); return; } - server = sh.service; + server = (MsaWS) sh.service; if ((wsInfo = setWebService(sh, false)) == null) { JOptionPane.showMessageDialog(Desktop.desktop, - "The Multiple Sequence Alignment Service named " - + sh.serviceType + " is unknown", - "Internal Jalview Error", JOptionPane.WARNING_MESSAGE); + MessageManager.formatMessage("label.msa_service_is_unknown", new String[]{sh.serviceType}), + MessageManager.getString("label.internal_jalview_error"), JOptionPane.WARNING_MESSAGE); return; } @@ -100,10 +128,10 @@ public class MsaWSClient extends Jws2Client private void startMsaWSClient(String altitle, AlignmentView msa, boolean submitGaps, boolean preserveOrder, Alignment seqdataset) { - //if (!locateWebService()) - // { - // return; - // } + // if (!locateWebService()) + // { + // return; + // } wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment") + " of " + altitle + "\nJob details\n"); @@ -129,9 +157,9 @@ public class MsaWSClient extends Jws2Client + "alignment of " + altitle; } - MsaWSThread msathread = new MsaWSThread(server, WsURL, wsInfo, - alignFrame, WebServiceName, jobtitle, msa, submitGaps, - preserveOrder, seqdataset); + MsaWSThread msathread = new MsaWSThread(server, preset, paramset, + WsURL, wsInfo, alignFrame, WebServiceName, jobtitle, msa, + submitGaps, preserveOrder, seqdataset); wsInfo.setthisService(msathread); msathread.start(); } @@ -159,47 +187,126 @@ public class MsaWSClient extends Jws2Client return (WebServiceName.indexOf("lustal") > -1); // cheat! } - public void attachWSMenuEntry(JMenu msawsmenu, + public void attachWSMenuEntry(JMenu rmsawsmenu, final Jws2Instance service, final AlignFrame alignFrame) { + if (registerAAConWSInstance(rmsawsmenu, service, alignFrame)) + { + // Alignment dependent analysis calculation WS gui + return; + } setWebService(service, true); // headless - JMenuItem method = new JMenuItem(WebServiceName); - method.setToolTipText(WsURL); - method.addActionListener(new ActionListener() + boolean finished = true, submitGaps = false; + JMenu msawsmenu = rmsawsmenu; + String svcname = WebServiceName; + if (svcname.endsWith("WS")) + { + svcname = svcname.substring(0, svcname.length() - 2); + } + String calcName = svcname + " "; + if (canSubmitGaps()) + { + msawsmenu = new JMenu(svcname); + rmsawsmenu.add(msawsmenu); + calcName = ""; + } + boolean hasparams = service.hasParameters(); + do { - public void actionPerformed(ActionEvent e) + String action = "Align "; + if (submitGaps == true) { - AlignmentView msa = alignFrame.gatherSequencesForAlignment(); - new MsaWSClient(service, alignFrame.getTitle(), - msa, false, true, alignFrame.getViewport().getAlignment() - .getDataset(), alignFrame); - + action = "Realign "; + msawsmenu = new JMenu(MessageManager.formatMessage( + "label.realign_with_params", new String[] + { svcname })); + msawsmenu.setToolTipText(MessageManager + .getString("label.align_sequences_to_existing_alignment")); + rmsawsmenu.add(msawsmenu); } + final boolean withGaps = submitGaps; - }); - msawsmenu.add(method); - if (canSubmitGaps()) - { - // We know that ClustalWS can accept partial alignments for refinement. - final JMenuItem methodR = new JMenuItem(WebServiceName - + " (With Gaps)"); - methodR.setToolTipText(WsURL); - methodR.addActionListener(new ActionListener() + JMenuItem method = new JMenuItem(MessageManager.formatMessage( + "label.calcname_with_default_settings", new String[] + { calcName })); + method.setToolTipText(MessageManager.formatMessage( + "label.action_with_default_settings", new String[] + { action })); + + method.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AlignmentView msa = alignFrame.gatherSequencesForAlignment(); - new MsaWSClient(service, alignFrame.getTitle(), - msa, true, true, alignFrame.getViewport().getAlignment() + new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps, + true, alignFrame.getViewport().getAlignment() .getDataset(), alignFrame); } - }); - msawsmenu.add(methodR); + msawsmenu.add(method); + if (hasparams) + { + // only add these menu options if the service has user-modifiable + // arguments + method = new JMenuItem( + MessageManager.getString("label.edit_settings_and_run")); + method.setToolTipText(MessageManager + .getString("label.view_and_change_parameters_before_alignment")); - } + method.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + AlignmentView msa = alignFrame.gatherSequencesForAlignment(); + new MsaWSClient(service, null, null, true, alignFrame + .getTitle(), msa, withGaps, true, alignFrame + .getViewport().getAlignment().getDataset(), alignFrame); - } + } + }); + msawsmenu.add(method); + List presets = service.getParamStore().getPresets(); + if (presets != null && presets.size() > 0) + { + JMenu presetlist = new JMenu(MessageManager.formatMessage( + "label.run_with_preset_params", new String[] + { calcName })); + + for (final WsParamSetI preset : presets) + { + final JMenuItem methodR = new JMenuItem(preset.getName()); + methodR.setToolTipText(JvSwingUtils.wrapTooltip(true, "

" + + (preset.isModifiable() ? MessageManager.getString("label.user_preset") + : MessageManager.getString("label.service_preset")) + "
" + + preset.getDescription() + "

")); + methodR.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + AlignmentView msa = alignFrame + .gatherSequencesForAlignment(); + new MsaWSClient(service, preset, alignFrame.getTitle(), + msa, false, true, alignFrame.getViewport() + .getAlignment().getDataset(), alignFrame); + + } + }); + presetlist.add(methodR); + } + msawsmenu.add(presetlist); + } + } + if (!submitGaps && canSubmitGaps()) + { + submitGaps = true; + finished = false; + } + else + { + finished = true; + } + } while (!finished); + } }