Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » JFace TreeViewer
JFace TreeViewer [message #669998] Thu, 12 May 2011 11:36 Go to next message
Stefan Ruzitschka is currently offline Stefan RuzitschkaFriend
Messages: 16
Registered: December 2010
Junior Member
Hey Folks,

I have a problem. I have a JFace TreeViewer, with an ITreeContentProvider.

The method the input for the treeviewer is treeitem defined by a backend.
The tree item himself has an ID.

In the getElements() method from the content provider the getChildren() is called.
The getChildren() method get all children from the backend depending on the ID of the input tree item and returns a list of tree items.

The getParent() method returns null.

The hasChildren() method returns getChildren(treeitem).length > 0.

The problem here is that I only get all children of the initial tree item.
This happens because I call the getChildren() method in the getElements() method.

Is there a solution to get the tree item himself as visible root item into the tree?

Greetings
Stefan R.
Re: JFace TreeViewer [message #670014 is a reply to message #669998] Thu, 12 May 2011 12:26 Go to previous messageGo to next message
arthurembo Simo is currently offline arthurembo SimoFriend
Messages: 16
Registered: May 2011
Location: Germany
Junior Member
I don't really understand, what you means but I can see, that you must also implement the method getParent(), else the treeviewer call back the method getParent() for every children and it returns null for all. That means, the treeviewer show only the children => in this case all children are like root elements.
Re: JFace TreeViewer [message #670017 is a reply to message #670014] Thu, 12 May 2011 12:33 Go to previous message
arthurembo Simo is currently offline arthurembo SimoFriend
Messages: 16
Registered: May 2011
Location: Germany
Junior Member
There is the strategy to build the treeviewer:

1- you must first have a treeItem, we give it the name "rootItem": the root element. It's not visible in the treeviewer
2- add your previous treeItem to the "rootItem" as child.
3- then add the previous children to your treeItem
4- give the input to the treeviewer the "rooItem"

It must be able to show all the elements!
Previous Topic:How do I scroll to an ExpandItem in an ExpandBar?
Next Topic:Drag and Drop with Button
Goto Forum:
  


Current Time: Thu Mar 28 11:31:21 GMT 2024

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

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

Back to the top