Dims
Dims

Reputation: 51239

How to expand TreeViewer programmatically?

How to expand TreeViewer programmatically?

If I use underlying Tree.setExpanded(true),

    action1 = new Action() {
        public void run() {
            viewer.getTree().getItems()[0].setExpanded(true);
        }
    };

element does not appear:

enter image description here

If I use mouse clicks, branch expands ok.

Upvotes: 2

Views: 1899

Answers (1)

Baz
Baz

Reputation: 36904

Have a look at AbsractTreeViewer#expandToLevel(Object, int):

Expands all ancestors of the given element or tree path so that the given element becomes visible in this viewer's tree control, and then expands the subtree rooted at the given element to the given level.

Upvotes: 4

Related Questions