From: hansonr Date: Wed, 31 Jul 2019 23:54:03 +0000 (-0500) Subject: JAL-3392 calculation workers notify Jalview X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2a8f05d270d7346dd6ec68da46ca08152dd84933;p=jalview.git JAL-3392 calculation workers notify Jalview --- diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 28d029c..7970437 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -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); + } + } diff --git a/src/jalview/workers/AlignCalcManager.java b/src/jalview/workers/AlignCalcManager.java index 08ef3a2..9a3fc8d 100644 --- a/src/jalview/workers/AlignCalcManager.java +++ b/src/jalview/workers/AlignCalcManager.java @@ -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()); updating = Collections.synchronizedMap( new Hashtable, List>()); - canUpdate = new HashSet(); + canUpdate = new HashSet<>(); } @Override @@ -82,6 +87,7 @@ public class AlignCalcManager implements AlignCalcManagerI { synchronized (updating) { + Jalview.getInstance().notifyWorker(worker, STARTED); List 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 upd = updating.get(worker.getClass()); @@ -285,7 +292,7 @@ public class AlignCalcManager implements AlignCalcManagerI public List getRegisteredWorkersOfClass( Class workerClass) { - List workingClass = new ArrayList(); + List workingClass = new ArrayList<>(); synchronized (canUpdate) { for (AlignCalcWorkerI worker : canUpdate) @@ -312,8 +319,8 @@ public class AlignCalcManager implements AlignCalcManagerI public void removeRegisteredWorkersOfClass( Class typeToRemove) { - List removable = new ArrayList(); - Set toremovannot = new HashSet(); + List removable = new ArrayList<>(); + Set 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 toRemove = new ArrayList(); + List toRemove = new ArrayList<>(); for (AlignCalcWorkerI worker : restartable) { if (worker.involves(ann))