JAL-3328 Made choice of invokeLater or invokeAndWait configurable
[jalview.git] / getdown / src / getdown / launcher / src / main / java / com / threerings / getdown / launcher / Getdown.java
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);