/***
 * Image/J Plugins
 * Copyright (C) 2002-2005 Jarek Sacha
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Latest release available at http://sourceforge.net/projects/ij-plugins/
 */
package net.sf.ij_plugins.util.progress;

import ij.IJ;

/**
 * Simple adapter for attaching a {@link ProgressReporter} to ImageJ's progress bar.
 * <p/>
 * Example use:
 * <pre>
 *   ProgressReporter r = ...;
 *   r.addProgressListener(new IJProgressBarAdapter());
 * </pre>
 *
 * @author Jarek Sacha
 * @version $Revision: 1.1 $
 */
public class IJProgressBarAdapter implements ProgressListener {
    public void progressNotification(ProgressEvent e) {
        IJ.showStatus(e.getMessage());
        IJ.showProgress(e.getProgress());
    }
}

@@ -934,16 +934,91 @@
 ij.IJ;%0A%0A
+import javax.swing.*;%0Aimport java.lang.reflect.InvocationTargetException;%0A%0A
 /**%0A * S
@@ -1279,17 +1279,17 @@
 sion: 1.
-1
+2
  $%0A */%0Ap
@@ -1388,16 +1388,22 @@
 ication(
+final 
 Progress
@@ -1413,16 +1413,74 @@
 nt e) %7B%0A
+        if (SwingUtilities.isEventDispatchThread()) %7B%0A    
         
@@ -1506,24 +1506,28 @@
 Message());%0A
+    
         IJ.s
@@ -1552,20 +1552,575 @@
 rogress());%0A
+        %7D else %7B%0A            try %7B%0A                SwingUtilities.invokeAndWait(new Runnable() %7B%0A                    public void run() %7B%0A                        IJ.showStatus(e.getMessage());%0A                        IJ.showProgress(e.getProgress());%0A                    %7D%0A                %7D);%0A            %7D catch (InterruptedException ex) %7B%0A                IJ.log(%22InterruptedException %22 + ex.getMessage());%0A            %7D catch (InvocationTargetException ex) %7B%0A                IJ.log(%22InvocationTargetException%22 + ex.getMessage());%0A            %7D%0A        %7D%0A
     %7D%0A%7D%0A

Make sure that progress is updated on event dispatch thread.