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);
}
});
}
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);
}
Aggregations