Example usage for com.vaadin.ui Tree addExpandListener

List of usage examples for com.vaadin.ui Tree addExpandListener

Introduction

In this page you can find the example usage for com.vaadin.ui Tree addExpandListener.

Prototype

public Registration addExpandListener(ExpandListener<T> listener) 

Source Link

Document

Adds an ExpandListener to this Tree.

Usage

From source file:com.haulmont.cuba.web.app.folders.CubaFoldersPane.java

License:Apache License

protected void collapseItemInTree(Tree tree, final String foldersCollapse) {
    String s = userSettingService.loadSetting(foldersCollapse);
    List<UUID> idFolders = strToIds(s);
    //noinspection unchecked, RedundantCast
    for (AbstractSearchFolder folder : (Collection<AbstractSearchFolder>) tree.getItemIds()) {
        if (idFolders.contains(folder.getId())) {
            tree.collapseItem(folder);//from  ww  w.j a  va 2  s  .  co m
        }
    }
    tree.addExpandListener(new Tree.ExpandListener() {
        @Override
        public void nodeExpand(Tree.ExpandEvent event) {
            if (event.getItemId() instanceof AbstractSearchFolder) {
                UUID uuid = ((AbstractSearchFolder) event.getItemId()).getId();
                String str = userSettingService.loadSetting(foldersCollapse);
                userSettingService.saveSetting(foldersCollapse, removeIdInStr(str, uuid));
            }
        }
    });
    tree.addCollapseListener(new Tree.CollapseListener() {
        @Override
        public void nodeCollapse(Tree.CollapseEvent event) {
            if (event.getItemId() instanceof AbstractSearchFolder) {
                UUID uuid = ((AbstractSearchFolder) event.getItemId()).getId();
                String str = userSettingService.loadSetting(foldersCollapse);
                userSettingService.saveSetting(foldersCollapse, addIdInStr(str, uuid));
            }
        }
    });
}