JAL-3328 Made choice of invokeLater or invokeAndWait configurable
authorBen Soares <bsoares@dundee.ac.uk>
Fri, 21 Jun 2019 22:37:27 +0000 (23:37 +0100)
committerBen Soares <bsoares@dundee.ac.uk>
Fri, 21 Jun 2019 22:37:27 +0000 (23:37 +0100)
getdown/lib/getdown-core.jar
getdown/lib/getdown-launcher.jar
getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java
getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java
getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java
gradle.properties
j11lib/getdown-core.jar
j8lib/getdown-core.jar

index a6aa23d..f435ab6 100644 (file)
Binary files a/getdown/lib/getdown-core.jar and b/getdown/lib/getdown-core.jar differ
index 2a34fe9..5533beb 100644 (file)
Binary files a/getdown/lib/getdown-launcher.jar and b/getdown/lib/getdown-launcher.jar differ
index d446e20..e60e985 100644 (file)
@@ -146,6 +146,9 @@ public class Application
         public final boolean hideProgressText;
 
         /** Whether the splash screen should retain focus. */
+        public final boolean progressSync;
+
+        /** Whether the splash screen should retain focus. */
         public final boolean keepOnTop;
 
         /** Whether to display the appbase. */
@@ -172,7 +175,7 @@ public class Application
                 ", pb=" + progressBar + ", srect=" + status + ", st=" + statusText +
                 ", shadow=" + textShadow + ", err=" + installError + ", nrect=" + patchNotes +
                 ", notes=" + patchNotesUrl + ", stepPercentages=" + stepPercentages +
-                ", hideProgressText=" + hideProgressText + ", keepOnTop=" + keepOnTop + ", minShow=" + minShowSeconds +
+                ", hideProgressText=" + hideProgressText + ", keepOnTop=" + keepOnTop + ", progressSync=" + progressSync + ", minShow=" + minShowSeconds +
                 ", displayAppbase=" + displayAppbase + ", displayVersion=" + displayVersion + "]";
         }
 
@@ -182,6 +185,7 @@ public class Application
             this.progress = config.getRect("ui.progress", new Rectangle(5, 5, 300, 15));
             this.progressText = config.getColor("ui.progress_text", Color.BLACK);
             this.hideProgressText =  config.getBoolean("ui.hide_progress_text");
+            this.progressSync =  config.getBoolean("ui.progress_sync");
             this.keepOnTop =  config.getBoolean("ui.keep_on_top");
             this.displayAppbase =  config.getBoolean("ui.display_appbase");
             this.displayVersion =  config.getBoolean("ui.display_version");
index e1ef2eb..bb018dd 100644 (file)
@@ -231,7 +231,9 @@ public abstract class Getdown extends Thread
         Config config = _app.init(true);
         if (preloads) doPredownloads(_app.getResources());
         _ifc = new Application.UpdateInterface(config);
-        _status.setAppbase(_app.getAppbase());
+        if (_status != null) {
+          _status.setAppbase(_app.getAppbase());
+        }
     }
 
     /**
@@ -571,7 +573,7 @@ public abstract class Getdown extends Thread
             // show the patch notes button, if applicable
             if (!StringUtil.isBlank(_ifc.patchNotesUrl)) {
                 createInterfaceAsync(false);
-                EventQueue.invokeLater(new Runnable() {
+                EQinvoke(new Runnable() {
                     public void run () {
                         _patchNotes.setVisible(true);
                     }
@@ -767,12 +769,8 @@ public abstract class Getdown extends Thread
         if (_silent || (_container != null && !reinit)) {
             return;
         }
-/*
-        EventQueue.invokeLater(new Runnable() {
-            public void run () {
-*/
-        try {
-        EventQueue.invokeAndWait(new Runnable() {
+        
+        EQinvoke (new Runnable() {
             public void run () {
                
                 if (_container == null || reinit) {
@@ -842,9 +840,7 @@ public abstract class Getdown extends Thread
                 showContainer();
             }
         });
-        } catch (Exception e) {
-               e.printStackTrace();
-        }
+        
     }
 
     /**
@@ -962,12 +958,7 @@ public abstract class Getdown extends Thread
             createInterfaceAsync(false);
         }
 
-/*
-        EventQueue.invokeLater(new Runnable() {
-            public void run () {
-*/
-        try {
-        EventQueue.invokeAndWait(new Runnable() {
+        EQinvoke(new Runnable() {
             public void run () {
 
                if (_status == null) {
@@ -986,9 +977,6 @@ public abstract class Getdown extends Thread
                 }
             }
         });
-        } catch (Exception e) {
-               e.printStackTrace();
-        }
     }
 
     protected void reportTrackingEvent (String event, int progress)
@@ -1117,6 +1105,20 @@ public abstract class Getdown extends Thread
             setStatusAsync(null, stepToGlobalPercent(percent), -1L, false);
         }
     };
+    
+    // Asynchronous or synchronous progress updates
+    protected void EQinvoke(Runnable r) {
+      try {
+        readConfig(false);
+        if (_ifc.progressSync) {
+          EventQueue.invokeAndWait(r);
+        } else {
+          EventQueue.invokeLater(r);
+        }
+      } catch (Exception e) {
+        EventQueue.invokeLater(r);
+      }
+    }
 
     protected Application _app;
     protected Application.UpdateInterface _ifc = new Application.UpdateInterface(Config.EMPTY);
index 684de30..59b0b85 100644 (file)
@@ -7,7 +7,6 @@ package com.threerings.getdown.launcher;
 
 import java.awt.Color;
 import java.awt.Container;
-import java.awt.EventQueue;
 import java.awt.Image;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
@@ -142,7 +141,7 @@ public class GetdownApp
           // move window to top, always on top
           if (_ifc.keepOnTop) {
                  log.info("Keep on top set to ", "keep_on_top", _ifc.keepOnTop);
-                         java.awt.EventQueue.invokeLater(new Runnable() {
+                         EQinvoke(new Runnable() {
                                        @Override
                                        public void run() {
                                                _frame.toFront();
@@ -264,7 +263,7 @@ public class GetdownApp
         super.fail(message);
         // super.fail causes the UI to be created (if needed) on the next UI tick, so we
         // want to wait until that happens before we attempt to redecorate the window
-        EventQueue.invokeLater(new Runnable() {
+        EQinvoke(new Runnable() {
           @Override
           public void run() {
             // if the frame was set to be undecorated, make window decoration available
index 519d272..58bcf84 100644 (file)
@@ -65,6 +65,7 @@ getdown_txt_multi_jvmarg = -Dgetdownappdir=%APPDIR%
 getdown_txt_strict_comments = true
 getdown_txt_title = Jalview
 getdown_txt_ui.name = Jalview
+getdown_txt_ui.progress_sync = true
 getdown_txt_ui.keep_on_top = true
 getdown_txt_ui.display_appbase = true
 getdown_txt_ui.display_version = true
index a6aa23d..f435ab6 100644 (file)
Binary files a/j11lib/getdown-core.jar and b/j11lib/getdown-core.jar differ
index a6aa23d..f435ab6 100644 (file)
Binary files a/j8lib/getdown-core.jar and b/j8lib/getdown-core.jar differ