Changeset 6096


Ignore:
Timestamp:
2003-12-02T17:26:37+13:00 (20 years ago)
Author:
jmt12
Message:

Added and then removed some debug comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/util/SynchronizedTreeModelTools.java

    r5581 r6096  
    3737public class SynchronizedTreeModelTools {
    3838    /** Adds an insertNodeInto model update onto the AWT Event queue. This gets around the lack of synchronization illustrated above. */
    39     static final public Runnable insertNodeInto(final DefaultTreeModel model, final MutableTreeNode parent, final MutableTreeNode target_node) {
     39    static final public Runnable insertNodeInto(DefaultTreeModel model, MutableTreeNode parent, MutableTreeNode target_node) {
     40    return insertNodeInto(model, parent, target_node, true);
     41    }
     42
     43    static final public Runnable insertNodeInto(final DefaultTreeModel model, final MutableTreeNode parent, final MutableTreeNode target_node, boolean wait_allowed) {
    4044    final Runnable doInsertNodeInto = new Runnable() {
    4145        public void run() {
     46            ///ystem.err.print("Running task... ");
    4247            int index = -1;
    4348            int pos = 0;
     
    7075        }
    7176        };
     77    ///ystem.err.print("Queuing Task... ");
    7278    try {
    73                 //SwingUtilities.invokeLater(doInsertNodeInto);
    74         SwingUtilities.invokeAndWait(doInsertNodeInto);
     79        if(wait_allowed && !SwingUtilities.isEventDispatchThread()) {
     80        ///ystem.err.print("In another thread - invoke and wait... ");
     81        SwingUtilities.invokeAndWait(doInsertNodeInto);
     82        }
     83        else {
     84        ///ystem.err.print("In Event Thread or wait not allowed - invoke later... ");
     85        SwingUtilities.invokeLater(doInsertNodeInto);
     86        }
    7587    }
    7688    catch (Exception e) {
    7789        e.printStackTrace();
    7890    }
    79     // If (and only if) we've thrown an error because we tried to invoke the runnable task and wait, when we are in the AWTEvent thread already, then try agin but with an invoke later.
    80     catch (java.lang.Error error) {
    81         if(error.toString().equals("java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread")) {
    82         SwingUtilities.invokeLater(doInsertNodeInto);
    83         }
    84     }
     91    ///ystem.err.print("Added Task... ");
    8592    return doInsertNodeInto;
    8693    }
Note: See TracChangeset for help on using the changeset viewer.