Den 07.06.2011 09:41, skrev Chris Bartlett:
Edvin,
I'm not totally sure that I understand your problem, but the following
might help.
The root nodes of a TreeView are simply the elements of the List that
the TreeView uses as its data model which is accessible via
treeView.getTreeData();
The thing is, I have a root node that is a TreeNode, and I right click
it to create a child node. This suddenly makes the TreeNode a
TreeBranch, so I have to recreate it and swap out the old TreeNode for
the new TreeBranch. Since the TreeNode is a root node (doesn't have a
parent), I can't call node.getParent().update() to make it re-render, so
I need to invoke the listeners on the TreeView itself to make this
happen. As you see, I also swap out the node in the treeData manually.
This is done automatically when I can call node.parent.update().
If you are looking to treat the root nodes in the same way as any
other node, I think you should be able to use a TreeBranch as the root
node (as it implements org.apache.pivot.collections.List<TreeNode>).
This assumes that you are using the provided
org.apache.pivot.wtk.content.TreeBranch and
org.apache.pivot.wtk.content.TreeNode classes rather than custom ones.
That would also change the rendering of the tree, showing my "root
nodes" under a single parent. I don't want that :)
I can create a short screencast to illustrate this if you want?
-- Edvin