Example usage for com.vaadin.ui Label setValue

List of usage examples for com.vaadin.ui Label setValue

Introduction

In this page you can find the example usage for com.vaadin.ui Label setValue.

Prototype

public void setValue(String value) 

Source Link

Document

Sets the text to be shown in the label.

Usage

From source file:de.mendelson.comm.as2.webclient2.TransactionDetailsDialog.java

private Label generateImageLabel(ThemeResource resource) {
    Label label = new Label();
    label.setContentMode(Label.CONTENT_XHTML);
    label.setIcon(resource);/*from  w ww  .  j  a v  a  2s .c o m*/
    label.setValue("<img src=\"" + themeURI + resource.getResourceId() + "\" />");
    return (label);
}

From source file:de.metas.ui.web.vaadin.window.view.WindowRecordIndicators.java

License:Open Source License

private Component createIndicatorComp(final String label, final String color) {
    final String indicatorId = STYLE_Indicator + "-" + (nextIndicatorId++);

    final Label comp = new Label();
    comp.setId(indicatorId);/* w  ww.  ja v a 2 s.  com*/
    comp.setPrimaryStyleName(STYLE_Indicator);
    comp.setValue(label);

    indicatorId2color.put(indicatorId, color);

    return comp;
}

From source file:de.symeda.sormas.ui.caze.AbstractCaseView.java

License:Open Source License

@Override
public void refreshMenu(SubMenu menu, Label infoLabel, Label infoLabelSub, String params) {
    String[] passedParams = params.split("\\?");
    if (passedParams.length > 0) {
        // Remove possible slash from filters
        String uuid = passedParams[0].replaceAll("/", "");
        caseRef = FacadeProvider.getCaseFacade().getReferenceByUuid(uuid);
    }/*from  w w  w .j a  v  a2s  .c o  m*/

    if (caseRef == null) {
        ControllerProvider.getCaseController().navigateToIndex();
        return;
    }

    CaseDataDto caze = FacadeProvider.getCaseFacade().getCaseDataByUuid(caseRef.getUuid());

    // Handle outbreaks for the disease and district of the case
    if (FacadeProvider.getOutbreakFacade().hasOutbreak(caze.getDistrict(), caze.getDisease())
            && caze.getDisease().usesSimpleViewForOutbreaks()) {
        hasOutbreak = true;

        //         viewConfiguration.setViewMode(ViewMode.SIMPLE);
        //         // param might change this
        //         if (passedParams.length > 1 && passedParams[1].startsWith(VIEW_MODE_URL_PREFIX + "=")) {
        //            String viewModeString = passedParams[1].substring(2);
        //            try {
        //               viewConfiguration.setViewMode(ViewMode.valueOf(viewModeString.toUpperCase()));
        //            } catch (IllegalArgumentException ex) { } // just ignore
        //         }
        //
        viewModeToggle.removeValueChangeListener(viewModeToggleListener);
        viewModeToggle.setValue(viewConfiguration.getViewMode());
        viewModeToggle.addValueChangeListener(viewModeToggleListener);
        viewModeToggle.setVisible(true);

    } else {
        hasOutbreak = false;
        viewModeToggle.setVisible(false);
    }

    menu.removeAllViews();
    menu.addView(CasesView.VIEW_NAME,
            I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, Captions.caseCasesList));
    menu.addView(CaseDataView.VIEW_NAME, I18nProperties.getCaption(CaseDataDto.I18N_PREFIX), params);

    if (!hasOutbreak || !caze.getDisease().usesSimpleViewForOutbreaks()
            || viewConfiguration.getViewMode() != ViewMode.SIMPLE) {
        menu.addView(CasePersonView.VIEW_NAME,
                I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.PERSON), params);
        if (caze.getDisease() == Disease.CONGENITAL_RUBELLA) {
            menu.addView(MaternalHistoryView.VIEW_NAME,
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.MATERNAL_HISTORY),
                    params);
        }
        if (!caze.isUnreferredPortHealthCase()
                && !UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) {
            menu.addView(HospitalizationView.VIEW_NAME,
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.HOSPITALIZATION),
                    params);
        }
        if (caze.getCaseOrigin() == CaseOrigin.POINT_OF_ENTRY
                && UserProvider.getCurrent().hasUserRight(UserRight.PORT_HEALTH_INFO_VIEW)) {
            menu.addView(PortHealthInfoView.VIEW_NAME,
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.PORT_HEALTH_INFO),
                    params);
        }
        menu.addView(CaseSymptomsView.VIEW_NAME,
                I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.SYMPTOMS), params);
        if (caze.getDisease() != Disease.CONGENITAL_RUBELLA) {
            menu.addView(EpiDataView.VIEW_NAME,
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.EPI_DATA), params);
        }
        if (UserProvider.getCurrent().hasUserRight(UserRight.THERAPY_VIEW)
                && !caze.isUnreferredPortHealthCase()) {
            menu.addView(TherapyView.VIEW_NAME,
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.THERAPY), params);
        }
        if (UserProvider.getCurrent().hasUserRight(UserRight.CLINICAL_COURSE_VIEW)
                && !caze.isUnreferredPortHealthCase()) {
            menu.addView(ClinicalCourseView.VIEW_NAME,
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CLINICAL_COURSE),
                    params);
        }
    }
    if (FacadeProvider.getDiseaseConfigurationFacade().hasFollowUp(caze.getDisease())
            && UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW)
            && !caze.isUnreferredPortHealthCase()) {
        menu.addView(CaseContactsView.VIEW_NAME,
                I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, Captions.caseContacts), params);
    }

    infoLabel.setValue(caseRef.getCaption());

    infoLabelSub.setValue(caze.getDisease() != Disease.OTHER ? DataHelper.toStringNullable(caze.getDisease())
            : DataHelper.toStringNullable(caze.getDiseaseDetails()));
}

From source file:de.symeda.sormas.ui.caze.CaseController.java

License:Open Source License

public void openClassificationRulesPopup(CaseDataDto caze) {
    VerticalLayout classificationRulesLayout = new VerticalLayout();
    classificationRulesLayout.setMargin(true);

    DiseaseClassificationCriteriaDto diseaseCriteria = FacadeProvider.getCaseClassificationFacade()
            .getByDisease(caze.getDisease());
    if (diseaseCriteria != null) {
        Label suspectContent = new Label();
        suspectContent.setContentMode(ContentMode.HTML);
        suspectContent.setWidth(100, Unit.PERCENTAGE);
        suspectContent.setValue(ClassificationHtmlRenderer.createSuspectHtmlString(diseaseCriteria));
        classificationRulesLayout.addComponent(suspectContent);

        Label probableContent = new Label();
        probableContent.setContentMode(ContentMode.HTML);
        probableContent.setWidth(100, Unit.PERCENTAGE);
        probableContent.setValue(ClassificationHtmlRenderer.createProbableHtmlString(diseaseCriteria));
        classificationRulesLayout.addComponent(probableContent);

        Label confirmedContent = new Label();
        confirmedContent.setContentMode(ContentMode.HTML);
        confirmedContent.setWidth(100, Unit.PERCENTAGE);
        confirmedContent.setValue(ClassificationHtmlRenderer.createConfirmedHtmlString(diseaseCriteria));
        classificationRulesLayout.addComponent(confirmedContent);
    }//  w  ww.j a v  a2 s . c om

    Window popupWindow = VaadinUiUtil.showPopupWindow(classificationRulesLayout);
    popupWindow.addCloseListener(e -> {
        popupWindow.close();
    });
    popupWindow.setWidth(860, Unit.PIXELS);
    popupWindow.setHeight(80, Unit.PERCENTAGE);
    popupWindow.setCaption(
            I18nProperties.getString(Strings.classificationRulesFor) + " " + caze.getDisease().toString());
}

From source file:de.symeda.sormas.ui.contact.AbstractContactView.java

License:Open Source License

@Override
public void refreshMenu(SubMenu menu, Label infoLabel, Label infoLabelSub, String params) {

    ContactDto contact = FacadeProvider.getContactFacade().getContactByUuid(params);
    contactRef = FacadeProvider.getContactFacade().getReferenceByUuid(contact.getUuid());

    menu.removeAllViews();//from  w w w. j  ava  2 s  . c o m
    menu.addView(ContactsView.VIEW_NAME, I18nProperties.getCaption(Captions.contactContactsList));
    menu.addView(CaseContactsView.VIEW_NAME, I18nProperties.getCaption(Captions.contactCaseContacts),
            contact.getCaze().getUuid(), true);
    menu.addView(ContactDataView.VIEW_NAME, I18nProperties.getCaption(ContactDto.I18N_PREFIX), params);
    menu.addView(ContactPersonView.VIEW_NAME,
            I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, ContactDto.PERSON), params);
    menu.addView(ContactVisitsView.VIEW_NAME,
            I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, ContactDto.VISITS), params);

    infoLabel.setValue(contactRef.getCaption());
    CaseDataDto caseData = FacadeProvider.getCaseFacade().getCaseDataByUuid(contact.getCaze().getUuid());
    infoLabelSub.setValue(caseData.getDisease() != Disease.OTHER ? caseData.getDisease().toShortString()
            : DataHelper.toStringNullable(caseData.getDiseaseDetails()));
}

From source file:de.symeda.sormas.ui.dashboard.map.DashboardMapComponent.java

License:Open Source License

private HorizontalLayout createHeader() {
    HorizontalLayout mapHeaderLayout = new HorizontalLayout();
    mapHeaderLayout.setWidth(100, Unit.PERCENTAGE);
    mapHeaderLayout.setSpacing(true);//from  www . j av a  2  s  .c  o m
    CssStyles.style(mapHeaderLayout, CssStyles.VSPACE_4);

    Label mapLabel = new Label();
    if (dashboardDataProvider.getDashboardType() == DashboardType.SURVEILLANCE) {
        mapLabel.setValue(I18nProperties.getString(Strings.headingCaseStatusMap));
    } else {
        mapLabel.setValue(I18nProperties.getString(Strings.headingContactMap));
    }
    mapLabel.setSizeUndefined();
    CssStyles.style(mapLabel, CssStyles.H2, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);

    mapHeaderLayout.addComponent(mapLabel);
    mapHeaderLayout.setComponentAlignment(mapLabel, Alignment.BOTTOM_LEFT);
    mapHeaderLayout.setExpandRatio(mapLabel, 1);

    // "Expand" and "Collapse" buttons
    Button expandMapButton = new Button("", VaadinIcons.EXPAND);
    CssStyles.style(expandMapButton, CssStyles.BUTTON_SUBTLE);
    expandMapButton.addStyleName(CssStyles.VSPACE_NONE);
    Button collapseMapButton = new Button("", VaadinIcons.COMPRESS);
    CssStyles.style(collapseMapButton, CssStyles.BUTTON_SUBTLE);
    collapseMapButton.addStyleName(CssStyles.VSPACE_NONE);

    expandMapButton.addClickListener(e -> {
        externalExpandListener.accept(true);
        mapHeaderLayout.removeComponent(expandMapButton);
        mapHeaderLayout.addComponent(collapseMapButton);
        mapHeaderLayout.setComponentAlignment(collapseMapButton, Alignment.MIDDLE_RIGHT);
    });
    collapseMapButton.addClickListener(e -> {
        externalExpandListener.accept(false);
        mapHeaderLayout.removeComponent(collapseMapButton);
        mapHeaderLayout.addComponent(expandMapButton);
        mapHeaderLayout.setComponentAlignment(expandMapButton, Alignment.MIDDLE_RIGHT);
    });
    mapHeaderLayout.addComponent(expandMapButton);
    mapHeaderLayout.setComponentAlignment(expandMapButton, Alignment.MIDDLE_RIGHT);

    return mapHeaderLayout;
}

From source file:de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsDiseaseElement.java

License:Open Source License

public DashboardStatisticsDiseaseElement(String caption, int count, int previousCount) {
    setMargin(false);//from ww  w  .  ja v  a  2 s.  co  m
    setSpacing(true);
    Label captionLabel = new Label(caption);
    captionLabel.setWidthUndefined();
    CssStyles.style(captionLabel, CssStyles.LABEL_SECONDARY, CssStyles.LABEL_BOLD, CssStyles.LABEL_LARGE);
    addComponent(captionLabel);

    Label lineLabel = new Label("&nbsp;", ContentMode.HTML);
    CssStyles.style(lineLabel, CssStyles.LABEL_BOTTOM_LINE);
    addComponent(lineLabel);

    Label countLabel = new Label(Integer.toString(count));
    countLabel.setWidthUndefined();
    CssStyles.style(countLabel, CssStyles.LABEL_SECONDARY, CssStyles.LABEL_BOLD, CssStyles.LABEL_LARGE);
    addComponent(countLabel);

    Label growthLabel = new Label();
    growthLabel.setContentMode(ContentMode.HTML);
    growthLabel.setWidth(15, Unit.PIXELS);

    CssStyles.removeStyles(growthLabel, CssStyles.LABEL_CRITICAL, CssStyles.LABEL_POSITIVE,
            CssStyles.LABEL_IMPORTANT);
    if (count > previousCount) {
        growthLabel.setValue(VaadinIcons.CHEVRON_UP.getHtml());
        CssStyles.style(growthLabel, CssStyles.LABEL_CRITICAL);
    } else if (count == previousCount) {
        growthLabel.setValue(VaadinIcons.CHEVRON_RIGHT.getHtml());
        CssStyles.style(growthLabel, CssStyles.LABEL_IMPORTANT, CssStyles.ALIGN_CENTER);
    } else {
        growthLabel.setValue(VaadinIcons.CHEVRON_DOWN.getHtml());
        CssStyles.style(growthLabel, CssStyles.LABEL_POSITIVE);
    }

    CssStyles.style(growthLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_LARGE);
    addComponent(growthLabel);

    setExpandRatio(lineLabel, 1);
}

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

License:Open Source License

@Override
public void refreshMenu(SubMenu menu, Label infoLabel, Label infoLabelSub, String params) {
    eventRef = FacadeProvider.getEventFacade().getReferenceByUuid(params);

    menu.removeAllViews();//from w  w w  .j  ava2  s.com
    menu.addView(EventsView.VIEW_NAME, I18nProperties.getCaption(Captions.eventEventsList));
    menu.addView(EventDataView.VIEW_NAME, I18nProperties.getCaption(EventDto.I18N_PREFIX), params);
    menu.addView(EventParticipantsView.VIEW_NAME, I18nProperties.getCaption(Captions.eventEventParticipants),
            params);
    infoLabel.setValue(eventRef.getCaption());
    infoLabelSub.setValue(DataHelper.getShortUuid(eventRef.getUuid()));
}

From source file:de.symeda.sormas.ui.importer.ImportPersonSelectField.java

License:Open Source License

@Override
protected Component initContent() {
    if (importedCase == null || importedPerson == null) {
        return null;
    }/*from  www.  ja  v  a 2s.  c  o  m*/

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeUndefined();
    layout.setWidth(100, Unit.PERCENTAGE);

    // Info label

    Label infoLabel = new Label(I18nProperties.getString(Strings.infoImportSimilarity));
    CssStyles.style(infoLabel, CssStyles.VSPACE_3);
    layout.addComponent(infoLabel);

    // Imported case info
    VerticalLayout outerCaseInfoLayout = new VerticalLayout();
    outerCaseInfoLayout.setWidth(100, Unit.PERCENTAGE);
    CssStyles.style(outerCaseInfoLayout, CssStyles.BACKGROUND_ROUNDED_CORNERS,
            CssStyles.BACKGROUND_SUB_CRITERIA, CssStyles.VSPACE_3, "v-scrollable");

    Label importedCaseLabel = new Label(I18nProperties.getString(Strings.headingImportedCaseInfo));
    CssStyles.style(importedCaseLabel, CssStyles.LABEL_BOLD, CssStyles.VSPACE_4);
    outerCaseInfoLayout.addComponent(importedCaseLabel);

    HorizontalLayout caseInfoLayout = new HorizontalLayout();
    caseInfoLayout.setSpacing(true);
    caseInfoLayout.setSizeUndefined();
    {
        Label diseaseField = new Label();
        diseaseField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISEASE));
        diseaseField
                .setValue(DiseaseHelper.toString(importedCase.getDisease(), importedCase.getDiseaseDetails()));
        diseaseField.setWidthUndefined();
        caseInfoLayout.addComponent(diseaseField);

        Label caseDateField = new Label();
        if (importedCase.getSymptoms().getOnsetDate() != null) {
            caseDateField.setCaption(
                    I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE));
            caseDateField.setValue(DateHelper.formatLocalShortDate(importedCase.getSymptoms().getOnsetDate()));
        } else {
            caseDateField.setCaption(
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REPORT_DATE));
            caseDateField.setValue(DateHelper.formatLocalShortDate(importedCase.getReportDate()));
        }
        caseDateField.setWidthUndefined();
        caseInfoLayout.addComponent(caseDateField);

        Label regionField = new Label();
        regionField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REGION));
        regionField.setValue(importedCase.getRegion().toString());
        regionField.setWidthUndefined();
        caseInfoLayout.addComponent(regionField);

        Label districtField = new Label();
        districtField
                .setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISTRICT));
        districtField.setValue(importedCase.getDistrict().toString());
        districtField.setWidthUndefined();
        caseInfoLayout.addComponent(districtField);

        Label communityField = new Label();
        communityField
                .setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.COMMUNITY));
        communityField
                .setValue(importedCase.getCommunity() != null ? importedCase.getCommunity().toString() : "");
        communityField.setWidthUndefined();
        caseInfoLayout.addComponent(communityField);

        Label facilityField = new Label();
        facilityField.setCaption(
                I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.HEALTH_FACILITY));
        facilityField.setValue(FacilityHelper.buildFacilityString(null,
                importedCase.getHealthFacility() != null ? importedCase.getHealthFacility().toString() : "",
                importedCase.getHealthFacilityDetails()));
        facilityField.setWidthUndefined();
        caseInfoLayout.addComponent(facilityField);
    }

    outerCaseInfoLayout.addComponent(caseInfoLayout);
    layout.addComponent(outerCaseInfoLayout);

    // Imported person info
    VerticalLayout outerPersonInfoLayout = new VerticalLayout();
    outerPersonInfoLayout.setWidth(100, Unit.PERCENTAGE);
    CssStyles.style(outerPersonInfoLayout, CssStyles.BACKGROUND_ROUNDED_CORNERS,
            CssStyles.BACKGROUND_SUB_CRITERIA, CssStyles.VSPACE_3, "v-scrollable");

    Label importedPersonLabel = new Label(I18nProperties.getString(Strings.headingImportedPersonInfo));
    CssStyles.style(importedPersonLabel, CssStyles.LABEL_BOLD, CssStyles.VSPACE_4);
    outerPersonInfoLayout.addComponent(importedPersonLabel);

    HorizontalLayout personInfoLayout = new HorizontalLayout();
    personInfoLayout.setSpacing(true);
    personInfoLayout.setSizeUndefined();
    {
        Label firstNameField = new Label();
        firstNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.FIRST_NAME));
        firstNameField.setValue(importedPerson.getFirstName());
        firstNameField.setWidthUndefined();
        personInfoLayout.addComponent(firstNameField);

        Label lastNameField = new Label();
        lastNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.LAST_NAME));
        lastNameField.setValue(importedPerson.getLastName());
        lastNameField.setWidthUndefined();
        personInfoLayout.addComponent(lastNameField);

        Label nicknameField = new Label();
        nicknameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.NICKNAME));
        nicknameField.setValue(importedPerson.getNickname());
        nicknameField.setWidthUndefined();
        personInfoLayout.addComponent(nicknameField);

        Label ageField = new Label();
        ageField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.APPROXIMATE_AGE));
        ageField.setValue(ApproximateAgeHelper.formatApproximateAge(importedPerson.getApproximateAge(),
                importedPerson.getApproximateAgeType()));
        ageField.setWidthUndefined();
        personInfoLayout.addComponent(ageField);

        Label sexField = new Label();
        sexField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.SEX));
        sexField.setValue(importedPerson.getSex() != null ? importedPerson.getSex().toString() : "");
        sexField.setWidthUndefined();
        personInfoLayout.addComponent(sexField);

        Label presentConditionField = new Label();
        presentConditionField.setCaption(
                I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.PRESENT_CONDITION));
        presentConditionField.setValue(
                importedPerson.getPresentCondition() != null ? importedPerson.getPresentCondition().toString()
                        : null);
        presentConditionField.setWidthUndefined();
        personInfoLayout.addComponent(presentConditionField);

        Label regionField = new Label();
        regionField.setCaption(I18nProperties.getPrefixCaption(LocationDto.I18N_PREFIX, LocationDto.REGION));
        regionField.setValue(importedPerson.getAddress().getRegion() != null
                ? importedPerson.getAddress().getRegion().toString()
                : "");
        regionField.setWidthUndefined();
        personInfoLayout.addComponent(regionField);

        Label districtField = new Label();
        districtField
                .setCaption(I18nProperties.getPrefixCaption(LocationDto.I18N_PREFIX, LocationDto.DISTRICT));
        districtField.setValue(importedPerson.getAddress().getDistrict() != null
                ? importedPerson.getAddress().getDistrict().toString()
                : "");
        districtField.setWidthUndefined();
        personInfoLayout.addComponent(districtField);

        Label communityField = new Label();
        communityField
                .setCaption(I18nProperties.getPrefixCaption(LocationDto.I18N_PREFIX, LocationDto.COMMUNITY));
        communityField.setValue(importedPerson.getAddress().getCommunity() != null
                ? importedPerson.getAddress().getCommunity().toString()
                : "");
        communityField.setWidthUndefined();
        personInfoLayout.addComponent(communityField);

        Label cityField = new Label();
        cityField.setCaption(I18nProperties.getPrefixCaption(LocationDto.I18N_PREFIX, LocationDto.CITY));
        cityField.setValue(importedPerson.getAddress().getCity());
        cityField.setWidthUndefined();
        personInfoLayout.addComponent(cityField);
    }

    outerPersonInfoLayout.addComponent(personInfoLayout);
    layout.addComponent(outerPersonInfoLayout);

    // Person selection/creation
    selectPerson = new OptionGroup(null);
    selectPerson.addItem(SELECT_PERSON);
    selectPerson.setItemCaption(SELECT_PERSON, I18nProperties.getCaption(Captions.personSelect));
    CssStyles.style(selectPerson, CssStyles.VSPACE_NONE);
    selectPerson.addValueChangeListener(e -> {
        if (e.getProperty().getValue() != null) {
            createNewPerson.setValue(null);
            personGrid.setEnabled(true);
            mergeCheckBox.setEnabled(true);
            if (selectionChangeCallback != null) {
                selectionChangeCallback.accept(personGrid.getSelectedRow() != null);
            }
        }
    });
    layout.addComponent(selectPerson);

    mergeCheckBox = new CheckBox();
    mergeCheckBox.setCaption(I18nProperties.getCaption(Captions.caseImportMergeCase));
    CssStyles.style(mergeCheckBox, CssStyles.VSPACE_3);
    layout.addComponent(mergeCheckBox);

    initPersonGrid();
    // Deselect "create new" when person is selected
    personGrid.addSelectionListener(e -> {
        if (e.getSelected().size() > 0) {
            createNewPerson.setValue(null);
        }
    });
    CssStyles.style(personGrid, CssStyles.VSPACE_3);
    layout.addComponent(personGrid);

    personGrid.addSelectionListener(e -> {
        if (selectionChangeCallback != null) {
            selectionChangeCallback.accept(!e.getSelected().isEmpty());
        }
    });

    createNewPerson = new OptionGroup(null);
    createNewPerson.addItem(CREATE_PERSON);
    createNewPerson.setItemCaption(CREATE_PERSON, I18nProperties.getCaption(Captions.personCreateNew));
    // Deselect grid when "create new" is selected
    createNewPerson.addValueChangeListener(e -> {
        if (e.getProperty().getValue() != null) {
            selectPerson.setValue(null);
            personGrid.select(null);
            personGrid.setEnabled(false);
            mergeCheckBox.setEnabled(false);
            if (selectionChangeCallback != null) {
                selectionChangeCallback.accept(true);
            }
        }
    });
    layout.addComponent(createNewPerson);

    // Set field values based on internal value
    setInternalValue(super.getInternalValue());

    return layout;
}

From source file:de.symeda.sormas.ui.login.LoginScreen.java

License:Open Source License

private CssLayout buildLoginSidebarLayout() {
    CssLayout loginSidebarLayout = new CssLayout();
    loginSidebarLayout.setStyleName("login-sidebar");

    Label htmlLabel = new Label();
    htmlLabel.setContentMode(ContentMode.HTML);

    Path customHtmlDirectory = Paths.get(FacadeProvider.getConfigFacade().getCustomFilesPath());
    Path filePath = customHtmlDirectory.resolve("loginsidebar.html");

    try {// w w w .  j  av a 2  s. co m
        byte[] encoded = Files.readAllBytes(filePath);
        htmlLabel.setValue(new String(encoded, "UTF-8"));
    } catch (IOException e) {
        htmlLabel.setValue("");
    }

    loginSidebarLayout.addComponent(htmlLabel);
    return loginSidebarLayout;
}