You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Robert Piotrowski <rp...@azonic.net> on 2010/02/11 16:51:48 UTC

TreeBranch & TreeNode attributes in the next version?

Are TreeBranches and TreeNodes getting userData collections soon?  I really
need a place to store some properties in a node.  The treenode properties
would store SOLR facet names but the treenode texts would show the
"friendly" names.

That's the only thing that I see lacking right now.  Otherwise, awesome
toolkit.  This is best thing since the old Thinlet "Classic" that is now
long gone.

Would it be too heavy to extend TreeBranches and TreeNodes from Component
instead of Object?

Should I just extend TreeNode so in contains one more property with a
getter/setter?






Thanks,
Bob

Re: TreeBranch & TreeNode attributes in the next version?

Posted by Greg Brown <gk...@mac.com>.
Hi Bob,

> Are TreeBranches and TreeNodes getting userData collections soon? 

TreeBranch and TreeNode are simply default tree data implementations that the default TreeNodeRenderer is capable of presenting. You are free to extend these classes or replace them entirely as needed by your application.

> Would it be too heavy to extend TreeBranches and TreeNodes from Component instead of Object?

These classes are data objects, so it wouldn't make sense to extend Component (i.e. making them extend Component wouldn't allow you to add components to a TreeView).

> Should I just extend TreeNode so in contains one more property with a getter/setter?

That is one option, though extending TreeNode would only allow you to add the property to the leaf nodes (TreeBranch would still extend the existing TreeNode base class, not your custom class). If your branch nodes also need the property, you'd also need to extend TreeBranch. In that case, you might want to define an interface that both subclasses would implement. Alternatively, you could extend TreeNode to add the property and then create a custom TreeBranch class that extends your custom TreeNode class.

The most flexible approach would be to create your own tree data classes and renderer. You can refer to the tree view classes in org.apache.pivot.wtk.content for examples:

http://svn.apache.org/repos/asf/pivot/tags/v1.4/wtk/src/org/apache/pivot/wtk/content/

Hope this helps,
Greg