/** * Removes the given items from the set of currently selected items. * <p> * If the none of the items were selected, this is a NO-OP. * <p> * This is a short-hand for {@link #updateSelection(Set, Set)} with nothing * to select. * * @param items * to remove from selection, not {@code null} */ public default void deselect(T... items) { Objects.requireNonNull(items); Stream.of(items).forEach(Objects::requireNonNull); updateSelection(Collections.emptySet(), new LinkedHashSet<>(Arrays.asList(items))); }
@Override public void updateSelection(Set<T> addedItems, Set<T> removedItems) { model.asMultiSelect().updateSelection(addedItems, removedItems); }
/** * Adds the given items to the set of currently selected items. * <p> * By default this does not clear any previous selection. To do that, use * {@link #deselectAll()}. * <p> * If the all the items were already selected, this is a NO-OP. * <p> * This is a short-hand for {@link #updateSelection(Set, Set)} with nothing * to deselect. * * @param items * to add to selection, not {@code null} */ public default void select(T... items) { Objects.requireNonNull(items); Stream.of(items).forEach(Objects::requireNonNull); updateSelection(new LinkedHashSet<>(Arrays.asList(items)), Collections.emptySet()); }
private void select(Stream<T> values) { if (this.multiSelect) { this.treeGrid.asMultiSelect().updateSelection(values.collect(toSet()), new HashSet<>()); } else { values.findFirst().ifPresent(this.treeGrid.asSingleSelect()::setValue); } } }