Example usage for com.vaadin.ui Tree addCollapseListener

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

Introduction

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

Prototype

public Registration addCollapseListener(CollapseListener<T> listener) 

Source Link

Document

Adds a CollapseListener 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 v  a 2s  .  c  o  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));
            }
        }
    });
}