added SeqSearch service interface. Documented and refactored web service client ...
[jalview.git] / src / jalview / ws / JPredClient.java
index 2475fb1..e14816c 100755 (executable)
@@ -18,6 +18,8 @@
  */
 package jalview.ws;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.util.*;
 
 import javax.swing.*;
@@ -114,7 +116,7 @@ public class JPredClient
     if (msa && msf.length > 1)
     {
 
-      String altitle = "JNet prediction on " + (viewonly ? "visible " : "") +
+      String altitle = getPredictionName(WebServiceName)+" on " + (viewonly ? "visible " : "") +
           seq.getName() +
           " using alignment from " + title;
 
@@ -154,7 +156,8 @@ public class JPredClient
       {
         throw new Error("Implementation Error! Multiple single sequence prediction jobs are not yet supported.");
       }
-      String altitle = "JNet prediction for " + (viewonly ? "visible " : "") +
+      
+      String altitle = getPredictionName(WebServiceName)+" for " + (viewonly ? "visible " : "") +
           "sequence " + seq.getName() +
           " from " +
           title;
@@ -181,6 +184,16 @@ public class JPredClient
     }
   }
 
+  private String getPredictionName(String webServiceName)
+  {
+    if (webServiceName.toLowerCase().indexOf("secondary structure prediction")>-1)
+    {
+      return webServiceName;
+    } else {
+      return webServiceName+"secondary structure prediction";
+    }
+  }
+
   public JPredClient(ext.vamsas.ServiceHandle sh, String title, SequenceI seq,
                      AlignFrame parentFrame)
   {
@@ -206,6 +219,13 @@ public class JPredClient
     startJPredClient(title, seq, null);
   }
 
+  public JPredClient()
+  {
+
+    super();
+    // add a class reference to the list
+  }
+
   private void startJPredClient(String title, SequenceI[] msf,
                                 AlignFrame parentFrame)
   {
@@ -317,4 +337,32 @@ public class JPredClient
 
     return server;
   }
+
+  public void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle sh, final AlignFrame af)
+  {
+    final JMenuItem method = new JMenuItem(sh.getName());
+    method.setToolTipText(sh.getEndpointURL());
+    method.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        AlignmentView msa = af.gatherSeqOrMsaForSecStrPrediction();
+        if (msa.getSequences().length == 1)
+        {
+          // Single Sequence prediction
+          new jalview.ws.JPredClient(sh, af.getTitle(), false, msa, af, true);
+        }
+        else
+        {
+          if (msa.getSequences().length > 1)
+          {
+            // Sequence profile based prediction
+            new jalview.ws.JPredClient(sh,
+                af.getTitle(), true, msa, af, true);
+          }
+        }
+      }
+    });
+    wsmenu.add(method);
+  }
 }