Example usage for com.vaadin.data.provider HierarchicalQuery getParent

List of usage examples for com.vaadin.data.provider HierarchicalQuery getParent

Introduction

In this page you can find the example usage for com.vaadin.data.provider HierarchicalQuery getParent.

Prototype

public T getParent() 

Source Link

Document

Get the hierarchical parent object, where null corresponds to the root node.

Usage

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

License:Open Source License

@Override
public DataProvider getDataProvider() {
    Map<String, Boolean> orders = new HashMap<>();
    HierarchicalDataProvider dataProvider = new AbstractBackEndHierarchicalDataProvider() {
        @Override/*www .ja va 2s.com*/
        protected Stream fetchChildrenFromBackEnd(HierarchicalQuery query) {
            int offset = query.getOffset();
            int limit = query.getLimit();
            Account parent = (Account) query.getParent();
            Iterator it = query.getSortOrders().iterator();
            while (it.hasNext()) {
                QuerySortOrder order = (QuerySortOrder) it.next();
                orders.put(order.getSorted(), order.getDirection() == SortDirection.DESCENDING);
            }
            try {
                return getAllChildren(offset, limit, orders, parent);
            } catch (Exception e) {
                getApp().getLog().error(e);
                return null;
            }
        }

        @Override
        public int getChildCount(HierarchicalQuery query) {
            try {
                if (query.getParent() != null)
                    return getChildrenCount((Account) query.getParent());
                return getItemCount();
            } catch (Exception e) {
                getApp().getLog().error(e);
                return 0;
            }
        }

        @Override
        public boolean hasChildren(Object item) {
            try {
                return hasChildrenAccounts((Account) item);
            } catch (Exception e) {
                getApp().getLog().error(e);
                return false;
            }
        }
    };
    return dataProvider;
}