Changeset 8577
- Timestamp:
- 2004-11-17T10:03:30+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/util/SynchronizedTreeModelTools.java
r8236 r8577 28 28 29 29 import java.lang.Runnable; 30 import java.lang.Thread;31 30 import javax.swing.SwingUtilities; 32 31 import javax.swing.tree.*; … … 95 94 return doInsertNodeInto; 96 95 } 96 97 97 98 /** Adds a removeNodeFromParent model update onto the AWT Event queue. This gets around the lack of synchronization illustrated above. 98 99 * @param model The <strong>GTreeModel</strong> we want to remove the node from. … … 112 113 catch (Exception exception) { 113 114 DebugStream.printStackTrace(exception); 114 ///ystem.err.println(e);115 115 } 116 116 // 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. … … 121 121 } 122 122 } 123 /** Adds a replaceNode model update onto the AWT Event queue. This gets around the lack of synchronization illustrated above.124 * @param model The <strong>GTreeModel</strong> we want to change.125 * @param old_node The <strong>GTreeNode</strong> to replace.126 * @param new_node The <strong>GTreeNode</strong> to replace it with.127 */128 static final public void replaceNode(final DefaultTreeModel model, final MutableTreeNode old_node, final MutableTreeNode new_node) {129 final Runnable doReplaceNode = new Runnable() {130 public void run() {131 MutableTreeNode parent = (MutableTreeNode) old_node.getParent();132 if(parent != null) {133 int index = parent.getIndex(old_node);134 model.removeNodeFromParent(old_node);135 model.insertNodeInto(new_node, parent, index);136 }137 parent = null;138 }139 };140 try {141 //SwingUtilities.invokeLater(doReplaceNode);142 SwingUtilities.invokeAndWait(doReplaceNode);143 }144 catch (Exception exception) {145 DebugStream.printStackTrace(exception);146 }147 }148 123 }
Note:
See TracChangeset
for help on using the changeset viewer.