JAL-3392 calculation workers notify Jalview
authorhansonr <hansonr@STO24954W.ad.stolaf.edu>
Wed, 31 Jul 2019 23:54:03 +0000 (18:54 -0500)
committerhansonr <hansonr@STO24954W.ad.stolaf.edu>
Wed, 31 Jul 2019 23:54:03 +0000 (18:54 -0500)
src/jalview/bin/Jalview.java
src/jalview/workers/AlignCalcManager.java

index 28d029c..7970437 100755 (executable)
@@ -20,6 +20,7 @@
  */
 package jalview.bin;
 
+import jalview.api.AlignCalcWorkerI;
 import jalview.api.AlignFrameI;
 import jalview.api.AlignViewportI;
 import jalview.api.JalviewApp;
@@ -640,14 +641,6 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
         // TODO ?
       }
 
-      if (aparser.contains(ArgsParser.SHOWOVERVIEW))
-      {
-        jalview.bin.Cache.setPropertyNoSave(Preferences.SHOW_OVERVIEW,
-                "true");
-
-        System.out.println("CMD [showoverview] executed successfully!");
-      }
-
       if (aparser.contains(ArgsParser.NOMENUBAR))
       {
         noMenuBar = true;
@@ -757,6 +750,13 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
           System.out.println(
                   "CMD [-annotations " + data + "] executed successfully!");
         }
+
+        if (aparser.contains(ArgsParser.SHOWOVERVIEW))
+        {
+          af.overviewMenuItem_actionPerformed(null);
+          System.out.println("CMD [showoverview] executed successfully!");
+        }
+
         // set or clear the sortbytree flag.
         if (aparser.contains(ArgsParser.SORTBYTREE))
         {
@@ -2050,5 +2050,11 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
     currentAlignFrame.overviewMenuItem_actionPerformed(null);
   }
 
+  public void notifyWorker(AlignCalcWorkerI worker, String status)
+  {
+    System.out.println("Jalview worker " + worker.getClass().getSimpleName()
+            + " " + status);
+  }
+
 }
 
index 08ef3a2..9a3fc8d 100644 (file)
@@ -22,6 +22,7 @@ package jalview.workers;
 
 import jalview.api.AlignCalcManagerI;
 import jalview.api.AlignCalcWorkerI;
+import jalview.bin.Jalview;
 import jalview.datamodel.AlignmentAnnotation;
 
 import java.util.ArrayList;
@@ -34,6 +35,10 @@ import java.util.Set;
 
 public class AlignCalcManager implements AlignCalcManagerI
 {
+  public static final String STARTED = "started";
+
+  public static final String FINISHED = "finished";
+
   /*
    * list of registered workers
    */
@@ -74,7 +79,7 @@ public class AlignCalcManager implements AlignCalcManagerI
             .synchronizedList(new ArrayList<AlignCalcWorkerI>());
     updating = Collections.synchronizedMap(
             new Hashtable<Class<? extends AlignCalcWorkerI>, List<AlignCalcWorkerI>>());
-    canUpdate = new HashSet<AlignCalcWorkerI>();
+    canUpdate = new HashSet<>();
   }
 
   @Override
@@ -82,6 +87,7 @@ public class AlignCalcManager implements AlignCalcManagerI
   {
     synchronized (updating)
     {
+      Jalview.getInstance().notifyWorker(worker, STARTED);
       List<AlignCalcWorkerI> upd = updating.get(worker.getClass());
       if (upd == null)
       {
@@ -144,6 +150,7 @@ public class AlignCalcManager implements AlignCalcManagerI
   {
     synchronized (inProgress)
     {
+      Jalview.getInstance().notifyWorker(worker, FINISHED);
       // System.err.println("Worker " + worker + " marked as complete.");
       inProgress.remove(worker);
       List<AlignCalcWorkerI> upd = updating.get(worker.getClass());
@@ -285,7 +292,7 @@ public class AlignCalcManager implements AlignCalcManagerI
   public List<AlignCalcWorkerI> getRegisteredWorkersOfClass(
           Class<? extends AlignCalcWorkerI> workerClass)
   {
-    List<AlignCalcWorkerI> workingClass = new ArrayList<AlignCalcWorkerI>();
+    List<AlignCalcWorkerI> workingClass = new ArrayList<>();
     synchronized (canUpdate)
     {
       for (AlignCalcWorkerI worker : canUpdate)
@@ -312,8 +319,8 @@ public class AlignCalcManager implements AlignCalcManagerI
   public void removeRegisteredWorkersOfClass(
           Class<? extends AlignCalcWorkerI> typeToRemove)
   {
-    List<AlignCalcWorkerI> removable = new ArrayList<AlignCalcWorkerI>();
-    Set<AlignCalcWorkerI> toremovannot = new HashSet<AlignCalcWorkerI>();
+    List<AlignCalcWorkerI> removable = new ArrayList<>();
+    Set<AlignCalcWorkerI> toremovannot = new HashSet<>();
     synchronized (restartable)
     {
       for (AlignCalcWorkerI worker : restartable)
@@ -363,7 +370,7 @@ public class AlignCalcManager implements AlignCalcManagerI
      * first just find those to remove (to avoid
      * ConcurrentModificationException)
      */
-    List<AlignCalcWorkerI> toRemove = new ArrayList<AlignCalcWorkerI>();
+    List<AlignCalcWorkerI> toRemove = new ArrayList<>();
     for (AlignCalcWorkerI worker : restartable)
     {
       if (worker.involves(ann))