svn commit: r13807 - trunk/src_new/org/argouml/ui/ProgressMonitorWindow.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2007-11-22 20:36:16-0800
New Revision: 13807

Modified:
   trunk/src_new/org/argouml/ui/ProgressMonitorWindow.java

Log:
Make sure Swing calls happen on the Swing event thread

Modified: trunk/src_new/org/argouml/ui/ProgressMonitorWindow.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/ProgressMonitorWindow.java?view=diff&rev=13807&p1=trunk/src_new/org/argouml/ui/ProgressMonitorWindow.java&p2=trunk/src_new/org/argouml/ui/ProgressMonitorWindow.java&r1=13806&r2=13807
==============================================================================
--- trunk/src_new/org/argouml/ui/ProgressMonitorWindow.java	(original)
+++ trunk/src_new/org/argouml/ui/ProgressMonitorWindow.java	2007-11-22 20:36:16-0800
@@ -69,7 +69,20 @@
      * @see org.argouml.persistence.ProgressListener#progress(org.argouml.persistence.ProgressEvent)
      */
     public void progress(final ProgressEvent event) {
-        updateProgress((int) event.getPosition());
+        final int progress = (int) event.getPosition();
+        if (this.pbar != null) {
+            // File load/save gets done on a background thread, so we'll 
+            // probably have to queue this to the Swing event thread
+            if (!SwingUtilities.isEventDispatchThread()) {
+                SwingUtilities.invokeLater(new Runnable() {
+                    public void run() {
+                        updateProgress(progress);                        
+                    }
+                });
+            } else {
+                updateProgress(progress);
+            }
+        }
     }
     
     /*
@@ -79,10 +92,11 @@
     public void updateProgress(final int progress) {
         if (this.pbar != null) {
             pbar.setProgress(progress);
-            Object[] args = new Object[]{String.valueOf(progress)};
+            Object[] args = new Object[] {String.valueOf(progress)};
             pbar.setNote(Translator.localize("dialog.progress.note", args));
         }
     }
+
     
     /*
      * @see org.argouml.application.api.ProgressMonitor#isCanceled()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.