/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
*/
package jalview.ws.jws2;
-import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
-import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
+import jalview.gui.JvOptionPane;
import jalview.gui.JvSwingUtils;
import jalview.util.MessageManager;
import jalview.ws.jws2.jabaws2.Jws2Instance;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
import javax.swing.ToolTipManager;
import compbio.data.msa.MsaWS;
public MsaWSClient(Jws2Instance 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,
public MsaWSClient(Jws2Instance sh, WsParamSetI preset, String altitle,
jalview.datamodel.AlignmentView msa, boolean submitGaps,
- boolean preserveOrder, Alignment seqdataset,
+ boolean preserveOrder, AlignmentI seqdataset,
AlignFrame _alignFrame)
{
this(sh, preset, null, false, altitle, msa, submitGaps, preserveOrder,
public MsaWSClient(Jws2Instance sh, WsParamSetI preset,
List<Argument> arguments, boolean editParams, String altitle,
jalview.datamodel.AlignmentView msa, boolean submitGaps,
- boolean preserveOrder, Alignment seqdataset,
+ boolean preserveOrder, AlignmentI seqdataset,
AlignFrame _alignFrame)
{
super(_alignFrame, preset, arguments);
if (!(sh.service instanceof MsaWS))
{
// redundant at mo - but may change
- JOptionPane.showMessageDialog(Desktop.desktop, MessageManager
- .formatMessage("label.service_called_is_not_msa_service",
+ JvOptionPane.showMessageDialog(Desktop.desktop,
+ MessageManager.formatMessage(
+ "label.service_called_is_not_msa_service",
new String[]
- { sh.serviceType }), MessageManager
- .getString("label.internal_jalview_error"),
- JOptionPane.WARNING_MESSAGE);
+ { sh.serviceType }),
+ MessageManager.getString("label.internal_jalview_error"),
+ JvOptionPane.WARNING_MESSAGE);
return;
}
server = (MsaWS) sh.service;
if ((wsInfo = setWebService(sh, false)) == null)
{
- JOptionPane.showMessageDialog(Desktop.desktop, MessageManager
+ JvOptionPane.showMessageDialog(Desktop.desktop, MessageManager
.formatMessage("label.msa_service_is_unknown", new String[]
- { sh.serviceType }), MessageManager
- .getString("label.internal_jalview_error"),
- JOptionPane.WARNING_MESSAGE);
+ { sh.serviceType }),
+ MessageManager.getString("label.internal_jalview_error"),
+ JvOptionPane.WARNING_MESSAGE);
return;
}
startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
-
}
public MsaWSClient()
}
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();
-
- }
-
- private boolean isValidAlignment(AlignmentView av)
- {
- int validSeqCount = 0;
- List<SequenceI> seqs = av.getVisibleAlignment('c').getSequences(); // .getSequences();
- if (seqs.size() < 2)
+ MsaWSThread msathread = new MsaWSThread(server, preset, paramset, WsURL,
+ wsInfo, alignFrame, WebServiceName, jobtitle, msa, submitGaps,
+ preserveOrder, seqdataset);
+ if (msathread.hasValidInput())
{
- JOptionPane
- .showMessageDialog(
- alignFrame,
- "A minimum of two sequences is required to perform this operation",
- "Invalid selection", JOptionPane.INFORMATION_MESSAGE);
-
- return false;
+ wsInfo.setthisService(msathread);
+ wsInfo.setVisible(true);
+ msathread.start();
}
-
- for (SequenceI seq : seqs)
+ else
{
-
- if (seq.getSequenceAsString().matches("(-*[a-zA-Z]-*){3}[a-zA-Z-]*"))
- {
- ++validSeqCount;
- }
- if (validSeqCount > 1)
- {
- return true;
- }
+ JvOptionPane.showMessageDialog(alignFrame,
+ MessageManager.getString("info.invalid_msa_input_mininfo"),
+ MessageManager.getString("info.invalid_msa_notenough"),
+ JvOptionPane.INFORMATION_MESSAGE);
+ wsInfo.setVisible(false);
}
-
- JOptionPane
- .showMessageDialog(
- alignFrame,
- "A minimum of two sequences with at least three non-gap character \nis required to perform this operation",
- "Invalid selection", JOptionPane.INFORMATION_MESSAGE);
-
- return false;
}
public static void main(String[] args)
System.out.println("A".matches("(-*[a-zA-Z]-*){1}[a-zA-Z-]*"));
}
-
-
protected String getServiceActionKey()
{
return "MsaWS";
return (WebServiceName.indexOf("lustal") > -1); // cheat!
}
+ @Override
public void attachWSMenuEntry(JMenu rmsawsmenu,
final Jws2Instance service, final AlignFrame alignFrame)
{
if (submitGaps == true)
{
action = "Realign ";
- msawsmenu = new JMenu(MessageManager.formatMessage(
- "label.realign_with_params", new String[]
+ msawsmenu = new JMenu(MessageManager
+ .formatMessage("label.realign_with_params", new String[]
{ svcname }));
msawsmenu.setToolTipText(MessageManager
.getString("label.align_sequences_to_existing_alignment"));
method.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
AlignmentView msa = alignFrame.gatherSequencesForAlignment();
- if (isValidAlignment(msa))
+ if (msa != null)
{
- new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
- true, alignFrame.getViewport().getAlignment()
- .getDataset(), alignFrame);
+ new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
+ true,
+ alignFrame.getViewport().getAlignment().getDataset(),
+ alignFrame);
}
}
// arguments
method = new JMenuItem(
MessageManager.getString("label.edit_settings_and_run"));
- method.setToolTipText(MessageManager
- .getString("label.view_and_change_parameters_before_alignment"));
+ method.setToolTipText(MessageManager.getString(
+ "label.view_and_change_parameters_before_alignment"));
method.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
AlignmentView msa = alignFrame.gatherSequencesForAlignment();
-
- if (isValidAlignment(msa))
+ if (msa != null)
{
- new MsaWSClient(service, null, null, true, alignFrame
- .getTitle(), msa, withGaps, true, alignFrame
- .getViewport().getAlignment().getDataset(), alignFrame);
+ new MsaWSClient(service, null, null, true,
+ alignFrame.getTitle(), msa, withGaps, true,
+ alignFrame.getViewport().getAlignment().getDataset(),
+ alignFrame);
}
}
@Override
public void mouseEntered(MouseEvent e)
{
- ToolTipManager.sharedInstance().setDismissDelay(
- QUICK_TOOLTIP);
+ ToolTipManager.sharedInstance()
+ .setDismissDelay(QUICK_TOOLTIP);
}
@Override
public void mouseExited(MouseEvent e)
{
- ToolTipManager.sharedInstance().setDismissDelay(showToolTipFor);
+ ToolTipManager.sharedInstance()
+ .setDismissDelay(showToolTipFor);
}
});
- methodR.setToolTipText(JvSwingUtils.wrapTooltip(
- true,
- "<p><strong>"
- + (preset.isModifiable() ? MessageManager
- .getString("label.user_preset")
- : MessageManager
- .getString("label.service_preset"))
- + "</strong><br/>" + preset.getDescription()
- + "</p>"));
+ 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 (isValidAlignment(msa))
+ if (msa != null)
{
- new MsaWSClient(service, preset, alignFrame.getTitle(),
- msa, false, true, alignFrame.getViewport()
- .getAlignment().getDataset(), alignFrame);
+ MsaWSClient msac = new MsaWSClient(service, preset,
+ alignFrame.getTitle(), msa, false, true,
+ alignFrame.getViewport().getAlignment()
+ .getDataset(),
+ alignFrame);
}
}