Reputation: 567
How can I expand the node to its root node?
So I have this method to expand its parent node recursively
private void expand( Object object ) {
if ( object.getParent() != null ) {
tree.setExpandedState( object.getParent(), true );
expand( object.getParent() );
}
}
Upvotes: 1
Views: 319
Reputation: 111217
Use the expandToLevel
TreeViewer
method:
viewer.expandToLevel(element, 1);
element
can be your model element (the object your content provider provides) or it can be a TreePath
. You may need to call setUseHashlookup(true)
on the viewer to speed up element lookup.
Upvotes: 1