Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » TreeViewer
TreeViewer [message #96712] Fri, 04 July 2008 08:04 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
>
Previous Topic:TableViewer Scroll Bug
Next Topic:Still Problem with IE bug #232799
Goto Forum:
  


Current Time: Thu Apr 25 15:56:40 GMT 2024

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

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

Back to the top