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 Alshubei is currently offline Mokhtar AlshubeiFriend
Messages: 121
Registered: November 2011
Location: Germany
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 AchmetowFriend
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 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 Apr 25 00:35:33 GMT 2024

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

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

Back to the top