added SeqSearch service interface. Documented and refactored web service client ...
[jalview.git] / src / jalview / ws / WSClient.java
index 29a8b92..91fd4b0 100755 (executable)
  */
 package jalview.ws;
 
+import javax.swing.JMenu;
+
 import ext.vamsas.*;
 import jalview.gui.*;
 
-public class WSClient
+public abstract class WSClient
 {
   /**
    * WSClient holds the basic attributes that are displayed to the user
@@ -73,6 +75,10 @@ public class WSClient
   {
     return setWebService(sh, false);
   }
+  /**
+   * original service handle that this client was derived from
+   */
+  ServiceHandle serviceHandle=null;
     /**
      * initialise WSClient service information attributes from the service handle
      * @param sh
@@ -102,4 +108,26 @@ public class WSClient
     }
     return wsInfo;
   }
+  /**
+   * convenience method to pass the serviceHandle reference that instantiated this 
+   * service on to the menu entry constructor
+   * @param wsmenu the menu to which any menu entries/sub menus are to be attached
+   * @param alignFrame the alignFrame instance that provides input data for the service
+   */
+  public void attachWSMenuEntry(JMenu wsmenu, final AlignFrame alignFrame)
+  {
+    if (serviceHandle==null)
+    {
+      throw new Error("IMPLEMENTATION ERROR: cannot attach WS Menu Entry without service handle reference!");
+    }
+    attachWSMenuEntry(wsmenu, serviceHandle, alignFrame);
+  }
+  /**
+   * method implemented by each WSClient implementation that creates menu entries that enact their service
+   * using data from alignFrame.
+   * @param wsmenu where new menu entries (and submenus) are to be attached
+   * @param serviceHandle the serviceHandle document for the service that entries are created for
+   * @param alignFrame
+   */
+  public abstract void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle serviceHandle, final AlignFrame alignFrame);
 }