/*
- * 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-Rel$$)
+ * Copyright (C) $$Year-Rel$$ 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 <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.ws.jws2;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AlignmentView;
+import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
+import jalview.gui.JvOptionPane;
+import jalview.gui.JvSwingUtils;
+import jalview.util.MessageManager;
+import jalview.ws.WSMenuEntryProviderI;
+import jalview.ws.api.JalviewServiceEndpointProviderI;
+import jalview.ws.api.MultipleSequenceAlignmentI;
+import jalview.ws.api.ServiceWithParameters;
+import jalview.ws.gui.MsaWSThread;
+import jalview.ws.jws2.jabaws2.Jws2Instance;
+import jalview.ws.params.ArgumentI;
+import jalview.ws.params.WsParamSetI;
+
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.util.ArrayList;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import java.util.List;
-import javax.swing.*;
-
-import jalview.datamodel.*;
-import jalview.gui.*;
-import compbio.data.msa.MsaWS;
-import compbio.metadata.Argument;
-import compbio.metadata.Option;
-import compbio.metadata.Preset;
-import compbio.metadata.PresetManager;
-import jalview.ws.jws2.Jws2Discoverer.Jws2Instance;
-import jalview.ws.jws2.dm.JabaWsParamSet;
-import jalview.ws.params.WsParamSetI;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.ToolTipManager;
/**
- * DOCUMENT ME!
+ * MsaWSClient
+ *
+ * Instantiates web service menu items for multiple alignment services, and
+ * holds logic for constructing a web service thread.
+ *
+ * TODO remove dependency on Jws2Client methods for creating AACon service UI
+ * elements.
*
- * @author $author$
+ * @author Jim Procter et al
* @version $Revision$
*/
-public class MsaWSClient extends Jws2Client
+public class MsaWSClient extends Jws2Client implements WSMenuEntryProviderI
{
/**
- * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
+ * server is a proxy class implementing the core methods for submitting,
+ * monitoring and retrieving results from a multiple sequence alignment
+ * service
*/
- MsaWS server;
+ MultipleSequenceAlignmentI server;
- AlignFrame alignFrame;
-
- private Preset preset;
-
- private List<Argument> paramset;
-
- public MsaWSClient(Jws2Discoverer.Jws2Instance sh, String altitle,
+ public MsaWSClient(ServiceWithParameters sh, String altitle,
jalview.datamodel.AlignmentView msa, boolean submitGaps,
- boolean preserveOrder, Alignment seqdataset,
+ boolean preserveOrder, AlignmentI seqdataset,
AlignFrame _alignFrame)
{
this(sh, null, null, false, altitle, msa, submitGaps, preserveOrder,
// TODO Auto-generated constructor stub
}
- public MsaWSClient(Jws2Discoverer.Jws2Instance sh, WsParamSetI preset,
- String altitle, jalview.datamodel.AlignmentView msa,
- boolean submitGaps, boolean preserveOrder, Alignment seqdataset,
+ public MsaWSClient(ServiceWithParameters sh, WsParamSetI preset,
+ String altitle,
+ jalview.datamodel.AlignmentView msa, boolean submitGaps,
+ boolean preserveOrder, AlignmentI seqdataset,
AlignFrame _alignFrame)
{
this(sh, preset, null, false, altitle, msa, submitGaps, preserveOrder,
* DOCUMENT ME!
*/
- public MsaWSClient(Jws2Discoverer.Jws2Instance sh, WsParamSetI preset,
- List<Argument> arguments, boolean editParams, String altitle,
+ public MsaWSClient(ServiceWithParameters sh, WsParamSetI preset,
+ List<ArgumentI> arguments, boolean editParams, String altitle,
jalview.datamodel.AlignmentView msa, boolean submitGaps,
- boolean preserveOrder, Alignment seqdataset,
+ boolean preserveOrder, AlignmentI seqdataset,
AlignFrame _alignFrame)
{
- super();
- alignFrame = _alignFrame;
- if (!(sh.service instanceof MsaWS))
+ super(_alignFrame, preset, arguments);
+ if (!processParams(sh, editParams))
{
- // 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);
-
return;
}
- server = sh.service;
- if (preset != null)
- {
- if (preset instanceof JabaPreset)
- {
- this.preset = ((JabaPreset) preset).p;
- }
- else if (preset instanceof JabaWsParamSet)
- {
- List<Argument> newargs = new ArrayList<Argument>();
- JabaWsParamSet pset = ((JabaWsParamSet) preset);
- for (Option opt : pset.getjabaArguments())
- {
- newargs.add(opt);
- }
- if (arguments != null && arguments.size() > 0)
- {
- // merge arguments with preset's own arguments.
- for (Argument opt : arguments)
- {
- newargs.add(opt);
- }
- }
- paramset = newargs;
- }
- else
- {
- throw new Error(
- "Implementation error: Can only instantiate Jaba parameter sets.");
- }
- }
- else
- {
- // just provided with a bunch of arguments
- this.paramset = arguments;
- }
- if (editParams)
+
+ if (!(sh instanceof JalviewServiceEndpointProviderI
+ && ((JalviewServiceEndpointProviderI) sh)
+ .getEndpoint() instanceof MultipleSequenceAlignmentI))
{
- if (sh.paramStore == null)
- {
- sh.paramStore = new JabaParamStore(sh, Desktop.getUserParameterStore());
- }
- WsJobParameters jobParams = new WsJobParameters(sh, preset);
- if (!jobParams.showRunDialog())
- {
- return;
- }
- WsParamSetI prset = jobParams.getPreset();
- if (prset == null)
- {
- paramset = JabaParamStore.getJabafromJwsArgs(jobParams
- .getJobParams());
- }
- else
- {
- this.preset = ((JabaPreset) prset).p;
- paramset = null; // no user supplied parameters.
- }
- }
+ // redundant at mo - but may change
+ JvOptionPane.showMessageDialog(Desktop.desktop,
+ MessageManager.formatMessage(
+ "label.service_called_is_not_msa_service",
+ new String[]
+ { sh.getName() }),
+ MessageManager.getString("label.internal_jalview_error"),
+ JvOptionPane.WARNING_MESSAGE);
+ return;
+ }
+ serviceHandle = sh;
+ server = (MultipleSequenceAlignmentI) ((JalviewServiceEndpointProviderI) sh)
+ .getEndpoint();
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);
+ JvOptionPane.showMessageDialog(Desktop.desktop, MessageManager
+ .formatMessage("label.msa_service_is_unknown", new String[]
+ { sh.getName() }),
+ MessageManager.getString("label.internal_jalview_error"),
+ JvOptionPane.WARNING_MESSAGE);
return;
}
+
startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
}
}
private void startMsaWSClient(String altitle, AlignmentView msa,
- boolean submitGaps, boolean preserveOrder, Alignment seqdataset)
+ boolean submitGaps, boolean preserveOrder, AlignmentI seqdataset)
{
// if (!locateWebService())
// {
String jobtitle = WebServiceName.toLowerCase();
if (jobtitle.endsWith("alignment"))
{
- if (submitGaps
- && (!jobtitle.endsWith("realignment") || jobtitle
- .indexOf("profile") == -1))
+ if (submitGaps && (!jobtitle.endsWith("realignment")
+ || jobtitle.indexOf("profile") == -1))
{
int pos = jobtitle.indexOf("alignment");
jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
+ "alignment of " + altitle;
}
- MsaWSThread msathread = new MsaWSThread(server, preset, paramset,
- WsURL, wsInfo, alignFrame, WebServiceName, jobtitle, msa,
- submitGaps, preserveOrder, seqdataset);
- wsInfo.setthisService(msathread);
- msathread.start();
+ MsaWSThread msathread = new MsaWSThread(server, preset, paramset, WsURL,
+ wsInfo, alignFrame, WebServiceName, jobtitle, msa, submitGaps,
+ preserveOrder, seqdataset);
+ if (msathread.hasValidInput())
+ {
+ wsInfo.setthisService(msathread);
+ wsInfo.setVisible(true);
+ msathread.start();
+ }
+ else
+ {
+ JvOptionPane.showMessageDialog(alignFrame,
+ MessageManager.getString("info.invalid_msa_input_mininfo"),
+ MessageManager.getString("info.invalid_msa_notenough"),
+ JvOptionPane.INFORMATION_MESSAGE);
+ wsInfo.setVisible(false);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ System.out.println("A".matches("(-*[a-zA-Z]-*){1}[a-zA-Z-]*"));
}
protected String getServiceActionKey()
return (WebServiceName.indexOf("lustal") > -1); // cheat!
}
+ @Override
public void attachWSMenuEntry(JMenu rmsawsmenu,
final Jws2Instance service, final AlignFrame alignFrame)
{
+ if (registerAAConWSInstance(rmsawsmenu, service, alignFrame))
+ {
+ // Alignment dependent analysis calculation WS gui
+ return;
+ }
+ serviceHandle = service;
setWebService(service, true); // headless
+ attachWSMenuEntry(rmsawsmenu, alignFrame);
+ }
+
+ @Override
+ public void attachWSMenuEntry(JMenu wsmenu, AlignFrame alignFrame)
+ {
boolean finished = true, submitGaps = false;
- JMenu msawsmenu = rmsawsmenu;
+ /**
+ * temp variables holding msa service submenu or root service menu
+ */
+ JMenu msawsmenu = wsmenu;
+ JMenu rmsawsmenu = wsmenu;
String svcname = WebServiceName;
if (svcname.endsWith("WS"))
{
rmsawsmenu.add(msawsmenu);
calcName = "";
}
-
+ boolean hasparams = serviceHandle.hasParameters();
+ ServiceWithParameters service = (ServiceWithParameters) serviceHandle;
do
{
+ String action = "Align ";
if (submitGaps == true)
{
- msawsmenu = new JMenu("profile " + svcname);
+ 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;
- JMenuItem method = new JMenuItem(calcName + "Defaults");
- method.setToolTipText("Align with default settings");
- method.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- AlignmentView msa = alignFrame.gatherSequencesForAlignment();
- new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
- true, alignFrame.getViewport().getAlignment()
- .getDataset(), alignFrame);
-
- }
- });
- msawsmenu.add(method);
- method = new JMenuItem(calcName + "Edit and run ...");
- method.setToolTipText("View and change the parameters before alignment.");
+ 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()
{
+ @Override
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);
+
+ if (msa != null)
+ {
+ new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
+ true,
+ alignFrame.getViewport().getAlignment().getDataset(),
+ alignFrame);
+ }
}
});
msawsmenu.add(method);
- List<WsParamSetI> presets = service.getParamStore().getPresets();
- if (presets != null && presets.size() > 0)
+ if (hasparams)
{
- JMenu presetlist = new JMenu(calcName + "Presets");
+ // 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"));
- for (final WsParamSetI preset : presets)
+ method.addActionListener(new ActionListener()
{
- final JMenuItem methodR = new JMenuItem(preset.getName());
- methodR.setToolTipText("<html><p>"+JvSwingUtils.wrapTooltip("<strong>"
- + (preset.isModifiable() ? "User Preset"
- : "Service Preset") + "</strong><br/>"
- + preset.getDescription() + "</p>")+"</html>");
- methodR.addActionListener(new ActionListener()
+ @Override
+ public void actionPerformed(ActionEvent e)
{
- public void actionPerformed(ActionEvent e)
+ AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+ if (msa != null)
{
- AlignmentView msa = alignFrame.gatherSequencesForAlignment();
- new MsaWSClient(service, preset, alignFrame.getTitle(), msa,
- false, true, alignFrame.getViewport().getAlignment()
- .getDataset(), alignFrame);
-
+ new MsaWSClient(service, null, null, true,
+ alignFrame.getTitle(), msa, withGaps, true,
+ alignFrame.getViewport().getAlignment().getDataset(),
+ alignFrame);
}
- });
- presetlist.add(methodR);
+ }
+ });
+ msawsmenu.add(method);
+ List<WsParamSetI> presets = service.getParamStore().getPresets();
+ if (presets != null && presets.size() > 0)
+ {
+ JMenu presetlist = new JMenu(MessageManager.formatMessage(
+ "label.run_with_preset_params", new String[]
+ { calcName }));
+
+ final int showToolTipFor = ToolTipManager.sharedInstance()
+ .getDismissDelay();
+ for (final WsParamSetI preset : presets)
+ {
+ final JMenuItem methodR = new JMenuItem(preset.getName());
+ final int QUICK_TOOLTIP = 1500;
+ // JAL-1582 shorten tooltip display time in these menu items as
+ // they can obscure other options
+ methodR.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mouseEntered(MouseEvent e)
+ {
+ ToolTipManager.sharedInstance()
+ .setDismissDelay(QUICK_TOOLTIP);
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e)
+ {
+ ToolTipManager.sharedInstance()
+ .setDismissDelay(showToolTipFor);
+ }
+
+ });
+ String tooltip = JvSwingUtils.wrapTooltip(true, "<strong>"
+ + (preset.isModifiable()
+ ? MessageManager.getString("label.user_preset")
+ : MessageManager
+ .getString("label.service_preset"))
+ + "</strong><br/>" + preset.getDescription());
+ methodR.setToolTipText(tooltip);
+ methodR.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ AlignmentView msa = alignFrame
+ .gatherSequencesForAlignment();
+
+ if (msa != null)
+ {
+ MsaWSClient msac = new MsaWSClient(service, preset,
+ alignFrame.getTitle(), msa, false, true,
+ alignFrame.getViewport().getAlignment()
+ .getDataset(),
+ alignFrame);
+ }
+
+ }
+
+ });
+ presetlist.add(methodR);
+ }
+ msawsmenu.add(presetlist);
}
- msawsmenu.add(presetlist);
}
if (!submitGaps && canSubmitGaps())
{