Search in sources :

Example 1 with DataProvider

use of com.vaadin.data.provider.DataProvider in project opencms-core by alkacon.

the class CmsUserEditDialog method iniRole.

/**
 * Initialized the role ComboBox. (Vaadin 8 version)<p>
 *
 * @param cms CmsObject
 * @param ou to load roles for
 * @param roleComboBox ComboBox
 * @param log LOG
 */
protected static void iniRole(CmsObject cms, String ou, com.vaadin.ui.ComboBox<CmsRole> roleComboBox, Log log) {
    try {
        List<CmsRole> roles = OpenCms.getRoleManager().getRoles(cms, ou, false);
        CmsRole.applySystemRoleOrder(roles);
        DataProvider provider = new ListDataProvider<CmsRole>(roles);
        roleComboBox.setDataProvider(provider);
        roleComboBox.setItemCaptionGenerator(role -> {
            try {
                return role.getDisplayName(cms, A_CmsUI.get().getLocale());
            } catch (CmsException e) {
                return "";
            }
        });
        roleComboBox.setEmptySelectionAllowed(false);
    } catch (CmsException e) {
        if (log != null) {
            log.error("Unable to read roles.", e);
        }
    }
}
Also used : DataProvider(com.vaadin.data.provider.DataProvider) ListDataProvider(com.vaadin.data.provider.ListDataProvider) ListDataProvider(com.vaadin.data.provider.ListDataProvider) CmsRole(org.opencms.security.CmsRole) CmsException(org.opencms.main.CmsException)

Example 2 with DataProvider

use of com.vaadin.data.provider.DataProvider 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 3 with DataProvider

use of com.vaadin.data.provider.DataProvider 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

DataProvider (com.vaadin.data.provider.DataProvider)3 ConfigurableFilterDataProvider (com.vaadin.data.provider.ConfigurableFilterDataProvider)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 ListDataProvider (com.vaadin.data.provider.ListDataProvider)1 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