Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » How can I programmatically expand items in a TreeViewer?
How can I programmatically expand items in a TreeViewer? [message #1200466] Thu, 21 November 2013 08:54
Martin Schröder is currently offline Martin SchröderFriend
Messages: 3
Registered: June 2013
Junior Member
I have a TreeViewer with an ILazyTreeContentProvider. I want to control the expansion of the top-level tree items: Initially they are unexpanded, but when an Action "Expand" is selected, the item should be expanded.

In the action.run() I currently do

final EntityTreeNode projectNode = (EntityTreeNode) ((ITreeSelection) 
    viewer.getSelection()).getFirstElement();
// notify the content provider that the node should be expanded; it creates child nodes 
// and updates the child count and calls viewer.setChildCount
((LazyEntityModelViewContentProvider) viewer.getContentProvider()).expandProject(projectNode);
viewer.expandToLevel(projectNode, 2);                   
viewer.refresh(projectNode);


But the node is not expanded. It should at least change it's icon to show that it has children..
Previous Topic:pre-submit validation of controls
Next Topic:[Databinding] Bind a bean with observable values as properties to table
Goto Forum:
  


Current Time: Thu Apr 25 06:35:03 GMT 2024

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

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

Back to the top