import java.util.List;
import java.util.Objects;
+import jalview.api.AlignViewportI;
import jalview.viewmodel.AlignmentViewport;
import jalview.ws.params.ArgumentI;
import jalview.ws2.actions.BaseAction;
+import jalview.ws2.actions.BaseTask;
+import jalview.ws2.actions.PollingTaskExecutor;
import jalview.ws2.actions.api.TaskEventListener;
import jalview.ws2.actions.api.TaskI;
import jalview.ws2.api.Credentials;
client = builder.client;
}
- @Override
+ @Deprecated
public TaskI<AlignmentResult> perform(AlignmentViewport viewport,
List<ArgumentI> args, Credentials credentials,
TaskEventListener<AlignmentResult> handler)
{
- var msa = viewport.getAlignmentView(true);
- var task = new AlignmentTask(
- client, this, args, credentials, msa, viewport, submitGaps, handler);
- task.start(viewport.getServiceExecutor());
+ var task = createTask(viewport, args, credentials);
+ var executor = PollingTaskExecutor.fromPool(viewport.getServiceExecutor());
+ task.addTaskEventListener(handler);
+ var future = executor.submit(task);
+ task.setCancelAction(() -> {
+ future.cancel(true);
+ });
return task;
}
+ @Override
+ public AlignmentTask createTask(AlignViewportI viewport,
+ List<ArgumentI> args, Credentials credentials)
+ {
+ return new AlignmentTask(
+ client, this, args, credentials, viewport, submitGaps);
+ }
+
/**
* Returns if the action is active for the given viewport. Alignment services
* are non-interactive, so the action is never active.
import java.util.List;
import java.util.Objects;
+import jalview.api.AlignViewportI;
import jalview.viewmodel.AlignmentViewport;
import jalview.ws.params.ArgumentI;
import jalview.ws2.actions.BaseAction;
requireAlignedSequences = builder.requireAlignedSequences;
filterSymbols = builder.filterSymbols;
}
-
+
@Override
- public TaskI<AnnotationResult> perform(AlignmentViewport viewport,
- List<ArgumentI> args, Credentials credentials,
- TaskEventListener<AnnotationResult> handler)
+ public AnnotationTask createTask(AlignViewportI viewport,
+ List<ArgumentI> args, Credentials credentials)
{
- var task = new AnnotationTask(client, this, args, credentials, viewport,
- handler);
- task.start(viewport.getCalcManager());
- return task;
+ return new AnnotationTask(client, this, args, credentials, viewport);
}
-
+
/**
* Return if this action is an alignment analysis service.
*/
import javax.swing.Icon;
+import jalview.api.AlignViewportI;
import jalview.viewmodel.AlignmentViewport;
import jalview.ws.params.ArgumentI;
import jalview.ws2.api.CredentialType;
EnumSet<CredentialType> getRequiredCredentials();
/**
- * Run the action, create and start a new task with provided viewport,
- * arguments and credentials and attach the handler to the task. The
- * implementations of this method are responsible for starting the task using
- * execution method appropriate for the action class.
+ * Create a new task with provided viewport, arguments and credentials ready
+ * to be started.
*
* @param viewport
* current alignment viewport
* job parameters appropriate for the service
* @param credentials
* optional user credentials
- * @param handler
- * event handler attached to the new task
- * @return new running task
+ * @return new task
*/
- TaskI<R> perform(AlignmentViewport viewport, List<ArgumentI> args,
- Credentials credentials, TaskEventListener<R> handler);
+ TaskI<R> createTask(AlignViewportI viewport, List<ArgumentI> args,
+ Credentials credentials);
/**
* Return if the action is currently active for the given viewport. Active