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 to use java.util.List backed tree structure with TreeView
Date Fri, 06 May 2011 12:25:50 GMT
OK. I think I'll start by wrapping my objects in TreeNode and TreeBranch 
and see how it goes. Can I ask why you didn't add generics to these 
objects? It would be nice to be able to do:

TreeNode<MyObject> node = new TreeNode<MyObject>();
node.setUserData(instanceOfMyObject)


...

MyObject myObject = node.getUserData()

-- Edvin

Den 06.05.2011 14:16, skrev Greg Brown:
> If a node implements org.apache.pivot.collections.List, it is considered a branch. Otherwise,
it is a leaf.
>
> On May 6, 2011, at 8:06 AM, Edvin Syse wrote:
>
>> ListAdapter was nice, thanks :)
>>
>> But how do I express what is supposed to be Leaf nodes and what to be Branch nodes?
>>
>> -- Edvin
>>
>> Den 06.05.2011 13:49, skrev Greg Brown:
>>> Have you looked at org.apache.pivot.collections.adapter.ListAdapter? You might
be able to use this in conjunction with TreeViewBranchListener to construct your tree nodes
from your backing data structure on demand.
>>>
>>> G
>>>
>>>
>>> On May 6, 2011, at 7:31 AM, Edvin Syse wrote:
>>>
>>>> I have a tree-structure represented by a list of domain objects. Some of
the domain objects have a "children" property with a java.util.List of children. The TreeView#setTreeData
method takes a org.apache.pivot.collections.List, and I figured I could do:
>>>>
>>>> setTreeData(new ArrayList(myJavaUtilListList.toArray()));
>>>>
>>>> This works so that I can see the first level of nodes, but I don't know how
to express branch nodes. Also, I would like to lazy load some of the nodes. I think I need
to use the TreeViewBranchListener somehow, but I can't find any documentation or examples.
>>>>
>>>> Do I need to wrap all my domain objects in TreeNodes or is there another
way to do this?
>>>>
>>>> -- Edvin
>>>
>

Mime
View raw message