Search in sources :

Example 1 with MultiSelect

use of com.vaadin.flow.data.selection.MultiSelect in project flow-components by vaadin.

the class AbstractGridMultiSelectionModel method asMultiSelect.

@Override
public MultiSelect<Grid<T>, T> asMultiSelect() {
    return new MultiSelect<Grid<T>, T>() {

        @SuppressWarnings({ "unchecked", "rawtypes" })
        @Override
        public Registration addValueChangeListener(ValueChangeListener<? super ComponentValueChangeEvent<Grid<T>, Set<T>>> listener) {
            Objects.requireNonNull(listener, "listener cannot be null");
            ComponentEventListener componentEventListener = event -> listener.valueChanged((ComponentValueChangeEvent<Grid<T>, Set<T>>) event);
            return ComponentUtil.addListener(getGrid(), MultiSelectionEvent.class, componentEventListener);
        }

        @Override
        public Registration addSelectionListener(MultiSelectionListener<Grid<T>, T> listener) {
            return addMultiSelectionListener(listener);
        }

        @Override
        public void deselectAll() {
            AbstractGridMultiSelectionModel.this.deselectAll();
        }

        @Override
        public void updateSelection(Set<T> addedItems, Set<T> removedItems) {
            AbstractGridMultiSelectionModel.this.updateSelection(addedItems, removedItems);
        }

        @Override
        public Element getElement() {
            return getGrid().getElement();
        }

        @Override
        public Set<T> getSelectedItems() {
            return AbstractGridMultiSelectionModel.this.getSelectedItems();
        }
    };
}
Also used : ComponentEventListener(com.vaadin.flow.component.ComponentEventListener) MultiSelect(com.vaadin.flow.data.selection.MultiSelect) ComponentUtil(com.vaadin.flow.component.ComponentUtil) Registration(com.vaadin.flow.shared.Registration) DataCommunicator(com.vaadin.flow.data.provider.DataCommunicator) HierarchicalQuery(com.vaadin.flow.data.provider.hierarchy.HierarchicalQuery) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) MultiSelectionEvent(com.vaadin.flow.data.selection.MultiSelectionEvent) DataProvider(com.vaadin.flow.data.provider.DataProvider) Map(java.util.Map) MultiSelectionListener(com.vaadin.flow.data.selection.MultiSelectionListener) Element(com.vaadin.flow.dom.Element) ComponentValueChangeEvent(com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent) SelectionEvent(com.vaadin.flow.data.selection.SelectionEvent) LinkedHashSet(java.util.LinkedHashSet) AbstractGridExtension(com.vaadin.flow.component.grid.Grid.AbstractGridExtension) Query(com.vaadin.flow.data.provider.Query) Set(java.util.Set) HierarchicalDataProvider(com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider) Collectors(java.util.stream.Collectors) SelectionListener(com.vaadin.flow.data.selection.SelectionListener) Objects(java.util.Objects) Consumer(java.util.function.Consumer) List(java.util.List) Stream(java.util.stream.Stream) Optional(java.util.Optional) JsonObject(elemental.json.JsonObject) Collections(java.util.Collections) MultiSelect(com.vaadin.flow.data.selection.MultiSelect) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) MultiSelectionListener(com.vaadin.flow.data.selection.MultiSelectionListener) ComponentEventListener(com.vaadin.flow.component.ComponentEventListener) ComponentValueChangeEvent(com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent)

Aggregations

ComponentValueChangeEvent (com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent)1 ComponentEventListener (com.vaadin.flow.component.ComponentEventListener)1 ComponentUtil (com.vaadin.flow.component.ComponentUtil)1 AbstractGridExtension (com.vaadin.flow.component.grid.Grid.AbstractGridExtension)1 DataCommunicator (com.vaadin.flow.data.provider.DataCommunicator)1 DataProvider (com.vaadin.flow.data.provider.DataProvider)1 Query (com.vaadin.flow.data.provider.Query)1 HierarchicalDataProvider (com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider)1 HierarchicalQuery (com.vaadin.flow.data.provider.hierarchy.HierarchicalQuery)1 MultiSelect (com.vaadin.flow.data.selection.MultiSelect)1 MultiSelectionEvent (com.vaadin.flow.data.selection.MultiSelectionEvent)1 MultiSelectionListener (com.vaadin.flow.data.selection.MultiSelectionListener)1 SelectionEvent (com.vaadin.flow.data.selection.SelectionEvent)1 SelectionListener (com.vaadin.flow.data.selection.SelectionListener)1 Element (com.vaadin.flow.dom.Element)1 Registration (com.vaadin.flow.shared.Registration)1 JsonObject (elemental.json.JsonObject)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1