use of de.symeda.sormas.ui.events.groups.EventGroupSelectionField in project SORMAS-Project by hzi-braunschweig.
the class EventGroupController method selectOrCreate.
public void selectOrCreate(List<EventReferenceDto> eventReferences, Runnable callback) {
Set<String> excludedEventGroupUuids = FacadeProvider.getEventGroupFacade().getCommonEventGroupsByEvents(eventReferences).stream().map(EventGroupReferenceDto::getUuid).collect(Collectors.toSet());
EventGroupSelectionField selectionField = new EventGroupSelectionField(excludedEventGroupUuids);
selectionField.setWidth(1024, Sizeable.Unit.PIXELS);
final CommitDiscardWrapperComponent<EventGroupSelectionField> component = new CommitDiscardWrapperComponent<>(selectionField);
component.addCommitListener(() -> {
EventGroupIndexDto selectedEventGroup = selectionField.getValue();
if (selectedEventGroup != null) {
FacadeProvider.getEventGroupFacade().linkEventsToGroup(eventReferences, selectedEventGroup.toReference());
FacadeProvider.getEventGroupFacade().notifyEventAddedToEventGroup(selectedEventGroup.toReference(), eventReferences);
Notification.show(I18nProperties.getString(Strings.messageEventLinkedToGroup), Type.TRAY_NOTIFICATION);
if (callback != null) {
callback.run();
} else {
SormasUI.refreshView();
}
} else {
create(eventReferences, callback);
}
});
selectionField.setSelectionChangeCallback((commitAllowed) -> component.getCommitButton().setEnabled(commitAllowed));
VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEventGroup));
}
use of de.symeda.sormas.ui.events.groups.EventGroupSelectionField in project SORMAS-Project by hzi-braunschweig.
the class EventGroupController method select.
public void select(List<EventReferenceDto> eventReferences, Runnable callback) {
Set<String> excludedEventGroupUuids = FacadeProvider.getEventGroupFacade().getCommonEventGroupsByEvents(eventReferences).stream().map(EventGroupReferenceDto::getUuid).collect(Collectors.toSet());
EventGroupSelectionField selectionField = new EventGroupSelectionField(excludedEventGroupUuids);
selectionField.setWidth(1024, Sizeable.Unit.PIXELS);
final CommitDiscardWrapperComponent<EventGroupSelectionField> component = new CommitDiscardWrapperComponent<>(selectionField);
component.addCommitListener(() -> {
EventGroupIndexDto selectedEventGroup = selectionField.getValue();
if (selectedEventGroup != null) {
FacadeProvider.getEventGroupFacade().linkEventsToGroup(eventReferences, selectedEventGroup.toReference());
FacadeProvider.getEventGroupFacade().notifyEventAddedToEventGroup(selectedEventGroup.toReference(), eventReferences);
Notification.show(I18nProperties.getString(Strings.messageEventLinkedToGroup), Type.TRAY_NOTIFICATION);
if (callback != null) {
callback.run();
} else {
SormasUI.refreshView();
}
}
});
selectionField.setSelectionChangeCallback((commitAllowed) -> component.getCommitButton().setEnabled(commitAllowed));
VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEventGroup));
}
Aggregations