TreeViewer and traversing nodes for a domain object [message #464708] |
Wed, 14 March 2007 01:27 |
Eclipse User |
|
|
|
Originally posted by: x.y.z
I'm having a tough time trying to figure out how to iterate through
the nodes of a TreeViewer to find a particular domain object. Most of
the time, the domain objects that I trying to look for are leaf nodes
on a fairly large and deep tree, but trying to traverse the tree to
match it against a particular domain object has been tricky.
The tree is composed of a hierarchy of nodes. Each node wraps some
domain object as a data model. Later on, I get a request to search
this tree for a domain object in order to programmatically select it.
I end up doing a brute force traversal of the tree nodes (starting at
the root node) to find the domain object, consisting of a deep and
ugly nested if-then-else block.
Have I overlooked something? I do get the feeling I am.
Thanks in advanced,
DW
|
|
|
|
Re: TreeViewer and traversing nodes for a domain object [message #464822 is a reply to message #464722] |
Fri, 16 March 2007 00:27 |
Eclipse User |
|
|
|
Originally posted by: kvjames22.hotmail.com
Thanks, Tom. That seems like a good way to do it now that you
mentioned it.
DW
Tom Schindl <tom.schindl@bestsolution.at> wrote in
news:et8nm5$gji$1@utils.eclipse.org:
> Hi,
>
> no you haven't TreeViewers have exactly the same problem and the
> solution for us is that we create a hash-map from the entries and
> use it to look up the objects when you e.g. call
> setSelection(IStructuredSelection). For TreeViewers you need to
> turn this feature on by call TreeViewer#setUseHashlookup(boolean)
> you could do this your own but you need take into account that you
> need to sync the Hash map.
>
> Tom
>
> dsw2 schrieb:
>> I'm having a tough time trying to figure out how to iterate
>> through the nodes of a TreeViewer to find a particular domain
>> object. Most of the time, the domain objects that I trying to
>> look for are leaf nodes on a fairly large and deep tree, but
>> trying to traverse the tree to match it against a particular
>> domain object has been tricky.
>>
>> The tree is composed of a hierarchy of nodes. Each node wraps
>> some domain object as a data model. Later on, I get a request to
>> search this tree for a domain object in order to programmatically
>> select it. I end up doing a brute force traversal of the tree
>> nodes (starting at the root node) to find the domain object,
>> consisting of a deep and ugly nested if-then-else block.
>>
>> Have I overlooked something? I do get the feeling I am.
>>
>> Thanks in advanced,
>> DW
>>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03709 seconds