JAL-3954 Log events TaskEventListener.NULL_LISTENER
[jalview.git] / src / jalview / ws2 / actions / api / ActionI.java
index 0fbbe22..52d70df 100644 (file)
@@ -3,10 +3,13 @@ package jalview.ws2.actions.api;
 import java.util.EnumSet;
 import java.util.List;
 
+import javax.swing.Icon;
+
 import jalview.viewmodel.AlignmentViewport;
 import jalview.ws.params.ArgumentI;
 import jalview.ws2.api.CredentialType;
 import jalview.ws2.api.Credentials;
+import jalview.ws2.api.WebService;
 
 /**
  * {@code Action} object represents an executable action that the web service
@@ -21,12 +24,19 @@ import jalview.ws2.api.Credentials;
  * 
  * @author mmwarowny
  *
- * @param <T>
+ * @param <R>
  *          task result type
  */
-public interface ActionI<T>
+public interface ActionI<R>
 {
   /**
+   * Get the web service containing this action.
+   * 
+   * @return containing web service
+   */
+  WebService<? extends ActionI<R>> getWebService();
+
+  /**
    * Get the name of the action. Typically, it should be the same as the name of
    * the service.
    * 
@@ -35,6 +45,21 @@ public interface ActionI<T>
   String getName();
 
   /**
+   * Get the full name of the action consisting of the service name and the
+   * action name if present.
+   * 
+   * @return full name of this action
+   */
+  default String getFullName()
+  {
+    var name = getName();
+    if (name == null || name.isEmpty())
+      return getWebService().getName();
+    else
+      return getWebService().getName() + " " + name;
+  }
+
+  /**
    * Get the tooltip for the action which contains extra details about the
    * action.
    * 
@@ -105,8 +130,8 @@ public interface ActionI<T>
    *          event handler attached to the new task
    * @return new running task
    */
-  TaskI<T> perform(AlignmentViewport viewport, List<ArgumentI> args,
-      Credentials credentials, TaskEventListener<T> handler);
+  TaskI<R> perform(AlignmentViewport viewport, List<ArgumentI> args,
+      Credentials credentials, TaskEventListener<R> handler);
 
   /**
    * Return if the action is currently active for the given viewport. Active