1 package jalview.ws2.actions.alignment;
4 import java.util.Objects;
6 import jalview.viewmodel.AlignmentViewport;
7 import jalview.ws.params.ArgumentI;
8 import jalview.ws2.actions.BaseAction;
9 import jalview.ws2.actions.api.TaskEventListener;
10 import jalview.ws2.actions.api.TaskI;
11 import jalview.ws2.api.Credentials;
12 import jalview.ws2.client.api.AlignmentWebServiceClientI;
15 * Implementation of the {@link BaseAction} that runs alignment services. This
16 * type of action requires {@link AlignmentWebServiceClientI} to retrieve
17 * alignment result from the server.
22 public class AlignmentAction extends BaseAction<AlignmentResult>
25 * A builder for AlignemntActions. Adds {@code client} and {@code submitGaps}
26 * parameters to the base builder.
30 public static class Builder extends BaseAction.Builder<AlignmentAction>
32 protected AlignmentWebServiceClientI client;
34 protected boolean submitGaps = false;
36 public Builder(AlignmentWebServiceClientI client)
39 Objects.requireNonNull(client);
43 public void submitGaps(boolean val)
48 public AlignmentAction build()
50 return new AlignmentAction(this);
54 public static Builder newBuilder(AlignmentWebServiceClientI client)
56 return new Builder(client);
59 protected final boolean submitGaps;
61 protected final AlignmentWebServiceClientI client;
63 public AlignmentAction(Builder builder)
66 submitGaps = builder.submitGaps;
67 client = builder.client;
71 public TaskI<AlignmentResult> perform(AlignmentViewport viewport,
72 List<ArgumentI> args, Credentials credentials,
73 TaskEventListener<AlignmentResult> handler)
75 var msa = viewport.getAlignmentView(true);
76 var task = new AlignmentTask(
77 client, this, args, credentials, msa, viewport, submitGaps, handler);
78 task.start(viewport.getServiceExecutor());
83 * Returns if the action is active for the given viewport. Alignment services
84 * are non-interactive, so the action is never active.
87 public boolean isActive(AlignmentViewport viewport)