Search in sources :

Example 56 with HorizontalLayout

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;
}
Also used : Button(com.vaadin.ui.Button) CheckBox(com.vaadin.v7.ui.CheckBox) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 57 with HorizontalLayout

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;
}
Also used : TreatmentType(de.symeda.sormas.api.therapy.TreatmentType) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) AbstractCaseView(de.symeda.sormas.ui.caze.AbstractCaseView) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) TreatmentCriteria(de.symeda.sormas.api.therapy.TreatmentCriteria) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) Label(com.vaadin.ui.Label) VaadinIcons(com.vaadin.icons.VaadinIcons) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) UserProvider(de.symeda.sormas.ui.UserProvider) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) PrescriptionDto(de.symeda.sormas.api.therapy.PrescriptionDto) TherapyDto(de.symeda.sormas.api.therapy.TherapyDto) MenuBar(com.vaadin.ui.MenuBar) ComboBox(com.vaadin.v7.ui.ComboBox) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) PrescriptionCriteria(de.symeda.sormas.api.therapy.PrescriptionCriteria) HeightMode(com.vaadin.v7.shared.ui.grid.HeightMode) HorizontalLayout(com.vaadin.ui.HorizontalLayout) TextField(com.vaadin.v7.ui.TextField) Strings(de.symeda.sormas.api.i18n.Strings) TreatmentDto(de.symeda.sormas.api.therapy.TreatmentDto) Button(com.vaadin.ui.Button) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) MenuBar(com.vaadin.ui.MenuBar) TextField(com.vaadin.v7.ui.TextField) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 58 with HorizontalLayout

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;
}
Also used : AuthProvider(de.symeda.sormas.api.AuthProvider) RowCount(de.symeda.sormas.ui.utils.RowCount) StreamResource(com.vaadin.server.StreamResource) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) VerticalLayout(com.vaadin.ui.VerticalLayout) LoggerFactory(org.slf4j.LoggerFactory) Alignment(com.vaadin.ui.Alignment) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) ViewConfiguration(de.symeda.sormas.ui.utils.ViewConfiguration) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) Notification(com.vaadin.ui.Notification) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) Page(com.vaadin.server.Page) ViewChangeEvent(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent) VaadinIcons(com.vaadin.icons.VaadinIcons) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) UserRole(de.symeda.sormas.api.user.UserRole) UserProvider(de.symeda.sormas.ui.UserProvider) AbstractView(de.symeda.sormas.ui.utils.AbstractView) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) DownloadUtil(de.symeda.sormas.ui.utils.DownloadUtil) DataHelper(de.symeda.sormas.api.utils.DataHelper) Files(java.nio.file.Files) MenuBar(com.vaadin.ui.MenuBar) ComboBox(com.vaadin.v7.ui.ComboBox) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) UserDto(de.symeda.sormas.api.user.UserDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) IOException(java.io.IOException) Captions(de.symeda.sormas.api.i18n.Captions) File(java.io.File) IOUtils(org.apache.commons.io.IOUtils) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) FileDownloader(com.vaadin.server.FileDownloader) TextField(com.vaadin.v7.ui.TextField) UserCriteria(de.symeda.sormas.api.user.UserCriteria) Descriptions(de.symeda.sormas.api.i18n.Descriptions) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) ViewConfiguration(de.symeda.sormas.ui.utils.ViewConfiguration) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 59 with HorizontalLayout

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;
}
Also used : RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) UserDto(de.symeda.sormas.api.user.UserDto) TextField(com.vaadin.v7.ui.TextField) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 60 with HorizontalLayout

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()));
}
Also used : UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) BeanFieldGroup(com.vaadin.v7.data.fieldgroup.BeanFieldGroup) Button(com.vaadin.ui.Button) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) SampleDto(de.symeda.sormas.api.sample.SampleDto) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) SampleCreateForm(de.symeda.sormas.ui.samples.SampleCreateForm) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Test(org.junit.Test)

Aggregations

HorizontalLayout (com.vaadin.ui.HorizontalLayout)53 Button (com.vaadin.ui.Button)37 Label (com.vaadin.ui.Label)32 VerticalLayout (com.vaadin.ui.VerticalLayout)32 ComboBox (com.vaadin.v7.ui.ComboBox)29 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)29 CssStyles (de.symeda.sormas.ui.utils.CssStyles)29 Alignment (com.vaadin.ui.Alignment)28 ValoTheme (com.vaadin.ui.themes.ValoTheme)28 Captions (de.symeda.sormas.api.i18n.Captions)28 ButtonHelper (de.symeda.sormas.ui.utils.ButtonHelper)27 FacadeProvider (de.symeda.sormas.api.FacadeProvider)26 Strings (de.symeda.sormas.api.i18n.Strings)26 VaadinIcons (com.vaadin.icons.VaadinIcons)25 UserProvider (de.symeda.sormas.ui.UserProvider)25 ControllerProvider (de.symeda.sormas.ui.ControllerProvider)24 ComboBoxHelper (de.symeda.sormas.ui.utils.ComboBoxHelper)23 MenuBar (com.vaadin.ui.MenuBar)22 UserRight (de.symeda.sormas.api.user.UserRight)22 ViewModelProviders (de.symeda.sormas.ui.ViewModelProviders)22