Example usage for com.vaadin.ui.themes ValoTheme BUTTON_LINK

List of usage examples for com.vaadin.ui.themes ValoTheme BUTTON_LINK

Introduction

In this page you can find the example usage for com.vaadin.ui.themes ValoTheme BUTTON_LINK.

Prototype

String BUTTON_LINK

To view the source code for com.vaadin.ui.themes ValoTheme BUTTON_LINK.

Click Source Link

Document

Makes the button look like the Link component.

Usage

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  w  w  w  . j  a  v a2  s  .  c om
    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);//from   w  w  w  .j a v  a2s . c o  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.SampleGridComponent.java

License:Open Source License

public HorizontalLayout createShipmentFilterBar() {
    HorizontalLayout shipmentFilterLayout = new HorizontalLayout();
    shipmentFilterLayout.setMargin(false);
    shipmentFilterLayout.setSpacing(true);
    shipmentFilterLayout.setWidth(100, Unit.PERCENTAGE);
    shipmentFilterLayout.addStyleName(CssStyles.VSPACE_3);

    statusButtons = new HashMap<>();

    HorizontalLayout buttonFilterLayout = new HorizontalLayout();
    buttonFilterLayout.setSpacing(true);
    {/*  w w w . j a v  a2s  .c o  m*/
        Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> processStatusChange(null));
        CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
        statusAll.setCaptionAsHtml(true);
        buttonFilterLayout.addComponent(statusAll);
        statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
        activeStatusButton = statusAll;

        Button notShippedButton = new Button(I18nProperties.getCaption(Captions.sampleNotShipped),
                e -> processStatusChange(NOT_SHIPPED));
        initializeStatusButton(notShippedButton, buttonFilterLayout, NOT_SHIPPED,
                I18nProperties.getCaption(Captions.sampleNotShipped));
        Button shippedButton = new Button(I18nProperties.getCaption(Captions.sampleShipped),
                e -> processStatusChange(SHIPPED));
        initializeStatusButton(shippedButton, buttonFilterLayout, SHIPPED,
                I18nProperties.getCaption(Captions.sampleShipped));
        Button receivedButton = new Button(I18nProperties.getCaption(Captions.sampleReceived),
                e -> processStatusChange(RECEIVED));
        initializeStatusButton(receivedButton, buttonFilterLayout, RECEIVED,
                I18nProperties.getCaption(Captions.sampleReceived));
        Button referredButton = new Button(I18nProperties.getCaption(Captions.sampleReferred),
                e -> processStatusChange(REFERRED));
        initializeStatusButton(referredButton, buttonFilterLayout, REFERRED,
                I18nProperties.getCaption(Captions.sampleReferred));
    }

    shipmentFilterLayout.addComponent(buttonFilterLayout);

    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show archived/active cases button
        if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW_ARCHIVED)) {
            switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.sampleShowArchived));
            switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
            switchArchivedActiveButton.addClickListener(e -> {
                criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE);
                samplesView.navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(switchArchivedActiveButton);
        }

        // Bulk operation dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            shipmentFilterLayout.setWidth(100, Unit.PERCENTAGE);

            MenuBar bulkOperationsDropdown = new MenuBar();
            MenuItem bulkOperationsItem = bulkOperationsDropdown
                    .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

            Command deleteCommand = selectedItem -> {
                ControllerProvider.getSampleController()
                        .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                    deleteCommand);

            actionButtonsLayout.addComponent(bulkOperationsDropdown);
        }
    }
    shipmentFilterLayout.addComponent(actionButtonsLayout);
    shipmentFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
    shipmentFilterLayout.setExpandRatio(actionButtonsLayout, 1);

    return shipmentFilterLayout;
}

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

License:Open Source License

private void updateArchivedButton() {
    if (switchArchivedActiveButton == null) {
        return;//www .j  a va 2 s . c o m
    }

    if (Boolean.TRUE.equals(criteria.getArchived())) {
        viewTitleLabel.setValue(I18nProperties.getPrefixCaption("View",
                SamplesView.VIEW_NAME.replaceAll("/", ".") + ".archive"));
        switchArchivedActiveButton.setCaption(I18nProperties.getCaption(Captions.sampleShowActive));
        switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
    } else {
        viewTitleLabel.setValue(originalViewTitle);
        switchArchivedActiveButton.setCaption(I18nProperties.getCaption(Captions.sampleShowArchived));
        switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
    }
}

From source file:de.symeda.sormas.ui.statistics.DatabaseExportView.java

License:Open Source License

private HorizontalLayout createSelectionButtonsLayout() {
    HorizontalLayout selectionButtonsLayout = new HorizontalLayout();
    selectionButtonsLayout.setMargin(false);
    selectionButtonsLayout.setSpacing(true);

    Button selectAll = new Button(I18nProperties.getCaption(Captions.actionSelectAll));
    CssStyles.style(selectAll, ValoTheme.BUTTON_LINK);
    selectAll.addClickListener(e -> {
        for (CheckBox checkBox : databaseTableToggles.keySet()) {
            checkBox.setValue(true);/*from  w w w  .jav  a 2s.com*/
        }
    });
    selectionButtonsLayout.addComponent(selectAll);

    Button selectAllSormasData = new Button(I18nProperties.getCaption(Captions.exportSelectSormasData));
    CssStyles.style(selectAllSormasData, ValoTheme.BUTTON_LINK);
    selectAllSormasData.addClickListener(e -> {
        for (CheckBox checkBox : databaseTableToggles.keySet()) {
            if (databaseTableToggles.get(checkBox).getDatabaseTableType() == DatabaseTableType.SORMAS) {
                checkBox.setValue(true);
            } else {
                checkBox.setValue(false);
            }
        }
    });
    selectionButtonsLayout.addComponent(selectAllSormasData);

    Button deselectAll = new Button(I18nProperties.getCaption(Captions.actionDeselectAll));
    CssStyles.style(deselectAll, ValoTheme.BUTTON_LINK);
    deselectAll.addClickListener(e -> {
        for (CheckBox checkBox : databaseTableToggles.keySet()) {
            checkBox.setValue(false);
        }
    });
    selectionButtonsLayout.addComponent(deselectAll);

    return selectionButtonsLayout;
}

From source file:de.symeda.sormas.ui.statistics.StatisticsFilterValuesElement.java

License:Open Source License

private VerticalLayout createUtilityButtonsLayout() {
    VerticalLayout utilityButtonsLayout = new VerticalLayout();
    utilityButtonsLayout.setMargin(false);
    utilityButtonsLayout.setSpacing(false);
    utilityButtonsLayout.setSizeUndefined();

    Button addAllButton = new Button(I18nProperties.getCaption(Captions.all), VaadinIcons.PLUS_CIRCLE);
    CssStyles.style(addAllButton, ValoTheme.BUTTON_LINK);
    addAllButton.addClickListener(e -> {
        for (TokenizableValue tokenizable : getFilterValues()) {
            tokenField.addTokenizable(tokenizable);
        }/*w  w w .ja va  2  s . co  m*/
    });

    Button removeAllButton = new Button(I18nProperties.getCaption(Captions.actionClear),
            VaadinIcons.CLOSE_CIRCLE);
    CssStyles.style(removeAllButton, ValoTheme.BUTTON_LINK);
    removeAllButton.addClickListener(e -> {
        for (Tokenizable tokenizable : tokenField.getValue()) {
            tokenField.removeTokenizable(tokenizable);
        }
    });

    utilityButtonsLayout.addComponent(addAllButton);
    utilityButtonsLayout.addComponent(removeAllButton);

    return utilityButtonsLayout;
}

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;//w w w .  ja v  a2s  .c  om
    }

    // 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.TaskGridComponent.java

License:Open Source License

public HorizontalLayout createAssigneeFilterBar() {
    HorizontalLayout assigneeFilterLayout = new HorizontalLayout();
    assigneeFilterLayout.setMargin(false);
    assigneeFilterLayout.setSpacing(true);
    assigneeFilterLayout.setWidth(100, Unit.PERCENTAGE);
    assigneeFilterLayout.addStyleName(CssStyles.VSPACE_3);

    statusButtons = new HashMap<>();

    HorizontalLayout buttonFilterLayout = new HorizontalLayout();
    buttonFilterLayout.setSpacing(true);
    {/*from   w w w  . j  a  v a2 s.  c  o m*/
        Button allTasks = new Button(I18nProperties.getCaption(Captions.all),
                e -> processAssigneeFilterChange(null));
        CssStyles.style(allTasks, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
        allTasks.setCaptionAsHtml(true);
        buttonFilterLayout.addComponent(allTasks);
        statusButtons.put(allTasks, I18nProperties.getCaption(Captions.all));

        Button officerTasks = new Button(I18nProperties.getCaption(Captions.taskOfficerTasks),
                e -> processAssigneeFilterChange(OFFICER_TASKS));
        initializeStatusButton(officerTasks, buttonFilterLayout, OFFICER_TASKS,
                I18nProperties.getCaption(Captions.taskOfficerTasks));
        Button myTasks = new Button(I18nProperties.getCaption(Captions.taskMyTasks),
                e -> processAssigneeFilterChange(MY_TASKS));
        initializeStatusButton(myTasks, buttonFilterLayout, MY_TASKS,
                I18nProperties.getCaption(Captions.taskMyTasks));

        // Default filter for lab users (that don't have any other role) is "My tasks"
        if ((UserProvider.getCurrent().hasUserRole(UserRole.LAB_USER)
                || UserProvider.getCurrent().hasUserRole(UserRole.EXTERNAL_LAB_USER))
                && UserProvider.getCurrent().getUserRoles().size() == 1) {
            activeStatusButton = myTasks;
        } else {
            activeStatusButton = allTasks;
        }
    }
    assigneeFilterLayout.addComponent(buttonFilterLayout);

    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show archived/active cases button
        if (UserProvider.getCurrent().hasUserRight(UserRight.TASK_VIEW_ARCHIVED)) {
            switchArchivedActiveButton = new Button(
                    I18nProperties.getCaption(I18nProperties.getCaption(Captions.taskShowArchived)));
            switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
            switchArchivedActiveButton.addClickListener(e -> {
                criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE);
                tasksView.navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(switchArchivedActiveButton);
        }
        // Bulk operation dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            assigneeFilterLayout.setWidth(100, Unit.PERCENTAGE);

            MenuBar bulkOperationsDropdown = new MenuBar();
            MenuItem bulkOperationsItem = bulkOperationsDropdown
                    .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

            Command deleteCommand = selectedItem -> {
                ControllerProvider.getTaskController()
                        .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                    deleteCommand);

            actionButtonsLayout.addComponent(bulkOperationsDropdown);
        }
    }
    assigneeFilterLayout.addComponent(actionButtonsLayout);
    assigneeFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
    assigneeFilterLayout.setExpandRatio(actionButtonsLayout, 1);

    return assigneeFilterLayout;
}

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

License:Open Source License

private void updateArchivedButton() {
    if (switchArchivedActiveButton == null) {
        return;/* ww w  .j a  va2s .  c  o  m*/
    }

    if (Boolean.TRUE.equals(criteria.getArchived())) {
        viewTitleLabel.setValue(
                I18nProperties.getPrefixCaption("View", TasksView.VIEW_NAME.replaceAll("/", ".") + ".archive"));
        switchArchivedActiveButton
                .setCaption(I18nProperties.getCaption(I18nProperties.getCaption(Captions.taskShowActive)));
        switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
    } else {
        viewTitleLabel.setValue(originalViewTitle);
        switchArchivedActiveButton
                .setCaption(I18nProperties.getCaption(I18nProperties.getCaption(Captions.taskShowArchived)));
        switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
    }
}

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/* ww 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;
}