pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edvin Syse <ed...@sysedata.no>
Subject Re: How do I update a node in a TreeView when it has no parent?
Date Tue, 07 Jun 2011 07:32:01 GMT
Den 07.06.2011 09:17, skrev Edvin Syse:
> Updating a node that has a parent, even changing it from a TreeNode to 
> a BranchNode is trivial via det node.getParent().update() method. But 
> when a node is at the root of the hierarchy, I don't have a parent to 
> call update on. I guess I need to invoke some listener on the TreeView 
> itselv, but how? :)
I did get it working:

             // Get index of current node
             int idx = getTreeData().indexOf(node);

             // Remove old node, add new node
             getTreeData().remove(idx, 1);
             getTreeData().insert(newNode, idx);

             // Traverse all NodeListeners and tell them I updated index 
pos at root (empty Path)
             Sequence.Tree.Path path = new Sequence.Tree.Path();
             for (TreeViewNodeListener l : getTreeViewNodeListeners())
                 l.nodeUpdated(this, path, idx);

.. but maybe there is a simpler/cleaner way? Maybe TreeView itself 
should have a rootNodeUpdated method, in line with the functionality on 
a TreeBranch? :)

-- Edvin

View raw message