package jalview.ws2.actions.alignment; import java.util.List; import java.util.Objects; import jalview.viewmodel.AlignmentViewport; import jalview.ws.params.ArgumentI; import jalview.ws2.actions.BaseAction; import jalview.ws2.actions.api.TaskEventListener; import jalview.ws2.actions.api.TaskI; import jalview.ws2.api.Credentials; import jalview.ws2.client.api.AlignmentWebServiceClientI; /** * Implementation of the {@link BaseAction} that runs alignment services. This * type of action requires {@link AlignmentWebServiceClientI} to retrieve * alignment result from the server. * * @author mmwarowny * */ public class AlignmentAction extends BaseAction { /** * A builder for AlignemntActions. Adds {@code client} and {@code submitGaps} * parameters to the base builder. * * @author mmwarowny */ public static class Builder extends BaseAction.Builder { protected AlignmentWebServiceClientI client; protected boolean submitGaps = false; public Builder(AlignmentWebServiceClientI client) { super(); Objects.requireNonNull(client); this.client = client; } public void submitGaps(boolean val) { submitGaps = val; } public AlignmentAction build() { return new AlignmentAction(this); } } public static Builder newBuilder(AlignmentWebServiceClientI client) { return new Builder(client); } protected final boolean submitGaps; protected final AlignmentWebServiceClientI client; public AlignmentAction(Builder builder) { super(builder); submitGaps = builder.submitGaps; client = builder.client; } @Override public TaskI perform(AlignmentViewport viewport, List args, Credentials credentials, TaskEventListener handler) { var msa = viewport.getAlignmentView(true); var task = new AlignmentTask( client, this, args, credentials, msa, viewport, submitGaps, handler); task.start(viewport.getServiceExecutor()); return task; } /** * Returns if the action is active for the given viewport. Alignment services * are non-interactive, so the action is never active. */ @Override public boolean isActive(AlignmentViewport viewport) { return false; } }