/** * Collapses the given item and removes its sub-hierarchy. Calling this * method will have no effect if the row is already collapsed. The index is * provided by the client-side or calculated from a full data request. * {@code syncAndRefresh} indicates whether the changes should be * synchronised to the client and the data provider be notified. * * @param item * the item to collapse * @param index * the index of the item * @param syncAndRefresh * {@code true} if the changes should be synchronised to the * client and the data provider should be notified of the * changes, {@code false} otherwise. */ private void doCollapse(T item, Integer index, boolean syncAndRefresh) { Range removedRows = mapper.collapse(item, index); if (syncAndRefresh) { if (!reset && !removedRows.isEmpty()) { getClientRpc().removeRows(removedRows.getStart(), removedRows.length()); } refresh(item); } }
/** * Expands the given item. Calling this method will have no effect if the * item is already expanded or if it has no children. The index is provided * by the client-side or calculated from a full data request. * {@code syncAndRefresh} indicates whether the changes should be * synchronised to the client and the data provider be notified. * * @param item * the item to expand * @param index * the index of the item * @param syncAndRefresh * {@code true} if the changes should be synchronised to the * client and the data provider should be notified of the * changes, {@code false} otherwise. */ private void doExpand(T item, Integer index, boolean syncAndRefresh) { Range addedRows = mapper.expand(item, index); if (syncAndRefresh) { if (!reset && !addedRows.isEmpty()) { getClientRpc().insertRows(addedRows.getStart(), addedRows.length()); Stream<T> children = mapper.fetchItems(item, Range.withLength(0, addedRows.length())); pushData(addedRows.getStart(), children.collect(Collectors.toList())); } refresh(item); } }