pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Bartlett <cbartlet...@gmail.com>
Subject Re: How do I update a node in a TreeView when it has no parent?
Date Tue, 07 Jun 2011 07:50:22 GMT
(I didn't see your replay until after I sent my reply)

Do you need to perform separate remove and insert calls?
Why not just    getTreeData().update(idx, newNode);

Or are you saying that there are events not being fired?

Chris

On 7 June 2011 14:32, Edvin Syse <edvin@sysedata.no> wrote:

> 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
>

Mime
View raw message