Example usage for com.vaadin.ui Button addStyleName

List of usage examples for com.vaadin.ui Button addStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui Button addStyleName.

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:de.symeda.sormas.ui.events.EventsView.java

License:Open Source License

public EventsView() {
    super(VIEW_NAME);

    originalViewTitle = getViewTitleLabel().getValue();

    criteria = ViewModelProviders.of(EventsView.class).get(EventCriteria.class);
    if (criteria.getArchived() == null) {
        criteria.archived(false);/*w  w w . j a  va2 s . c om*/
    }

    grid = new EventGrid();
    grid.setCriteria(criteria);
    gridLayout = new VerticalLayout();
    gridLayout.addComponent(createFilterBar());
    gridLayout.addComponent(createStatusFilterBar());
    gridLayout.addComponent(grid);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(false);
    gridLayout.setSizeFull();
    gridLayout.setExpandRatio(grid, 1);
    gridLayout.setStyleName("crud-main-layout");
    grid.getDataProvider().addDataProviderListener(e -> updateStatusButtons());

    addComponent(gridLayout);

    if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EXPORT)) {
        Button exportButton = new Button(I18nProperties.getCaption(Captions.export));
        exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        exportButton.setIcon(VaadinIcons.DOWNLOAD);

        StreamResource streamResource = new GridExportStreamResource(grid, "sormas_events",
                "sormas_events_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        FileDownloader fileDownloader = new FileDownloader(streamResource);
        fileDownloader.extend(exportButton);

        addHeaderComponent(exportButton);
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_CREATE)) {
        createButton = new Button(I18nProperties.getCaption(Captions.eventNewEvent));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(e -> ControllerProvider.getEventController().create());
        addHeaderComponent(createButton);
    }
}

From source file:de.symeda.sormas.ui.Menu.java

License:Open Source License

public Menu(Navigator navigator) {
    this.navigator = navigator;
    setPrimaryStyleName(ValoTheme.MENU_ROOT);
    menuPart = new CssLayout();
    menuPart.addStyleName(ValoTheme.MENU_PART);

    // header of the menu
    final HorizontalLayout top = new HorizontalLayout();
    top.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    top.addStyleName(ValoTheme.MENU_TITLE);
    top.setSpacing(true);/*  w w w. j  a  va2s .c  o m*/
    Label title = new Label("SORMAS");
    title.setSizeUndefined();
    Image image = new Image(null, new ThemeResource("img/sormas-logo.png"));
    CssStyles.style(image, ValoTheme.MENU_LOGO, ValoTheme.BUTTON_LINK);
    image.addClickListener(new MouseEvents.ClickListener() {
        @Override
        public void click(MouseEvents.ClickEvent event) {
            SormasUI.get().getNavigator().navigateTo(SurveillanceDashboardView.VIEW_NAME);
        }
    });
    top.addComponent(image);
    top.addComponent(title);
    menuPart.addComponent(top);

    // logout menu item
    MenuBar logoutMenu = new MenuBar();
    logoutMenu.addItem(I18nProperties.getCaption(Captions.actionLogout) + " ("
            + UserProvider.getCurrent().getUserName() + ")", VaadinIcons.SIGN_OUT, new Command() {
                @Override
                public void menuSelected(MenuItem selectedItem) {
                    LoginHelper.logout();
                }
            });

    logoutMenu.addStyleName("user-menu");
    menuPart.addComponent(logoutMenu);

    // button for toggling the visibility of the menu when on a small screen
    final Button showMenu = new Button(I18nProperties.getCaption(Captions.menu), new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) {
                menuPart.removeStyleName(VALO_MENU_VISIBLE);
            } else {
                menuPart.addStyleName(VALO_MENU_VISIBLE);
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(VALO_MENU_TOGGLE);
    showMenu.setIcon(VaadinIcons.MENU);
    menuPart.addComponent(showMenu);

    // container for the navigation buttons, which are added by addView()
    menuItemsLayout = new CssLayout();
    menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS);
    menuPart.addComponent(menuItemsLayout);

    addComponent(menuPart);
}

From source file:de.symeda.sormas.ui.Menu.java

License:Open Source License

/**
 * Highlights a view navigation button as the currently active view in the
 * menu. This method does not perform the actual navigation.
 *
 * @param viewName//from  www  .j a  v a  2 s.c  o  m
 *            the name of the view to show as active
 */
public void setActiveView(String viewName) {
    for (Button button : viewButtons.values()) {
        button.removeStyleName("selected");
    }

    Button selected = viewButtons.get(viewName);
    if (selected == null && viewName.contains("/")) {
        // might be a sub-view
        viewName = viewName.substring(0, viewName.indexOf('/'));
        selected = viewButtons.get(viewName);
    }

    if (selected != null) {
        selected.addStyleName("selected");
    }

    menuPart.removeStyleName(VALO_MENU_VISIBLE);
}

From source file:de.symeda.sormas.ui.reports.ReportsView.java

License:Open Source License

public HorizontalLayout createFilterBar() {
    HorizontalLayout filterLayout = new HorizontalLayout();
    filterLayout.setMargin(false);//from www  .  java  2 s  .c o  m
    filterLayout.setSpacing(true);
    filterLayout.addStyleName(CssStyles.VSPACE_3);
    filterLayout.setWidth(100, Unit.PERCENTAGE);

    EpiWeek prevEpiWeek = DateHelper.getPreviousEpiWeek(new Date());
    int year = prevEpiWeek.getYear();
    int week = prevEpiWeek.getWeek();

    yearFilter = new ComboBox();
    yearFilter.setWidth(200, Unit.PIXELS);
    yearFilter.addItems(DateHelper.getYearsToNow());
    yearFilter.select(year);
    yearFilter.setCaption(I18nProperties.getString(Strings.year));
    yearFilter.setItemCaptionMode(ItemCaptionMode.ID_TOSTRING);
    yearFilter.addValueChangeListener(e -> {
        updateEpiWeeks((int) e.getProperty().getValue(), (int) epiWeekFilter.getValue());
        reloadGrid();
    });
    filterLayout.addComponent(yearFilter);

    epiWeekFilter = new ComboBox();
    epiWeekFilter.setWidth(200, Unit.PIXELS);
    updateEpiWeeks(year, week);
    epiWeekFilter.setCaption(I18nProperties.getString(Strings.epiWeek));
    epiWeekFilter.addValueChangeListener(e -> {
        reloadGrid();
    });
    filterLayout.addComponent(epiWeekFilter);

    Button lastWeekButton = new Button(I18nProperties.getCaption(Captions.dashboardLastWeek));
    lastWeekButton.addStyleName(CssStyles.FORCE_CAPTION);
    lastWeekButton.addClickListener(e -> {
        EpiWeek epiWeek = DateHelper.getPreviousEpiWeek(new Date());
        yearFilter.select(epiWeek.getYear());
        epiWeekFilter.select(epiWeek.getWeek());
    });
    filterLayout.addComponent(lastWeekButton);

    Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
    infoLabel.setDescription(I18nProperties.getString(Strings.infoWeeklyReportsView));
    infoLabel.setSizeUndefined();
    CssStyles.style(infoLabel, CssStyles.LABEL_XLARGE, CssStyles.LABEL_SECONDARY);
    filterLayout.addComponent(infoLabel);
    filterLayout.setComponentAlignment(infoLabel, Alignment.MIDDLE_RIGHT);
    filterLayout.setExpandRatio(infoLabel, 1);

    return filterLayout;
}

From source file:de.symeda.sormas.ui.samples.SampleController.java

License:Open Source License

public CommitDiscardWrapperComponent<SampleEditForm> getSampleEditComponent(final String sampleUuid) {
    SampleEditForm form = new SampleEditForm(UserRight.SAMPLE_EDIT);
    form.setWidth(form.getWidth() * 10 / 12, Unit.PIXELS);
    SampleDto dto = FacadeProvider.getSampleFacade().getSampleByUuid(sampleUuid);
    form.setValue(dto);//from   ww w  . j a v a2s .  c  o  m
    final CommitDiscardWrapperComponent<SampleEditForm> editView = new CommitDiscardWrapperComponent<SampleEditForm>(
            form, form.getFieldGroup());

    editView.addCommitListener(new CommitListener() {
        @Override
        public void onCommit() {
            if (!form.getFieldGroup().isModified()) {
                SampleDto dto = form.getValue();
                SampleDto originalDto = FacadeProvider.getSampleFacade().getSampleByUuid(dto.getUuid());
                FacadeProvider.getSampleFacade().saveSample(dto);
                SormasUI.refreshView();

                if (dto.getSpecimenCondition() != originalDto.getSpecimenCondition()
                        && dto.getSpecimenCondition() == SpecimenCondition.NOT_ADEQUATE
                        && UserProvider.getCurrent().hasUserRight(UserRight.TASK_CREATE)) {
                    requestSampleCollectionTaskCreation(dto, form);
                } else {
                    Notification.show(I18nProperties.getString(Strings.messageSampleSaved),
                            Type.TRAY_NOTIFICATION);
                }
            }
        }
    });

    if (UserProvider.getCurrent().hasUserRole(UserRole.ADMIN)) {
        editView.addDeleteListener(new DeleteListener() {
            @Override
            public void onDelete() {
                FacadeProvider.getSampleFacade().deleteSample(dto.toReference(),
                        UserProvider.getCurrent().getUserReference().getUuid());
                UI.getCurrent().getNavigator().navigateTo(SamplesView.VIEW_NAME);
            }
        }, I18nProperties.getString(Strings.entitySample));
    }

    // Initialize 'Refer to another laboratory' button or link to referred sample
    Button referOrLinkToOtherLabButton = new Button();
    referOrLinkToOtherLabButton.addStyleName(ValoTheme.BUTTON_LINK);
    if (dto.getReferredTo() == null) {
        if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_TRANSFER)) {
            referOrLinkToOtherLabButton.setCaption(I18nProperties.getCaption(Captions.sampleRefer));
            referOrLinkToOtherLabButton.addClickListener(new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    try {
                        form.commit();
                        SampleDto sampleDto = form.getValue();
                        sampleDto = FacadeProvider.getSampleFacade().saveSample(sampleDto);
                        createReferral(sampleDto);
                    } catch (SourceException | InvalidValueException e) {
                        Notification.show(I18nProperties.getString(Strings.messageSampleErrors),
                                Type.ERROR_MESSAGE);
                    }
                }
            });

            editView.getButtonsPanel().addComponentAsFirst(referOrLinkToOtherLabButton);
            editView.getButtonsPanel().setComponentAlignment(referOrLinkToOtherLabButton,
                    Alignment.BOTTOM_LEFT);
        }
    } else {
        SampleDto referredDto = FacadeProvider.getSampleFacade().getSampleByUuid(dto.getReferredTo().getUuid());
        referOrLinkToOtherLabButton.setCaption(
                I18nProperties.getCaption(Captions.sampleReferredTo) + " " + referredDto.getLab().toString());
        referOrLinkToOtherLabButton.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                navigateToData(dto.getReferredTo().getUuid());
            }
        });

        editView.getButtonsPanel().addComponentAsFirst(referOrLinkToOtherLabButton);
        editView.getButtonsPanel().setComponentAlignment(referOrLinkToOtherLabButton, Alignment.BOTTOM_LEFT);
    }

    return editView;
}

From source file:de.symeda.sormas.ui.samples.SampleEditForm.java

License:Open Source License

@Override
protected void addFields() {
    addField(SampleDto.LAB_SAMPLE_ID, TextField.class);
    DateTimeField sampleDateField = addField(SampleDto.SAMPLE_DATE_TIME, DateTimeField.class);
    sampleDateField.setInvalidCommitted(false);
    addField(SampleDto.SAMPLE_MATERIAL, ComboBox.class);
    addField(SampleDto.SAMPLE_MATERIAL_TEXT, TextField.class);
    ComboBox sampleSource = addField(SampleDto.SAMPLE_SOURCE, ComboBox.class);
    DateField shipmentDate = addDateField(SampleDto.SHIPMENT_DATE, DateField.class, 7);
    addField(SampleDto.SHIPMENT_DETAILS, TextField.class);
    DateField receivedDate = addField(SampleDto.RECEIVED_DATE, DateField.class);
    ComboBox lab = addField(SampleDto.LAB, ComboBox.class);
    lab.addItems(FacadeProvider.getFacilityFacade().getAllLaboratories(true));
    TextField labDetails = addField(SampleDto.LAB_DETAILS, TextField.class);
    labDetails.setVisible(false);/* w  ww. j  a  v a  2  s  .  co  m*/
    addField(SampleDto.SPECIMEN_CONDITION, ComboBox.class);
    addField(SampleDto.NO_TEST_POSSIBLE_REASON, TextField.class);
    addField(SampleDto.COMMENT, TextArea.class).setRows(2);
    CheckBox shipped = addField(SampleDto.SHIPPED, CheckBox.class);
    CheckBox received = addField(SampleDto.RECEIVED, CheckBox.class);
    ComboBox pathogenTestResultField = addField(SampleDto.PATHOGEN_TEST_RESULT, ComboBox.class);

    initializeRequestedTests();

    // Validators
    sampleDateField.addValidator(new DateComparisonValidator(sampleDateField, shipmentDate, true, false,
            I18nProperties.getValidationError(Validations.beforeDate, sampleDateField.getCaption(),
                    shipmentDate.getCaption())));
    sampleDateField.addValidator(new DateComparisonValidator(sampleDateField, receivedDate, true, false,
            I18nProperties.getValidationError(Validations.beforeDate, sampleDateField.getCaption(),
                    receivedDate.getCaption())));
    shipmentDate.addValidator(new DateComparisonValidator(shipmentDate, sampleDateField, false, false,
            I18nProperties.getValidationError(Validations.afterDate, shipmentDate.getCaption(),
                    sampleDateField.getCaption())));
    shipmentDate.addValidator(new DateComparisonValidator(shipmentDate, receivedDate, true, false,
            I18nProperties.getValidationError(Validations.beforeDate, shipmentDate.getCaption(),
                    receivedDate.getCaption())));
    receivedDate.addValidator(new DateComparisonValidator(receivedDate, sampleDateField, false, false,
            I18nProperties.getValidationError(Validations.afterDate, receivedDate.getCaption(),
                    sampleDateField.getCaption())));
    receivedDate.addValidator(new DateComparisonValidator(receivedDate, shipmentDate, false, false,
            I18nProperties.getValidationError(Validations.afterDate, receivedDate.getCaption(),
                    shipmentDate.getCaption())));

    FieldHelper.setVisibleWhen(getFieldGroup(), SampleDto.SAMPLE_MATERIAL_TEXT, SampleDto.SAMPLE_MATERIAL,
            Arrays.asList(SampleMaterial.OTHER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), SampleDto.NO_TEST_POSSIBLE_REASON, SampleDto.SPECIMEN_CONDITION,
            Arrays.asList(SpecimenCondition.NOT_ADEQUATE), true);
    FieldHelper.setRequiredWhen(getFieldGroup(), SampleDto.SAMPLE_MATERIAL,
            Arrays.asList(SampleDto.SAMPLE_MATERIAL_TEXT), Arrays.asList(SampleMaterial.OTHER));
    FieldHelper.setRequiredWhen(getFieldGroup(), SampleDto.SPECIMEN_CONDITION,
            Arrays.asList(SampleDto.NO_TEST_POSSIBLE_REASON), Arrays.asList(SpecimenCondition.NOT_ADEQUATE));

    addValueChangeListener(e -> {
        CaseDataDto caze = FacadeProvider.getCaseFacade()
                .getCaseDataByUuid(getValue().getAssociatedCase().getUuid());

        FieldHelper.setRequiredWhen(getFieldGroup(), received,
                Arrays.asList(SampleDto.RECEIVED_DATE, SampleDto.SPECIMEN_CONDITION), Arrays.asList(true));
        FieldHelper.setEnabledWhen(getFieldGroup(), received, Arrays.asList(true),
                Arrays.asList(SampleDto.RECEIVED_DATE, SampleDto.LAB_SAMPLE_ID, SampleDto.SPECIMEN_CONDITION,
                        SampleDto.NO_TEST_POSSIBLE_REASON),
                true);

        if (caze.getDisease() != Disease.NEW_INFLUENCA) {
            sampleSource.setVisible(false);
        }

        if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_EDIT_NOT_OWNED)
                || UserProvider.getCurrent().getUuid().equals(getValue().getReportingUser().getUuid())) {
            FieldHelper.setEnabledWhen(getFieldGroup(), shipped, Arrays.asList(true),
                    Arrays.asList(SampleDto.SHIPMENT_DATE, SampleDto.SHIPMENT_DETAILS), true);
            FieldHelper.setRequiredWhen(getFieldGroup(), shipped, Arrays.asList(SampleDto.SHIPMENT_DATE),
                    Arrays.asList(true));
            setRequired(true, SampleDto.SAMPLE_DATE_TIME, SampleDto.SAMPLE_MATERIAL, SampleDto.LAB);
        } else {
            getField(SampleDto.SAMPLE_DATE_TIME).setEnabled(false);
            getField(SampleDto.SAMPLE_MATERIAL).setEnabled(false);
            getField(SampleDto.SAMPLE_MATERIAL_TEXT).setEnabled(false);
            getField(SampleDto.LAB).setEnabled(false);
            getField(SampleDto.SHIPPED).setEnabled(false);
            getField(SampleDto.SHIPMENT_DATE).setEnabled(false);
            getField(SampleDto.SHIPMENT_DETAILS).setEnabled(false);
            getField(SampleDto.SAMPLE_SOURCE).setEnabled(false);
        }

        shipped.addValueChangeListener(event -> {
            if ((boolean) event.getProperty().getValue() == true) {
                if (shipmentDate.getValue() == null) {
                    shipmentDate.setValue(new Date());
                }
            }
        });

        received.addValueChangeListener(event -> {
            if ((boolean) event.getProperty().getValue() == true) {
                if (receivedDate.getValue() == null) {
                    receivedDate.setValue(new Date());
                }
            }
        });

        // Initialize referral and report information
        VerticalLayout reportInfoLayout = new VerticalLayout();

        String reportInfoText = I18nProperties.getString(Strings.reportedOn) + " "
                + DateHelper.formatLocalDateTime(getValue().getReportDateTime()) + " "
                + I18nProperties.getString(Strings.by) + " " + getValue().getReportingUser().toString();
        Label reportInfoLabel = new Label(reportInfoText);
        reportInfoLabel.setEnabled(false);
        reportInfoLayout.addComponent(reportInfoLabel);

        SampleReferenceDto referredFromRef = FacadeProvider.getSampleFacade()
                .getReferredFrom(getValue().getUuid());
        if (referredFromRef != null) {
            SampleDto referredFrom = FacadeProvider.getSampleFacade()
                    .getSampleByUuid(referredFromRef.getUuid());
            Button referredButton = new Button(I18nProperties.getCaption(Captions.sampleReferredFrom) + " "
                    + referredFrom.getLab().toString());
            referredButton.addStyleName(ValoTheme.BUTTON_LINK);
            referredButton.addStyleName(CssStyles.VSPACE_NONE);
            referredButton.addClickListener(
                    s -> ControllerProvider.getSampleController().navigateToData(referredFrom.getUuid()));
            reportInfoLayout.addComponent(referredButton);
        }

        getContent().addComponent(reportInfoLayout, REPORT_INFORMATION_LOC);

        if (FacadeProvider.getPathogenTestFacade().hasPathogenTest(getValue().toReference())) {
            pathogenTestResultField.setRequired(true);
        } else {
            pathogenTestResultField.setEnabled(false);
        }
    });

    lab.addValueChangeListener(event -> {
        if (event.getProperty().getValue() != null && ((FacilityReferenceDto) event.getProperty().getValue())
                .getUuid().equals(FacilityDto.OTHER_LABORATORY_UUID)) {
            labDetails.setVisible(true);
            labDetails.setRequired(true);
        } else {
            labDetails.setVisible(false);
            labDetails.setRequired(false);
            labDetails.clear();
        }
    });
}

From source file:de.symeda.sormas.ui.samples.SamplesView.java

License:Open Source License

public SamplesView() {
    super(VIEW_NAME);

    sampleListComponent = new SampleGridComponent(getViewTitleLabel(), this);
    setSizeFull();/*from   w  ww .  ja v  a2s. c o m*/
    addComponent(sampleListComponent);

    if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_EXPORT)) {
        PopupButton exportButton = new PopupButton(I18nProperties.getCaption(Captions.export));
        exportButton.setIcon(VaadinIcons.DOWNLOAD);
        VerticalLayout exportLayout = new VerticalLayout();
        exportLayout.setSpacing(true);
        exportLayout.setMargin(true);
        exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
        exportLayout.setWidth(200, Unit.PIXELS);
        exportButton.setContent(exportLayout);
        addHeaderComponent(exportButton);

        Button basicExportButton = new Button(I18nProperties.getCaption(Captions.exportBasic));
        basicExportButton.setDescription(I18nProperties.getString(Strings.infoBasicExport));
        basicExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        basicExportButton.setIcon(VaadinIcons.TABLE);
        basicExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(basicExportButton);

        StreamResource streamResource = new GridExportStreamResource(sampleListComponent.getGrid(),
                "sormas_samples", "sormas_samples_" + DateHelper.formatDateForExport(new Date()) + ".csv",
                SampleGrid.EDIT_BTN_ID);
        FileDownloader fileDownloader = new FileDownloader(streamResource);
        fileDownloader.extend(basicExportButton);

        Button extendedExportButton = new Button(I18nProperties.getCaption(Captions.exportDetailed));
        extendedExportButton.setDescription(I18nProperties.getString(Strings.infoDetailedExport));
        extendedExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        extendedExportButton.setIcon(VaadinIcons.FILE_TEXT);
        extendedExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(extendedExportButton);

        StreamResource extendedExportStreamResource = DownloadUtil.createCsvExportStreamResource(
                SampleExportDto.class,
                (Integer start, Integer max) -> FacadeProvider.getSampleFacade().getExportList(
                        UserProvider.getCurrent().getUuid(), sampleListComponent.getGrid().getCriteria(), start,
                        max),
                (propertyId, type) -> {
                    String caption = I18nProperties.getPrefixCaption(SampleExportDto.I18N_PREFIX, propertyId,
                            I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, propertyId,
                                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, propertyId,
                                            I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, propertyId,
                                                    I18nProperties.getPrefixCaption(
                                                            AdditionalTestDto.I18N_PREFIX, propertyId)))));
                    if (Date.class.isAssignableFrom(type)) {
                        caption += " (" + DateHelper.getLocalShortDatePattern() + ")";
                    }
                    return caption;
                }, "sormas_samples_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        new FileDownloader(extendedExportStreamResource).extend(extendedExportButton);
    }
}

From source file:de.symeda.sormas.ui.symptoms.SymptomsForm.java

License:Open Source License

@Override
protected void addFields() {
    if (disease == null || symptomsContext == null) {
        // workaround to stop initialization until disease is set 
        return;//from   w w  w  . j  a va  2 s .c o m
    }

    // Add fields

    DateField onsetDateField = addField(SymptomsDto.ONSET_DATE, DateField.class);
    ComboBox onsetSymptom = addField(SymptomsDto.ONSET_SYMPTOM, ComboBox.class);
    if (symptomsContext == SymptomsContext.CASE) {
        onsetDateField.addValidator(new DateComparisonValidator(onsetDateField,
                caze.getHospitalization().getAdmissionDate(), true, false,
                I18nProperties.getValidationError(Validations.beforeDateSoft, onsetDateField.getCaption(),
                        I18nProperties.getPrefixCaption(HospitalizationDto.I18N_PREFIX,
                                HospitalizationDto.ADMISSION_DATE))));
        onsetDateField.setInvalidCommitted(true);
    }

    ComboBox temperature = addField(SymptomsDto.TEMPERATURE, ComboBox.class);
    for (Float temperatureValue : SymptomsHelper.getTemperatureValues()) {
        temperature.addItem(temperatureValue);
        temperature.setItemCaption(temperatureValue, SymptomsHelper.getTemperatureString(temperatureValue));
    }
    if (symptomsContext == SymptomsContext.CASE) {
        temperature.setCaption(I18nProperties.getCaption(Captions.symptomsMaxTemperature));
    }
    addField(SymptomsDto.TEMPERATURE_SOURCE);

    ComboBox bloodPressureSystolic = addField(SymptomsDto.BLOOD_PRESSURE_SYSTOLIC, ComboBox.class);
    bloodPressureSystolic.addItems(SymptomsHelper.getBloodPressureValues());
    ComboBox bloodPressureDiastolic = addField(SymptomsDto.BLOOD_PRESSURE_DIASTOLIC, ComboBox.class);
    bloodPressureDiastolic.addItems(SymptomsHelper.getBloodPressureValues());
    ComboBox heartRate = addField(SymptomsDto.HEART_RATE, ComboBox.class);
    heartRate.addItems(SymptomsHelper.getHeartRateValues());
    ComboBox respiratoryRate = addField(SymptomsDto.RESPIRATORY_RATE, ComboBox.class);
    respiratoryRate.addItems(SymptomsHelper.getRespiratoryRateValues());
    ComboBox weight = addField(SymptomsDto.WEIGHT, ComboBox.class);
    for (Integer weightValue : SymptomsHelper.getWeightValues()) {
        weight.addItem(weightValue);
        weight.setItemCaption(weightValue, SymptomsHelper.getDecimalString(weightValue));
    }
    ComboBox height = addField(SymptomsDto.HEIGHT, ComboBox.class);
    height.addItems(SymptomsHelper.getHeightValues());
    ComboBox midUpperArmCircumference = addField(SymptomsDto.MID_UPPER_ARM_CIRCUMFERENCE, ComboBox.class);
    for (Integer circumferenceValue : SymptomsHelper.getMidUpperArmCircumferenceValues()) {
        midUpperArmCircumference.addItem(circumferenceValue);
        midUpperArmCircumference.setItemCaption(circumferenceValue,
                SymptomsHelper.getDecimalString(circumferenceValue));
    }
    ComboBox glasgowComaScale = addField(SymptomsDto.GLASGOW_COMA_SCALE, ComboBox.class);
    glasgowComaScale.addItems(SymptomsHelper.getGlasgowComaScaleValues());

    addFields(SymptomsDto.FEVER, SymptomsDto.VOMITING, SymptomsDto.DIARRHEA, SymptomsDto.BLOOD_IN_STOOL,
            SymptomsDto.NAUSEA, SymptomsDto.ABDOMINAL_PAIN, SymptomsDto.HEADACHE, SymptomsDto.MUSCLE_PAIN,
            SymptomsDto.FATIGUE_WEAKNESS, SymptomsDto.SKIN_RASH, SymptomsDto.NECK_STIFFNESS,
            SymptomsDto.SORE_THROAT, SymptomsDto.COUGH, SymptomsDto.RUNNY_NOSE,
            SymptomsDto.DIFFICULTY_BREATHING, SymptomsDto.CHEST_PAIN, SymptomsDto.CONJUNCTIVITIS,
            SymptomsDto.EYE_PAIN_LIGHT_SENSITIVE, SymptomsDto.KOPLIKS_SPOTS, SymptomsDto.THROBOCYTOPENIA,
            SymptomsDto.OTITIS_MEDIA, SymptomsDto.HEARINGLOSS, SymptomsDto.DEHYDRATION,
            SymptomsDto.ANOREXIA_APPETITE_LOSS, SymptomsDto.REFUSAL_FEEDOR_DRINK, SymptomsDto.JOINT_PAIN,
            SymptomsDto.HICCUPS, SymptomsDto.BACKACHE, SymptomsDto.EYES_BLEEDING, SymptomsDto.JAUNDICE,
            SymptomsDto.DARK_URINE, SymptomsDto.STOMACH_BLEEDING, SymptomsDto.RAPID_BREATHING,
            SymptomsDto.SWOLLEN_GLANDS, SymptomsDto.SYMPTOMS_COMMENTS, SymptomsDto.UNEXPLAINED_BLEEDING,
            SymptomsDto.GUMS_BLEEDING, SymptomsDto.INJECTION_SITE_BLEEDING, SymptomsDto.NOSE_BLEEDING,
            SymptomsDto.BLOODY_BLACK_STOOL, SymptomsDto.RED_BLOOD_VOMIT, SymptomsDto.DIGESTED_BLOOD_VOMIT,
            SymptomsDto.COUGHING_BLOOD, SymptomsDto.BLEEDING_VAGINA, SymptomsDto.SKIN_BRUISING,
            SymptomsDto.BLOOD_URINE, SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS,
            SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS_TEXT, SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS,
            SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT, SymptomsDto.LESIONS, SymptomsDto.LESIONS_THAT_ITCH,
            SymptomsDto.LESIONS_SAME_STATE, SymptomsDto.LESIONS_SAME_SIZE, SymptomsDto.LESIONS_DEEP_PROFOUND,
            SymptomsDto.LESIONS_FACE, SymptomsDto.LESIONS_LEGS, SymptomsDto.LESIONS_SOLES_FEET,
            SymptomsDto.LESIONS_PALMS_HANDS, SymptomsDto.LESIONS_THORAX, SymptomsDto.LESIONS_ARMS,
            SymptomsDto.LESIONS_GENITALS, SymptomsDto.LESIONS_ALL_OVER_BODY,
            SymptomsDto.LYMPHADENOPATHY_AXILLARY, SymptomsDto.LYMPHADENOPATHY_CERVICAL,
            SymptomsDto.LYMPHADENOPATHY_INGUINAL, SymptomsDto.CHILLS_SWEATS, SymptomsDto.BEDRIDDEN,
            SymptomsDto.ORAL_ULCERS, SymptomsDto.PAINFUL_LYMPHADENITIS, SymptomsDto.BLACKENING_DEATH_OF_TISSUE,
            SymptomsDto.BUBOES_GROIN_ARMPIT_NECK, SymptomsDto.BULGING_FONTANELLE,
            SymptomsDto.PHARYNGEAL_ERYTHEMA, SymptomsDto.PHARYNGEAL_EXUDATE, SymptomsDto.OEDEMA_FACE_NECK,
            SymptomsDto.OEDEMA_LOWER_EXTREMITY, SymptomsDto.LOSS_SKIN_TURGOR, SymptomsDto.PALPABLE_LIVER,
            SymptomsDto.PALPABLE_SPLEEN, SymptomsDto.MALAISE, SymptomsDto.SUNKEN_EYES_FONTANELLE,
            SymptomsDto.SIDE_PAIN, SymptomsDto.FLUID_IN_LUNG_CAVITY, SymptomsDto.TREMOR,
            SymptomsDto.BILATERAL_CATARACTS, SymptomsDto.UNILATERAL_CATARACTS, SymptomsDto.CONGENITAL_GLAUCOMA,
            SymptomsDto.CONGENITAL_HEART_DISEASE, SymptomsDto.PIGMENTARY_RETINOPATHY,
            SymptomsDto.RADIOLUCENT_BONE_DISEASE, SymptomsDto.SPLENOMEGALY, SymptomsDto.MICROCEPHALY,
            SymptomsDto.MENINGOENCEPHALITIS, SymptomsDto.PURPURIC_RASH, SymptomsDto.DEVELOPMENTAL_DELAY,
            SymptomsDto.CONGENITAL_HEART_DISEASE_TYPE, SymptomsDto.CONGENITAL_HEART_DISEASE_DETAILS,
            SymptomsDto.JAUNDICE_WITHIN_24_HOURS_OF_BIRTH, SymptomsDto.PATIENT_ILL_LOCATION);
    addField(SymptomsDto.LESIONS_ONSET_DATE, DateField.class);

    // complications
    addFields(SymptomsDto.ALTERED_CONSCIOUSNESS, SymptomsDto.CONFUSED_DISORIENTED,
            SymptomsDto.HEMORRHAGIC_SYNDROME, SymptomsDto.HYPERGLYCEMIA, SymptomsDto.HYPOGLYCEMIA,
            SymptomsDto.MENINGEAL_SIGNS, SymptomsDto.SEIZURES, SymptomsDto.SEPSIS, SymptomsDto.SHOCK);

    monkeypoxImageFieldIds = Arrays.asList(SymptomsDto.LESIONS_RESEMBLE_IMG1, SymptomsDto.LESIONS_RESEMBLE_IMG2,
            SymptomsDto.LESIONS_RESEMBLE_IMG3, SymptomsDto.LESIONS_RESEMBLE_IMG4);
    for (String propertyId : monkeypoxImageFieldIds) {
        @SuppressWarnings("rawtypes")
        Field monkeypoxImageField = addField(propertyId);
        CssStyles.style(monkeypoxImageField, CssStyles.VSPACE_NONE);
    }

    // Set initial visibilities

    initializeVisibilitiesAndAllowedVisibilities(disease, viewMode);

    if (symptomsContext != SymptomsContext.CLINICAL_VISIT) {
        setVisible(false, SymptomsDto.BLOOD_PRESSURE_SYSTOLIC, SymptomsDto.BLOOD_PRESSURE_DIASTOLIC,
                SymptomsDto.HEART_RATE, SymptomsDto.RESPIRATORY_RATE, SymptomsDto.WEIGHT, SymptomsDto.HEIGHT,
                SymptomsDto.MID_UPPER_ARM_CIRCUMFERENCE, SymptomsDto.GLASGOW_COMA_SCALE);
    } else {
        setVisible(false, SymptomsDto.ONSET_SYMPTOM, SymptomsDto.ONSET_DATE);
    }

    // Initialize lists

    conditionalBleedingSymptomFieldIds = Arrays.asList(SymptomsDto.GUMS_BLEEDING,
            SymptomsDto.INJECTION_SITE_BLEEDING, SymptomsDto.NOSE_BLEEDING, SymptomsDto.BLOODY_BLACK_STOOL,
            SymptomsDto.RED_BLOOD_VOMIT, SymptomsDto.DIGESTED_BLOOD_VOMIT, SymptomsDto.EYES_BLEEDING,
            SymptomsDto.COUGHING_BLOOD, SymptomsDto.BLEEDING_VAGINA, SymptomsDto.SKIN_BRUISING,
            SymptomsDto.STOMACH_BLEEDING, SymptomsDto.BLOOD_URINE, SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS);
    lesionsFieldIds = Arrays.asList(SymptomsDto.LESIONS_SAME_STATE, SymptomsDto.LESIONS_SAME_SIZE,
            SymptomsDto.LESIONS_DEEP_PROFOUND, SymptomsDto.LESIONS_THAT_ITCH);
    lesionsLocationFieldIds = Arrays.asList(SymptomsDto.LESIONS_FACE, SymptomsDto.LESIONS_LEGS,
            SymptomsDto.LESIONS_SOLES_FEET, SymptomsDto.LESIONS_PALMS_HANDS, SymptomsDto.LESIONS_THORAX,
            SymptomsDto.LESIONS_ARMS, SymptomsDto.LESIONS_GENITALS, SymptomsDto.LESIONS_ALL_OVER_BODY);
    unconditionalSymptomFieldIds = Arrays.asList(SymptomsDto.FEVER, SymptomsDto.VOMITING, SymptomsDto.DIARRHEA,
            SymptomsDto.BLOOD_IN_STOOL, SymptomsDto.NAUSEA, SymptomsDto.ABDOMINAL_PAIN, SymptomsDto.HEADACHE,
            SymptomsDto.MUSCLE_PAIN, SymptomsDto.FATIGUE_WEAKNESS, SymptomsDto.SKIN_RASH,
            SymptomsDto.NECK_STIFFNESS, SymptomsDto.SORE_THROAT, SymptomsDto.COUGH, SymptomsDto.RUNNY_NOSE,
            SymptomsDto.DIFFICULTY_BREATHING, SymptomsDto.CHEST_PAIN, SymptomsDto.CONJUNCTIVITIS,
            SymptomsDto.EYE_PAIN_LIGHT_SENSITIVE, SymptomsDto.KOPLIKS_SPOTS, SymptomsDto.THROBOCYTOPENIA,
            SymptomsDto.OTITIS_MEDIA, SymptomsDto.HEARINGLOSS, SymptomsDto.DEHYDRATION,
            SymptomsDto.ANOREXIA_APPETITE_LOSS, SymptomsDto.REFUSAL_FEEDOR_DRINK, SymptomsDto.JOINT_PAIN,
            SymptomsDto.HICCUPS, SymptomsDto.BACKACHE, SymptomsDto.JAUNDICE, SymptomsDto.DARK_URINE,
            SymptomsDto.RAPID_BREATHING, SymptomsDto.SWOLLEN_GLANDS, SymptomsDto.UNEXPLAINED_BLEEDING,
            SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS, SymptomsDto.LESIONS,
            SymptomsDto.LYMPHADENOPATHY_AXILLARY, SymptomsDto.LYMPHADENOPATHY_CERVICAL,
            SymptomsDto.LYMPHADENOPATHY_INGUINAL, SymptomsDto.CHILLS_SWEATS, SymptomsDto.BEDRIDDEN,
            SymptomsDto.ORAL_ULCERS, SymptomsDto.PAINFUL_LYMPHADENITIS, SymptomsDto.BLACKENING_DEATH_OF_TISSUE,
            SymptomsDto.BUBOES_GROIN_ARMPIT_NECK, SymptomsDto.BULGING_FONTANELLE,
            SymptomsDto.PHARYNGEAL_ERYTHEMA, SymptomsDto.PHARYNGEAL_EXUDATE, SymptomsDto.OEDEMA_FACE_NECK,
            SymptomsDto.OEDEMA_LOWER_EXTREMITY, SymptomsDto.LOSS_SKIN_TURGOR, SymptomsDto.PALPABLE_LIVER,
            SymptomsDto.PALPABLE_SPLEEN, SymptomsDto.MALAISE, SymptomsDto.SUNKEN_EYES_FONTANELLE,
            SymptomsDto.SIDE_PAIN, SymptomsDto.FLUID_IN_LUNG_CAVITY, SymptomsDto.TREMOR,
            SymptomsDto.BILATERAL_CATARACTS, SymptomsDto.UNILATERAL_CATARACTS, SymptomsDto.CONGENITAL_GLAUCOMA,
            SymptomsDto.CONGENITAL_HEART_DISEASE, SymptomsDto.RADIOLUCENT_BONE_DISEASE,
            SymptomsDto.SPLENOMEGALY, SymptomsDto.MICROCEPHALY, SymptomsDto.MENINGOENCEPHALITIS,
            SymptomsDto.DEVELOPMENTAL_DELAY, SymptomsDto.PURPURIC_RASH, SymptomsDto.PIGMENTARY_RETINOPATHY,
            // complications
            SymptomsDto.ALTERED_CONSCIOUSNESS, SymptomsDto.CONFUSED_DISORIENTED,
            SymptomsDto.HEMORRHAGIC_SYNDROME, SymptomsDto.HYPERGLYCEMIA, SymptomsDto.HYPOGLYCEMIA,
            SymptomsDto.MENINGEAL_SIGNS, SymptomsDto.SEIZURES, SymptomsDto.SEPSIS, SymptomsDto.SHOCK);

    // Set visibilities

    FieldHelper.setVisibleWhen(getFieldGroup(), conditionalBleedingSymptomFieldIds,
            SymptomsDto.UNEXPLAINED_BLEEDING, Arrays.asList(SymptomState.YES), true, SymptomsDto.class,
            disease);

    FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS_TEXT,
            SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS, Arrays.asList(SymptomState.YES), true);

    FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT,
            SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS, Arrays.asList(SymptomState.YES), true);

    FieldHelper.setVisibleWhen(getFieldGroup(), lesionsFieldIds, SymptomsDto.LESIONS,
            Arrays.asList(SymptomState.YES), true);

    FieldHelper.setVisibleWhen(getFieldGroup(), lesionsLocationFieldIds, SymptomsDto.LESIONS,
            Arrays.asList(SymptomState.YES), true);

    FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.LESIONS_ONSET_DATE, SymptomsDto.LESIONS,
            Arrays.asList(SymptomState.YES), true);

    FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.CONGENITAL_HEART_DISEASE_TYPE,
            SymptomsDto.CONGENITAL_HEART_DISEASE, Arrays.asList(SymptomState.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.CONGENITAL_HEART_DISEASE_DETAILS,
            SymptomsDto.CONGENITAL_HEART_DISEASE_TYPE, Arrays.asList(CongenitalHeartDiseaseType.OTHER), true);
    if (isVisibleAllowed(getFieldGroup().getField(SymptomsDto.JAUNDICE_WITHIN_24_HOURS_OF_BIRTH))) {
        FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.JAUNDICE_WITHIN_24_HOURS_OF_BIRTH,
                SymptomsDto.JAUNDICE, Arrays.asList(SymptomState.YES), true);
    }

    FieldHelper.addSoftRequiredStyle(getField(SymptomsDto.LESIONS_ONSET_DATE));

    boolean isInfant = person != null && person.getApproximateAge() != null
            && ((person.getApproximateAge() <= 12
                    && person.getApproximateAgeType() == ApproximateAgeType.MONTHS)
                    || person.getApproximateAge() <= 1);
    if (!isInfant) {
        getFieldGroup().getField(SymptomsDto.BULGING_FONTANELLE).setVisible(false);
    }

    // Handle visibility of lesions locations caption
    Label lesionsLocationsCaption = new Label(I18nProperties.getCaption(Captions.symptomsLesionsLocations));
    CssStyles.style(lesionsLocationsCaption, CssStyles.VSPACE_3);
    getContent().addComponent(lesionsLocationsCaption, LESIONS_LOCATIONS_LOC);
    getContent().getComponent(LESIONS_LOCATIONS_LOC)
            .setVisible(getFieldGroup().getField(SymptomsDto.LESIONS).getValue() == SymptomState.YES);
    getFieldGroup().getField(SymptomsDto.LESIONS).addValueChangeListener(e -> {
        getContent().getComponent(LESIONS_LOCATIONS_LOC)
                .setVisible(e.getProperty().getValue() == SymptomState.YES);
    });

    // Symptoms hint text
    Label symptomsHint = new Label(
            I18nProperties.getString(symptomsContext == SymptomsContext.CASE ? Strings.messageSymptomsHint
                    : Strings.messageSymptomsVisitHint),
            ContentMode.HTML);
    getContent().addComponent(symptomsHint, SYMPTOMS_HINT_LOC);

    if (disease == Disease.MONKEYPOX) {
        setUpMonkeypoxVisibilities();
    }

    if (symptomsContext != SymptomsContext.CASE) {
        getFieldGroup().getField(SymptomsDto.PATIENT_ILL_LOCATION).setVisible(false);
    }

    FieldHelper.setRequiredWhen(getFieldGroup(),
            getFieldGroup().getField(SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS),
            Arrays.asList(SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS_TEXT), Arrays.asList(SymptomState.YES),
            disease);
    FieldHelper.setRequiredWhen(getFieldGroup(),
            getFieldGroup().getField(SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS),
            Arrays.asList(SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT), Arrays.asList(SymptomState.YES),
            disease);
    FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(SymptomsDto.LESIONS), lesionsFieldIds,
            Arrays.asList(SymptomState.YES), disease);
    FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(SymptomsDto.LESIONS),
            monkeypoxImageFieldIds, Arrays.asList(SymptomState.YES), disease);

    addListenerForOnsetFields(onsetSymptom, onsetDateField);

    Button clearAllButton = new Button(I18nProperties.getCaption(Captions.actionClearAll));
    clearAllButton.addStyleName(ValoTheme.BUTTON_LINK);

    clearAllButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            for (Object symptomId : unconditionalSymptomFieldIds) {
                getFieldGroup().getField(symptomId).setValue(null);
            }
            for (Object symptomId : conditionalBleedingSymptomFieldIds) {
                getFieldGroup().getField(symptomId).setValue(null);
            }
            for (Object symptomId : lesionsFieldIds) {
                getFieldGroup().getField(symptomId).setValue(null);
            }
            for (Object symptomId : lesionsLocationFieldIds) {
                getFieldGroup().getField(symptomId).setValue(null);
            }
            for (Object symptomId : monkeypoxImageFieldIds) {
                getFieldGroup().getField(symptomId).setValue(null);
            }
        }
    });

    Button setEmptyToNoButton = new Button(I18nProperties.getCaption(Captions.symptomsSetClearedToNo));
    setEmptyToNoButton.addStyleName(ValoTheme.BUTTON_LINK);

    setEmptyToNoButton.addClickListener(new ClickListener() {
        @SuppressWarnings("unchecked")
        @Override
        public void buttonClick(ClickEvent event) {
            for (Object symptomId : unconditionalSymptomFieldIds) {
                Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId);
                if (symptom.isVisible() && symptom.getValue() == null) {
                    symptom.setValue(SymptomState.NO);
                }
            }
            for (Object symptomId : conditionalBleedingSymptomFieldIds) {
                Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId);
                if (symptom.isVisible() && symptom.getValue() == null) {
                    symptom.setValue(SymptomState.NO);
                }
            }
            for (Object symptomId : lesionsFieldIds) {
                Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId);
                if (symptom.isVisible() && symptom.getValue() == null) {
                    symptom.setValue(SymptomState.NO);
                }
            }
            for (Object symptomId : monkeypoxImageFieldIds) {
                Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId);
                if (symptom.isVisible() && symptom.getValue() == null) {
                    symptom.setValue(SymptomState.NO);
                }
            }
        }
    });

    // Complications heading - not displayed for Rubella (dirty, should be made generic)
    Label complicationsHeading = new Label(I18nProperties.getString(Strings.headingComplications));
    CssStyles.style(complicationsHeading, CssStyles.H3);
    if (disease != Disease.CONGENITAL_RUBELLA) {
        getContent().addComponent(complicationsHeading, COMPLICATIONS_HEADING);
    }

    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.addComponent(clearAllButton);
    buttonsLayout.addComponent(setEmptyToNoButton);
    buttonsLayout.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT);
    getContent().addComponent(buttonsLayout, BUTTONS_LOC);
}

From source file:de.symeda.sormas.ui.task.TasksView.java

License:Open Source License

public TasksView() {
    super(VIEW_NAME);

    if (!ViewModelProviders.of(TasksView.class).has(TaskCriteria.class)) {
        // init default filter
        TaskCriteria taskCriteria = new TaskCriteria();
        taskCriteria.taskStatus(TaskStatus.PENDING);
        ViewModelProviders.of(TasksView.class).get(TaskCriteria.class, taskCriteria);
    }//from   w w w . ja v a  2  s.c  o m

    taskListComponent = new TaskGridComponent(getViewTitleLabel(), this);
    addComponent(taskListComponent);

    if (UserProvider.getCurrent().hasUserRight(UserRight.TASK_CREATE)) {
        Button createButton = new Button(I18nProperties.getCaption(Captions.taskNewTask));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(e -> ControllerProvider.getTaskController().create(TaskContext.GENERAL,
                null, taskListComponent.getGrid()::reload));
        addHeaderComponent(createButton);
    }
}

From source file:de.symeda.sormas.ui.user.UserController.java

License:Open Source License

public Button createResetPasswordButton(String userUuid, CommitDiscardWrapperComponent<UserEditForm> editView) {
    Button resetPasswordButton = new Button(null, VaadinIcons.UNLOCK);
    resetPasswordButton.setCaption(I18nProperties.getCaption(Captions.userResetPassword));
    resetPasswordButton.addStyleName(ValoTheme.BUTTON_LINK);
    resetPasswordButton.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override/*from w  w w  .j  a  va  2  s . co m*/
        public void buttonClick(ClickEvent event) {
            ConfirmationComponent resetPasswordComponent = getResetPasswordConfirmationComponent(userUuid,
                    editView);
            Window popupWindow = VaadinUiUtil.showPopupWindow(resetPasswordComponent);
            resetPasswordComponent.addDoneListener(new DoneListener() {
                public void onDone() {
                    popupWindow.close();
                }
            });
            resetPasswordComponent.getCancelButton().addClickListener(new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    popupWindow.close();
                }
            });
            popupWindow.setCaption(I18nProperties.getString(Strings.headingUpdatePassword));
        }
    });

    return resetPasswordButton;
}