use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class DashboardFilterLayout method createResetAndApplyButtons.
public void createResetAndApplyButtons() {
HorizontalLayout buttonLayout = new HorizontalLayout();
Button.ClickListener resetListener = e -> dashboardView.navigateTo(null);
resetButton = ButtonHelper.createButton(Captions.actionResetFilters, resetListener, CssStyles.BUTTON_FILTER_LIGHT);
buttonLayout.addComponent(resetButton);
Button.ClickListener applyListener = e -> dashboardView.refreshDashboard();
applyButton = ButtonHelper.createButton(Captions.actionApplyFilters, applyListener, CssStyles.BUTTON_FILTER_LIGHT);
applyButton.setClickShortcut(ShortcutAction.KeyCode.ENTER);
applyButton.addClickListener(e -> {
if (getDateFilterChangeCallback() != null) {
getDateFilterChangeCallback().run();
}
});
buttonLayout.addComponent(applyButton);
addCustomComponent(buttonLayout, RESET_AND_APPLY_BUTTONS);
}
use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class RegionsView method createFilterBar.
private HorizontalLayout createFilterBar() {
filterLayout = new HorizontalLayout();
filterLayout.setMargin(false);
filterLayout.setSpacing(true);
filterLayout.setWidth(100, Unit.PERCENTAGE);
searchField = new SearchField();
searchField.addTextChangeListener(e -> {
criteria.nameEpidLike(e.getText());
grid.reload();
});
filterLayout.addComponent(searchField);
countryFilter = addCountryFilter(filterLayout, country -> {
criteria.country(country);
grid.reload();
}, null);
resetButton = ButtonHelper.createButton(Captions.actionResetFilters, event -> {
ViewModelProviders.of(RegionsView.class).remove(RegionCriteria.class);
navigateTo(null);
}, CssStyles.FORCE_CAPTION);
resetButton.setVisible(false);
filterLayout.addComponent(resetButton);
HorizontalLayout actionButtonsLayout = new HorizontalLayout();
actionButtonsLayout.setSpacing(true);
{
// Show active/archived/all dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_VIEW)) {
relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
relevanceStatusFilter.setId("relevanceStatus");
relevanceStatusFilter.setWidth(220, Unit.PERCENTAGE);
relevanceStatusFilter.setNullSelectionAllowed(false);
relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.regionActiveRegions));
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.regionArchivedRegions));
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.regionAllRegions));
relevanceStatusFilter.addValueChangeListener(e -> {
criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
navigateTo(criteria);
});
actionButtonsLayout.addComponent(relevanceStatusFilter);
// Bulk operation dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionArchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(true, grid.asMultiSelect().getSelectedItems(), InfrastructureType.REGION, () -> navigateTo(criteria));
}, EntityRelevanceStatus.ACTIVE.equals(criteria.getRelevanceStatus())), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDearchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(false, grid.asMultiSelect().getSelectedItems(), InfrastructureType.REGION, () -> navigateTo(criteria));
}, EntityRelevanceStatus.ARCHIVED.equals(criteria.getRelevanceStatus())));
bulkOperationsDropdown.setVisible(isBulkOperationsDropdownVisible());
actionButtonsLayout.addComponent(bulkOperationsDropdown);
}
}
}
filterLayout.addComponent(actionButtonsLayout);
filterLayout.setComponentAlignment(actionButtonsLayout, Alignment.BOTTOM_RIGHT);
filterLayout.setExpandRatio(actionButtonsLayout, 1);
return filterLayout;
}
use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class OutbreakRegionConfigurationForm method createAffectedDistrictsComponent.
private HorizontalLayout createAffectedDistrictsComponent() {
HorizontalLayout affectedDistrictsComponent = new HorizontalLayout();
affectedDistrictsComponent.setWidth(100, Unit.PERCENTAGE);
affectedDistrictsComponent.setMargin(false);
style(affectedDistrictsComponent, VSPACE_3);
// Create two columns to display the districts
VerticalLayout leftColumn = new VerticalLayout();
leftColumn.setMargin(false);
VerticalLayout middleColumn = new VerticalLayout();
middleColumn.setMargin(false);
VerticalLayout rightColumn = new VerticalLayout();
rightColumn.setMargin(false);
affectedDistrictsComponent.addComponent(leftColumn);
// Add spacer label
affectedDistrictsComponent.addComponent(new Label());
affectedDistrictsComponent.addComponent(middleColumn);
// Add spacer label
affectedDistrictsComponent.addComponent(new Label());
affectedDistrictsComponent.addComponent(rightColumn);
affectedDistrictsComponent.setExpandRatio(leftColumn, 1);
affectedDistrictsComponent.setExpandRatio(middleColumn, 1);
affectedDistrictsComponent.setExpandRatio(rightColumn, 1);
List<DistrictReferenceDto> districts = FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid());
int index = 1;
for (DistrictReferenceDto district : districts) {
OptionGroup outbreakToggle = createOutbreakToggle(district);
outbreakToggle.setWidth(100, Unit.PERCENTAGE);
outbreakToggles[index - 1] = outbreakToggle;
// Split districts evenly to all three columns
if ((districts.size() % 3 == 0 && index <= districts.size() / 3) || (districts.size() % 3 != 0 && index <= (districts.size() / 3) + 1)) {
leftColumn.addComponent(outbreakToggle);
} else if ((districts.size() % 3 == 0 && index <= districts.size() / 1.5f) || ((districts.size() % 3 == 1 || districts.size() % 3 == 2) && index <= (districts.size() / 1.5f) + 1)) {
middleColumn.addComponent(outbreakToggle);
} else {
rightColumn.addComponent(outbreakToggle);
}
index++;
}
return affectedDistrictsComponent;
}
use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class ContactsView method createStatusFilterBar.
public HorizontalLayout createStatusFilterBar() {
HorizontalLayout statusFilterLayout = new HorizontalLayout();
statusFilterLayout.setMargin(false);
statusFilterLayout.setSpacing(true);
statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
statusFilterLayout.addStyleName(CssStyles.VSPACE_3);
statusButtons = new HashMap<>();
Button statusAll = ButtonHelper.createButton(I18nProperties.getCaption(Captions.all), e -> {
criteria.contactStatus(null);
navigateTo(criteria);
}, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
statusAll.setCaptionAsHtml(true);
if (ContactsViewType.FOLLOW_UP_VISITS_OVERVIEW.equals(viewConfiguration.getViewType())) {
CssStyles.style(statusAll, CssStyles.FORCE_CAPTION);
}
statusFilterLayout.addComponent(statusAll);
statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
activeStatusButton = statusAll;
for (ContactStatus status : ContactStatus.values()) {
Button statusButton = ButtonHelper.createButton("status-" + status.toString(), status.toString(), e -> {
criteria.contactStatus(status);
navigateTo(criteria);
}, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
statusButton.setCaptionAsHtml(true);
statusButton.setData(status);
if (ContactsViewType.FOLLOW_UP_VISITS_OVERVIEW.equals(viewConfiguration.getViewType())) {
CssStyles.style(statusButton, CssStyles.FORCE_CAPTION);
}
statusFilterLayout.addComponent(statusButton);
statusButtons.put(statusButton, status.toString());
}
HorizontalLayout actionButtonsLayout = new HorizontalLayout();
actionButtonsLayout.setSpacing(true);
{
// Show active/archived/all dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW)) {
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.AUTOMATIC_ARCHIVING, CoreEntityType.CONTACT)) {
int daysAfterContactGetsArchived = FacadeProvider.getFeatureConfigurationFacade().getProperty(FeatureType.AUTOMATIC_ARCHIVING, CoreEntityType.CONTACT, FeatureTypeProperty.THRESHOLD_IN_DAYS, Integer.class);
if (daysAfterContactGetsArchived > 0) {
relevanceStatusInfoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + String.format(I18nProperties.getString(Strings.infoArchivedContacts), daysAfterContactGetsArchived), ContentMode.HTML);
relevanceStatusInfoLabel.setVisible(false);
relevanceStatusInfoLabel.addStyleName(CssStyles.LABEL_VERTICAL_ALIGN_SUPER);
actionButtonsLayout.addComponent(relevanceStatusInfoLabel);
actionButtonsLayout.setComponentAlignment(relevanceStatusInfoLabel, Alignment.MIDDLE_RIGHT);
}
}
relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
relevanceStatusFilter.setId("relevanceStatus");
relevanceStatusFilter.setWidth(140, Unit.PERCENTAGE);
relevanceStatusFilter.setNullSelectionAllowed(false);
relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.contactActiveContacts));
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.contactArchivedContacts));
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.contactAllContacts));
relevanceStatusFilter.addValueChangeListener(e -> {
if (relevanceStatusInfoLabel != null) {
relevanceStatusInfoLabel.setVisible(EntityRelevanceStatus.ARCHIVED.equals(e.getProperty().getValue()));
}
criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
navigateTo(criteria);
});
actionButtonsLayout.addComponent(relevanceStatusFilter);
}
// Bulk operation dropdown
if (isBulkEditAllowed()) {
statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
boolean hasBulkOperationsRight = UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS);
List<MenuBarHelper.MenuBarItem> bulkActions = new ArrayList<>(Arrays.asList(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, mi -> grid.bulkActionHandler(items -> ControllerProvider.getContactController().showBulkContactDataEditComponent(items, null)), hasBulkOperationsRight), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp), VaadinIcons.CLOSE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getContactController().cancelFollowUpOfAllSelectedItems(items, () -> navigateTo(criteria))), hasBulkOperationsRight), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp), VaadinIcons.UNLINK, mi -> grid.bulkActionHandler(items -> ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp(items, () -> navigateTo(criteria))), hasBulkOperationsRight), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, mi -> grid.bulkActionHandler(items -> ControllerProvider.getContactController().deleteAllSelectedItems(items, () -> navigateTo(criteria)), true), hasBulkOperationsRight), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.sormasToSormasShare), VaadinIcons.SHARE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getSormasToSormasController().shareSelectedContacts(items, () -> navigateTo(criteria))), FacadeProvider.getSormasToSormasFacade().isSharingCasesContactsAndSamplesEnabledForUser())));
if (isDocGenerationAllowed() && grid instanceof AbstractContactGrid) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkActionCreatDocuments), VaadinIcons.FILE_TEXT, mi -> grid.bulkActionHandler(items -> {
List<ReferenceDto> references = ((AbstractContactGrid<?>) grid).asMultiSelect().getSelectedItems().stream().map(ContactIndexDto::toReference).collect(Collectors.toList());
if (references.size() == 0) {
new Notification(I18nProperties.getString(Strings.headingNoContactsSelected), I18nProperties.getString(Strings.messageNoContactsSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
return;
}
ControllerProvider.getDocGenerationController().showBulkQuarantineOrderDocumentDialog(references, DocumentWorkflow.QUARANTINE_ORDER_CONTACT);
})));
}
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_SURVEILLANCE)) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkLinkToEvent), VaadinIcons.PHONE, mi -> grid.bulkActionHandler(items -> {
List<ContactIndexDto> selectedContacts = grid.asMultiSelect().getSelectedItems().stream().map(item -> (ContactIndexDto) item).collect(Collectors.toList());
if (selectedContacts.isEmpty()) {
new Notification(I18nProperties.getString(Strings.headingNoContactsSelected), I18nProperties.getString(Strings.messageNoContactsSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
return;
}
if (!selectedContacts.stream().allMatch(contact -> contact.getDisease().equals(selectedContacts.stream().findAny().get().getDisease()))) {
new Notification(I18nProperties.getString(Strings.messageBulkContactsWithDifferentDiseasesSelected), Notification.Type.WARNING_MESSAGE).show(Page.getCurrent());
return;
}
ControllerProvider.getEventController().selectOrCreateEventForContactList(selectedContacts.stream().map(ContactIndexDto::toReference).collect(Collectors.toList()));
})));
}
bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, bulkActions);
bulkOperationsDropdown.setVisible(viewConfiguration.isInEagerMode());
actionButtonsLayout.addComponent(bulkOperationsDropdown);
}
}
statusFilterLayout.addComponent(actionButtonsLayout);
statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);
return statusFilterLayout;
}
use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class ContactsFilterForm method applyDependenciesOnNewValue.
@Override
protected void applyDependenciesOnNewValue(ContactCriteria newValue) {
final RegionReferenceDto region = newValue.getRegion();
final DistrictReferenceDto district = newValue.getDistrict();
applyRegionAndDistrictFilterDependency(region, ContactCriteria.DISTRICT, district, ContactCriteria.COMMUNITY);
final UserDto user = currentUserDto();
ComboBox officerField = getField(ContactCriteria.CONTACT_OFFICER);
if (user.getRegion() != null) {
officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRights(user.getRegion(), newValue.getDisease(), UserRight.CONTACT_RESPONSIBLE));
} else if (region != null) {
officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRights(region, newValue.getDisease(), UserRight.CONTACT_RESPONSIBLE));
} else {
officerField.removeAllItems();
}
ComboBox birthDateDD = getField(ContactCriteria.BIRTHDATE_DD);
if (getField(ContactCriteria.BIRTHDATE_YYYY).getValue() != null && getField(ContactCriteria.BIRTHDATE_MM).getValue() != null) {
birthDateDD.addItems(DateHelper.getDaysInMonth((Integer) getField(ContactCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(ContactCriteria.BIRTHDATE_YYYY).getValue()));
birthDateDD.setEnabled(true);
} else {
birthDateDD.clear();
birthDateDD.setEnabled(false);
}
// Date/Epi week filter
HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
@SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
ContactDateType contactDateType = newValue.getReportDateFrom() != null ? ContactDateType.REPORT_DATE : newValue.getLastContactDateFrom() != null ? ContactDateType.LAST_CONTACT_DATE : null;
weekAndDateFilter.getDateTypeSelector().setValue(contactDateType);
weekAndDateFilter.getDateFilterOptionFilter().setValue(newValue.getDateFilterOption());
Date dateFrom = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateFrom() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateFrom() : null;
Date dateTo = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateTo() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateTo() : null;
if (DateFilterOption.EPI_WEEK.equals(newValue.getDateFilterOption())) {
weekAndDateFilter.getWeekFromFilter().setValue(dateFrom == null ? null : DateHelper.getEpiWeek(dateFrom));
weekAndDateFilter.getWeekToFilter().setValue(dateTo == null ? null : DateHelper.getEpiWeek(dateTo));
} else {
weekAndDateFilter.getDateFromFilter().setValue(dateFrom);
weekAndDateFilter.getDateToFilter().setValue(dateTo);
}
if (StringUtils.isBlank(newValue.getEventLike())) {
clearAndDisableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
} else {
enableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
}
ComboBox diseaseField = getField(ContactIndexDto.DISEASE);
ComboBox diseaseVariantField = getField(ContactCriteria.DISEASE_VARIANT);
Disease disease = (Disease) diseaseField.getValue();
if (disease == null) {
FieldHelper.updateItems(diseaseVariantField, Collections.emptyList());
FieldHelper.setEnabled(false, diseaseVariantField);
} else {
List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
FieldHelper.setEnabled(CollectionUtils.isNotEmpty(diseaseVariants), diseaseVariantField);
}
}
Aggregations