Link to home
Start Free TrialLog in
Avatar of kumarSaravanan
kumarSaravananFlag for United States of America

asked on

RCP: Tree Viewer- selecting a node and passing the underlying object

I have a Treeviewer with 3 levels of nodes, main,branch,leaf. If I select the leaf, the underlying leaf object should be available to me to pass on to other UI elements.
I tried the listener, addSelectionChangedListener. The SelectionChangedEvent, brings only the text which is displayed - not the entire object.

Any insight is highly appreciated.
Thanks
ASKER CERTIFIED SOLUTION
Avatar of gudii9
gudii9
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kumarSaravanan

ASKER

public void selectionChanged(SelectionChangedEvent event) {
		
				
				IStructuredSelection sel = (IStructuredSelection) event.getSelection();
				
				TreeObject element = (TreeObject)sel.getFirstElement();

...

}

Open in new window


IStructuredSelection allows me to get to the underlying object.
The above code snippet illustrates that.