summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/gui/dialog
diff options
context:
space:
mode:
authorGravatar gegy10002019-06-19 20:28:01 +0200
committerGravatar gegy10002019-06-19 20:28:01 +0200
commite9f9f8f29f2504bb750ea0af11840c1aa746b476 (patch)
treec08d8cec3387b535141cee9bd7ffddd5bb431652 /src/main/java/cuchaz/enigma/gui/dialog
parentMerge pull request #150 from Runemoro/short-inner-class-names (diff)
downloadenigma-fork-e9f9f8f29f2504bb750ea0af11840c1aa746b476.tar.gz
enigma-fork-e9f9f8f29f2504bb750ea0af11840c1aa746b476.tar.xz
enigma-fork-e9f9f8f29f2504bb750ea0af11840c1aa746b476.zip
Only open mappings once jar is loaded
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/dialog')
-rw-r--r--src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java b/src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java
index c135d03..cf5c2c8 100644
--- a/src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java
+++ b/src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java
@@ -17,6 +17,7 @@ import cuchaz.enigma.utils.Utils;
17 17
18import javax.swing.*; 18import javax.swing.*;
19import java.awt.*; 19import java.awt.*;
20import java.util.concurrent.CompletableFuture;
20 21
21public class ProgressDialog implements ProgressListener, AutoCloseable { 22public class ProgressDialog implements ProgressListener, AutoCloseable {
22 23
@@ -57,15 +58,19 @@ public class ProgressDialog implements ProgressListener, AutoCloseable {
57 this.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); 58 this.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
58 } 59 }
59 60
60 public static void runOffThread(final JFrame parent, final ProgressRunnable runnable) { 61 public static CompletableFuture<Void> runOffThread(final JFrame parent, final ProgressRunnable runnable) {
62 CompletableFuture<Void> future = new CompletableFuture<>();
61 new Thread(() -> 63 new Thread(() ->
62 { 64 {
63 try (ProgressDialog progress = new ProgressDialog(parent)) { 65 try (ProgressDialog progress = new ProgressDialog(parent)) {
64 runnable.run(progress); 66 runnable.run(progress);
67 future.complete(null);
65 } catch (Exception ex) { 68 } catch (Exception ex) {
69 future.completeExceptionally(ex);
66 throw new Error(ex); 70 throw new Error(ex);
67 } 71 }
68 }).start(); 72 }).start();
73 return future;
69 } 74 }
70 75
71 @Override 76 @Override