|
|
Re: question regarding the TreeViewer selection [message #298230 is a reply to message #298197] |
Thu, 26 January 2006 15:39   |
Eclipse User |
|
|
|
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 #298240 is a reply to message #298238] |
Thu, 26 January 2006 19:04  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03236 seconds