JAL-1620 version bump and release notes
[jalview.git] / src / jalview / ws / jws2 / MsaWSClient.java
index ebd826e..49a3412 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
  * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
@@ -21,9 +21,7 @@
 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.JvSwingUtils;
@@ -33,11 +31,14 @@ import jalview.ws.params.WsParamSetI;
 
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
 import java.util.List;
 
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 import javax.swing.JOptionPane;
+import javax.swing.ToolTipManager;
 
 import compbio.data.msa.MsaWS;
 import compbio.metadata.Argument;
@@ -106,25 +107,30 @@ public class MsaWSClient extends Jws2Client
     if (!(sh.service instanceof MsaWS))
     {
       // redundant at mo - but may change
-      JOptionPane
-              .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);
+      JOptionPane.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);
 
       return;
     }
     server = (MsaWS) sh.service;
     if ((wsInfo = setWebService(sh, false)) == null)
     {
-      JOptionPane.showMessageDialog(Desktop.desktop,
-                 MessageManager.formatMessage("label.msa_service_is_unknown", new String[]{sh.serviceType}),
-                 MessageManager.getString("label.internal_jalview_error"), JOptionPane.WARNING_MESSAGE);
+      JOptionPane.showMessageDialog(Desktop.desktop, MessageManager
+              .formatMessage("label.msa_service_is_unknown", new String[]
+              { sh.serviceType }), MessageManager
+              .getString("label.internal_jalview_error"),
+              JOptionPane.WARNING_MESSAGE);
 
       return;
     }
+
     startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
 
+
   }
 
   public MsaWSClient()
@@ -168,54 +174,25 @@ public class MsaWSClient extends Jws2Client
     MsaWSThread msathread = new MsaWSThread(server, preset, paramset,
             WsURL, wsInfo, alignFrame, WebServiceName, jobtitle, msa,
             submitGaps, preserveOrder, seqdataset);
-    wsInfo.setthisService(msathread);
-    if (isValidAlignment(alignFrame.getCurrentView().getAlignment()))
-    {
-
-    msathread.start();
-    }
-  }
-
-  private boolean isValidAlignment(AlignmentI seqdataset)
-  {
-    String header = wsInfo.getInfoText()
-            + "\nValidating submited Alignment...";
-    wsInfo.setInfoText(header);
-    int validSeqCount = 0;
-    List<SequenceI> seqs = seqdataset.getSequences();
-    if (seqs.size() < 2)
+    if (msathread.hasValidInput())
     {
-      wsInfo.setInfoText(header
-              + "\nA minimum of two sequences is required to perform this operation");
-      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)
-      {
-        wsInfo.setInfoText(header
-                + "\nAlignment sequences was successfully validated");
-        return true;
-      }
+      JOptionPane.showMessageDialog(alignFrame,
+              MessageManager.getString("info.invalid_msa_input_mininfo"),
+              MessageManager.getString("info.invalid_msa_notenough"),
+              JOptionPane.INFORMATION_MESSAGE);
+      wsInfo.setVisible(false);
     }
-
-    wsInfo.setInfoText(header
-            + "\nA minimum of two sequences with at least one non-gap character in each sequence is required to perform this operation");
-    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-]*"));
   }
 
 
@@ -294,9 +271,13 @@ public class MsaWSClient extends Jws2Client
         public void actionPerformed(ActionEvent e)
         {
           AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+
+          if (msa != null)
+          {
           new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
                   true, alignFrame.getViewport().getAlignment()
                           .getDataset(), alignFrame);
+          }
 
         }
       });
@@ -315,9 +296,12 @@ public class MsaWSClient extends Jws2Client
           public void actionPerformed(ActionEvent e)
           {
             AlignmentView msa = alignFrame.gatherSequencesForAlignment();
-            new MsaWSClient(service, null, null, true, alignFrame
+            if (msa != null)
+            {
+              new MsaWSClient(service, null, null, true, alignFrame
                     .getTitle(), msa, withGaps, true, alignFrame
                     .getViewport().getAlignment().getDataset(), alignFrame);
+            }
 
           }
         });
@@ -329,22 +313,53 @@ public class MsaWSClient extends Jws2Client
                   "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());
-            methodR.setToolTipText(JvSwingUtils.wrapTooltip(true, "<p><strong>"
-                            + (preset.isModifiable() ? MessageManager.getString("label.user_preset")
-                                    : MessageManager.getString("label.service_preset")) + "</strong><br/>"
-                            + preset.getDescription() + "</p>"));
+            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);
+              }
+
+            });
+            methodR.setToolTipText(JvSwingUtils.wrapTooltip(
+                    true,
+                    "<p><strong>"
+                            + (preset.isModifiable() ? MessageManager
+                                    .getString("label.user_preset")
+                                    : MessageManager
+                                            .getString("label.service_preset"))
+                            + "</strong><br/>" + preset.getDescription()
+                            + "</p>"));
             methodR.addActionListener(new ActionListener()
             {
               public void actionPerformed(ActionEvent e)
               {
                 AlignmentView msa = alignFrame
                         .gatherSequencesForAlignment();
-                new MsaWSClient(service, preset, alignFrame.getTitle(),
+
+                if (msa != null)
+                {
+                  MsaWSClient msac = new MsaWSClient(service, preset,
+                          alignFrame.getTitle(),
                         msa, false, true, alignFrame.getViewport()
                                 .getAlignment().getDataset(), alignFrame);
+                }
 
               }