@Override public void treeSourceItemSetChanged(TreeItems.ItemSetChangeEvent<E> event) { // #PL-2035, reload selection from ds Set<E> selectedItems = getSelected(); Set<E> newSelection = new HashSet<>(); TreeItems<E> source = event.getSource(); for (E item : selectedItems) { if (source.containsItem(item)) { newSelection.add(source.getItem(item.getId())); } } if (source.getState() == BindingState.ACTIVE && source instanceof EntityTreeItems && ((EntityTreeItems<E>) source).getSelectedItem() != null) { newSelection.add(((EntityTreeItems<E>) source).getSelectedItem()); } if (newSelection.isEmpty()) { setSelected((E) null); } else { // Workaround for the MultiSelect model. // Set the selected items only if the previous selection is different // Otherwise, the tree rows will display the values before editing if (isMultiSelect() && !selectedItems.equals(newSelection)) { setSelectedInternal(newSelection); } } refreshActionsState(); }
protected void datasourceCollectionChanged(@SuppressWarnings("unused") CollectionDatasource.CollectionChangeEvent<E, K> e) { events.publish(ItemSetChangeEvent.class, new ItemSetChangeEvent<>(this)); }
protected void containerCollectionChanged(@SuppressWarnings("unused") CollectionContainer.CollectionChangeEvent<E> e) { events.publish(ItemSetChangeEvent.class, new ItemSetChangeEvent<>(this)); }