Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » question regarding the TreeViewer selection
question regarding the TreeViewer selection [message #298161] Wed, 25 January 2006 21:27 Go to next message
Eclipse UserFriend
hello All,
I have the following question. I have a dialog box that I am using to show a
tree viewer with some contents in it. The contents are strictly two level.
It has named filter on it too. Now, I want to show the first element (after
sorting) in the tree selected when the dialog box pops up. Can any one tell
me how I can do it.
Attached is the screen shot of what I want to achieve when a dialog box is
popped.

thanks in advance,
Sridhar


  • Attachment: temp.JPG
    (Size: 4.32KB, Downloaded 74 times)
Re: question regarding the TreeViewer selection [message #298197 is a reply to message #298161] Thu, 26 January 2006 10:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Use TreeViewer's setSelection(ISelction, boolean) to select it and use
true for the boolean to reveal.

Sridhar wrote:
> hello All,
> I have the following question. I have a dialog box that I am using to show a
> tree viewer with some contents in it. The contents are strictly two level.
> It has named filter on it too. Now, I want to show the first element (after
> sorting) in the tree selected when the dialog box pops up. Can any one tell
> me how I can do it.
> Attached is the screen shot of what I want to achieve when a dialog box is
> popped.
>
> thanks in advance,
> Sridhar
>
>
>

--
Thanks,
Rich Kulp
Re: question regarding the TreeViewer selection [message #298230 is a reply to message #298197] Thu, 26 January 2006 15:39 Go to previous messageGo to next message
Eclipse UserFriend
Hello Rich,
Thanks for the reply...but may be I did not explain my problem
properly...The issue is I dont know the first child node object of the first
parent node object in the diaplayed view.
If I knew it, I can pass it using the ISelection.
Because, the display is showing the objects that are added randomly and then
sorted by using a view sorter.
thanks,
Sridhar


"Rich Kulp" <richkulp@us.NO_SPAM.ibm.com> wrote in message
news:drao5r$q76$1@utils.eclipse.org...
> Use TreeViewer's setSelection(ISelction, boolean) to select it and use
> true for the boolean to reveal.
>
> Sridhar wrote:
>> hello All,
>> I have the following question. I have a dialog box that I am using to
>> show a tree viewer with some contents in it. The contents are strictly
>> two level. It has named filter on it too. Now, I want to show the first
>> element (after sorting) in the tree selected when the dialog box pops up.
>> Can any one tell me how I can do it.
>> Attached is the screen shot of what I want to achieve when a dialog box
>> is popped.
>>
>> thanks in advance,
>> Sridhar
>
> --
> Thanks,
> Rich Kulp
Re: question regarding the TreeViewer selection [message #298238 is a reply to message #298230] Thu, 26 January 2006 18:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

You can try this:

Tree tree = treeviewer.getTree();
TreeItem parentItem = tree.getItem(0);
TreeItem childItem = parentItem.getItem(0);
tree.setSelection(new TreeItem[] {childItem});
tree.showSelection();

The only thing I'm not sure of is that the tree.setSelection() method
might not fire selection changed. I'm not sure.

--
Thanks,
Rich Kulp
Re: question regarding the TreeViewer selection [message #298240 is a reply to message #298238] Thu, 26 January 2006 19:04 Go to previous message
Eclipse UserFriend
You are right, eventhough the widget showing the selection, there was no
event fired. I fixed it by changing the code as follows.

Tree tree = treeViewer.getTree();
TreeItem selectionItem = tree.getItem(0);
selectionItem = selectionItem.getItem(0);
treeViewer.setSelection(new StructuredSelection(new
Object[]{selectionItem.getData()}));

thanks,
Sridhar


"Rich Kulp" <richkulp@us.NO_SPAM.ibm.com> wrote in message
news:drbkf5$co0$1@utils.eclipse.org...
> You can try this:
>
> Tree tree = treeviewer.getTree();
> TreeItem parentItem = tree.getItem(0);
> TreeItem childItem = parentItem.getItem(0);
> tree.setSelection(new TreeItem[] {childItem});
> tree.showSelection();
>
> The only thing I'm not sure of is that the tree.setSelection() method
> might not fire selection changed. I'm not sure.
>
> --
> Thanks,
> Rich Kulp
Previous Topic:classpath - environment variable
Next Topic:Eclipse Internal Browser
Goto Forum:
  


Current Time: Thu May 08 06:23:49 EDT 2025

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

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

Back to the top