Search in sources :

Example 1 with TreatmentType

use of de.symeda.sormas.api.therapy.TreatmentType in project SORMAS-Project by hzi-braunschweig.

the class TherapyView method createTreatmentsHeader.

private VerticalLayout createTreatmentsHeader() {
    VerticalLayout treatmentsHeader = new VerticalLayout();
    treatmentsHeader.setMargin(false);
    treatmentsHeader.setSpacing(false);
    treatmentsHeader.setWidth(100, Unit.PERCENTAGE);
    HorizontalLayout headlineRow = new HorizontalLayout();
    headlineRow.setMargin(false);
    headlineRow.setSpacing(true);
    headlineRow.setWidth(100, Unit.PERCENTAGE);
    {
        Label treatmentsLabel = new Label(I18nProperties.getString(Strings.headingTreatments));
        CssStyles.style(treatmentsLabel, CssStyles.H3);
        headlineRow.addComponent(treatmentsLabel);
        headlineRow.setExpandRatio(treatmentsLabel, 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().deleteAllSelectedTreatments(treatmentGrid.getSelectedRows(), new Runnable() {

                    public void run() {
                        reloadTreatmentGrid();
                    }
                });
            }));
            headlineRow.addComponent(bulkOperationsDropdown);
            headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT);
        }
        Button newTreatmentButton = ButtonHelper.createButton(Captions.treatmentNewTreatment, e -> {
            ControllerProvider.getTherapyController().openTreatmentCreateForm(treatmentCriteria.getTherapy(), this::reloadTreatmentGrid);
        });
        headlineRow.addComponent(newTreatmentButton);
        headlineRow.setComponentAlignment(newTreatmentButton, Alignment.MIDDLE_RIGHT);
    }
    treatmentsHeader.addComponent(headlineRow);
    HorizontalLayout filterRow = new HorizontalLayout();
    filterRow.setMargin(false);
    filterRow.setSpacing(true);
    {
        treatmentTypeFilter = ComboBoxHelper.createComboBoxV7();
        treatmentTypeFilter.setWidth(140, Unit.PIXELS);
        treatmentTypeFilter.setInputPrompt(I18nProperties.getPrefixCaption(TreatmentDto.I18N_PREFIX, TreatmentDto.TREATMENT_TYPE));
        treatmentTypeFilter.addItems((Object[]) TreatmentType.values());
        treatmentTypeFilter.addValueChangeListener(e -> {
            treatmentCriteria.treatmentType(((TreatmentType) e.getProperty().getValue()));
            navigateTo(treatmentCriteria);
        });
        filterRow.addComponent(treatmentTypeFilter);
        treatmentTextFilter = new TextField();
        treatmentTextFilter.setWidth(300, Unit.PIXELS);
        treatmentTextFilter.setNullRepresentation("");
        treatmentTextFilter.setInputPrompt(I18nProperties.getString(Strings.promptTreatmentTextFilter));
        treatmentTextFilter.addTextChangeListener(e -> {
            treatmentCriteria.textFilter(e.getText());
            reloadTreatmentGrid();
        });
        filterRow.addComponent(treatmentTextFilter);
    }
    treatmentsHeader.addComponent(filterRow);
    return treatmentsHeader;
}
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 2 with TreatmentType

use of de.symeda.sormas.api.therapy.TreatmentType 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)

Aggregations

VaadinIcons (com.vaadin.icons.VaadinIcons)2 Alignment (com.vaadin.ui.Alignment)2 Button (com.vaadin.ui.Button)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 Label (com.vaadin.ui.Label)2 MenuBar (com.vaadin.ui.MenuBar)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 ValoTheme (com.vaadin.ui.themes.ValoTheme)2 HeightMode (com.vaadin.v7.shared.ui.grid.HeightMode)2 ComboBox (com.vaadin.v7.ui.ComboBox)2 TextField (com.vaadin.v7.ui.TextField)2 FacadeProvider (de.symeda.sormas.api.FacadeProvider)2 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)2 Captions (de.symeda.sormas.api.i18n.Captions)2 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)2 Strings (de.symeda.sormas.api.i18n.Strings)2 PrescriptionCriteria (de.symeda.sormas.api.therapy.PrescriptionCriteria)2 PrescriptionDto (de.symeda.sormas.api.therapy.PrescriptionDto)2 TherapyDto (de.symeda.sormas.api.therapy.TherapyDto)2 TreatmentCriteria (de.symeda.sormas.api.therapy.TreatmentCriteria)2