JAL-3878 Start interactive job by registering them with calcManager
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Tue, 19 Oct 2021 13:29:57 +0000 (15:29 +0200)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Tue, 19 Oct 2021 13:29:57 +0000 (15:29 +0200)
src/jalview/ws2/operations/AnnotationOperation.java

index 1eb5da0..b2e3fc6 100644 (file)
@@ -1,41 +1,28 @@
 package jalview.ws2.operations;
 
-import java.io.IOException;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.concurrent.CancellationException;
 import java.util.concurrent.CompletionStage;
 
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 
 import jalview.api.AlignmentViewPanel;
-import jalview.bin.Cache;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.gui.AlignFrame;
 import jalview.gui.AlignViewport;
 import jalview.gui.WsJobParameters;
-import jalview.io.AnnotationFile;
 import jalview.io.FeaturesFile;
-import jalview.util.MathUtils;
 import jalview.util.MessageManager;
-import jalview.workers.AlignCalcManager2;
 import jalview.ws.params.ArgumentI;
 import jalview.ws.params.WsParamSetI;
 import jalview.ws2.MenuEntryProviderI;
 import jalview.ws2.ResultSupplier;
-import jalview.ws2.WSJob;
-import jalview.ws2.WSJobStatus;
 import jalview.ws2.PollingTaskExecutor;
 import jalview.ws2.WebServiceI;
-import jalview.ws2.WebServiceWorkerI;
-import jalview.ws2.utils.WSJobList;
-
-import static java.lang.String.format;
 
 /**
- * 
+ *
  * @author mmwarowny
  *
  */
@@ -49,6 +36,10 @@ public class AnnotationOperation implements Operation
 
   final ResultSupplier<FeaturesFile> featuresSupplier;
 
+  boolean alignmentAnalysis = false;
+
+  boolean interactive = false;
+
   public AnnotationOperation(WebServiceI service,
       ResultSupplier<List<AlignmentAnnotation>> annotSupplier,
       ResultSupplier<FeaturesFile> featSupplier, String operationName)
@@ -110,13 +101,23 @@ public class AnnotationOperation implements Operation
   @Override
   public boolean isInteractive()
   {
-    return false;
+    return interactive;
+  }
+
+  public void setInteractive(boolean value)
+  {
+    this.interactive = value;
   }
 
   @Override
   public boolean isAlignmentAnalysis()
   {
-    return false;
+    return alignmentAnalysis;
+  }
+
+  public void setAlignmentAnalysis(boolean value)
+  {
+    this.alignmentAnalysis = value;
   }
 
   @Override
@@ -151,8 +152,10 @@ public class AnnotationOperation implements Operation
         var worker = new AnnotationServiceWorker(this, service,
             Collections.emptyList(), viewport, alignPanel, frame, frame,
             calcManager);
-        calcManager.startWorker(worker);
-        // TODO create and submit AnnotataionServiceWorker
+        if (isInteractive())
+          calcManager.registerWorker(worker);
+        else
+          calcManager.startWorker(worker);
       });
       parent.add(item);
     }
@@ -172,10 +175,14 @@ public class AnnotationOperation implements Operation
                 var worker = new AnnotationServiceWorker(
                     AnnotationOperation.this, service, arguments, viewport,
                     alignPanel, frame, frame, calcManager);
-                calcManager.startWorker(worker);
+                if (isInteractive())
+                  calcManager.registerWorker(worker);
+                else
+                  calcManager.startWorker(worker);
               }
             });
       });
+      parent.add(item);
     }
   }