Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » get element in treeviewer given treeitem
get element in treeviewer given treeitem [message #1028648] Thu, 28 March 2013 14:51 Go to next message
Mokhtar Abdu is currently offline Mokhtar AbduFriend
Messages: 104
Registered: November 2011
Senior Member

i have a multicolumn tree with a treeviewer. At some point i need to get the model object given a TreeItem. How can I do this? as it is easier with tableviewer using tableviewer.getElementAt(index). I think i have to use treeviewer.getVisibleExpandedElements() but how?

EDIT: and yes i select the leave node which is not retrieved by treeviewer#getVisibleExpandedElements() Sad. I need the model object of the selected leave node

appreciate any help.

[Updated on: Thu, 28 March 2013 15:24]

Report message to a moderator

Re: get element in treeviewer given treeitem [message #1028683 is a reply to message #1028648] Thu, 28 March 2013 15:55 Go to previous messageGo to next message
Timur Achmetow is currently offline Timur AchmetowFriend
Messages: 38
Registered: April 2012

one solution is to work with TreeSelection:
((TreeSelection) getViewer().getSelection());
(IStructuredSelection) getViewer().getSelection();
Re: get element in treeviewer given treeitem [message #1034739 is a reply to message #1028648] Fri, 05 April 2013 20:53 Go to previous message
Nigel Westbury is currently offline Nigel WestburyFriend
Messages: 18
Registered: July 2009
Junior Member
JFace sets the element as the un-named data object, so you can get the
element by simply calling the TreeItem:getData method.
Previous Topic:CoolBar on Windows does not works in Eclipse
Next Topic:Serializable DataBinding
Goto Forum:

Current Time: Thu Jun 21 16:39:13 GMT 2018

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

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

Back to the top