Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.greenstone.gatherer.util
Class SynchronizedTreeModelTools  view SynchronizedTreeModelTools download SynchronizedTreeModelTools.java

java.lang.Object
  extended byorg.greenstone.gatherer.util.SynchronizedTreeModelTools

public class SynchronizedTreeModelTools
extends java.lang.Object

Due to the TreeModel objects not having any synchronization, certain assumptions, such as the model state remaining constant during a repaint, don't always hold - especially given that I'm changing the tree model on a different thread. In order to get around this I will use the latest swing paradigm wherein you flag a section of code to be executed by the AWT GUI Event queue, as soon as other gui tasks have finished. This way I shouldn't have tree redraws throwing NPEs because the array size of the children of a certain node has changed -while- the repaint call was made, i.e. repaint() calls getChildCount() = 13, removeNodeFromParent() called, repaint calls getChildAt(12) = ArrayIndexOutOfBoundsException.

Version:
2.3c

Constructor Summary
SynchronizedTreeModelTools()
           
 
Method Summary
static java.lang.Runnable insertNodeInto(javax.swing.tree.DefaultTreeModel model, javax.swing.tree.MutableTreeNode parent, javax.swing.tree.MutableTreeNode target_node)
          Adds an insertNodeInto model update onto the AWT Event queue.
static java.lang.Runnable insertNodeInto(javax.swing.tree.DefaultTreeModel model, javax.swing.tree.MutableTreeNode parent, javax.swing.tree.MutableTreeNode target_node, boolean wait_allowed)
           
static void removeNodeFromParent(javax.swing.tree.DefaultTreeModel model, javax.swing.tree.MutableTreeNode target_node)
          Adds a removeNodeFromParent model update onto the AWT Event queue.
static void replaceNode(javax.swing.tree.DefaultTreeModel model, javax.swing.tree.MutableTreeNode old_node, javax.swing.tree.MutableTreeNode new_node)
          Adds a replaceNode model update onto the AWT Event queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SynchronizedTreeModelTools

public SynchronizedTreeModelTools()
Method Detail

insertNodeInto

public static final java.lang.Runnable insertNodeInto(javax.swing.tree.DefaultTreeModel model,
                                                      javax.swing.tree.MutableTreeNode parent,
                                                      javax.swing.tree.MutableTreeNode target_node)
Adds an insertNodeInto model update onto the AWT Event queue. This gets around the lack of synchronization illustrated above.


insertNodeInto

public static final java.lang.Runnable insertNodeInto(javax.swing.tree.DefaultTreeModel model,
                                                      javax.swing.tree.MutableTreeNode parent,
                                                      javax.swing.tree.MutableTreeNode target_node,
                                                      boolean wait_allowed)

removeNodeFromParent

public static final void removeNodeFromParent(javax.swing.tree.DefaultTreeModel model,
                                              javax.swing.tree.MutableTreeNode target_node)
Adds a removeNodeFromParent model update onto the AWT Event queue. This gets around the lack of synchronization illustrated above.


replaceNode

public static final void replaceNode(javax.swing.tree.DefaultTreeModel model,
                                     javax.swing.tree.MutableTreeNode old_node,
                                     javax.swing.tree.MutableTreeNode new_node)
Adds a replaceNode model update onto the AWT Event queue. This gets around the lack of synchronization illustrated above.