--- /dev/null
+package jalview.ws2.gui;
+
+import java.util.List;
+
+import jalview.gui.AlignFrame;
+import jalview.gui.AlignmentPanel;
+import jalview.gui.IProgressIndicator;
+import jalview.gui.IProgressIndicatorHandler;
+import jalview.ws2.actions.annotation.AnnotationAction;
+import jalview.ws2.actions.annotation.AnnotationResult;
+import jalview.ws2.actions.api.JobI;
+import jalview.ws2.actions.api.TaskEventListener;
+import jalview.ws2.actions.api.TaskI;
+import jalview.ws2.api.JobStatus;
+
+public class AnnotationServiceGuiHandler
+ implements TaskEventListener<AnnotationResult>
+{
+ private final AlignFrame alignFrame;
+
+ private final AlignmentPanel alignPanel;
+
+ private final IProgressIndicator progressIndicator;
+
+ private final AnnotationAction action;
+
+ public AnnotationServiceGuiHandler(AnnotationAction action, AlignFrame frame)
+ {
+ this.alignFrame = frame;
+ this.alignPanel = frame.alignPanel;
+ this.progressIndicator = frame;
+ this.action = action;
+ }
+
+ @Override
+ public void taskStarted(TaskI<AnnotationResult> source, List<? extends JobI> subJobs)
+ {
+ progressIndicator.registerHandler(source.getUid(),
+ new IProgressIndicatorHandler()
+ {
+ @Override
+ public boolean cancelActivity(long id)
+ {
+ source.cancel();
+ return true;
+ }
+
+ @Override
+ public boolean canCancel()
+ {
+ return true;
+ }
+ });
+ }
+
+ @Override
+ public void taskStatusChanged(TaskI<AnnotationResult> source, JobStatus status)
+ {
+ switch (status)
+ {
+ case INVALID:
+ case COMPLETED:
+ case CANCELLED:
+ case FAILED:
+ case SERVER_ERROR:
+ progressIndicator.removeProgressBar(source.getUid());
+ break;
+ case READY:
+ case SUBMITTED:
+ case QUEUED:
+ case RUNNING:
+ case UNKNOWN:
+ progressIndicator.addProgressBar(source.getUid(), action.getFullName());
+ break;
+ }
+ }
+
+ @Override
+ public void taskCompleted(TaskI<AnnotationResult> source, AnnotationResult result)
+ {
+ if (result == null)
+ return;
+ if (result.getTransferFeatures() && alignFrame.alignPanel == alignPanel)
+ {
+ alignFrame.getViewport().setShowSequenceFeatures(true);
+ alignFrame.setMenusForViewport();
+ }
+ alignPanel.adjustAnnotationHeight();
+ }
+
+ @Override
+ public void taskException(TaskI<AnnotationResult> source, Exception e)
+ {
+
+ }
+
+ @Override
+ public void taskRestarted(TaskI<AnnotationResult> source)
+ {
+
+ }
+
+ @Override
+ public void subJobStatusChanged(TaskI<AnnotationResult> source, JobI job, JobStatus status)
+ {
+
+ }
+
+ @Override
+ public void subJobLogChanged(TaskI<AnnotationResult> source, JobI job, String log)
+ {
+
+ }
+
+ @Override
+ public void subJobErrorLogChanged(TaskI<AnnotationResult> source, JobI job, String log)
+ {
+
+ }
+}
import jalview.ws.params.ParamDatastoreI;
import jalview.ws.params.WsParamSetI;
import jalview.ws2.actions.alignment.AlignmentAction;
+import jalview.ws2.actions.annotation.AnnotationAction;
import jalview.ws2.actions.api.ActionI;
import jalview.ws2.actions.api.TaskI;
import jalview.ws2.api.Credentials;
var handler = new AlignmentServiceGuiHandler(_action, frame);
return _action.perform(viewport, args, credentials, handler);
}
+ if (action instanceof AnnotationAction)
+ {
+ var _action = (AnnotationAction) action;
+ var handler = new AnnotationServiceGuiHandler(_action, frame);
+ return _action.perform(viewport, args, credentials, handler);
+ }
throw new IllegalArgumentException(
String.format("Illegal action type %s", action.getClass().getName()));
}