- Timestamp:
- 2010-12-09T22:27:33+13:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/util/SynchronizedTreeModelTools.java
r11084 r23433 31 31 import javax.swing.tree.*; 32 32 import org.greenstone.gatherer.DebugStream; 33 import org.greenstone.gatherer.metadata.FilenameEncoding; 34 import org.greenstone.gatherer.collection.CollectionTreeNode; 33 35 34 36 /** 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. … … 104 106 final Runnable doRemoveNodeFromParent = new Runnable() { 105 107 public void run() { 106 model.removeNodeFromParent(target_node); 108 // If we're dealing with a collection tree node, it may have 109 // gs.FilenameEncoding assigned, so we remove its entry from the map. 110 // Needs to be done here because the tree is constantly changing 111 // when nodes are being removed, renamed and deleted, and this 112 // affects lookup queries sent to the map. 113 // Don't need to do a recursive reset on this coltreenode, because 114 // Delete/Move/Rename FileJobs were created for *each* node 115 if(target_node instanceof CollectionTreeNode) { 116 CollectionTreeNode colNode = (CollectionTreeNode)target_node; 117 FilenameEncoding.map.remove(colNode.getURLEncodedFilePath()); 118 } 119 120 model.removeNodeFromParent(target_node); 107 121 } 108 122 };
Note:
See TracChangeset
for help on using the changeset viewer.