From: Mateusz Warowny Date: Fri, 7 Jul 2023 14:47:08 +0000 (+0200) Subject: JAL-4199 Fix interactive jobs not being stopped X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8680991d282c52d1524c65f1b8e9053b55634171;p=jalview.git JAL-4199 Fix interactive jobs not being stopped --- diff --git a/src/jalview/api/AlignCalcWorkerI.java b/src/jalview/api/AlignCalcWorkerI.java index b51b94e..89470e0 100644 --- a/src/jalview/api/AlignCalcWorkerI.java +++ b/src/jalview/api/AlignCalcWorkerI.java @@ -65,4 +65,12 @@ public interface AlignCalcWorkerI * @return */ boolean isDeletable(); + + /** + * Returns the name of this calculation. + */ + public default String getCalcName() + { + return null; + } } diff --git a/src/jalview/workers/AlignCalcManager2.java b/src/jalview/workers/AlignCalcManager2.java index 39111ae..582c84f 100644 --- a/src/jalview/workers/AlignCalcManager2.java +++ b/src/jalview/workers/AlignCalcManager2.java @@ -302,10 +302,7 @@ public class AlignCalcManager2 implements AlignCalcManagerI2 @Override public void removeWorker(AlignCalcWorkerI worker) { - if (worker.isDeletable()) - { - registered.remove(worker); - } + registered.remove(worker); } @Override diff --git a/src/jalview/ws2/actions/annotation/AlignCalcWorkerAdapter.java b/src/jalview/ws2/actions/annotation/AlignCalcWorkerAdapter.java index 994e3fc..7a58a89 100644 --- a/src/jalview/ws2/actions/annotation/AlignCalcWorkerAdapter.java +++ b/src/jalview/ws2/actions/annotation/AlignCalcWorkerAdapter.java @@ -50,6 +50,12 @@ public class AlignCalcWorkerAdapter extends AlignCalcWorker implements PollableA } @Override + public String getCalcName() + { + return action.getWebService().getName(); + } + + @Override public void updateAnnotation() { @@ -130,4 +136,10 @@ public class AlignCalcWorkerAdapter extends AlignCalcWorker implements PollableA if (currentTask != null) currentTask.removeTaskEventListener(listener); } + + @Override + public String toString() + { + return "AlignCalcWorkerAdapter for " + getCalcName(); + } } diff --git a/src/jalview/ws2/gui/WebServicesMenuManager.java b/src/jalview/ws2/gui/WebServicesMenuManager.java index f081915..5fd4734 100644 --- a/src/jalview/ws2/gui/WebServicesMenuManager.java +++ b/src/jalview/ws2/gui/WebServicesMenuManager.java @@ -445,18 +445,20 @@ public class WebServicesMenuManager if (action instanceof AnnotationAction) { var calcManager = viewport.getCalcManager(); - var oldWorkers = calcManager.getWorkersOfClass(AlignCalcWorkerAdapter.class); - for (var worker : oldWorkers) - { - calcManager.cancelWorker(worker); - calcManager.removeWorker(worker); - } var _action = (AnnotationAction) action; var worker = new AlignCalcWorkerAdapter(viewport, frame.alignPanel, _action, args, credentials); var handler = new AnnotationServiceGuiHandler(_action, frame); worker.addTaskEventListener(handler); + for (var w : calcManager.getWorkers()) + { + if (worker.getCalcName() != null && worker.getCalcName().equals(w.getCalcName())) + { + calcManager.cancelWorker(w); + calcManager.removeWorker(w); + } + } if (action.getWebService().isInteractive()) calcManager.registerWorker(worker); else