1 package jalview.ws2.actions.api;
3 import java.util.EnumSet;
6 import javax.swing.Icon;
8 import jalview.api.AlignViewportI;
9 import jalview.viewmodel.AlignmentViewport;
10 import jalview.ws.params.ArgumentI;
11 import jalview.ws2.api.CredentialType;
12 import jalview.ws2.api.Credentials;
13 import jalview.ws2.api.WebService;
16 * {@code Action} object represents an executable action that the web service
17 * can perform. Actions are factories for {@link TaskI} objects which are
18 * created by {@link #perform} method. Actions are instantiated by
19 * {@link WebServiceDiscovererI} from the service definition obtained from the
20 * server and are added to and provided by the {@link WebService}.
22 * Majority of web services will have a single action only, however multiple
23 * actions providing variation to job execution are possible e.g. align and
24 * realign actions of ClustalO service.
31 public interface ActionI<R>
34 * Get the web service containing this action.
36 * @return containing web service
38 WebService<? extends ActionI<R>> getWebService();
41 * Get the name of the action. Typically, it should be the same as the name of
49 * Get the full name of the action consisting of the service name and the
50 * action name if present.
52 * @return full name of this action
54 default String getFullName()
57 if (name == null || name.isEmpty())
58 return getWebService().getName();
60 return getWebService().getName() + " " + name;
64 * Get the tooltip for the action which contains extra details about the
67 * @return action tooltip
72 * Get the subcategory this action belongs to. Can be used to group or
73 * separate multiple actions.
75 * @return action subcategory
77 String getSubcategory();
80 * Get the minimum number of sequences this action requires to run or -1 for
81 * no minimum. Actions may still run if the requirement is not met, but may
82 * produce meaningless results.
84 * @return minimum required number of sequences
86 int getMinSequences();
89 * Get the maximum number of sequences this action requires to run or -1 for
90 * no maximum. Actions may still run if the requirement is not met, but may
91 * produce meaningless or incomplete results.
93 * @return maximum required number of sequences
95 int getMaxSequences();
98 * Return if this action allows protein sequences.
100 * @return {@code true} if protein sequences are allowed
102 boolean doAllowProtein();
105 * Return if this action allows nucleotide sequences.
107 * @return {@code true} if nucleotide sequences are allowed
109 boolean doAllowNucleotide();
112 * Get the set of credentials required to run the action.
114 * @return required credentials
116 EnumSet<CredentialType> getRequiredCredentials();
119 * Create a new task with provided viewport, arguments and credentials ready
123 * current alignment viewport
125 * job parameters appropriate for the service
127 * optional user credentials
130 TaskI<R> createTask(AlignViewportI viewport, List<ArgumentI> args,
131 Credentials credentials);
134 * Return if the action is currently active for the given viewport. Active
135 * actions refer to interactive services which are registered to run
136 * repeatedly on viewport changes. This method has no use for one-shot
137 * services and should always return {@code false} in that case.
140 * viewport being checked for interactive services
141 * @return if there are interactive services registered for viewport
143 boolean isActive(AlignmentViewport viewport);