Search in sources :

Example 26 with VerticalLayout

use of com.vaadin.v7.ui.VerticalLayout in project SORMAS-Project by hzi-braunschweig.

the class ClinicalCourseView method createClinicalVisitsHeader.

private VerticalLayout createClinicalVisitsHeader() {
    VerticalLayout clinicalVisitsHeader = new VerticalLayout();
    clinicalVisitsHeader.setMargin(false);
    clinicalVisitsHeader.setSpacing(false);
    clinicalVisitsHeader.setWidth(100, Unit.PERCENTAGE);
    HorizontalLayout headlineRow = new HorizontalLayout();
    headlineRow.setMargin(false);
    headlineRow.setSpacing(true);
    headlineRow.setWidth(100, Unit.PERCENTAGE);
    {
        Label clinicalVisitsLabel = new Label(I18nProperties.getString(Strings.entityClinicalVisits));
        CssStyles.style(clinicalVisitsLabel, CssStyles.H3);
        headlineRow.addComponent(clinicalVisitsLabel);
        headlineRow.setExpandRatio(clinicalVisitsLabel, 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.getClinicalCourseController().deleteAllSelectedClinicalVisits(clinicalVisitGrid.getSelectedRows(), new Runnable() {

                    public void run() {
                        clinicalVisitGrid.reload();
                    }
                });
            }));
            headlineRow.addComponent(bulkOperationsDropdown);
            headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT);
        }
        Button newClinicalVisitButton = ButtonHelper.createButton(Captions.clinicalVisitNewClinicalVisit, e -> {
            ControllerProvider.getClinicalCourseController().openClinicalVisitCreateForm(clinicalVisitCriteria.getClinicalCourse(), getCaseRef().getUuid(), this::reloadClinicalVisitGrid);
        }, ValoTheme.BUTTON_PRIMARY);
        headlineRow.addComponent(newClinicalVisitButton);
        headlineRow.setComponentAlignment(newClinicalVisitButton, Alignment.MIDDLE_RIGHT);
    }
    clinicalVisitsHeader.addComponent(headlineRow);
    return clinicalVisitsHeader;
}
Also used : 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) ClinicalVisitCriteria(de.symeda.sormas.api.clinicalcourse.ClinicalVisitCriteria) AbstractCaseView(de.symeda.sormas.ui.caze.AbstractCaseView) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) Label(com.vaadin.ui.Label) VaadinIcons(com.vaadin.icons.VaadinIcons) UserProvider(de.symeda.sormas.ui.UserProvider) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) MenuBar(com.vaadin.ui.MenuBar) 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) HeightMode(com.vaadin.v7.shared.ui.grid.HeightMode) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Strings(de.symeda.sormas.api.i18n.Strings) ClinicalCourseDto(de.symeda.sormas.api.clinicalcourse.ClinicalCourseDto) Button(com.vaadin.ui.Button) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) MenuBar(com.vaadin.ui.MenuBar) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 27 with VerticalLayout

use of com.vaadin.v7.ui.VerticalLayout in project SORMAS-Project by hzi-braunschweig.

the class CasePickOrImportField method addInfoComponent.

@Override
protected void addInfoComponent() {
    HorizontalLayout infoLayout = new HorizontalLayout();
    infoLayout.setWidth(100, Unit.PERCENTAGE);
    infoLayout.setSpacing(true);
    Image icon = new Image(null, new ThemeResource("img/info-icon.png"));
    icon.setHeight(35, Unit.PIXELS);
    icon.setWidth(35, Unit.PIXELS);
    infoLayout.addComponent(icon);
    Label infoLabel = new Label(I18nProperties.getString(Strings.infoImportSimilarity));
    infoLayout.addComponent(infoLabel);
    infoLayout.setExpandRatio(infoLabel, 1);
    mainLayout.addComponent(infoLayout);
    CssStyles.style(infoLayout, CssStyles.VSPACE_3);
    // Imported case info
    VerticalLayout caseInfoContainer = new VerticalLayout();
    caseInfoContainer.setWidth(100, Unit.PERCENTAGE);
    CssStyles.style(caseInfoContainer, CssStyles.BACKGROUND_ROUNDED_CORNERS, CssStyles.BACKGROUND_SUB_CRITERIA, CssStyles.VSPACE_3, "v-scrollable");
    Label newCaseLabel = new Label(I18nProperties.getString(Strings.headingImportedCaseInfo));
    CssStyles.style(newCaseLabel, CssStyles.LABEL_BOLD, CssStyles.VSPACE_4);
    caseInfoContainer.addComponent(newCaseLabel);
    HorizontalLayout caseInfoLayout = new HorizontalLayout();
    caseInfoLayout.setSpacing(true);
    caseInfoLayout.setSizeUndefined();
    {
        Label diseaseField = new Label();
        diseaseField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISEASE));
        diseaseField.setValue(DiseaseHelper.toString(newCase.getDisease(), newCase.getDiseaseDetails()));
        diseaseField.setWidthUndefined();
        caseInfoLayout.addComponent(diseaseField);
        Label reportDateField = new Label();
        reportDateField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REPORT_DATE));
        reportDateField.setValue(DateFormatHelper.formatDate(newCase.getReportDate()));
        reportDateField.setWidthUndefined();
        caseInfoLayout.addComponent(reportDateField);
        Label responsibleRegionField = new Label();
        responsibleRegionField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.RESPONSIBLE_REGION));
        responsibleRegionField.setValue(newCase.getResponsibleRegion().toString());
        responsibleRegionField.setWidthUndefined();
        caseInfoLayout.addComponent(responsibleRegionField);
        Label responsibleDistrictField = new Label();
        responsibleDistrictField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.RESPONSIBLE_DISTRICT));
        responsibleDistrictField.setValue(newCase.getResponsibleDistrict().toString());
        responsibleDistrictField.setWidthUndefined();
        caseInfoLayout.addComponent(responsibleDistrictField);
        if (newCase.getRegion() != null) {
            Label regionField = new Label();
            regionField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REGION));
            regionField.setValue(newCase.getRegion().toString());
            regionField.setWidthUndefined();
            caseInfoLayout.addComponent(regionField);
        }
        if (newCase.getDistrict() != null) {
            Label districtField = new Label();
            districtField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISTRICT));
            districtField.setValue(newCase.getDistrict().toString());
            districtField.setWidthUndefined();
            caseInfoLayout.addComponent(districtField);
        }
        Label facilityField = new Label();
        facilityField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.HEALTH_FACILITY));
        facilityField.setValue(FacilityHelper.buildFacilityString(null, newCase.getHealthFacility() != null ? newCase.getHealthFacility().toString() : "", newCase.getHealthFacilityDetails()));
        facilityField.setWidthUndefined();
        caseInfoLayout.addComponent(facilityField);
        Label firstNameField = new Label();
        firstNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.FIRST_NAME));
        firstNameField.setValue(newPerson.getFirstName());
        firstNameField.setWidthUndefined();
        caseInfoLayout.addComponent(firstNameField);
        Label lastNameField = new Label();
        lastNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.LAST_NAME));
        lastNameField.setValue(newPerson.getLastName());
        lastNameField.setWidthUndefined();
        caseInfoLayout.addComponent(lastNameField);
        Label ageAndBirthDateField = new Label();
        ageAndBirthDateField.setCaption(I18nProperties.getCaption(Captions.personAgeAndBirthdate));
        ageAndBirthDateField.setValue(PersonHelper.getAgeAndBirthdateString(newPerson.getApproximateAge(), newPerson.getApproximateAgeType(), newPerson.getBirthdateDD(), newPerson.getBirthdateMM(), newPerson.getBirthdateYYYY()));
        ageAndBirthDateField.setWidthUndefined();
        caseInfoLayout.addComponent(ageAndBirthDateField);
        Label sexField = new Label();
        sexField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.SEX));
        sexField.setValue(newPerson.getSex() != null ? newPerson.getSex().toString() : "");
        sexField.setWidthUndefined();
        caseInfoLayout.addComponent(sexField);
    }
    caseInfoContainer.addComponent(caseInfoLayout);
    mainLayout.addComponent(caseInfoContainer);
}
Also used : Label(com.vaadin.v7.ui.Label) ThemeResource(com.vaadin.server.ThemeResource) VerticalLayout(com.vaadin.ui.VerticalLayout) Image(com.vaadin.ui.Image) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 28 with VerticalLayout

use of com.vaadin.v7.ui.VerticalLayout in project SORMAS-Project by hzi-braunschweig.

the class CasesView method addCommonCasesOverviewToolbar.

private void addCommonCasesOverviewToolbar() {
    final PopupMenu moreButton = new PopupMenu(I18nProperties.getCaption(Captions.moreActions));
    Button openGuideButton = ButtonHelper.createIconButton(Captions.caseOpenCasesGuide, VaadinIcons.QUESTION, e -> buildAndOpenCasesInstructions(), ValoTheme.BUTTON_PRIMARY);
    openGuideButton.setWidth(100, Unit.PERCENTAGE);
    moreButton.addMenuEntry(openGuideButton);
    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_IMPORT)) {
        VerticalLayout importLayout = new VerticalLayout();
        {
            importLayout.setSpacing(true);
            importLayout.setMargin(true);
            importLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
            importLayout.setWidth(250, Unit.PIXELS);
            PopupButton importButton = ButtonHelper.createIconPopupButton(Captions.actionImport, VaadinIcons.UPLOAD, importLayout);
            addHeaderComponent(importButton);
        }
        addImportButton(importLayout, Captions.importLineListing, Strings.headingLineListingImport, LineListingImportLayout::new);
        addImportButton(importLayout, Captions.importDetailed, Strings.headingImportCases, CaseImportLayout::new);
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_EXPORT)) {
        VerticalLayout exportLayout = new VerticalLayout();
        {
            exportLayout.setSpacing(true);
            exportLayout.setMargin(true);
            exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
            exportLayout.setWidth(250, Unit.PIXELS);
        }
        PopupButton exportPopupButton = ButtonHelper.createIconPopupButton(Captions.export, VaadinIcons.DOWNLOAD, exportLayout);
        addHeaderComponent(exportPopupButton);
        {
            StreamResource streamResource = GridExportStreamResource.createStreamResourceWithSelectedItems(grid, () -> this.viewConfiguration.isInEagerMode() ? this.grid.asMultiSelect().getSelectedItems() : Collections.emptySet(), ExportEntityName.CASES);
            addExportButton(streamResource, exportPopupButton, exportLayout, VaadinIcons.TABLE, Captions.exportBasic, Strings.infoBasicExport);
        }
        {
            StreamResource exportStreamResource = CaseDownloadUtil.createCaseExportResource(grid.getCriteria(), this::getSelectedRows, CaseExportType.CASE_SURVEILLANCE, detailedExportConfiguration);
            addExportButton(exportStreamResource, exportPopupButton, exportLayout, VaadinIcons.FILE_TEXT, Captions.exportDetailed, Strings.infoDetailedExport);
        }
        if (hasClinicalCourseRight || hasTherapyRight) {
            StreamResource caseManagementExportStreamResource = DownloadUtil.createCaseManagementExportResource(grid.getCriteria(), this::getSelectedRows, ExportEntityName.CONTACTS);
            addExportButton(caseManagementExportStreamResource, exportPopupButton, exportLayout, VaadinIcons.FILE_TEXT, Captions.exportCaseManagement, Strings.infoCaseManagementExport);
        }
        {
            StreamResource sampleExportStreamResource = DownloadUtil.createCsvExportStreamResource(SampleExportDto.class, null, (Integer start, Integer max) -> FacadeProvider.getSampleFacade().getExportList(grid.getCriteria(), this.getSelectedRows(), start, max), (propertyId, type) -> {
                String caption = I18nProperties.findPrefixCaption(propertyId, SampleExportDto.I18N_PREFIX, SampleDto.I18N_PREFIX, CaseDataDto.I18N_PREFIX, PersonDto.I18N_PREFIX, AdditionalTestDto.I18N_PREFIX);
                if (Date.class.isAssignableFrom(type)) {
                    caption += " (" + DateFormatHelper.getDateFormatPattern() + ")";
                }
                return caption;
            }, ExportEntityName.SAMPLES, null);
            addExportButton(sampleExportStreamResource, exportPopupButton, exportLayout, VaadinIcons.FILE_TEXT, Captions.exportSamples, Strings.infoSampleExport);
        }
        if (FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_SWITZERLAND) && UserProvider.getCurrent().hasUserRight(UserRight.BAG_EXPORT)) {
            StreamResource bagExportResource = DownloadUtil.createCsvExportStreamResource(BAGExportCaseDto.class, null, (Integer start, Integer max) -> FacadeProvider.getBAGExportFacade().getCaseExportList(this.getSelectedRows(), start, max), (propertyId, type) -> propertyId, ExportEntityName.BAG_CASES, null);
            addExportButton(bagExportResource, exportPopupButton, exportLayout, VaadinIcons.FILE_TEXT, Captions.BAGExport, Strings.infoBAGExport);
        }
        {
            Button btnCustomCaseExport = ButtonHelper.createIconButton(Captions.exportCaseCustom, VaadinIcons.FILE_TEXT, e -> {
                Window customExportWindow = VaadinUiUtil.createPopupWindow();
                ExportConfigurationsLayout customExportsLayout = new ExportConfigurationsLayout(ExportType.CASE, ImportExportUtils.getCaseExportProperties(CaseDownloadUtil::getPropertyCaption, caseFollowUpEnabled, hasClinicalCourseRight, hasTherapyRight, FacadeProvider.getConfigFacade().getCountryLocale()), customExportWindow::close);
                customExportsLayout.setExportCallback((exportConfig) -> Page.getCurrent().open(CaseDownloadUtil.createCaseExportResource(grid.getCriteria(), this::getSelectedRows, null, exportConfig), null, true));
                customExportWindow.setWidth(1024, Unit.PIXELS);
                customExportWindow.setCaption(I18nProperties.getCaption(Captions.exportCaseCustom));
                customExportWindow.setContent(customExportsLayout);
                UI.getCurrent().addWindow(customExportWindow);
                exportPopupButton.setPopupVisible(false);
            }, ValoTheme.BUTTON_PRIMARY);
            btnCustomCaseExport.setDescription(I18nProperties.getString(Strings.infoCustomExport));
            btnCustomCaseExport.setWidth(100, Unit.PERCENTAGE);
            exportLayout.addComponent(btnCustomCaseExport);
        }
        {
            // Warning if no filters have been selected
            Label warningLabel = new Label(I18nProperties.getString(Strings.infoExportNoFilters), ContentMode.HTML);
            warningLabel.setWidth(100, Unit.PERCENTAGE);
            exportLayout.addComponent(warningLabel);
            warningLabel.setVisible(false);
            exportPopupButton.addClickListener(e -> warningLabel.setVisible(!criteria.hasAnyFilterActive()));
        }
    }
    if (isBulkEditAllowed()) {
        btnEnterBulkEditMode = ButtonHelper.createIconButton(Captions.actionEnterBulkEditMode, VaadinIcons.CHECK_SQUARE_O, e -> {
            if (grid.getItemCount() > BULK_EDIT_MODE_WARNING_THRESHOLD) {
                VaadinUiUtil.showConfirmationPopup(I18nProperties.getCaption(Captions.actionEnterBulkEditMode), new Label(String.format(I18nProperties.getString(Strings.confirmationEnterBulkEditMode), BULK_EDIT_MODE_WARNING_THRESHOLD)), I18nProperties.getString(Strings.yes), I18nProperties.getString(Strings.no), 640, (result) -> {
                    if (result == true) {
                        enterBulkEditMode();
                    }
                });
            } else {
                enterBulkEditMode();
            }
        }, ValoTheme.BUTTON_PRIMARY);
        btnEnterBulkEditMode.setVisible(!viewConfiguration.isInEagerMode());
        btnEnterBulkEditMode.setWidth(100, Unit.PERCENTAGE);
        moreButton.addMenuEntry(btnEnterBulkEditMode);
        btnLeaveBulkEditMode = ButtonHelper.createIconButton(Captions.actionLeaveBulkEditMode, VaadinIcons.CLOSE, e -> {
            bulkOperationsDropdown.setVisible(false);
            ViewModelProviders.of(CasesView.class).get(CasesViewConfiguration.class).setInEagerMode(false);
            btnLeaveBulkEditMode.setVisible(false);
            btnEnterBulkEditMode.setVisible(true);
            this.filterForm.enableSearchAndReportingUser();
            navigateTo(criteria);
        }, ValoTheme.BUTTON_PRIMARY);
        btnLeaveBulkEditMode.setVisible(viewConfiguration.isInEagerMode());
        addHeaderComponent(btnLeaveBulkEditMode);
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_MERGE)) {
        Button mergeDuplicatesButton = ButtonHelper.createIconButton(Captions.caseMergeDuplicates, VaadinIcons.COMPRESS_SQUARE, e -> ControllerProvider.getCaseController().navigateToMergeCasesView(), ValoTheme.BUTTON_PRIMARY);
        mergeDuplicatesButton.setWidth(100, Unit.PERCENTAGE);
        moreButton.addMenuEntry(mergeDuplicatesButton);
    }
    Button searchSpecificCaseButton = ButtonHelper.createIconButton(Captions.caseSearchSpecificCase, VaadinIcons.SEARCH, e -> buildAndOpenSearchSpecificCaseWindow(), ValoTheme.BUTTON_PRIMARY);
    searchSpecificCaseButton.setWidth(100, Unit.PERCENTAGE);
    moreButton.addMenuEntry(searchSpecificCaseButton);
    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_CREATE)) {
        final ExpandableButton lineListingButton = new ExpandableButton(Captions.lineListing).expand(e -> ControllerProvider.getCaseController().openLineListingWindow());
        addHeaderComponent(lineListingButton);
        final ExpandableButton createButton = new ExpandableButton(Captions.caseNewCase).expand(e -> ControllerProvider.getCaseController().create());
        addHeaderComponent(createButton);
    }
    if (moreButton.hasMenuEntries()) {
        addHeaderComponent(moreButton);
    }
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) CaseImportLayout(de.symeda.sormas.ui.caze.importer.CaseImportLayout) TextField(com.vaadin.ui.TextField) Date(java.util.Date) DocumentWorkflow(de.symeda.sormas.api.docgeneneration.DocumentWorkflow) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) ReferenceDto(de.symeda.sormas.api.ReferenceDto) Window(com.vaadin.ui.Window) PersonDto(de.symeda.sormas.api.person.PersonDto) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) ExpandableButton(de.symeda.sormas.ui.utils.components.expandablebutton.ExpandableButton) 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) UserProvider(de.symeda.sormas.ui.UserProvider) ValoTheme(com.vaadin.ui.themes.ValoTheme) DownloadUtil(de.symeda.sormas.ui.utils.DownloadUtil) FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) DateField(com.vaadin.ui.DateField) MenuBar(com.vaadin.ui.MenuBar) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) ComboBox(com.vaadin.v7.ui.ComboBox) ExportType(de.symeda.sormas.api.importexport.ExportType) Set(java.util.Set) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) InvestigationStatus(de.symeda.sormas.api.caze.InvestigationStatus) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) ExportConfigurationDto(de.symeda.sormas.api.importexport.ExportConfigurationDto) List(java.util.List) LocalDate(java.time.LocalDate) CoreEntityType(de.symeda.sormas.api.common.CoreEntityType) DateHelper8(de.symeda.sormas.ui.utils.DateHelper8) ExportConfigurationsLayout(de.symeda.sormas.ui.customexport.ExportConfigurationsLayout) FollowUpUtils.createFollowUpLegend(de.symeda.sormas.ui.utils.FollowUpUtils.createFollowUpLegend) StreamResource(com.vaadin.server.StreamResource) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) SearchSpecificLayout(de.symeda.sormas.ui.SearchSpecificLayout) FacadeProvider(de.symeda.sormas.api.FacadeProvider) DateFormatHelper(de.symeda.sormas.ui.utils.DateFormatHelper) VerticalLayout(com.vaadin.ui.VerticalLayout) DateHelper(de.symeda.sormas.api.utils.DateHelper) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) HashMap(java.util.HashMap) PopupButton(org.vaadin.hene.popupbutton.PopupButton) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) AdditionalTestDto(de.symeda.sormas.api.sample.AdditionalTestDto) PopupMenu(de.symeda.sormas.ui.utils.components.popupmenu.PopupMenu) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) CaseExportType(de.symeda.sormas.api.caze.CaseExportType) OptionGroup(com.vaadin.v7.ui.OptionGroup) Notification(com.vaadin.ui.Notification) SormasUI(de.symeda.sormas.ui.SormasUI) Label(com.vaadin.ui.Label) CountryHelper(de.symeda.sormas.api.CountryHelper) AbstractView(de.symeda.sormas.ui.utils.AbstractView) CaseDownloadUtil(de.symeda.sormas.ui.utils.CaseDownloadUtil) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ContentMode(com.vaadin.shared.ui.ContentMode) Validations(de.symeda.sormas.api.i18n.Validations) LineListingImportLayout(de.symeda.sormas.ui.caze.importer.LineListingImportLayout) BAGExportCaseDto(de.symeda.sormas.api.bagexport.BAGExportCaseDto) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) SampleExportDto(de.symeda.sormas.api.sample.SampleExportDto) ImportExportUtils(de.symeda.sormas.api.importexport.ImportExportUtils) SampleDto(de.symeda.sormas.api.sample.SampleDto) HorizontalLayout(com.vaadin.ui.HorizontalLayout) FeatureTypeProperty(de.symeda.sormas.api.feature.FeatureTypeProperty) Strings(de.symeda.sormas.api.i18n.Strings) ExportPropertyMetaInfo(de.symeda.sormas.api.importexport.ExportPropertyMetaInfo) DocGenerationHelper.isDocGenerationAllowed(de.symeda.sormas.ui.docgeneration.DocGenerationHelper.isDocGenerationAllowed) Collections(java.util.Collections) Component(com.vaadin.ui.Component) Window(com.vaadin.ui.Window) SampleExportDto(de.symeda.sormas.api.sample.SampleExportDto) ExpandableButton(de.symeda.sormas.ui.utils.components.expandablebutton.ExpandableButton) ExportConfigurationsLayout(de.symeda.sormas.ui.customexport.ExportConfigurationsLayout) Label(com.vaadin.ui.Label) CaseImportLayout(de.symeda.sormas.ui.caze.importer.CaseImportLayout) Date(java.util.Date) LocalDate(java.time.LocalDate) CaseDownloadUtil(de.symeda.sormas.ui.utils.CaseDownloadUtil) PopupButton(org.vaadin.hene.popupbutton.PopupButton) StreamResource(com.vaadin.server.StreamResource) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) ExpandableButton(de.symeda.sormas.ui.utils.components.expandablebutton.ExpandableButton) PopupButton(org.vaadin.hene.popupbutton.PopupButton) Button(com.vaadin.ui.Button) LineListingImportLayout(de.symeda.sormas.ui.caze.importer.LineListingImportLayout) VerticalLayout(com.vaadin.ui.VerticalLayout) PopupMenu(de.symeda.sormas.ui.utils.components.popupmenu.PopupMenu)

Example 29 with VerticalLayout

use of com.vaadin.v7.ui.VerticalLayout in project SORMAS-Project by hzi-braunschweig.

the class SampleController method addPathogenTestComponent.

/**
 * @param sampleComponent
 *            to add the pathogen test create component to.
 * @param pathogenTest
 *            the preset values to insert. May be null.
 * @param caseSampleCount
 *            describes how many samples already exist for a case related to the pathogen test's sample (if a case exists, otherwise 0
 *            is valid).
 * @param callback
 *            use it to define additional actions that need to be taken after the pathogen test is saved (e.g. refresh the UI)
 * @return the pathogen test create component added.
 */
public PathogenTestForm addPathogenTestComponent(CommitDiscardWrapperComponent<? extends AbstractSampleForm> sampleComponent, PathogenTestDto pathogenTest, int caseSampleCount, Runnable callback) {
    // add horizontal rule to clearly distinguish the component
    Label horizontalRule = new Label("<br><hr /><br>", ContentMode.HTML);
    horizontalRule.setWidth(100f, Unit.PERCENTAGE);
    sampleComponent.addComponent(horizontalRule, sampleComponent.getComponentCount() - 1);
    PathogenTestForm pathogenTestForm = new PathogenTestForm(sampleComponent.getWrappedComponent().getValue(), true, caseSampleCount, false);
    // prefill fields
    if (pathogenTest != null) {
        pathogenTestForm.setValue(pathogenTest);
        // show typingId field when it has a preset value
        if (pathogenTest.getTypingId() != null && !"".equals(pathogenTest.getTypingId())) {
            pathogenTestForm.getField(PathogenTestDto.TYPING_ID).setVisible(true);
        }
    } else {
        pathogenTestForm.setValue(PathogenTestDto.build(sampleComponent.getWrappedComponent().getValue(), UserProvider.getCurrent().getUser()));
        // remove value invalid for newly created pathogen tests
        ComboBox pathogenTestResultField = pathogenTestForm.getField(PathogenTestDto.TEST_RESULT);
        pathogenTestResultField.removeItem(PathogenTestResultType.NOT_DONE);
        pathogenTestResultField.setValue(PathogenTestResultType.PENDING);
        ComboBox testDiseaseField = pathogenTestForm.getField(PathogenTestDto.TESTED_DISEASE);
        testDiseaseField.setValue(FacadeProvider.getDiseaseConfigurationFacade().getDefaultDisease());
    }
    // setup field updates
    Field testLabField = pathogenTestForm.getField(PathogenTestDto.LAB);
    NullableOptionGroup samplePurposeField = sampleComponent.getWrappedComponent().getField(SampleDto.SAMPLE_PURPOSE);
    Runnable updateTestLabFieldRequired = () -> testLabField.setRequired(!SamplePurpose.INTERNAL.equals(samplePurposeField.getValue()));
    updateTestLabFieldRequired.run();
    samplePurposeField.addValueChangeListener(e -> updateTestLabFieldRequired.run());
    // validate pathogen test create component before saving the sample
    sampleComponent.addFieldGroups(pathogenTestForm.getFieldGroup());
    CommitDiscardWrapperComponent.CommitListener savePathogenTest = () -> {
        ControllerProvider.getPathogenTestController().savePathogenTest(pathogenTestForm.getValue(), null, true, true);
        if (callback != null) {
            callback.run();
        }
    };
    sampleComponent.addCommitListener(savePathogenTest);
    // Discard button configuration
    Button discardButton = ButtonHelper.createButton(I18nProperties.getCaption(Captions.pathogenTestRemove));
    VerticalLayout buttonLayout = new VerticalLayout(discardButton);
    buttonLayout.setComponentAlignment(discardButton, Alignment.TOP_LEFT);
    // add the discard button above the overall discard and commit buttons
    sampleComponent.addComponent(buttonLayout, sampleComponent.getComponentCount() - 1);
    discardButton.addClickListener(o -> {
        sampleComponent.removeComponent(horizontalRule);
        sampleComponent.removeComponent(buttonLayout);
        sampleComponent.removeComponent(pathogenTestForm);
        sampleComponent.removeFieldGroups(pathogenTestForm.getFieldGroup());
        sampleComponent.removeCommitListener(savePathogenTest);
        pathogenTestForm.discard();
    });
    // Country specific configuration
    boolean germanInstance = FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_GERMANY);
    pathogenTestForm.getField(PathogenTestDto.REPORT_DATE).setVisible(germanInstance);
    pathogenTestForm.getField(PathogenTestDto.EXTERNAL_ID).setVisible(germanInstance);
    pathogenTestForm.getField(PathogenTestDto.EXTERNAL_ORDER_ID).setVisible(germanInstance);
    pathogenTestForm.getField(PathogenTestDto.VIA_LIMS).setVisible(germanInstance);
    // Sample creation specific configuration
    final DateTimeField sampleDateField = sampleComponent.getWrappedComponent().getField(SampleDto.SAMPLE_DATE_TIME);
    final DateTimeField testDateField = pathogenTestForm.getField(PathogenTestDto.TEST_DATE_TIME);
    testDateField.addValidator(new DateComparisonValidator(testDateField, sampleDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, testDateField.getCaption(), sampleDateField.getCaption())));
    // add the pathogenTestForm above the overall discard and commit buttons
    sampleComponent.addComponent(pathogenTestForm, sampleComponent.getComponentCount() - 1);
    return pathogenTestForm;
}
Also used : NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) ComboBox(com.vaadin.v7.ui.ComboBox) Label(com.vaadin.ui.Label) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) DateTimeField(de.symeda.sormas.ui.utils.DateTimeField) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) Field(com.vaadin.v7.ui.Field) DateTimeField(de.symeda.sormas.ui.utils.DateTimeField) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout)

Example 30 with VerticalLayout

use of com.vaadin.v7.ui.VerticalLayout in project SORMAS-Project by hzi-braunschweig.

the class ContactsEpiCurveComponent method createEpiCurveModeSelector.

@Override
protected PopupButton createEpiCurveModeSelector() {
    if (epiCurveContactsMode == null) {
        epiCurveContactsMode = ContactsEpiCurveMode.FOLLOW_UP_STATUS;
        epiCurveLabel.setValue(I18nProperties.getCaption(Captions.dashboardFollowUpStatusChart));
    }
    VerticalLayout groupingLayout = new VerticalLayout();
    groupingLayout.setMargin(true);
    groupingLayout.setSizeUndefined();
    PopupButton dataDropdown = ButtonHelper.createPopupButton(Captions.dashboardData, groupingLayout, CssStyles.BUTTON_SUBTLE);
    OptionGroup dataSelect = new OptionGroup();
    dataSelect.setWidth(100, Unit.PERCENTAGE);
    dataSelect.addItems((Object[]) ContactsEpiCurveMode.values());
    dataSelect.setValue(epiCurveContactsMode);
    dataSelect.select(epiCurveContactsMode);
    dataSelect.addValueChangeListener(e -> {
        epiCurveContactsMode = (ContactsEpiCurveMode) e.getProperty().getValue();
        switch(epiCurveContactsMode) {
            case FOLLOW_UP_STATUS:
                epiCurveLabel.setValue(I18nProperties.getCaption(Captions.dashboardFollowUpStatusChart));
                break;
            case CONTACT_CLASSIFICATION:
                epiCurveLabel.setValue(I18nProperties.getCaption(Captions.dashboardContactClassificationChart));
                break;
            case FOLLOW_UP_UNTIL:
                epiCurveLabel.setValue(I18nProperties.getCaption(Captions.dashboardFollowUpUntilChart));
                break;
        }
        clearAndFillEpiCurveChart();
    });
    groupingLayout.addComponent(dataSelect);
    return dataDropdown;
}
Also used : OptionGroup(com.vaadin.v7.ui.OptionGroup) PopupButton(org.vaadin.hene.popupbutton.PopupButton) VerticalLayout(com.vaadin.ui.VerticalLayout)

Aggregations

VerticalLayout (com.vaadin.v7.ui.VerticalLayout)34 VerticalLayout (com.vaadin.ui.VerticalLayout)25 Button (com.vaadin.ui.Button)22 Label (com.vaadin.ui.Label)18 Label (com.vaadin.v7.ui.Label)17 HorizontalLayout (com.vaadin.ui.HorizontalLayout)16 Window (com.vaadin.ui.Window)12 Component (com.vaadin.ui.Component)11 ValoTheme (com.vaadin.ui.themes.ValoTheme)11 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)11 VaadinIcons (com.vaadin.icons.VaadinIcons)10 Panel (com.vaadin.ui.Panel)10 TextField (com.vaadin.v7.ui.TextField)10 Strings (de.symeda.sormas.api.i18n.Strings)10 ButtonHelper (de.symeda.sormas.ui.utils.ButtonHelper)10 CssStyles (de.symeda.sormas.ui.utils.CssStyles)10 Captions (de.symeda.sormas.api.i18n.Captions)9 Alignment (com.vaadin.ui.Alignment)8 CheckBox (com.vaadin.v7.ui.CheckBox)8 OptionGroup (com.vaadin.v7.ui.OptionGroup)8