Search in sources :

Example 21 with EventCriteria

use of de.symeda.sormas.api.event.EventCriteria 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 22 with EventCriteria

use of de.symeda.sormas.api.event.EventCriteria in project SORMAS-Project by hzi-braunschweig.

the class SuperordinateEventComponent method initialize.

private void initialize() {
    setWidthFull();
    setMargin(false);
    setSpacing(false);
    Label lblHeading = new Label(I18nProperties.getCaption(Captions.eventSuperordinateEvent));
    lblHeading.addStyleName(CssStyles.H3);
    addComponent(lblHeading);
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setMargin(false);
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth(100, Unit.PERCENTAGE);
    CssStyles.style(buttonLayout, CssStyles.VSPACE_TOP_3);
    if (subordinateEvent.getSuperordinateEvent() != null) {
        addComponent(new SuperordinateEventInfoLayout(FacadeProvider.getEventFacade().getEventByUuid(subordinateEvent.getSuperordinateEvent().getUuid(), false)));
        if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EDIT)) {
            Button btnUnlinkEvent = ButtonHelper.createIconButtonWithCaption("unlinkSuperordinateEvent", I18nProperties.getCaption(Captions.eventUnlinkEvent), VaadinIcons.UNLINK, e -> createEventWithConfirmationWindow(() -> ControllerProvider.getEventController().removeSuperordinateEvent(subordinateEvent, true, I18nProperties.getString(Strings.messageEventSuperordinateEventUnlinked))), ValoTheme.BUTTON_PRIMARY);
            btnUnlinkEvent.setWidthFull();
            buttonLayout.addComponent(btnUnlinkEvent);
            Button btnOpenEvent = ButtonHelper.createIconButtonWithCaption("openSuperordinateEvent", I18nProperties.getCaption(Captions.eventOpenSuperordinateEvent), VaadinIcons.EYE, e -> ControllerProvider.getEventController().navigateToData(subordinateEvent.getSuperordinateEvent().getUuid()), ValoTheme.BUTTON_PRIMARY);
            btnOpenEvent.setWidthFull();
            buttonLayout.addComponent(btnOpenEvent);
        }
    } else {
        addComponent(new Label(I18nProperties.getString(Strings.infoNoSuperordinateEvent)));
        if (UserProvider.getCurrent().hasAllUserRights(UserRight.EVENT_CREATE, UserRight.EVENT_EDIT)) {
            Button btnLinkEvent = ButtonHelper.createIconButtonWithCaption("linkSuperordinateEvent", I18nProperties.getCaption(Captions.linkEvent), VaadinIcons.PLUS_CIRCLE, thisEvent -> {
                long events = FacadeProvider.getEventFacade().count(new EventCriteria());
                if (events > 0) {
                    createEventWithConfirmationWindow(() -> ControllerProvider.getEventController().selectOrCreateSuperordinateEvent(subordinateEvent.toReference()));
                } else {
                    createEventWithConfirmationWindow(() -> ControllerProvider.getEventController().createSuperordinateEvent(subordinateEvent.toReference()));
                }
            }, ValoTheme.BUTTON_PRIMARY);
            buttonLayout.addComponent(btnLinkEvent);
        }
    }
    addComponent(buttonLayout);
}
Also used : Button(com.vaadin.ui.Button) Label(com.vaadin.ui.Label) EventCriteria(de.symeda.sormas.api.event.EventCriteria) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

EventCriteria (de.symeda.sormas.api.event.EventCriteria)22 EventIndexDto (de.symeda.sormas.api.event.EventIndexDto)11 Date (java.util.Date)11 EventReferenceDto (de.symeda.sormas.api.event.EventReferenceDto)9 EventDto (de.symeda.sormas.api.event.EventDto)8 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)7 Test (org.junit.Test)7 UserDto (de.symeda.sormas.api.user.UserDto)6 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)6 ExternalShareInfo (de.symeda.sormas.backend.share.ExternalShareInfo)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 Button (com.vaadin.ui.Button)4 Label (com.vaadin.ui.Label)4 Notification (com.vaadin.ui.Notification)4 EntityRelevanceStatus (de.symeda.sormas.api.EntityRelevanceStatus)4 SortProperty (de.symeda.sormas.api.utils.SortProperty)4 District (de.symeda.sormas.backend.infrastructure.district.District)4 Collections (java.util.Collections)4