Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Select item in TreeViewer from code
Select item in TreeViewer from code [message #262975] Wed, 21 July 2004 20:18 Go to next message
Eclipse UserFriend
Originally posted by: myname(with.between names).lombardisoftware.com

I have a problem with the TreeViewer and selecting a specific object from
code.

I'm trying something like this:

treeviewer.setSelection(new StructuredSelection(myObject), true);

where myObject is an object in the model. This works fine as long as
myObject is already visible and expanded. If the tree is not currently
showing the object, it doesn't seem to select it (or the selection at least
isn't visible)..

Is there a simple nice way to "select and expand if needed" method out
there?
Re: Select item in TreeViewer from code [message #263066 is a reply to message #262975] Thu, 22 July 2004 03:48 Go to previous message
Eclipse UserFriend
Originally posted by: markus_keller.ch.ibm.spam.protect.com

treeviewer.expandToLevel(myObject, 0);

Markus


Morten Moeller wrote:
> I have a problem with the TreeViewer and selecting a specific object from
> code.
>
> I'm trying something like this:
>
> treeviewer.setSelection(new StructuredSelection(myObject), true);
>
> where myObject is an object in the model. This works fine as long as
> myObject is already visible and expanded. If the tree is not currently
> showing the object, it doesn't seem to select it (or the selection at least
> isn't visible)..
>
> Is there a simple nice way to "select and expand if needed" method out
> there?
>
>
Previous Topic:Using libraries as a separate plugin
Next Topic:enabling/disabling of an IAction at the startup based on conditions
Goto Forum:
  


Current Time: Fri Jul 18 01:05:21 EDT 2025

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

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

Back to the top