How to automatic expand the item on TreeTable?

Hello,
I use TreeTable to generate my navigation tree in my application.
When user click the item on TreeTable , then add a tab to a Tabsheet or open the tab which have been added.

Now I want to do that :
When user change the tab selected, the related item on TreeTable shoud be highlighted and visible.
I ues the code below:

treeTable.select(itemID);

This code can highlight the item.
But when the parent of item is collapsed, this code can not automatic expand its parent.
so the item is not visible,and user can not know whether the item have selected.

What should I do to make the item visible automatic?

I use vaadin 6.8.0.

Thank you for your help.

Expanding items and selecting items from TreeTable are two separate things. There’s method setCollapsed(Object itemId, boolean collapsed) in TreeTable. It takes the container itemId as parameter which you can use to collapse/expand specific item. You can store this id to your tab for example and in SelectedTabChangeListener get the id of opened tab and call collapsing method with false to ‘expand’ it.

Thank you for answer.
But this make itself expanded only. When its partent is collapsed, the item is also not visible.

Now ,I resovle this issue, by creating a method to make its parent expanded recursively util the root node is expanded. It works!


navTree.select(itemID);
setTreeItemVisible(itemID, true);
 private void setTreeItemVisible(TreeTable navTree, Object itemID, boolean visible) {
        Object parentID = navTree.getParent(itemID);

        if (parentID != null) {
            if (visible) {
                setTreeItemVisible(parentID, visible);
                navTree.setCollapsed(itemID, false);
            } else {
                navTree.setCollapsed(parentID, true);
            }
        } else {
            if (visible) {
                navTree.setCollapsed(itemID, false);
            }
        }
    }

But I think this is a terrible experience to make its parent and parent‘s parent and … until root node expanded recursively , when the root node is collapsed,and the item to select is a leaf node with deep level.
If I make a item selected,I should see the item immediately.Why I need to make all its parent nodes expanded first?