/** * Returns whether a given item is expanded or collapsed. * * @param item * the item to check * @return true if the item is expanded, false if collapsed */ public boolean isExpanded(T item) { return getDataCommunicator().isExpanded(item); }
/** * Collapse the given items. * <p> * For items that are already collapsed, does nothing. * * @param items * the collection of items to collapse */ public void collapse(Collection<T> items) { HierarchicalDataCommunicator<T> communicator = getDataCommunicator(); items.forEach(item -> { if (communicator.isExpanded(item)) { communicator.collapse(item); fireCollapseEvent(item, false); } }); }
/** * Expands the given items. * <p> * If an item is currently expanded, does nothing. If an item does not have * any children, does nothing. * * @param items * the items to expand */ public void expand(Collection<T> items) { HierarchicalDataCommunicator<T> communicator = getDataCommunicator(); items.forEach(item -> { if (!communicator.isExpanded(item) && communicator.hasChildren(item)) { communicator.expand(item); fireExpandEvent(item, false); } }); }
private void registerTreeGridRpc() { registerRpc((NodeCollapseRpc) (rowKey, rowIndex, collapse, userOriginated) -> { T item = getDataCommunicator().getKeyMapper().get(rowKey); if (collapse && getDataCommunicator().isExpanded(item)) { getDataCommunicator().collapse(item, rowIndex); fireCollapseEvent( getDataCommunicator().getKeyMapper().get(rowKey), userOriginated); } else if (!collapse && !getDataCommunicator().isExpanded(item)) { getDataCommunicator().expand(item, rowIndex); fireExpandEvent( getDataCommunicator().getKeyMapper().get(rowKey), userOriginated); } }); registerRpc((FocusParentRpc) (rowKey, cellIndex) -> { Integer parentIndex = getDataCommunicator().getParentIndex( getDataCommunicator().getKeyMapper().get(rowKey)); if (parentIndex != null) { getRpcProxy(FocusRpc.class).focusCell(parentIndex, cellIndex); } }); }