Search in sources :

Example 1 with DataProviderListener

use of com.vaadin.data.provider.DataProviderListener in project SORMAS-Project by hzi-braunschweig.

the class EventSelectionGrid method setLazyDataProvider.

public void setLazyDataProvider() {
    DataProvider<EventIndexDto, EventCriteria> dataProvider = DataProvider.fromFilteringCallbacks(query -> FacadeProvider.getEventFacade().getIndexList(query.getFilter().orElse(null), query.getOffset(), query.getLimit(), query.getSortOrders().stream().map(sortOrder -> new SortProperty(sortOrder.getSorted(), sortOrder.getDirection() == SortDirection.ASCENDING)).collect(Collectors.toList())).stream(), query -> (int) FacadeProvider.getEventFacade().count(query.getFilter().orElse(null)));
    setDataProvider(dataProvider);
    setSelectionMode(com.vaadin.ui.Grid.SelectionMode.NONE);
    EventSelectionGrid tempGrid = this;
    dataProvider.addDataProviderListener((DataProviderListener<EventIndexDto>) dataChangeEvent -> {
        if (tempGrid.getItemCount() > 0) {
            tempGrid.setHeightByRows(Math.min(tempGrid.getItemCount(), 5));
        } else {
            tempGrid.setHeightByRows(1);
        }
    });
}
Also used : EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) DataProviderListener(com.vaadin.data.provider.DataProviderListener) EventGrid(de.symeda.sormas.ui.events.EventGrid) Date(java.util.Date) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) DateHelper(de.symeda.sormas.api.utils.DateHelper) SortDirection(com.vaadin.shared.data.sort.SortDirection) SortProperty(de.symeda.sormas.api.utils.SortProperty) Collectors(java.util.stream.Collectors) Language(de.symeda.sormas.api.Language) HeightMode(com.vaadin.shared.ui.grid.HeightMode) ConfigurableFilterDataProvider(com.vaadin.data.provider.ConfigurableFilterDataProvider) EventCriteria(de.symeda.sormas.api.event.EventCriteria) FieldAccessColumnStyleGenerator(de.symeda.sormas.ui.utils.FieldAccessColumnStyleGenerator) DataProvider(com.vaadin.data.provider.DataProvider) DateRenderer(com.vaadin.ui.renderers.DateRenderer) SortProperty(de.symeda.sormas.api.utils.SortProperty) EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) EventCriteria(de.symeda.sormas.api.event.EventCriteria)

Example 2 with DataProviderListener

use of com.vaadin.data.provider.DataProviderListener in project SORMAS-Project by hzi-braunschweig.

the class EventGroupSelectionGrid method setLazyDataProvider.

public void setLazyDataProvider() {
    DataProvider<EventGroupIndexDto, EventGroupCriteria> dataProvider = DataProvider.fromFilteringCallbacks(query -> FacadeProvider.getEventGroupFacade().getIndexList(query.getFilter().orElse(null), query.getOffset(), query.getLimit(), query.getSortOrders().stream().map(sortOrder -> new SortProperty(sortOrder.getSorted(), sortOrder.getDirection() == SortDirection.ASCENDING)).collect(Collectors.toList())).stream(), query -> (int) FacadeProvider.getEventGroupFacade().count(query.getFilter().orElse(null)));
    setDataProvider(dataProvider);
    setSelectionMode(SelectionMode.NONE);
    EventGroupSelectionGrid tempGrid = this;
    dataProvider.addDataProviderListener((DataProviderListener<EventGroupIndexDto>) dataChangeEvent -> {
        if (tempGrid.getItemCount() > 0) {
            tempGrid.setHeightByRows(Math.min(tempGrid.getItemCount(), 5));
        } else {
            tempGrid.setHeightByRows(1);
        }
    });
}
Also used : FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) ConfigurableFilterDataProvider(com.vaadin.data.provider.ConfigurableFilterDataProvider) DataProviderListener(com.vaadin.data.provider.DataProviderListener) EventGroupIndexDto(de.symeda.sormas.api.event.EventGroupIndexDto) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) EventGroupCriteria(de.symeda.sormas.api.event.EventGroupCriteria) SortDirection(com.vaadin.shared.data.sort.SortDirection) SortProperty(de.symeda.sormas.api.utils.SortProperty) Collectors(java.util.stream.Collectors) DataProvider(com.vaadin.data.provider.DataProvider) HeightMode(com.vaadin.shared.ui.grid.HeightMode) SortProperty(de.symeda.sormas.api.utils.SortProperty) EventGroupCriteria(de.symeda.sormas.api.event.EventGroupCriteria) EventGroupIndexDto(de.symeda.sormas.api.event.EventGroupIndexDto)

Aggregations

ConfigurableFilterDataProvider (com.vaadin.data.provider.ConfigurableFilterDataProvider)2 DataProvider (com.vaadin.data.provider.DataProvider)2 DataProviderListener (com.vaadin.data.provider.DataProviderListener)2 SortDirection (com.vaadin.shared.data.sort.SortDirection)2 HeightMode (com.vaadin.shared.ui.grid.HeightMode)2 FacadeProvider (de.symeda.sormas.api.FacadeProvider)2 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)2 SortProperty (de.symeda.sormas.api.utils.SortProperty)2 FilteredGrid (de.symeda.sormas.ui.utils.FilteredGrid)2 Collectors (java.util.stream.Collectors)2 DateRenderer (com.vaadin.ui.renderers.DateRenderer)1 Language (de.symeda.sormas.api.Language)1 EventCriteria (de.symeda.sormas.api.event.EventCriteria)1 EventGroupCriteria (de.symeda.sormas.api.event.EventGroupCriteria)1 EventGroupIndexDto (de.symeda.sormas.api.event.EventGroupIndexDto)1 EventIndexDto (de.symeda.sormas.api.event.EventIndexDto)1 DateHelper (de.symeda.sormas.api.utils.DateHelper)1 EventGrid (de.symeda.sormas.ui.events.EventGrid)1 FieldAccessColumnStyleGenerator (de.symeda.sormas.ui.utils.FieldAccessColumnStyleGenerator)1 Date (java.util.Date)1