Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » TreeViewer and traversing nodes for a domain object
TreeViewer and traversing nodes for a domain object [message #464708] Wed, 14 March 2007 01:27 Go to next message
Eclipse UserFriend
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 #464722 is a reply to message #464708] Wed, 14 March 2007 11:52 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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
>


--
B e s t S o l u t i o n . a t EDV Systemhaus GmbH
----------------------------------------------------
tom schindl Eclipse JFace Committer
Re: TreeViewer and traversing nodes for a domain object [message #464822 is a reply to message #464722] Fri, 16 March 2007 00:27 Go to previous message
Eclipse UserFriend
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
>>
>
>
Previous Topic:Once again: DeleteAction in a MultiPageEditor
Next Topic:Changing default browse location of "File > Open File"
Goto Forum:
  


Current Time: Wed Oct 09 04:51:52 GMT 2024

Powered by FUDForum. Page generated in 0.03709 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top