1 package jalview.ws2.actions.api;
3 import java.util.EnumSet;
6 import javax.swing.Icon;
8 import jalview.viewmodel.AlignmentViewport;
9 import jalview.ws.params.ArgumentI;
10 import jalview.ws2.api.CredentialType;
11 import jalview.ws2.api.Credentials;
12 import jalview.ws2.api.WebService;
15 * {@code Action} object represents an executable action that the web service
16 * can perform. Actions are factories for {@link TaskI} objects which are
17 * created by {@link #perform} method. Actions are instantiated by
18 * {@link WebServiceDiscovererI} from the service definition obtained from the
19 * server and are added to and provided by the {@link WebService}.
21 * Majority of web services will have a single action only, however multiple
22 * actions providing variation to job execution are possible e.g. align and
23 * realign actions of ClustalO service.
30 public interface ActionI<R>
33 * Get the web service containing this action.
35 * @return containing web service
37 WebService<? extends ActionI<R>> getWebService();
40 * Get the name of the action. Typically, it should be the same as the name of
48 * Get the full name of the action consisting of the service name and the
49 * action name if present.
51 * @return full name of this action
53 default String getFullName()
56 if (name == null || name.isEmpty())
57 return getWebService().getName();
59 return getWebService().getName() + " " + name;
63 * Get the tooltip for the action which contains extra details about the
66 * @return action tooltip
71 * Get the subcategory this action belongs to. Can be used to group or
72 * separate multiple actions.
74 * @return action subcategory
76 String getSubcategory();
79 * Get the minimum number of sequences this action requires to run or -1 for
80 * no minimum. Actions may still run if the requirement is not met, but may
81 * produce meaningless results.
83 * @return minimum required number of sequences
85 int getMinSequences();
88 * Get the maximum number of sequences this action requires to run or -1 for
89 * no maximum. Actions may still run if the requirement is not met, but may
90 * produce meaningless or incomplete results.
92 * @return maximum required number of sequences
94 int getMaxSequences();
97 * Return if this action allows protein sequences.
99 * @return {@code true} if protein sequences are allowed
101 boolean doAllowProtein();
104 * Return if this action allows nucleotide sequences.
106 * @return {@code true} if nucleotide sequences are allowed
108 boolean doAllowNucleotide();
111 * Get the set of credentials required to run the action.
113 * @return required credentials
115 EnumSet<CredentialType> getRequiredCredentials();
118 * Run the action, create and start a new task with provided viewport,
119 * arguments and credentials and attach the handler to the task. The
120 * implementations of this method are responsible for starting the task using
121 * execution method appropriate for the action class.
124 * current alignment viewport
126 * job parameters appropriate for the service
128 * optional user credentials
130 * event handler attached to the new task
131 * @return new running task
133 TaskI<R> perform(AlignmentViewport viewport, List<ArgumentI> args,
134 Credentials credentials, TaskEventListener<R> handler);
137 * Return if the action is currently active for the given viewport. Active
138 * actions refer to interactive services which are registered to run
139 * repeatedly on viewport changes. This method has no use for one-shot
140 * services and should always return {@code false} in that case.
143 * viewport being checked for interactive services
144 * @return if there are interactive services registered for viewport
146 boolean isActive(AlignmentViewport viewport);