Revision: 17507
          http://sourceforge.net/p/gate/code/17507
Author:   markagreenwood
Date:     2014-03-03 13:50:56 +0000 (Mon, 03 Mar 2014)
Log Message:
-----------
use the write formatter rather than the default eclipse one

Modified Paths:
--------------
    gate/trunk/plugins/Developer_Tools/src/gate/creole/EDTMonitor.java
    gate/trunk/plugins/Developer_Tools/src/gate/creole/Reveal.java
    
gate/trunk/plugins/Developer_Tools/src/org/jdesktop/swinghelper/debug/CheckThreadViolationRepaintManager.java
    
gate/trunk/plugins/Developer_Tools/src/org/jdesktop/swinghelper/debug/EventDispatchThreadHangMonitor.java

Modified: gate/trunk/plugins/Developer_Tools/src/gate/creole/EDTMonitor.java
===================================================================
--- gate/trunk/plugins/Developer_Tools/src/gate/creole/EDTMonitor.java  
2014-03-03 13:45:23 UTC (rev 17506)
+++ gate/trunk/plugins/Developer_Tools/src/gate/creole/EDTMonitor.java  
2014-03-03 13:50:56 UTC (rev 17507)
@@ -1,15 +1,15 @@
 /*
- *  EDTMonitor.java
- *
- *  Copyright (c) 1995-2014, The University of Sheffield. See the file
- *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
- *
- *  This file is part of GATE (see http://gate.ac.uk/), and is free
- *  software, licenced under the GNU Library General Public License,
- *  Version 2, June 1991 (in the distribution as file licence.html,
- *  and also available at http://gate.ac.uk/gate/licence.html).
- *
- *  Mark A. Greenwood, 3/3/2014
+ * EDTMonitor.java
+ * 
+ * Copyright (c) 1995-2014, The University of Sheffield. See the file
+ * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ * 
+ * This file is part of GATE (see http://gate.ac.uk/), and is free software,
+ * licenced under the GNU Library General Public License, Version 2, June 1991
+ * (in the distribution as file licence.html, and also available at
+ * http://gate.ac.uk/gate/licence.html).
+ * 
+ * Mark A. Greenwood, 3/3/2014
  */
 package gate.creole;
 
@@ -24,16 +24,12 @@
 
 @CreoleResource(tool = true, isPrivate = true, autoinstances = @AutoInstance, 
name = "EDT Monitor")
 public class EDTMonitor extends AbstractResource {
+  private static final long serialVersionUID = -549306599972622831L;
 
-       private static final long serialVersionUID = -549306599972622831L;
-
-       @Override
-       public Resource init() throws ResourceInstantiationException {
-               RepaintManager
-                               .setCurrentManager(new 
CheckThreadViolationRepaintManager());
-               
-               EventDispatchThreadHangMonitor.initMonitoring();
-
-               return this;
-       }
+  @Override
+  public Resource init() throws ResourceInstantiationException {
+    RepaintManager.setCurrentManager(new CheckThreadViolationRepaintManager());
+    EventDispatchThreadHangMonitor.initMonitoring();
+    return this;
+  }
 }

Modified: gate/trunk/plugins/Developer_Tools/src/gate/creole/Reveal.java
===================================================================
--- gate/trunk/plugins/Developer_Tools/src/gate/creole/Reveal.java      
2014-03-03 13:45:23 UTC (rev 17506)
+++ gate/trunk/plugins/Developer_Tools/src/gate/creole/Reveal.java      
2014-03-03 13:50:56 UTC (rev 17507)
@@ -1,3 +1,16 @@
+/*
+ * Reveal.java
+ * 
+ * Copyright (c) 1995-2014, The University of Sheffield. See the file
+ * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ * 
+ * This file is part of GATE (see http://gate.ac.uk/), and is free software,
+ * licenced under the GNU Library General Public License, Version 2, June 1991
+ * (in the distribution as file licence.html, and also available at
+ * http://gate.ac.uk/gate/licence.html).
+ * 
+ * Mark A. Greenwood, 3/3/2014
+ */
 package gate.creole;
 
 import gate.CreoleRegister;
@@ -21,30 +34,25 @@
 import javax.swing.UIManager;
 
 @SuppressWarnings("serial")
-@CreoleResource(tool = true, isPrivate = true, autoinstances = @AutoInstance, 
name="Show/Hide Resources")
+@CreoleResource(tool = true, isPrivate = true, autoinstances = @AutoInstance, 
name = "Show/Hide Resources")
 public class Reveal extends ResourceHelper implements ActionsPublisher {
-
   private List<Action> actions;
 
   @Override
   public List<Action> getActions() {
     if(actions == null) {
       actions = new ArrayList<Action>();
-
-      actions.add(new AbstractAction("Show Hidden Resources", new 
RevealIcon(24,24)) {
-
+      actions.add(new AbstractAction("Show Hidden Resources", new RevealIcon(
+          24, 24)) {
         @Override
         public void actionPerformed(ActionEvent e) {
           MainFrame mf = MainFrame.getInstance();
-          
           CreoleRegister reg = Gate.getCreoleRegister();
           List<Resource> resources = new ArrayList<Resource>();
-          
           resources.addAll(reg.getLrInstances());
           resources.addAll(reg.getPrInstances());
-          
-          for (Resource r : resources) {
-            if (Gate.getHiddenAttribute(r.getFeatures())) {
+          for(Resource r : resources) {
+            if(Gate.getHiddenAttribute(r.getFeatures())) {
               Gate.setHiddenAttribute(r.getFeatures(), false);
               mf.resourceLoaded(new CreoleEvent(r, 
CreoleEvent.RESOURCE_LOADED));
             }
@@ -52,28 +60,24 @@
         }
       });
     }
-
     return actions;
   }
 
   @Override
   protected List<Action> buildActions(final NameBearerHandle handle) {
-         
-         
-         final MainFrame mf = MainFrame.getInstance();
-         int height = 
mf.getFontMetrics(UIManager.getFont("MenuItem.font")).getHeight();         
-         
-         List<Action> rightClick = new ArrayList<Action>();
-         rightClick.add(new AbstractAction("Hide Resource", new 
RevealIcon(height,height)) {
-
-               @Override
-               public void actionPerformed(ActionEvent e) {
-                       Resource r = (Resource)handle.getTarget();
-                       mf.resourceUnloaded(new CreoleEvent(r, 
CreoleEvent.RESOURCE_UNLOADED));
-                       Gate.setHiddenAttribute(r.getFeatures(), true);         
   
-               }                 
-         });
-       
-         return rightClick;
+    final MainFrame mf = MainFrame.getInstance();
+    int height =
+        mf.getFontMetrics(UIManager.getFont("MenuItem.font")).getHeight();
+    List<Action> rightClick = new ArrayList<Action>();
+    rightClick.add(new AbstractAction("Hide Resource", new RevealIcon(height,
+        height)) {
+      @Override
+      public void actionPerformed(ActionEvent e) {
+        Resource r = (Resource)handle.getTarget();
+        mf.resourceUnloaded(new CreoleEvent(r, CreoleEvent.RESOURCE_UNLOADED));
+        Gate.setHiddenAttribute(r.getFeatures(), true);
+      }
+    });
+    return rightClick;
   }
 }
\ No newline at end of file

Modified: 
gate/trunk/plugins/Developer_Tools/src/org/jdesktop/swinghelper/debug/CheckThreadViolationRepaintManager.java
===================================================================
--- 
gate/trunk/plugins/Developer_Tools/src/org/jdesktop/swinghelper/debug/CheckThreadViolationRepaintManager.java
       2014-03-03 13:45:23 UTC (rev 17506)
+++ 
gate/trunk/plugins/Developer_Tools/src/org/jdesktop/swinghelper/debug/CheckThreadViolationRepaintManager.java
       2014-03-03 13:50:56 UTC (rev 17507)
@@ -1,19 +1,18 @@
 /*
- * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ * 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.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
-
 package org.jdesktop.swinghelper.debug;
 
 import java.lang.ref.WeakReference;
@@ -39,142 +38,138 @@
  * @author Alexander Potochkin
  */
 public class CheckThreadViolationRepaintManager extends RepaintManager {
-       // it is recommended to pass the complete check
-       private boolean completeCheck = true;
-       private WeakReference<JComponent> lastComponent;
+  // it is recommended to pass the complete check
+  private boolean completeCheck = true;
 
-       public CheckThreadViolationRepaintManager(boolean completeCheck) {
-               this.completeCheck = completeCheck;
-       }
+  private WeakReference<JComponent> lastComponent;
 
-       public CheckThreadViolationRepaintManager() {
-               this(true);
-       }
+  public CheckThreadViolationRepaintManager(boolean completeCheck) {
+    this.completeCheck = completeCheck;
+  }
 
-       public boolean isCompleteCheck() {
-               return completeCheck;
-       }
+  public CheckThreadViolationRepaintManager() {
+    this(true);
+  }
 
-       public void setCompleteCheck(boolean completeCheck) {
-               this.completeCheck = completeCheck;
-       }
+  public boolean isCompleteCheck() {
+    return completeCheck;
+  }
 
-       public synchronized void addInvalidComponent(JComponent component) {
-               checkThreadViolations(component);
-               super.addInvalidComponent(component);
-       }
+  public void setCompleteCheck(boolean completeCheck) {
+    this.completeCheck = completeCheck;
+  }
 
-       public void addDirtyRegion(JComponent component, int x, int y, int w, 
int h) {
-               checkThreadViolations(component);
-               super.addDirtyRegion(component, x, y, w, h);
-       }
+  public synchronized void addInvalidComponent(JComponent component) {
+    checkThreadViolations(component);
+    super.addInvalidComponent(component);
+  }
 
-       private void checkThreadViolations(JComponent c) {
-               if (!SwingUtilities.isEventDispatchThread()
-                               && (completeCheck || c.isShowing())) {
-                       boolean repaint = false;
-                       boolean fromSwing = false;
-                       boolean imageUpdate = false;
-                       StackTraceElement[] stackTrace = Thread.currentThread()
-                                       .getStackTrace();
-                       for (StackTraceElement st : stackTrace) {
-                               if (repaint && 
st.getClassName().startsWith("javax.swing.") &&
-                               // for details see
-                               // 
https://swinghelper.dev.java.net/issues/show_bug.cgi?id=1
-                                               !st.getClassName()
-                                                               
.startsWith("javax.swing.SwingWorker")) {
-                                       fromSwing = true;
-                               }
-                               if (repaint && 
"imageUpdate".equals(st.getMethodName())) {
-                                       imageUpdate = true;
-                               }
-                               if ("repaint".equals(st.getMethodName())) {
-                                       repaint = true;
-                                       fromSwing = false;
-                               }
-                       }
-                       if (imageUpdate) {
-                               // assuming it is 
java.awt.image.ImageObserver.imageUpdate(...)
-                               // image was asynchronously updated, that's ok
-                               return;
-                       }
-                       if (repaint && !fromSwing) {
-                               // no problems here, since repaint() is thread 
safe
-                               return;
-                       }
-                       // ignore the last processed component
-                       if (lastComponent != null && c == lastComponent.get()) {
-                               return;
-                       }
-                       lastComponent = new WeakReference<JComponent>(c);
-                       violationFound(c, stackTrace);
-               }
-       }
+  public void addDirtyRegion(JComponent component, int x, int y, int w, int h) 
{
+    checkThreadViolations(component);
+    super.addDirtyRegion(component, x, y, w, h);
+  }
 
-       protected void violationFound(JComponent c, StackTraceElement[] 
stackTrace) {
-               System.out.println();
-               System.out.println("EDT violation detected");
-               System.out.println(c);
-               for (StackTraceElement st : stackTrace) {
-                       System.out.println("\tat " + st);
-               }
-       }
+  private void checkThreadViolations(JComponent c) {
+    if(!SwingUtilities.isEventDispatchThread()
+        && (completeCheck || c.isShowing())) {
+      boolean repaint = false;
+      boolean fromSwing = false;
+      boolean imageUpdate = false;
+      StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+      for(StackTraceElement st : stackTrace) {
+        if(repaint && st.getClassName().startsWith("javax.swing.") &&
+        // for details see
+        // https://swinghelper.dev.java.net/issues/show_bug.cgi?id=1
+            !st.getClassName().startsWith("javax.swing.SwingWorker")) {
+          fromSwing = true;
+        }
+        if(repaint && "imageUpdate".equals(st.getMethodName())) {
+          imageUpdate = true;
+        }
+        if("repaint".equals(st.getMethodName())) {
+          repaint = true;
+          fromSwing = false;
+        }
+      }
+      if(imageUpdate) {
+        // assuming it is java.awt.image.ImageObserver.imageUpdate(...)
+        // image was asynchronously updated, that's ok
+        return;
+      }
+      if(repaint && !fromSwing) {
+        // no problems here, since repaint() is thread safe
+        return;
+      }
+      // ignore the last processed component
+      if(lastComponent != null && c == lastComponent.get()) { return; }
+      lastComponent = new WeakReference<JComponent>(c);
+      violationFound(c, stackTrace);
+    }
+  }
 
-       public static void main(String[] args) throws Exception {
-               // set CheckThreadViolationRepaintManager
-               RepaintManager
-                               .setCurrentManager(new 
CheckThreadViolationRepaintManager());
-               // Valid code
-               SwingUtilities.invokeAndWait(new Runnable() {
-                       public void run() {
-                               test();
-                       }
-               });
-               System.out.println("Valid code passed...");
-               repaintTest();
-               System.out.println("Repaint test - correct code");
-               // Invalide code (stack trace expected)
-               test();
-       }
+  protected void violationFound(JComponent c, StackTraceElement[] stackTrace) {
+    System.out.println();
+    System.out.println("EDT violation detected");
+    System.out.println(c);
+    for(StackTraceElement st : stackTrace) {
+      System.out.println("\tat " + st);
+    }
+  }
 
-       static void test() {
-               JFrame frame = new JFrame("Am I on EDT?");
-               frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-               frame.add(new JButton("JButton"));
-               frame.pack();
-               frame.setVisible(true);
-               frame.dispose();
-       }
+  public static void main(String[] args) throws Exception {
+    // set CheckThreadViolationRepaintManager
+    RepaintManager.setCurrentManager(new CheckThreadViolationRepaintManager());
+    // Valid code
+    SwingUtilities.invokeAndWait(new Runnable() {
+      public void run() {
+        test();
+      }
+    });
+    System.out.println("Valid code passed...");
+    repaintTest();
+    System.out.println("Repaint test - correct code");
+    // Invalide code (stack trace expected)
+    test();
+  }
 
-       // this test must pass
-       static void imageUpdateTest() {
-               JFrame frame = new JFrame();
-               frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-               JEditorPane editor = new JEditorPane();
-               frame.setContentPane(editor);
-               editor.setContentType("text/html");
-               // it works with no valid image as well
-               editor.setText("<html><img src=\"file:\\lala.png\"></html>");
-               frame.setSize(300, 200);
-               frame.setVisible(true);
-       }
+  static void test() {
+    JFrame frame = new JFrame("Am I on EDT?");
+    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+    frame.add(new JButton("JButton"));
+    frame.pack();
+    frame.setVisible(true);
+    frame.dispose();
+  }
 
-       private static JButton test;
+  // this test must pass
+  static void imageUpdateTest() {
+    JFrame frame = new JFrame();
+    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+    JEditorPane editor = new JEditorPane();
+    frame.setContentPane(editor);
+    editor.setContentType("text/html");
+    // it works with no valid image as well
+    editor.setText("<html><img src=\"file:\\lala.png\"></html>");
+    frame.setSize(300, 200);
+    frame.setVisible(true);
+  }
 
-       static void repaintTest() {
-               try {
-                       SwingUtilities.invokeAndWait(new Runnable() {
-                               public void run() {
-                                       test = new JButton();
-                                       test.setSize(100, 100);
-                               }
-                       });
-               } catch (Exception e) {
-                       e.printStackTrace();
-               }
-               // repaint(Rectangle) should be ok
-               test.repaint(test.getBounds());
-               test.repaint(0, 0, 100, 100);
-               test.repaint();
-       }
+  private static JButton test;
+
+  static void repaintTest() {
+    try {
+      SwingUtilities.invokeAndWait(new Runnable() {
+        public void run() {
+          test = new JButton();
+          test.setSize(100, 100);
+        }
+      });
+    } catch(Exception e) {
+      e.printStackTrace();
+    }
+    // repaint(Rectangle) should be ok
+    test.repaint(test.getBounds());
+    test.repaint(0, 0, 100, 100);
+    test.repaint();
+  }
 }
\ No newline at end of file

Modified: 
gate/trunk/plugins/Developer_Tools/src/org/jdesktop/swinghelper/debug/EventDispatchThreadHangMonitor.java
===================================================================
--- 
gate/trunk/plugins/Developer_Tools/src/org/jdesktop/swinghelper/debug/EventDispatchThreadHangMonitor.java
   2014-03-03 13:45:23 UTC (rev 17506)
+++ 
gate/trunk/plugins/Developer_Tools/src/org/jdesktop/swinghelper/debug/EventDispatchThreadHangMonitor.java
   2014-03-03 13:50:56 UTC (rev 17507)
@@ -1,19 +1,18 @@
 /*
- * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ * 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.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
-
 package org.jdesktop.swinghelper.debug;
 
 import gate.gui.MainFrame;
@@ -47,9 +46,7 @@
  * processing a single event for too long, it prints a stack trace showing what
  * the event dispatch thread is doing, and continues to time it until it 
finally
  * finishes. This is useful in determining what code is causing your Java
- * application's GUI to be unresponsive.
- * 
- * The original blog can be found here<br>
+ * application's GUI to be unresponsive. The original blog can be found 
here<br>
  * <a href=
  * 
"http://elliotth.blogspot.com/2005/05/automatically-detecting-awt-event.html";
  * > Automatically detecting AWT event dispatch thread hangs</a>
@@ -57,455 +54,435 @@
  * @author Elliott Hughes <[email protected]>
  */
 public final class EventDispatchThreadHangMonitor extends EventQueue {
-       private static final EventDispatchThreadHangMonitor INSTANCE = new 
EventDispatchThreadHangMonitor();
+  private static final EventDispatchThreadHangMonitor INSTANCE =
+      new EventDispatchThreadHangMonitor();
 
-       // Time to wait between checks that the event dispatch thread isn't 
hung.
-       private static final long CHECK_INTERVAL_MS = 100;
+  // Time to wait between checks that the event dispatch thread isn't hung.
+  private static final long CHECK_INTERVAL_MS = 100;
 
-       // Maximum time we won't warn about. This used to be 500 ms, but 1.5 on
-       // late-2004 hardware isn't really up to it; there are too many parts of
-       // the JDK that can go away for that long (often code that has to be
-       // called on the event dispatch thread, like font loading).
-       private static final long UNREASONABLE_DISPATCH_DURATION_MS = 1000;
+  // Maximum time we won't warn about. This used to be 500 ms, but 1.5 on
+  // late-2004 hardware isn't really up to it; there are too many parts of
+  // the JDK that can go away for that long (often code that has to be
+  // called on the event dispatch thread, like font loading).
+  private static final long UNREASONABLE_DISPATCH_DURATION_MS = 1000;
 
-       // Help distinguish multiple hangs in the log, and match start and end 
too.
-       // Only access this via getNewHangNumber.
-       private static int hangCount = 0;
+  // Help distinguish multiple hangs in the log, and match start and end too.
+  // Only access this via getNewHangNumber.
+  private static int hangCount = 0;
 
-       // Prevents us complaining about hangs during start-up, which are 
probably
-       // the JVM vendor's fault.
-       private boolean haveShownSomeComponent = false;
+  // Prevents us complaining about hangs during start-up, which are probably
+  // the JVM vendor's fault.
+  private boolean haveShownSomeComponent = false;
 
-       // The currently outstanding event dispatches. The implementation of
-       // modal dialogs is a common cause for multiple outstanding dispatches.
-       private final LinkedList<DispatchInfo> dispatches = new 
LinkedList<DispatchInfo>();
+  // The currently outstanding event dispatches. The implementation of
+  // modal dialogs is a common cause for multiple outstanding dispatches.
+  private final LinkedList<DispatchInfo> dispatches =
+      new LinkedList<DispatchInfo>();
 
-       private static class DispatchInfo {
-               // The last-dumped hung stack trace for this dispatch.
-               private StackTraceElement[] lastReportedStack;
-               // If so; what was the identifying hang number?
-               private int hangNumber;
+  private static class DispatchInfo {
+    // The last-dumped hung stack trace for this dispatch.
+    private StackTraceElement[] lastReportedStack;
 
-               // The EDT for this dispatch (for the purpose of getting stack 
traces).
-               // I don't know of any API for getting the event dispatch 
thread,
-               // but we can assume that it's the current thread if we're in 
the
-               // middle of dispatching an AWT event...
-               // We can't cache this because the EDT can die and be replaced 
by a
-               // new EDT if there's an uncaught exception.
-               private final Thread eventDispatchThread = 
Thread.currentThread();
+    // If so; what was the identifying hang number?
+    private int hangNumber;
 
-               // The last time in milliseconds at which we saw a dispatch on 
the above
-               // thread.
-               private long lastDispatchTimeMillis = 
System.currentTimeMillis();
+    // The EDT for this dispatch (for the purpose of getting stack traces).
+    // I don't know of any API for getting the event dispatch thread,
+    // but we can assume that it's the current thread if we're in the
+    // middle of dispatching an AWT event...
+    // We can't cache this because the EDT can die and be replaced by a
+    // new EDT if there's an uncaught exception.
+    private final Thread eventDispatchThread = Thread.currentThread();
 
-               public DispatchInfo() {
-                       // All initialization is done by the field initializers.
-               }
+    // The last time in milliseconds at which we saw a dispatch on the above
+    // thread.
+    private long lastDispatchTimeMillis = System.currentTimeMillis();
 
-               public void checkForHang() {
-                       if (timeSoFar() > UNREASONABLE_DISPATCH_DURATION_MS) {
-                               examineHang();
-                       }
-               }
+    public DispatchInfo() {
+      // All initialization is done by the field initializers.
+    }
 
-               // We can't use StackTraceElement.equals because that insists on
-               // checking the filename and line number.
-               // That would be version-specific.
-               private static boolean stackTraceElementIs(StackTraceElement e,
-                               String className, String methodName, boolean 
isNative) {
-                       return e.getClassName().equals(className)
-                                       && e.getMethodName().equals(methodName)
-                                       && e.isNativeMethod() == isNative;
-               }
+    public void checkForHang() {
+      if(timeSoFar() > UNREASONABLE_DISPATCH_DURATION_MS) {
+        examineHang();
+      }
+    }
 
-               // Checks whether the given stack looks like it's waiting for 
another
-               // event.
-               // This relies on JDK implementation details.
-               private boolean isWaitingForNextEvent(StackTraceElement[] 
currentStack) {
-                       return stackTraceElementIs(currentStack[0], 
"java.lang.Object",
-                                       "wait", true)
-                                       && stackTraceElementIs(currentStack[1], 
"java.lang.Object",
-                                                       "wait", false)
-                                       && stackTraceElementIs(currentStack[2],
-                                                       "java.awt.EventQueue", 
"getNextEvent", false);
-               }
+    // We can't use StackTraceElement.equals because that insists on
+    // checking the filename and line number.
+    // That would be version-specific.
+    private static boolean stackTraceElementIs(StackTraceElement e,
+        String className, String methodName, boolean isNative) {
+      return e.getClassName().equals(className)
+          && e.getMethodName().equals(methodName)
+          && e.isNativeMethod() == isNative;
+    }
 
-               private void examineHang() {
-                       StackTraceElement[] currentStack = eventDispatchThread
-                                       .getStackTrace();
+    // Checks whether the given stack looks like it's waiting for another
+    // event.
+    // This relies on JDK implementation details.
+    private boolean isWaitingForNextEvent(StackTraceElement[] currentStack) {
+      return stackTraceElementIs(currentStack[0], "java.lang.Object", "wait",
+          true)
+          && stackTraceElementIs(currentStack[1], "java.lang.Object", "wait",
+              false)
+          && stackTraceElementIs(currentStack[2], "java.awt.EventQueue",
+              "getNextEvent", false);
+    }
 
-                       if (isWaitingForNextEvent(currentStack)) {
-                               // Don't be fooled by a modal dialog if it's 
waiting for its
-                               // next event.
-                               // As long as the modal dialog's event pump 
doesn't get stuck,
-                               // it's okay for the outer pump to be suspended.
-                               return;
-                       }
+    private void examineHang() {
+      StackTraceElement[] currentStack = eventDispatchThread.getStackTrace();
+      if(isWaitingForNextEvent(currentStack)) {
+        // Don't be fooled by a modal dialog if it's waiting for its
+        // next event.
+        // As long as the modal dialog's event pump doesn't get stuck,
+        // it's okay for the outer pump to be suspended.
+        return;
+      }
+      if(stacksEqual(lastReportedStack, currentStack)) {
+        // Don't keep reporting the same hang every time the timer goes
+        // off.
+        return;
+      }
+      hangNumber = getNewHangNumber();
+      String stackTrace = stackTraceToString(currentStack);
+      lastReportedStack = currentStack;
+      Log.warn("(hang #" + hangNumber
+          + ") event dispatch thread stuck processing event for " + timeSoFar()
+          + " ms:" + stackTrace);
+      // MAG: we already check for deadlocks in GATE
+      // checkForDeadlock();
+    }
 
-                       if (stacksEqual(lastReportedStack, currentStack)) {
-                               // Don't keep reporting the same hang every 
time the timer goes
-                               // off.
-                               return;
-                       }
+    private static boolean stacksEqual(StackTraceElement[] a,
+        StackTraceElement[] b) {
+      if(a == null) { return false; }
+      if(a.length != b.length) { return false; }
+      for(int i = 0; i < a.length; ++i) {
+        if(a[i].equals(b[i]) == false) { return false; }
+      }
+      return true;
+    }
 
-                       hangNumber = getNewHangNumber();
-                       String stackTrace = stackTraceToString(currentStack);
-                       lastReportedStack = currentStack;
-                       Log.warn("(hang #" + hangNumber
-                                       + ") event dispatch thread stuck 
processing event for "
-                                       + timeSoFar() + " ms:" + stackTrace);
+    /**
+     * Returns how long this dispatch has been going on (in milliseconds).
+     */
+    private long timeSoFar() {
+      return (System.currentTimeMillis() - lastDispatchTimeMillis);
+    }
 
-                       // MAG: we already check for deadlocks in GATE
-                       // checkForDeadlock();
-               }
+    public void dispose() {
+      if(lastReportedStack != null) {
+        Log.warn("(hang #" + hangNumber
+            + ") event dispatch thread unstuck after " + timeSoFar() + " ms.");
+      }
+    }
+  }
 
-               private static boolean stacksEqual(StackTraceElement[] a,
-                               StackTraceElement[] b) {
-                       if (a == null) {
-                               return false;
-                       }
-                       if (a.length != b.length) {
-                               return false;
-                       }
-                       for (int i = 0; i < a.length; ++i) {
-                               if (a[i].equals(b[i]) == false) {
-                                       return false;
-                               }
-                       }
-                       return true;
-               }
+  private EventDispatchThreadHangMonitor() {
+    initTimer();
+  }
 
-               /**
-                * Returns how long this dispatch has been going on (in 
milliseconds).
-                */
-               private long timeSoFar() {
-                       return (System.currentTimeMillis() - 
lastDispatchTimeMillis);
-               }
+  /**
+   * Sets up a timer to check for hangs frequently.
+   */
+  private void initTimer() {
+    final long initialDelayMs = 0;
+    final boolean isDaemon = true;
+    Timer timer = new Timer("EventDispatchThreadHangMonitor", isDaemon);
+    timer.schedule(new HangChecker(), initialDelayMs, CHECK_INTERVAL_MS);
+  }
 
-               public void dispose() {
-                       if (lastReportedStack != null) {
-                               Log.warn("(hang #" + hangNumber
-                                               + ") event dispatch thread 
unstuck after "
-                                               + timeSoFar() + " ms.");
-                       }
-               }
-       }
+  private class HangChecker extends TimerTask {
+    @Override
+    public void run() {
+      synchronized(dispatches) {
+        if(dispatches.isEmpty() || !haveShownSomeComponent) {
+          // Nothing to do.
+          // We don't destroy the timer when there's nothing happening
+          // because it would mean a lot more work on every single AWT
+          // event that gets dispatched.
+          return;
+        }
+        // Only the most recent dispatch can be hung; nested dispatches
+        // by their nature cause the outer dispatch pump to be
+        // suspended.
+        dispatches.getLast().checkForHang();
+      }
+    }
+  }
 
-       private EventDispatchThreadHangMonitor() {
-               initTimer();
-       }
+  /**
+   * Sets up hang detection for the event dispatch thread.
+   */
+  public static void initMonitoring() {
+    Toolkit.getDefaultToolkit().getSystemEventQueue().push(INSTANCE);
+  }
 
-       /**
-        * Sets up a timer to check for hangs frequently.
-        */
-       private void initTimer() {
-               final long initialDelayMs = 0;
-               final boolean isDaemon = true;
-               Timer timer = new Timer("EventDispatchThreadHangMonitor", 
isDaemon);
-               timer.schedule(new HangChecker(), initialDelayMs, 
CHECK_INTERVAL_MS);
-       }
+  /**
+   * Overrides EventQueue.dispatchEvent to call our pre and post hooks either
+   * side of the system's event dispatch code.
+   */
+  @Override
+  protected void dispatchEvent(AWTEvent event) {
+    try {
+      preDispatchEvent();
+      super.dispatchEvent(event);
+    } finally {
+      postDispatchEvent();
+      if(!haveShownSomeComponent && event instanceof WindowEvent
+          && event.getID() == WindowEvent.WINDOW_OPENED) {
+        haveShownSomeComponent = true;
+      }
+    }
+  }
 
-       private class HangChecker extends TimerTask {
-               @Override
-               public void run() {
-                       synchronized (dispatches) {
-                               if (dispatches.isEmpty() || 
!haveShownSomeComponent) {
-                                       // Nothing to do.
-                                       // We don't destroy the timer when 
there's nothing happening
-                                       // because it would mean a lot more 
work on every single AWT
-                                       // event that gets dispatched.
-                                       return;
-                               }
-                               // Only the most recent dispatch can be hung; 
nested dispatches
-                               // by their nature cause the outer dispatch 
pump to be
-                               // suspended.
-                               dispatches.getLast().checkForHang();
-                       }
-               }
-       }
+  private void debug(String which) {
+    if(false) {
+      for(int i = dispatches.size(); i >= 0; --i) {
+        System.out.print(' ');
+      }
+      System.out.println(which);
+    }
+  }
 
-       /**
-        * Sets up hang detection for the event dispatch thread.
-        */
-       public static void initMonitoring() {
-               
Toolkit.getDefaultToolkit().getSystemEventQueue().push(INSTANCE);
-       }
+  /**
+   * Starts tracking a dispatch.
+   */
+  private synchronized void preDispatchEvent() {
+    debug("pre");
+    synchronized(dispatches) {
+      dispatches.addLast(new DispatchInfo());
+    }
+  }
 
-       /**
-        * Overrides EventQueue.dispatchEvent to call our pre and post hooks 
either
-        * side of the system's event dispatch code.
-        */
-       @Override
-       protected void dispatchEvent(AWTEvent event) {
-               try {
-                       preDispatchEvent();
-                       super.dispatchEvent(event);
-               } finally {
-                       postDispatchEvent();
-                       if (!haveShownSomeComponent && event instanceof 
WindowEvent
-                                       && event.getID() == 
WindowEvent.WINDOW_OPENED) {
-                               haveShownSomeComponent = true;
-                       }
-               }
-       }
+  /**
+   * Stops tracking a dispatch.
+   */
+  private synchronized void postDispatchEvent() {
+    synchronized(dispatches) {
+      // We've finished the most nested dispatch, and don't need it any
+      // longer.
+      DispatchInfo justFinishedDispatch = dispatches.removeLast();
+      justFinishedDispatch.dispose();
+      // The other dispatches, which have been waiting, need to be
+      // credited extra time.
+      // We do this rather simplistically by pretending they've just been
+      // redispatched.
+      Thread currentEventDispatchThread = Thread.currentThread();
+      for(DispatchInfo dispatchInfo : dispatches) {
+        if(dispatchInfo.eventDispatchThread == currentEventDispatchThread) {
+          dispatchInfo.lastDispatchTimeMillis = System.currentTimeMillis();
+        }
+      }
+    }
+    debug("post");
+  }
 
-       private void debug(String which) {
-               if (false) {
-                       for (int i = dispatches.size(); i >= 0; --i) {
-                               System.out.print(' ');
-                       }
-                       System.out.println(which);
-               }
-       }
+  private static void checkForDeadlock() {
+    ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
+    long[] threadIds = threadBean.findMonitorDeadlockedThreads();
+    if(threadIds == null) { return; }
+    Log.warn("deadlock detected involving the following threads:");
+    ThreadInfo[] threadInfos =
+        threadBean.getThreadInfo(threadIds, Integer.MAX_VALUE);
+    for(ThreadInfo info : threadInfos) {
+      Log.warn("Thread #" + info.getThreadId() + " " + info.getThreadName()
+          + " (" + info.getThreadState() + ") waiting on " + info.getLockName()
+          + " held by " + info.getLockOwnerName()
+          + stackTraceToString(info.getStackTrace()));
+    }
+  }
 
-       /**
-        * Starts tracking a dispatch.
-        */
-       private synchronized void preDispatchEvent() {
-               debug("pre");
-               synchronized (dispatches) {
-                       dispatches.addLast(new DispatchInfo());
-               }
-       }
+  private static String stackTraceToString(StackTraceElement[] stackTrace) {
+    StringBuilder result = new StringBuilder();
+    // We used to avoid showing any code above where this class gets
+    // involved in event dispatch, but that hides potentially useful
+    // information when dealing with modal dialogs. Maybe we should
+    // reinstate that, but search from the other end of the stack?
+    for(StackTraceElement stackTraceElement : stackTrace) {
+      String indentation = "    ";
+      result.append("\n" + indentation + stackTraceElement);
+    }
+    return result.toString();
+  }
 
-       /**
-        * Stops tracking a dispatch.
-        */
-       private synchronized void postDispatchEvent() {
-               synchronized (dispatches) {
-                       // We've finished the most nested dispatch, and don't 
need it any
-                       // longer.
-                       DispatchInfo justFinishedDispatch = 
dispatches.removeLast();
-                       justFinishedDispatch.dispose();
+  private synchronized static int getNewHangNumber() {
+    return ++hangCount;
+  }
 
-                       // The other dispatches, which have been waiting, need 
to be
-                       // credited extra time.
-                       // We do this rather simplistically by pretending 
they've just been
-                       // redispatched.
-                       Thread currentEventDispatchThread = 
Thread.currentThread();
-                       for (DispatchInfo dispatchInfo : dispatches) {
-                               if (dispatchInfo.eventDispatchThread == 
currentEventDispatchThread) {
-                                       dispatchInfo.lastDispatchTimeMillis = 
System
-                                                       .currentTimeMillis();
-                               }
-                       }
-               }
-               debug("post");
-       }
+  public static void main(String[] args) {
+    initMonitoring();
+    // special case for deadlock test
+    if(args.length > 0 && "deadlock".equals(args[0])) {
+      EventDispatchThreadHangMonitor.INSTANCE.haveShownSomeComponent = true;
+      Tests.runDeadlockTest();
+      return;
+    }
+    Tests.main(args);
+  }
 
-       private static void checkForDeadlock() {
-               ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
-               long[] threadIds = threadBean.findMonitorDeadlockedThreads();
-               if (threadIds == null) {
-                       return;
-               }
-               Log.warn("deadlock detected involving the following threads:");
-               ThreadInfo[] threadInfos = threadBean.getThreadInfo(threadIds,
-                               Integer.MAX_VALUE);
-               for (ThreadInfo info : threadInfos) {
-                       Log.warn("Thread #" + info.getThreadId() + " "
-                                       + info.getThreadName() + " (" + 
info.getThreadState()
-                                       + ") waiting on " + info.getLockName() 
+ " held by "
-                                       + info.getLockOwnerName()
-                                       + 
stackTraceToString(info.getStackTrace()));
-               }
-       }
+  private static class Tests {
+    public static void main(final String[] args) {
+      java.awt.EventQueue.invokeLater(new Runnable() {
+        public void run() {
+          for(String arg : args) {
+            final JFrame frame = new JFrame();
+            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+            frame.setLocationRelativeTo(null);
+            if(arg.equals("exception")) {
+              runExceptionTest(frame);
+            } else if(arg.equals("focus")) {
+              runFocusTest(frame);
+            } else if(arg.equals("modal-hang")) {
+              runModalTest(frame, true);
+            } else if(arg.equals("modal-no-hang")) {
+              runModalTest(frame, false);
+            } else {
+              System.err.println("unknown regression test '" + arg + "'");
+              System.exit(1);
+            }
+            frame.pack();
+            frame.setVisible(true);
+          }
+        }
+      });
+    }
 
-       private static String stackTraceToString(StackTraceElement[] 
stackTrace) {
-               StringBuilder result = new StringBuilder();
-               // We used to avoid showing any code above where this class gets
-               // involved in event dispatch, but that hides potentially useful
-               // information when dealing with modal dialogs. Maybe we should
-               // reinstate that, but search from the other end of the stack?
-               for (StackTraceElement stackTraceElement : stackTrace) {
-                       String indentation = "    ";
-                       result.append("\n" + indentation + stackTraceElement);
-               }
-               return result.toString();
-       }
+    private static void runDeadlockTest() {
+      class Locker {
+        private Locker locker;
 
-       private synchronized static int getNewHangNumber() {
-               return ++hangCount;
-       }
+        public void setLocker(Locker locker) {
+          this.locker = locker;
+        }
 
-       public static void main(String[] args) {
-               initMonitoring();
-               // special case for deadlock test
-               if (args.length > 0 && "deadlock".equals(args[0])) {
-                       
EventDispatchThreadHangMonitor.INSTANCE.haveShownSomeComponent = true;
-                       Tests.runDeadlockTest();
-                       return;
-               }
-               Tests.main(args);
-       }
+        public synchronized void tryToDeadlock() {
+          locker.toString();
+        }
 
-       private static class Tests {
-               public static void main(final String[] args) {
+        public synchronized String toString() {
+          try {
+            Thread.sleep(50);
+          } catch(InterruptedException e) {
+            e.printStackTrace();
+          }
+          return super.toString();
+        }
+      }
+      final Locker one = new Locker();
+      final Locker two = new Locker();
+      one.setLocker(two);
+      two.setLocker(one);
+      // Deadlock expected here:
+      for(int i = 0; i < 100; i++) {
+        SwingUtilities.invokeLater(new Runnable() {
+          public void run() {
+            one.tryToDeadlock();
+          }
+        });
+        two.tryToDeadlock();
+      }
+    }
 
-                       java.awt.EventQueue.invokeLater(new Runnable() {
-                               public void run() {
-                                       for (String arg : args) {
-                                               final JFrame frame = new 
JFrame();
-                                               
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-                                               
frame.setLocationRelativeTo(null);
-                                               if (arg.equals("exception")) {
-                                                       runExceptionTest(frame);
-                                               } else if (arg.equals("focus")) 
{
-                                                       runFocusTest(frame);
-                                               } else if 
(arg.equals("modal-hang")) {
-                                                       runModalTest(frame, 
true);
-                                               } else if 
(arg.equals("modal-no-hang")) {
-                                                       runModalTest(frame, 
false);
-                                               } else {
-                                                       
System.err.println("unknown regression test '"
-                                                                       + arg + 
"'");
-                                                       System.exit(1);
-                                               }
-                                               frame.pack();
-                                               frame.setVisible(true);
-                                       }
-                               }
-                       });
-               }
+    // If we don't do our post-dispatch activity in a finally block, we'll
+    // report bogus hangs.
+    private static void runExceptionTest(final JFrame frame) {
+      JButton button = new JButton("Throw Exception");
+      button.addActionListener(new ActionListener() {
+        public void actionPerformed(ActionEvent e) {
+          // This shouldn't cause us to report a hang.
+          throw new RuntimeException("Nobody expects the Spanish 
Inquisition!");
+        }
+      });
+      frame.add(button);
+    }
 
-               private static void runDeadlockTest() {
-                       class Locker {
-                               private Locker locker;
+    // A demonstration of nested calls to dispatchEvent caused by
+    // SequencedEvent.
+    private static void runFocusTest(final JFrame frame) {
+      final JDialog dialog = new JDialog(frame, "Non-Modal Dialog");
+      dialog.add(new JLabel("Close me!"));
+      dialog.pack();
+      dialog.setLocationRelativeTo(frame);
+      dialog.addWindowFocusListener(new WindowAdapter() {
+        public void windowGainedFocus(WindowEvent e) {
+          System.out.println("FocusTest.windowGainedFocus");
+          // If you don't cope with nested calls to dispatchEvent, you
+          // won't detect this.
+          // See java.awt.SequencedEvent for an example.
+          sleep(2500);
+        }
+      });
+      JButton button = new JButton("Show Non-Modal Dialog");
+      button.addActionListener(new ActionListener() {
+        public void actionPerformed(ActionEvent e) {
+          dialog.setVisible(true);
+        }
+      });
+      frame.add(button);
+    }
 
-                               public void setLocker(Locker locker) {
-                                       this.locker = locker;
-                               }
+    // A demonstration of the problems of dealing with modal dialogs.
+    private static void runModalTest(final JFrame frame,
+        final boolean shouldSleep) {
+      System.out.println(shouldSleep
+          ? "Expect hangs!"
+          : "There should be no hangs...");
+      JButton button = new JButton("Show Modal Dialog");
+      button.addActionListener(new ActionListener() {
+        public void actionPerformed(ActionEvent e) {
+          if(shouldSleep) {
+            sleep(2500); // This is easy.
+          }
+          JDialog dialog = new JDialog(frame, "Modal dialog", true);
+          dialog.setLayout(new FlowLayout());
+          dialog.add(new JLabel("Close this dialog!"));
+          final JLabel label = new JLabel(" ");
+          dialog.add(label);
+          dialog.pack();
+          dialog.setLocation(frame.getX() - 100, frame.getY());
+          // Make sure the new event pump has some work to do, each
+          // unit of which is insufficient to cause a hang.
+          new Thread(new Runnable() {
+            public void run() {
+              for(int i = 0; i <= 100000; ++i) {
+                final int value = i;
+                EventQueue.invokeLater(new Runnable() {
+                  public void run() {
+                    label.setText(Integer.toString(value));
+                  }
+                });
+              }
+            }
+          }).start();
+          dialog.setVisible(true);
+          if(shouldSleep) {
+            sleep(2500); // If you don't distinguish different stack
+            // traces, you won't report this.
+          }
+        }
+      });
+      frame.add(button);
+    }
 
-                               public synchronized void tryToDeadlock() {
-                                       locker.toString();
-                               }
+    private static void sleep(long ms) {
+      try {
+        System.out.println("Sleeping for " + ms + " ms on "
+            + Thread.currentThread() + "...");
+        Thread.sleep(ms);
+        System.out.println("Finished sleeping...");
+      } catch(Exception ex) {
+        ex.printStackTrace();
+      }
+    }
+  }
 
-                               public synchronized String toString() {
-                                       try {
-                                               Thread.sleep(50);
-                                       } catch (InterruptedException e) {
-                                               e.printStackTrace();
-                                       }
-                                       return super.toString();
-                               }
-                       }
-                       final Locker one = new Locker();
-                       final Locker two = new Locker();
-                       one.setLocker(two);
-                       two.setLocker(one);
-
-                       // Deadlock expected here:
-                       for (int i = 0; i < 100; i++) {
-                               SwingUtilities.invokeLater(new Runnable() {
-                                       public void run() {
-                                               one.tryToDeadlock();
-                                       }
-                               });
-                               two.tryToDeadlock();
-                       }
-               }
-
-               // If we don't do our post-dispatch activity in a finally 
block, we'll
-               // report bogus hangs.
-               private static void runExceptionTest(final JFrame frame) {
-                       JButton button = new JButton("Throw Exception");
-                       button.addActionListener(new ActionListener() {
-                               public void actionPerformed(ActionEvent e) {
-                                       // This shouldn't cause us to report a 
hang.
-                                       throw new RuntimeException(
-                                                       "Nobody expects the 
Spanish Inquisition!");
-                               }
-                       });
-                       frame.add(button);
-               }
-
-               // A demonstration of nested calls to dispatchEvent caused by
-               // SequencedEvent.
-               private static void runFocusTest(final JFrame frame) {
-                       final JDialog dialog = new JDialog(frame, "Non-Modal 
Dialog");
-                       dialog.add(new JLabel("Close me!"));
-                       dialog.pack();
-                       dialog.setLocationRelativeTo(frame);
-                       dialog.addWindowFocusListener(new WindowAdapter() {
-                               public void windowGainedFocus(WindowEvent e) {
-                                       
System.out.println("FocusTest.windowGainedFocus");
-                                       // If you don't cope with nested calls 
to dispatchEvent, you
-                                       // won't detect this.
-                                       // See java.awt.SequencedEvent for an 
example.
-                                       sleep(2500);
-                               }
-                       });
-                       JButton button = new JButton("Show Non-Modal Dialog");
-                       button.addActionListener(new ActionListener() {
-                               public void actionPerformed(ActionEvent e) {
-                                       dialog.setVisible(true);
-                               }
-                       });
-                       frame.add(button);
-               }
-
-               // A demonstration of the problems of dealing with modal 
dialogs.
-               private static void runModalTest(final JFrame frame,
-                               final boolean shouldSleep) {
-                       System.out.println(shouldSleep ? "Expect hangs!"
-                                       : "There should be no hangs...");
-                       JButton button = new JButton("Show Modal Dialog");
-                       button.addActionListener(new ActionListener() {
-                               public void actionPerformed(ActionEvent e) {
-                                       if (shouldSleep) {
-                                               sleep(2500); // This is easy.
-                                       }
-                                       JDialog dialog = new JDialog(frame, 
"Modal dialog", true);
-                                       dialog.setLayout(new FlowLayout());
-                                       dialog.add(new JLabel("Close this 
dialog!"));
-                                       final JLabel label = new JLabel(" ");
-                                       dialog.add(label);
-                                       dialog.pack();
-                                       dialog.setLocation(frame.getX() - 100, 
frame.getY());
-
-                                       // Make sure the new event pump has 
some work to do, each
-                                       // unit of which is insufficient to 
cause a hang.
-                                       new Thread(new Runnable() {
-                                               public void run() {
-                                                       for (int i = 0; i <= 
100000; ++i) {
-                                                               final int value 
= i;
-                                                               
EventQueue.invokeLater(new Runnable() {
-                                                                       public 
void run() {
-                                                                               
label.setText(Integer.toString(value));
-                                                                       }
-                                                               });
-                                                       }
-                                               }
-                                       }).start();
-
-                                       dialog.setVisible(true);
-
-                                       if (shouldSleep) {
-                                               sleep(2500); // If you don't 
distinguish different stack
-                                                                               
// traces, you won't report this.
-                                       }
-                               }
-                       });
-                       frame.add(button);
-               }
-
-               private static void sleep(long ms) {
-                       try {
-                               System.out.println("Sleeping for " + ms + " ms 
on "
-                                               + Thread.currentThread() + 
"...");
-                               Thread.sleep(ms);
-                               System.out.println("Finished sleeping...");
-                       } catch (Exception ex) {
-                               ex.printStackTrace();
-                       }
-               }
-       }
-
-       private static class Log {
-               public static void warn(String str) {
-                       // MAG: send messages to the console, because if the 
AWT is locked
-                       // then they won't show up anyway
-                       MainFrame.getInstance().getOriginalOut().println(str);
-               }
-       }
+  private static class Log {
+    public static void warn(String str) {
+      // MAG: send messages to the console, because if the AWT is locked
+      // then they won't show up anyway
+      MainFrame.getInstance().getOriginalOut().println(str);
+    }
+  }
 }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to