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 Abdu
Messages: 104
Registered: November 2011
Senior Member
Hi,

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.
Mok

[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 Achmetow
Messages: 38
Registered: April 2012
Member
Hi,

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 Westbury
Messages: 16
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:ControlContribution Does not fire MouseTrackListener
Next Topic:Serializable DataBinding
Goto Forum:
  


Current Time: Wed Oct 01 18:22:20 GMT 2014

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

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