TreeViewer [message #96712] |
Fri, 04 July 2008 08:04 |
Eclipse User |
|
|
|
Originally posted by: rglorius.web.de
Hello,
I've build a TreeViewer like the Mail-example.
The TreeViewer is build by a TreeParent with TreeParents and TreeObjects.
I add a DoubleClickEvent to open new views by clicking on the treeView. At
this event I check which Tree-Element has been selected, but I only can
check the elements' String and not the hole Elements-data.
some code:
viewer.addDoubleClickListener(new IDoubleClickListener(){public void
doubleClick(DoubleClickEvent event) {
...
IStructuredSelection selection = (IStructuredSelection)
event.getSelection();
String selectedString = selection.getFirstElement().toString();
Is there a way to get Access to the TreeObject which has been selected?
Thanks, Rob
|
|
|
Re: TreeViewer [message #96845 is a reply to message #96712] |
Fri, 04 July 2008 10:14 |
Eclipse User |
|
|
|
Originally posted by: rherrmann.innoopract.com
Rob,
if the selection isn't empty, getFirstElement() will return your
model-object, presumably TreeObject/TreeParent in your case.
You need to explicitly cast the returned object.
HTH
Rüdiger
Rob wrote:
> Hello,
>
> I've build a TreeViewer like the Mail-example. The TreeViewer is build
> by a TreeParent with TreeParents and TreeObjects.
>
> I add a DoubleClickEvent to open new views by clicking on the treeView.
> At this event I check which Tree-Element has been selected, but I only
> can check the elements' String and not the hole Elements-data.
>
> some code:
>
> viewer.addDoubleClickListener(new IDoubleClickListener(){public void
> doubleClick(DoubleClickEvent event) {
> ...
> IStructuredSelection selection = (IStructuredSelection)
> event.getSelection();
> String selectedString = selection.getFirstElement().toString();
>
> Is there a way to get Access to the TreeObject which has been selected?
>
> Thanks, Rob
>
|
|
|
Powered by
FUDForum. Page generated in 0.02508 seconds