From: jprocter Date: Mon, 1 Oct 2012 09:12:35 +0000 (+0100) Subject: JAL-1183 dialog queue X-Git-Tag: Jalview_2_9~285 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=403136e499a24498237778aa19adb2860c625882;p=jalview.git JAL-1183 dialog queue --- 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); + } }