1

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() );
    }
}

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.