X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws2%2Factions%2Fannotation%2FAnnotationAction.java;fp=src%2Fjalview%2Fws2%2Factions%2Fannotation%2FAnnotationAction.java;h=02829fd0e30e9a6f6815000ec90b1c2f4fe7012e;hb=bea1d9b563d2fea018de3dbde9112dd59149126e;hp=0000000000000000000000000000000000000000;hpb=49ab19e8189569edf0bc1f4ba8dac14e67f4ca36;p=jalview.git diff --git a/src/jalview/ws2/actions/annotation/AnnotationAction.java b/src/jalview/ws2/actions/annotation/AnnotationAction.java new file mode 100644 index 0000000..02829fd --- /dev/null +++ b/src/jalview/ws2/actions/annotation/AnnotationAction.java @@ -0,0 +1,128 @@ +package jalview.ws2.actions.annotation; + +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.AnnotationWebServiceClientI; + +public class AnnotationAction extends BaseAction +{ + /** + * A builder of {@link AnnotationAction} instances. + */ + public static class Builder extends BaseAction.Builder + { + protected AnnotationWebServiceClientI client; + + protected boolean alignmentAnalysis = false; + + protected boolean requireAlignedSequences = false; + + protected boolean filterSymbols = true; + + public Builder(AnnotationWebServiceClientI client) + { + super(); + Objects.requireNonNull(client); + this.client = client; + } + + /** + * Set if action is an alignment analysis action. + */ + public void alignmentAnalysis(boolean val) + { + alignmentAnalysis = val; + } + + /** + * Set if action require aligned sequences. + */ + public void requireAlignedSequences(boolean val) + { + requireAlignedSequences = val; + } + + /** + * Set if action requires non-standard residues to be filtered out + */ + public void filterSymbols(boolean val) + { + filterSymbols = val; + } + + public AnnotationAction build() + { + return new AnnotationAction(this); + } + } + + public static Builder newBuilder(AnnotationWebServiceClientI client) + { + return new Builder(client); + } + + protected final AnnotationWebServiceClientI client; + + protected final boolean alignmentAnalysis; + + protected final boolean requireAlignedSequences; + + protected final boolean filterSymbols; + + protected AnnotationAction(Builder builder) + { + super(builder); + client = builder.client; + alignmentAnalysis = builder.alignmentAnalysis; + requireAlignedSequences = builder.requireAlignedSequences; + filterSymbols = builder.filterSymbols; + } + + @Override + public TaskI perform(AlignmentViewport viewport, + List args, Credentials credentials, + TaskEventListener handler) + { + var task = new AnnotationTask(client, this, args, credentials, viewport, + handler); + task.start(viewport.getCalcManager()); + return task; + } + + /** + * Return if this action is an alignment analysis service. + */ + public boolean isAlignmentAnalysis() + { + return alignmentAnalysis; + } + + /** + * Return if this action require sequences to be aligned. + */ + public boolean getRequireAlignedSequences() + { + return requireAlignedSequences; + } + + /** + * Return if this action require non-standard symbols to be filtered out. + */ + public boolean getFilterSymbols() + { + return filterSymbols; + } + + @Override + public boolean isActive(AlignmentViewport viewport) + { + return false; + } +}