use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class DatabaseExportView method createSelectionButtonsLayout.
private HorizontalLayout createSelectionButtonsLayout() {
HorizontalLayout selectionButtonsLayout = new HorizontalLayout();
selectionButtonsLayout.setMargin(false);
selectionButtonsLayout.setSpacing(true);
Button selectAll = ButtonHelper.createButton(Captions.actionSelectAll, e -> {
for (CheckBox checkBox : databaseTableToggles.keySet()) {
checkBox.setValue(true);
}
}, ValoTheme.BUTTON_LINK);
selectionButtonsLayout.addComponent(selectAll);
Button selectAllSormasData = ButtonHelper.createButton(Captions.exportSelectSormasData, e -> {
for (CheckBox checkBox : databaseTableToggles.keySet()) {
if (databaseTableToggles.get(checkBox).getDatabaseTableType() == DatabaseTableType.SORMAS) {
checkBox.setValue(true);
} else {
checkBox.setValue(false);
}
}
}, ValoTheme.BUTTON_LINK);
selectionButtonsLayout.addComponent(selectAllSormasData);
Button deselectAll = ButtonHelper.createButton(Captions.actionDeselectAll, e -> {
for (CheckBox checkBox : databaseTableToggles.keySet()) {
checkBox.setValue(false);
}
}, ValoTheme.BUTTON_LINK);
selectionButtonsLayout.addComponent(deselectAll);
return selectionButtonsLayout;
}
use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class TherapyView method createPrescriptionsHeader.
private VerticalLayout createPrescriptionsHeader() {
VerticalLayout prescriptionsHeader = new VerticalLayout();
prescriptionsHeader.setMargin(false);
prescriptionsHeader.setSpacing(false);
prescriptionsHeader.setWidth(100, Unit.PERCENTAGE);
HorizontalLayout headlineRow = new HorizontalLayout();
headlineRow.setMargin(false);
headlineRow.setSpacing(true);
headlineRow.setWidth(100, Unit.PERCENTAGE);
{
Label prescriptionsLabel = new Label(I18nProperties.getString(Strings.entityPrescriptions));
CssStyles.style(prescriptionsLabel, CssStyles.H3);
headlineRow.addComponent(prescriptionsLabel);
headlineRow.setExpandRatio(prescriptionsLabel, 1);
// Bulk operations
if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
MenuBar bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, selectedItem -> {
ControllerProvider.getTherapyController().deleteAllSelectedPrescriptions(prescriptionGrid.getSelectedRows(), new Runnable() {
public void run() {
reloadPrescriptionGrid();
}
});
}));
headlineRow.addComponent(bulkOperationsDropdown);
headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT);
}
Button newPrescriptionButton = ButtonHelper.createButton(Captions.prescriptionNewPrescription, e -> {
ControllerProvider.getTherapyController().openPrescriptionCreateForm(prescriptionCriteria.getTherapy(), this::reloadPrescriptionGrid);
}, ValoTheme.BUTTON_PRIMARY);
headlineRow.addComponent(newPrescriptionButton);
headlineRow.setComponentAlignment(newPrescriptionButton, Alignment.MIDDLE_RIGHT);
}
prescriptionsHeader.addComponent(headlineRow);
HorizontalLayout filterRow = new HorizontalLayout();
filterRow.setMargin(false);
filterRow.setSpacing(true);
{
prescriptionTypeFilter = ComboBoxHelper.createComboBoxV7();
prescriptionTypeFilter.setWidth(140, Unit.PIXELS);
prescriptionTypeFilter.setInputPrompt(I18nProperties.getPrefixCaption(PrescriptionDto.I18N_PREFIX, PrescriptionDto.PRESCRIPTION_TYPE));
prescriptionTypeFilter.addItems((Object[]) TreatmentType.values());
prescriptionTypeFilter.addValueChangeListener(e -> {
prescriptionCriteria.prescriptionType(((TreatmentType) e.getProperty().getValue()));
navigateTo(prescriptionCriteria);
});
filterRow.addComponent(prescriptionTypeFilter);
prescriptionTextFilter = new TextField();
prescriptionTextFilter.setWidth(300, Unit.PIXELS);
prescriptionTextFilter.setNullRepresentation("");
prescriptionTextFilter.setInputPrompt(I18nProperties.getString(Strings.promptPrescriptionTextFilter));
prescriptionTextFilter.addTextChangeListener(e -> {
prescriptionCriteria.textFilter(e.getText());
reloadPrescriptionGrid();
});
filterRow.addComponent(prescriptionTextFilter);
}
prescriptionsHeader.addComponent(filterRow);
return prescriptionsHeader;
}
use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class UsersView method createActionsBar.
public HorizontalLayout createActionsBar() {
HorizontalLayout statusFilterLayout = new HorizontalLayout();
statusFilterLayout.setSpacing(true);
statusFilterLayout.setMargin(false);
statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
statusFilterLayout.addStyleName(CssStyles.VSPACE_3);
HorizontalLayout actionButtonsLayout = new HorizontalLayout();
actionButtonsLayout.setSpacing(true);
{
// Bulk operation dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionEnable), VaadinIcons.CHECK_SQUARE_O, selectedItem -> {
ControllerProvider.getUserController().enableAllSelectedItems(grid.asMultiSelect().getSelectedItems(), () -> navigateTo(criteria));
}, true), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDisable), VaadinIcons.THIN_SQUARE, selectedItem -> {
ControllerProvider.getUserController().disableAllSelectedItems(grid.asMultiSelect().getSelectedItems(), () -> navigateTo(criteria));
}, true));
bulkOperationsDropdown.setVisible(ViewModelProviders.of(UsersView.class).get(ViewConfiguration.class).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 UsersView method createFilterBar.
public HorizontalLayout createFilterBar() {
HorizontalLayout filterLayout = new HorizontalLayout();
filterLayout.setMargin(false);
filterLayout.setSpacing(true);
filterLayout.setSizeUndefined();
activeFilter = ComboBoxHelper.createComboBoxV7();
activeFilter.setId(UserDto.ACTIVE);
activeFilter.setWidth(200, Unit.PIXELS);
activeFilter.setInputPrompt(I18nProperties.getPrefixCaption(UserDto.I18N_PREFIX, UserDto.ACTIVE));
activeFilter.addItems(ACTIVE_FILTER, INACTIVE_FILTER);
activeFilter.addValueChangeListener(e -> {
criteria.active(ACTIVE_FILTER.equals(e.getProperty().getValue()) ? Boolean.TRUE : INACTIVE_FILTER.equals(e.getProperty().getValue()) ? Boolean.FALSE : null);
navigateTo(criteria);
});
filterLayout.addComponent(activeFilter);
userRolesFilter = ComboBoxHelper.createComboBoxV7();
userRolesFilter.setId(UserDto.USER_ROLES);
userRolesFilter.setWidth(200, Unit.PIXELS);
userRolesFilter.setInputPrompt(I18nProperties.getPrefixCaption(UserDto.I18N_PREFIX, UserDto.USER_ROLES));
userRolesFilter.addItems(UserUiHelper.getAssignableRoles(Collections.emptySet()));
userRolesFilter.addValueChangeListener(e -> {
criteria.userRole((UserRole) e.getProperty().getValue());
navigateTo(criteria);
});
filterLayout.addComponent(userRolesFilter);
UserDto user = UserProvider.getCurrent().getUser();
regionFilter = ComboBoxHelper.createComboBoxV7();
regionFilter.setId(CaseDataDto.REGION);
if (user.getRegion() == null) {
regionFilter.setWidth(140, Unit.PIXELS);
regionFilter.setInputPrompt(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REGION));
regionFilter.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
regionFilter.addValueChangeListener(e -> {
RegionReferenceDto region = (RegionReferenceDto) e.getProperty().getValue();
if (!DataHelper.equal(region, criteria.getRegion())) {
criteria.district(null);
}
criteria.region(region);
navigateTo(criteria);
});
filterLayout.addComponent(regionFilter);
}
districtFilter = ComboBoxHelper.createComboBoxV7();
districtFilter.setId(CaseDataDto.DISTRICT);
districtFilter.setWidth(140, Unit.PIXELS);
districtFilter.setInputPrompt(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISTRICT));
districtFilter.setDescription(I18nProperties.getDescription(Descriptions.descDistrictFilter));
districtFilter.addValueChangeListener(e -> {
DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue();
criteria.district(district);
navigateTo(criteria);
});
filterLayout.addComponent(districtFilter);
searchField = new TextField();
searchField.setId("search");
searchField.setWidth(200, Unit.PIXELS);
searchField.setNullRepresentation("");
searchField.setInputPrompt(I18nProperties.getString(Strings.promptUserSearch));
searchField.setImmediate(true);
searchField.addTextChangeListener(e -> {
criteria.freeText(e.getText());
grid.reload();
rowsCount.update(grid.getItemCount());
});
filterLayout.addComponent(searchField);
return filterLayout;
}
use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class LabMessageUiHelperUnitTest method testEstablishFinalCommitButtons.
@Test
public void testEstablishFinalCommitButtons() {
Mockito.mockConstruction(SampleCreateForm.class);
UserReferenceDto user = new UserReferenceDto();
CaseReferenceDto caze = new CaseReferenceDto();
SampleDto sample = SampleDto.build(user, caze);
SampleCreateForm createForm = new SampleCreateForm(Disease.CORONAVIRUS);
when(createForm.getFieldGroup()).thenReturn(new BeanFieldGroup(SampleDto.class));
CommitDiscardWrapperComponent<SampleCreateForm> sampleComponent = new CommitDiscardWrapperComponent<>(createForm, true, createForm.getFieldGroup());
when(sampleComponent.getWrappedComponent().getValue()).thenReturn(sample);
LabMessageUiHelper.establishFinalCommitButtons(sampleComponent);
HorizontalLayout buttonsPanel = sampleComponent.getButtonsPanel();
Button saveAndOpenEntryButton = (Button) buttonsPanel.getComponent(buttonsPanel.getComponentCount() - 2);
assertThat(saveAndOpenEntryButton.getStyleName(), equalTo(sampleComponent.getCommitButton().getStyleName()));
assertThat(saveAndOpenEntryButton.getId(), equalTo("saveAndOpenEntryButton"));
// Both commit buttons should do the same, except each one should trigger a different navigation
assertThat(saveAndOpenEntryButton.getListeners(Button.ClickEvent.class).size(), equalTo(sampleComponent.getCommitButton().getListeners(Button.ClickEvent.class).size()));
}
Aggregations