Search in sources :

Example 1 with ComponentValueChangeEvent

use of com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent in project aire-components by aire-ux.

the class ModuleGrid method valueChanged.

@Override
public void valueChanged(ComponentValueChangeEvent<TextField, String> event) {
    val text = textField.getValue();
    val matches = getZephyr().getPlugins().stream().filter(module -> module.getCoordinate().getName().contains(text) || module.getCoordinate().getGroup().contains(text) || module.getCoordinate().getVersion().toString().contains(text)).collect(Collectors.toList());
    grid.setItems(new ListDataProvider<>(matches));
}
Also used : lombok.val(lombok.val) ListDataProvider(com.vaadin.flow.data.provider.ListDataProvider) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) MenuBar(com.vaadin.flow.component.menubar.MenuBar) Component(com.vaadin.flow.component.Component) CssImport(com.vaadin.flow.component.dependency.CssImport) MenuBarVariant(com.vaadin.flow.component.menubar.MenuBarVariant) SerializableBiConsumer(com.vaadin.flow.function.SerializableBiConsumer) ValueProvider(com.vaadin.flow.function.ValueProvider) Route(com.vaadin.flow.router.Route) Inject(javax.inject.Inject) Overlays(io.sunshower.zephyr.ui.components.Overlays) ComponentValueChangeEvent(com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent) TextField(com.vaadin.flow.component.textfield.TextField) Notification(com.vaadin.flow.component.notification.Notification) ValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode) Zephyr(io.zephyr.cli.Zephyr) Grid(com.vaadin.flow.component.grid.Grid) GridVariant(com.vaadin.flow.component.grid.GridVariant) NotificationVariant(com.vaadin.flow.component.notification.NotificationVariant) NonNull(lombok.NonNull) Position(com.vaadin.flow.component.notification.Notification.Position) lombok.val(lombok.val) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Breadcrumb(io.sunshower.zephyr.ui.controls.Breadcrumb) Collectors(java.util.stream.Collectors) ValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener) Button(com.vaadin.flow.component.button.Button) MainView(io.sunshower.zephyr.MainView) JsModule(com.vaadin.flow.component.dependency.JsModule) Span(com.vaadin.flow.component.html.Span) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) Module(io.zephyr.kernel.Module)

Example 2 with ComponentValueChangeEvent

use of com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent 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)

Example 3 with ComponentValueChangeEvent

use of com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent in project flow-components by vaadin.

the class AbstractGridSingleSelectionModel method asSingleSelect.

@Override
public SingleSelect<Grid<T>, T> asSingleSelect() {
    return new SingleSelect<Grid<T>, T>() {

        @Override
        public void setValue(T value) {
            setSelectedItem(value);
        }

        @Override
        public T getValue() {
            return getSelectedItem().orElse(getEmptyValue());
        }

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

        @Override
        public Element getElement() {
            return getGrid().getElement();
        }
    };
}
Also used : ComponentEventListener(com.vaadin.flow.component.ComponentEventListener) AbstractGridExtension(com.vaadin.flow.component.grid.Grid.AbstractGridExtension) ComponentUtil(com.vaadin.flow.component.ComponentUtil) Registration(com.vaadin.flow.shared.Registration) SingleSelect(com.vaadin.flow.data.selection.SingleSelect) SingleSelectionEvent(com.vaadin.flow.data.selection.SingleSelectionEvent) SelectionListener(com.vaadin.flow.data.selection.SelectionListener) Objects(java.util.Objects) Element(com.vaadin.flow.dom.Element) ComponentValueChangeEvent(com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent) Optional(java.util.Optional) SelectionEvent(com.vaadin.flow.data.selection.SelectionEvent) JsonObject(elemental.json.JsonObject) Collections(java.util.Collections) SingleSelectionListener(com.vaadin.flow.data.selection.SingleSelectionListener) SingleSelect(com.vaadin.flow.data.selection.SingleSelect) ComponentEventListener(com.vaadin.flow.component.ComponentEventListener) ComponentValueChangeEvent(com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent)

Aggregations

ComponentValueChangeEvent (com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent)3 ComponentEventListener (com.vaadin.flow.component.ComponentEventListener)2 ComponentUtil (com.vaadin.flow.component.ComponentUtil)2 AbstractGridExtension (com.vaadin.flow.component.grid.Grid.AbstractGridExtension)2 SelectionEvent (com.vaadin.flow.data.selection.SelectionEvent)2 SelectionListener (com.vaadin.flow.data.selection.SelectionListener)2 Element (com.vaadin.flow.dom.Element)2 Registration (com.vaadin.flow.shared.Registration)2 JsonObject (elemental.json.JsonObject)2 Collections (java.util.Collections)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Component (com.vaadin.flow.component.Component)1 ValueChangeListener (com.vaadin.flow.component.HasValue.ValueChangeListener)1 Button (com.vaadin.flow.component.button.Button)1 CssImport (com.vaadin.flow.component.dependency.CssImport)1 JsModule (com.vaadin.flow.component.dependency.JsModule)1 Grid (com.vaadin.flow.component.grid.Grid)1 GridVariant (com.vaadin.flow.component.grid.GridVariant)1