Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Going from a TreeViewer element to a TreeItem and vice versa
icon5.gif  Going from a TreeViewer element to a TreeItem and vice versa [message #544022] Thu, 01 July 2010 11:51 Go to next message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
Are there methods in TreeViewer or its parents which would let me find a TreeItem which corresponds to a domain model element? And vice versa?

My actual problem is that I want to find the root visible element of a node without calling getParent in the ITreeContentProvider (since that requires remote communication in my ITreeContentProvider), so if I had such methods I could write
Object getRoot(Object element) {
  TreeItem item = element;
  while ((TreeItem parent = item.getParentItem) != null) { item = parent; }
  return getElement(item);
}
Re: Going from a TreeViewer element to a TreeItem and vice versa [message #547256 is a reply to message #544022] Fri, 16 July 2010 06:56 Go to previous message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
In case anyone else needs an answer: going by the source, treeItem.getData() will return the element; and you can go back by iterating over all TreeItems in the control (but this probably won't work well if the VIRTUAL style bit is set).

[Updated on: Fri, 16 July 2010 06:57]

Report message to a moderator

Previous Topic:Setting a child of SashForm to a desired size
Next Topic:getColumnImage implementation problem
Goto Forum:
  


Current Time: Fri Mar 29 04:48:47 GMT 2024

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

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

Back to the top