X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fjws2%2FMsaWSClient.java;h=b961cfd09b757bac1f890669a6d368569a2f5765;hb=17e77c3f2949a0729322b4a8d907f3f34b6a9914;hp=d9452a3c06b0722900df9403660bf26020eace97;hpb=501d5434f5e6a535d6ffcdced863d15aa84d2b61;p=jalview.git diff --git a/src/jalview/ws/jws2/MsaWSClient.java b/src/jalview/ws/jws2/MsaWSClient.java index d9452a3..b961cfd 100644 --- a/src/jalview/ws/jws2/MsaWSClient.java +++ b/src/jalview/ws/jws2/MsaWSClient.java @@ -1,6 +1,6 @@ /* - * 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 2.9) + * Copyright (C) 2015 The Jalview Authors * * This file is part of Jalview. * @@ -22,7 +22,6 @@ package jalview.ws.jws2; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentView; -import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; import jalview.gui.Desktop; import jalview.gui.JvSwingUtils; @@ -110,8 +109,7 @@ public class MsaWSClient extends Jws2Client // redundant at mo - but may change JOptionPane.showMessageDialog(Desktop.desktop, MessageManager .formatMessage("label.service_called_is_not_msa_service", - new String[] - { sh.serviceType }), MessageManager + new String[] { sh.serviceType }), MessageManager .getString("label.internal_jalview_error"), JOptionPane.WARNING_MESSAGE); @@ -121,8 +119,8 @@ public class MsaWSClient extends Jws2Client if ((wsInfo = setWebService(sh, false)) == null) { JOptionPane.showMessageDialog(Desktop.desktop, MessageManager - .formatMessage("label.msa_service_is_unknown", new String[] - { sh.serviceType }), MessageManager + .formatMessage("label.msa_service_is_unknown", + new String[] { sh.serviceType }), MessageManager .getString("label.internal_jalview_error"), JOptionPane.WARNING_MESSAGE); @@ -131,7 +129,6 @@ public class MsaWSClient extends Jws2Client startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset); - } public MsaWSClient() @@ -175,59 +172,27 @@ public class MsaWSClient extends Jws2Client 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 seqs = av.getVisibleAlignment('c').getSequences(); // .getSequences(); - if (seqs.size() < 2) + 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?)(-?)(.?)]+)?[a-zA-Z]([(a-zA-Z?)(-?)(.?)]+)?")) - { - ++validSeqCount; - } - if (validSeqCount > 1) - { - return true; - } + JOptionPane.showMessageDialog(alignFrame, + MessageManager.getString("info.invalid_msa_input_mininfo"), + MessageManager.getString("info.invalid_msa_notenough"), + JOptionPane.INFORMATION_MESSAGE); + wsInfo.setVisible(false); } - - JOptionPane - .showMessageDialog( - alignFrame, - "A minimum of two sequences with at least one non-gap character \nin each sequence is 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?)(-?)(.?)]+)?[a-zA-Z]([(a-zA-Z?)(-?)(.?)]+)?")); + System.out.println("A".matches("(-*[a-zA-Z]-*){1}[a-zA-Z-]*")); } - - protected String getServiceActionKey() { return "MsaWS"; @@ -282,8 +247,7 @@ public class MsaWSClient extends Jws2Client { action = "Realign "; msawsmenu = new JMenu(MessageManager.formatMessage( - "label.realign_with_params", new String[] - { svcname })); + "label.realign_with_params", new String[] { svcname })); msawsmenu.setToolTipText(MessageManager .getString("label.align_sequences_to_existing_alignment")); rmsawsmenu.add(msawsmenu); @@ -291,11 +255,11 @@ public class MsaWSClient extends Jws2Client final boolean withGaps = submitGaps; 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 })); + "label.calcname_with_default_settings", + new String[] { calcName })); + method.setToolTipText(MessageManager + .formatMessage("label.action_with_default_settings", + new String[] { action })); method.addActionListener(new ActionListener() { @@ -303,11 +267,11 @@ public class MsaWSClient extends Jws2Client { 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); } } @@ -327,12 +291,12 @@ public class MsaWSClient extends Jws2Client 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); } } @@ -341,9 +305,10 @@ public class MsaWSClient extends Jws2Client 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 })); + JMenu presetlist = new JMenu( + MessageManager.formatMessage( + "label.run_with_preset_params", + new String[] { calcName })); final int showToolTipFor = ToolTipManager.sharedInstance() .getDismissDelay(); @@ -365,7 +330,8 @@ public class MsaWSClient extends Jws2Client @Override public void mouseExited(MouseEvent e) { - ToolTipManager.sharedInstance().setDismissDelay(showToolTipFor); + ToolTipManager.sharedInstance().setDismissDelay( + showToolTipFor); } }); @@ -385,11 +351,12 @@ public class MsaWSClient extends Jws2Client 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); } }