From 403136e499a24498237778aa19adb2860c625882 Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 1 Oct 2012 10:12:35 +0100 Subject: [PATCH] JAL-1183 dialog queue --- src/jalview/gui/Desktop.java | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index d6ab3ae..712c9ce 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -64,6 +64,8 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.StringTokenizer; import java.util.Vector; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import javax.swing.DefaultDesktopManager; import javax.swing.DesktopManager; @@ -1038,6 +1040,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements storeLastKnownDimensions("JALVIEW_RSS_WINDOW_", jvnews.getBounds()); } + if (dialogExecutor!=null) + { + dialogExecutor.shutdownNow(); + } System.exit(0); } @@ -2604,6 +2610,22 @@ public class Desktop extends jalview.jbgui.GDesktop implements } } - + /** + * single thread that handles display of dialogs to user. + */ + ExecutorService dialogExecutor=null; + + /** + * add another dialog thread to the queue + * @param prompter + */ + public synchronized void addDialogThread(Runnable prompter) + { + if (dialogExecutor==null) + { + dialogExecutor = Executors.newSingleThreadExecutor(); + } + dialogExecutor.submit(prompter); + } } -- 1.7.10.2