From 57fd2205a01b65d6d6c4614e600c15154b5ce860 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Mon, 11 Apr 2022 18:19:38 +0200 Subject: [PATCH] JAL-3878 Implement gui elements for annotation servicces --- .../ws2/gui/AnnotationServiceGuiHandler.java | 120 ++++++++++++++++++++ src/jalview/ws2/gui/WebServicesMenuManager.java | 7 ++ 2 files changed, 127 insertions(+) create mode 100644 src/jalview/ws2/gui/AnnotationServiceGuiHandler.java diff --git a/src/jalview/ws2/gui/AnnotationServiceGuiHandler.java b/src/jalview/ws2/gui/AnnotationServiceGuiHandler.java new file mode 100644 index 0000000..43e2680 --- /dev/null +++ b/src/jalview/ws2/gui/AnnotationServiceGuiHandler.java @@ -0,0 +1,120 @@ +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 +{ + 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 source, List 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 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 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 source, Exception e) + { + + } + + @Override + public void taskRestarted(TaskI source) + { + + } + + @Override + public void subJobStatusChanged(TaskI source, JobI job, JobStatus status) + { + + } + + @Override + public void subJobLogChanged(TaskI source, JobI job, String log) + { + + } + + @Override + public void subJobErrorLogChanged(TaskI source, JobI job, String log) + { + + } +} diff --git a/src/jalview/ws2/gui/WebServicesMenuManager.java b/src/jalview/ws2/gui/WebServicesMenuManager.java index 188f587..c75c483 100644 --- a/src/jalview/ws2/gui/WebServicesMenuManager.java +++ b/src/jalview/ws2/gui/WebServicesMenuManager.java @@ -30,6 +30,7 @@ import jalview.ws.params.ArgumentI; 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; @@ -249,6 +250,12 @@ public class WebServicesMenuManager 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())); } -- 1.7.10.2