JAL-1183 dialog queue
authorjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 1 Oct 2012 09:12:35 +0000 (10:12 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 1 Oct 2012 09:12:35 +0000 (10:12 +0100)
src/jalview/gui/Desktop.java

index d6ab3ae..712c9ce 100644 (file)
@@ -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);
+  }
 
 }