Changeset 6212
- Timestamp:
- 2003-12-10T17:03:57+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/util/SynchronizedTreeModelTools.java
r6096 r6212 31 31 import javax.swing.SwingUtilities; 32 32 import javax.swing.tree.*; 33 import org.greenstone.gatherer.Gatherer; 33 34 /** 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. 34 35 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 86 87 } 87 88 } 88 catch (Exception e ) {89 e.printStackTrace();89 catch (Exception exception) { 90 Gatherer.printStackTrace(exception); 90 91 } 91 92 ///ystem.err.print("Added Task... "); … … 104 105 }; 105 106 try { 106 107 //SwingUtilities.invokeLater(doRemoveNodeFromParent); 107 108 SwingUtilities.invokeAndWait(doRemoveNodeFromParent); 108 109 } 109 catch (Exception e ) {110 e.printStackTrace();111 110 catch (Exception exception) { 111 Gatherer.printStackTrace(exception); 112 ///ystem.err.println(e); 112 113 } 113 114 // 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. … … 136 137 }; 137 138 try { 138 139 //SwingUtilities.invokeLater(doReplaceNode); 139 140 SwingUtilities.invokeAndWait(doReplaceNode); 140 141 } 141 catch (Exception e ) {142 e.printStackTrace();142 catch (Exception exception) { 143 Gatherer.printStackTrace(exception); 143 144 } 144 145 }
Note:
See TracChangeset
for help on using the changeset viewer.