Example usage for com.vaadin.ui TreeGrid setItemCollapseAllowedProvider

List of usage examples for com.vaadin.ui TreeGrid setItemCollapseAllowedProvider

Introduction

In this page you can find the example usage for com.vaadin.ui TreeGrid setItemCollapseAllowedProvider.

Prototype

public void setItemCollapseAllowedProvider(ItemCollapseAllowedProvider<T> provider) 

Source Link

Document

Sets the item collapse allowed provider for this TreeGrid.

Usage

From source file:org.jpos.qi.minigl.AccountsView.java

License:Open Source License

@Override
public Grid createGrid() {
    TreeGrid<Account> tree = new TreeGrid();
    tree.setSizeFull();//from  w w  w . j  a v a 2s  .c o m
    tree.setSelectionMode(Grid.SelectionMode.SINGLE);
    tree.addItemClickListener(event -> {
        //do nothing if it's root
        if (event.getItem().getRoot().getId() != event.getItem().getId()) {
            String url = getGeneralRoute() + "/" + getHelper().getItemId(event.getItem());
            getApp().getNavigator().navigateTo(url);
        }
    });
    tree.setItemCollapseAllowedProvider(account -> account.getParent() != null);
    tree.addExpandListener(listener -> {
        if (listener.getExpandedItem().getParent() != null)
            expandedItems.add(listener.getExpandedItem());
    });
    tree.addCollapseListener(listener -> expandedItems.remove(listener.getCollapsedItem()));
    return tree;
}