Example usage for com.vaadin.ui VerticalLayout setSizeUndefined

List of usage examples for com.vaadin.ui VerticalLayout setSizeUndefined

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setSizeUndefined.

Prototype

@Override
    public void setSizeUndefined() 

Source Link

Usage

From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java

private void addLinkUserContainer() {

    VerticalLayout cDeletePrompt = new VerticalLayout();
    cPlaceholder.addComponent(cDeletePrompt);
    cPlaceholder.setComponentAlignment(cDeletePrompt, Alignment.MIDDLE_CENTER);
    // cDeletePrompt.setWidth("100%");
    cDeletePrompt.setStyleName("c_link");
    cDeletePrompt.setSpacing(true);//www  . ja v a2s  . c om
    String username = curUser;

    Label lbActivationPrompt = new Label(
            "<span style='text-align: center;'>Please enter Child Username to link to " + username
                    + "'s Account</span>");
    lbActivationPrompt.setContentMode(ContentMode.HTML);
    lbActivationPrompt.setWidth("300px");
    lbActivationPrompt.setStyleName("lb_link_user");

    cDeletePrompt.addComponent(lbActivationPrompt);
    cDeletePrompt.setComponentAlignment(lbActivationPrompt, Alignment.TOP_LEFT);

    VerticalLayout frmDeleteReason = new VerticalLayout();
    frmDeleteReason.setSizeUndefined();
    frmDeleteReason.setSpacing(true);
    frmDeleteReason.setMargin(true);
    cDeletePrompt.addComponent(frmDeleteReason);
    cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.TOP_CENTER);

    tFU = new TextField("Child Username");
    tFU.setRequired(true);

    final ComboBox comboUProf = new ComboBox("Select Profile");
    comboUProf.setNullSelectionAllowed(false);
    comboUProf.setRequired(true);
    comboUProf.addItem(8);
    comboUProf.setItemCaption(8, "DEPOSIT_ONLY");

    comboUProf.addItem(9);
    comboUProf.setItemCaption(9, "DEPOSIT_AND_WITHDRAWAL");

    comboUProf.select(8);

    final TextField tFP = new TextField("Parent Account ID");
    tFP.setValue(username);
    tFP.setEnabled(false);

    final TextField tFInitUser = new TextField("Initiating User");
    tFInitUser.setValue(UI.getCurrent().getSession().getAttribute("user").toString());
    tFInitUser.focus();
    tFInitUser.setEnabled(false);

    frmDeleteReason.addComponent(tFU);
    frmDeleteReason.addComponent(comboUProf);
    frmDeleteReason.addComponent(tFP);
    frmDeleteReason.addComponent(tFInitUser);

    HorizontalLayout cPopupBtns = new HorizontalLayout();
    cPopupBtns.setSizeUndefined();
    cPopupBtns.setSpacing(true);

    final Button btnCancel = new Button();
    btnCancel.setIcon(FontAwesome.UNDO);
    btnCancel.setStyleName("btn_link");
    btnCancel.setDescription("Cancel");

    final Button btnSet = new Button("Link");
    btnSet.setDescription("Link specified account.");
    btnSet.setIcon(FontAwesome.LINK);
    cPopupBtns.addComponent(btnSet);
    cPopupBtns.addComponent(btnCancel);
    frmDeleteReason.addComponent(cPopupBtns);

    cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.MIDDLE_CENTER);
    btnSet.setClickShortcut(KeyCode.ENTER, null);

    btnSet.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -6318666715385643538L;

        @Override
        public void buttonClick(ClickEvent event) {

            tFU.validate();
            btnSet.setEnabled(false);
            btnCancel.setEnabled(false);

            Button btn = event.getButton();

            if (ums == null)
                ums = new UserManagementService();
            btn.setEnabled(false);

            String strResponse = null;
            try {

                strResponse = UserManagementService.linkUser(tFP.getValue(),
                        new Integer(comboUProf.getValue().toString()), tFInitUser.getValue(), tFU.getValue());

                if (strResponse.equals("The operation was successful and completed")) {

                    updateLinksTable(tFU.getValue());
                    cPlaceholder.setVisible(false);
                    tFU.setValue("");
                    btnLink.setVisible(true);

                    NotifCustom.show("Link", strResponse);

                } else {
                    NotifCustom.show("Link", strResponse);
                }

            } catch (RemoteException e) {

                e.printStackTrace();

            }

            btnSet.setEnabled(true);
            btnCancel.setEnabled(true);

        }
    });

    btnCancel.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 7161821652386306043L;

        @Override
        public void buttonClick(ClickEvent event) {
            btnLink.setVisible(true);
            cPlaceholder.setVisible(false);

        }

    });

}

From source file:com.toptal.ui.view.LoginView.java

License:Open Source License

/**
 * Adds login form.//  w ww .  j av  a 2s  . co m
 */
private void addForm() {
    final VerticalLayout form = new VerticalLayout();
    form.setSizeUndefined();
    form.setSpacing(true);
    form.addComponent(this.header());
    form.addComponent(this.content());
    this.addComponent(form);
    this.setComponentAlignment(form, Alignment.MIDDLE_CENTER);
}

From source file:com.wcs.wcslib.vaadin.widget.multifileupload.ui.ConfirmDialog.java

License:Apache License

private void initForm() {
    VerticalLayout windowLayout = new VerticalLayout();
    setContent(windowLayout);/*from   w w  w .j  a v a  2s  .  co  m*/
    windowLayout.setSizeUndefined();
    windowLayout.setMargin(true);
    setCaption(confirmHeader);

    question = new Label(confirmQuestion);
    windowLayout.addComponent(question);

    HorizontalLayout buttonLayout = createButtonLayout();
    windowLayout.addComponent(buttonLayout);
    windowLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_CENTER);
}

From source file:com.wintindustries.pfserver.interfaces.view.dashboard.LoginView.java

private Component buildLoginForm() {
    final VerticalLayout loginPanel = new VerticalLayout();
    loginPanel.setSizeUndefined();
    loginPanel.setSpacing(true);//from w  w w. j av  a2s  . com
    Responsive.makeResponsive(loginPanel);
    loginPanel.addStyleName("login-panel");

    loginPanel.addComponent(buildLabels());
    loginPanel.addComponent(buildFields());
    loginPanel.addComponent(new CheckBox("Remember me", true));
    return loginPanel;
}

From source file:de.symeda.sormas.ui.dashboard.contacts.ContactsEpiCurveComponent.java

License:Open Source License

@Override
protected PopupButton createEpiCurveModeSelector() {
    if (epiCurveContactsMode == null) {
        epiCurveContactsMode = ContactsEpiCurveMode.FOLLOW_UP_STATUS;
        epiCurveLabel.setValue(epiCurveContactsMode.toString() + " Chart");
    }//from  ww  w  .  j  a va  2 s . co  m

    PopupButton dataDropdown = new PopupButton(I18nProperties.getCaption(Captions.dashboardData));
    CssStyles.style(dataDropdown, CssStyles.BUTTON_SUBTLE);

    VerticalLayout groupingLayout = new VerticalLayout();
    groupingLayout.setMargin(true);
    groupingLayout.setSizeUndefined();
    dataDropdown.setContent(groupingLayout);

    OptionGroup dataSelect = new OptionGroup();
    dataSelect.setWidth(100, Unit.PERCENTAGE);
    dataSelect.addItems((Object[]) ContactsEpiCurveMode.values());
    dataSelect.setValue(epiCurveContactsMode);
    dataSelect.select(epiCurveContactsMode);
    dataSelect.addValueChangeListener(e -> {
        epiCurveContactsMode = (ContactsEpiCurveMode) e.getProperty().getValue();
        epiCurveLabel.setValue(epiCurveContactsMode.toString() + " Chart");
        clearAndFillEpiCurveChart();
    });
    groupingLayout.addComponent(dataSelect);

    return dataDropdown;
}

From source file:de.symeda.sormas.ui.dashboard.diagram.AbstractEpiCurveComponent.java

License:Open Source License

private HorizontalLayout createFooter() {
    HorizontalLayout epiCurveFooterLayout = new HorizontalLayout();
    epiCurveFooterLayout.setWidth(100, Unit.PERCENTAGE);
    epiCurveFooterLayout.setSpacing(true);
    CssStyles.style(epiCurveFooterLayout, CssStyles.VSPACE_4);

    // Grouping/*from   w  ww .  ja  v a 2  s  .c  om*/
    PopupButton groupingDropdown = new PopupButton(I18nProperties.getCaption(Captions.dashboardGrouping));
    CssStyles.style(groupingDropdown, CssStyles.BUTTON_SUBTLE);
    {
        VerticalLayout groupingLayout = new VerticalLayout();
        groupingLayout.setMargin(true);
        groupingLayout.setSizeUndefined();
        groupingDropdown.setContent(groupingLayout);

        // Grouping option group
        OptionGroup groupingSelect = new OptionGroup();
        groupingSelect.setWidth(100, Unit.PERCENTAGE);
        groupingSelect.addItems((Object[]) EpiCurveGrouping.values());
        groupingSelect.setValue(epiCurveGrouping);
        groupingSelect.addValueChangeListener(e -> {
            epiCurveGrouping = (EpiCurveGrouping) e.getProperty().getValue();
            clearAndFillEpiCurveChart();
        });
        groupingLayout.addComponent(groupingSelect);

        // "Always show at least 7 entries" checkbox
        CheckBox minimumEntriesCheckbox = new CheckBox(
                I18nProperties.getCaption(Captions.dashboardShowMinimumEntries));
        CssStyles.style(minimumEntriesCheckbox, CssStyles.VSPACE_NONE);
        minimumEntriesCheckbox.setValue(showMinimumEntries);
        minimumEntriesCheckbox.addValueChangeListener(e -> {
            showMinimumEntries = (boolean) e.getProperty().getValue();
            clearAndFillEpiCurveChart();
        });
        groupingLayout.addComponent(minimumEntriesCheckbox);

        groupingDropdown.setContent(groupingLayout);
    }
    epiCurveFooterLayout.addComponent(groupingDropdown);
    epiCurveFooterLayout.setComponentAlignment(groupingDropdown, Alignment.MIDDLE_RIGHT);
    epiCurveFooterLayout.setExpandRatio(groupingDropdown, 1);

    // Epi curve mode
    AbstractComponent epiCurveModeSelector = createEpiCurveModeSelector();
    epiCurveFooterLayout.addComponent(epiCurveModeSelector);
    epiCurveFooterLayout.setComponentAlignment(epiCurveModeSelector, Alignment.MIDDLE_RIGHT);
    epiCurveFooterLayout.setExpandRatio(epiCurveModeSelector, 0);

    return epiCurveFooterLayout;
}

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

License:Open Source License

private HorizontalLayout createFooter() {
    HorizontalLayout mapFooterLayout = new HorizontalLayout();
    mapFooterLayout.setWidth(100, Unit.PERCENTAGE);
    mapFooterLayout.setSpacing(true);/*from  w ww  . j a v  a 2s .c  om*/
    CssStyles.style(mapFooterLayout, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);

    // Map key dropdown button
    legendDropdown = new PopupButton(I18nProperties.getCaption(Captions.dashboardMapKey));
    CssStyles.style(legendDropdown, CssStyles.BUTTON_SUBTLE);
    legendDropdown.setContent(createLegend());
    mapFooterLayout.addComponent(legendDropdown);
    mapFooterLayout.setComponentAlignment(legendDropdown, Alignment.MIDDLE_RIGHT);
    mapFooterLayout.setExpandRatio(legendDropdown, 1);

    // Layers dropdown button
    PopupButton layersDropdown = new PopupButton(I18nProperties.getCaption(Captions.dashboardMapLayers));
    {
        CssStyles.style(layersDropdown, CssStyles.BUTTON_SUBTLE);

        VerticalLayout layersLayout = new VerticalLayout();
        layersLayout.setMargin(true);
        layersLayout.setSpacing(false);
        layersLayout.setSizeUndefined();
        layersDropdown.setContent(layersLayout);

        // Add check boxes and apply button
        {
            OptionGroup mapCaseDisplayModeSelect = new OptionGroup();
            mapCaseDisplayModeSelect.setWidth(100, Unit.PERCENTAGE);
            mapCaseDisplayModeSelect.addItems((Object[]) MapCaseDisplayMode.values());
            mapCaseDisplayModeSelect.setValue(mapCaseDisplayMode);
            mapCaseDisplayModeSelect.addValueChangeListener(event -> {
                mapCaseDisplayMode = (MapCaseDisplayMode) event.getProperty().getValue();
                refreshMap();
            });

            HorizontalLayout showCasesLayout = new HorizontalLayout();
            {
                showCasesLayout.setMargin(false);
                showCasesLayout.setSpacing(false);
                CheckBox showCasesCheckBox = new CheckBox();
                showCasesCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowCases));
                showCasesCheckBox.setValue(showCases);
                showCasesCheckBox.addValueChangeListener(e -> {
                    showCases = (boolean) e.getProperty().getValue();
                    mapCaseDisplayModeSelect.setEnabled(showCases);
                    mapCaseDisplayModeSelect.setValue(mapCaseDisplayMode);
                    refreshMap();
                });
                showCasesLayout.addComponent(showCasesCheckBox);

                Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
                infoLabel.setDescription(I18nProperties.getString(Strings.infoCaseMap));
                CssStyles.style(infoLabel, CssStyles.LABEL_MEDIUM, CssStyles.LABEL_SECONDARY,
                        CssStyles.HSPACE_LEFT_3);
                infoLabel.setHeightUndefined();
                showCasesLayout.addComponent(infoLabel);
                showCasesLayout.setComponentAlignment(infoLabel, Alignment.TOP_CENTER);
            }
            layersLayout.addComponent(showCasesLayout);

            layersLayout.addComponent(mapCaseDisplayModeSelect);
            mapCaseDisplayModeSelect.setEnabled(showCases);

            CheckBox showConfirmedContactsCheckBox = new CheckBox();
            CheckBox showUnconfirmedContactsCheckBox = new CheckBox();

            CheckBox showContactsCheckBox = new CheckBox();
            showContactsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowContacts));
            showContactsCheckBox.setValue(showContacts);
            showContactsCheckBox.addValueChangeListener(e -> {
                showContacts = (boolean) e.getProperty().getValue();
                showConfirmedContactsCheckBox.setEnabled(showContacts);
                showConfirmedContactsCheckBox.setValue(true);
                showUnconfirmedContactsCheckBox.setEnabled(showContacts);
                showUnconfirmedContactsCheckBox.setValue(true);
                refreshMap();
            });
            layersLayout.addComponent(showContactsCheckBox);

            showConfirmedContactsCheckBox
                    .setCaption(I18nProperties.getCaption(Captions.dashboardShowConfirmedContacts));
            showConfirmedContactsCheckBox.setValue(showConfirmedContacts);
            showConfirmedContactsCheckBox.addValueChangeListener(e -> {
                showConfirmedContacts = (boolean) e.getProperty().getValue();
                refreshMap();
            });
            layersLayout.addComponent(showConfirmedContactsCheckBox);

            CssStyles.style(showUnconfirmedContactsCheckBox, CssStyles.VSPACE_3);
            showUnconfirmedContactsCheckBox
                    .setCaption(I18nProperties.getCaption(Captions.dashboardShowUnconfirmedContacts));
            showUnconfirmedContactsCheckBox.setValue(showUnconfirmedContacts);
            showUnconfirmedContactsCheckBox.addValueChangeListener(e -> {
                showUnconfirmedContacts = (boolean) e.getProperty().getValue();
                refreshMap();
            });
            layersLayout.addComponent(showUnconfirmedContactsCheckBox);

            showConfirmedContactsCheckBox.setEnabled(showContacts);
            showUnconfirmedContactsCheckBox.setEnabled(showContacts);

            CheckBox showEventsCheckBox = new CheckBox();
            CssStyles.style(showEventsCheckBox, CssStyles.VSPACE_3);
            showEventsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowEvents));
            showEventsCheckBox.setValue(showEvents);
            showEventsCheckBox.addValueChangeListener(e -> {
                showEvents = (boolean) e.getProperty().getValue();
                refreshMap();
            });
            layersLayout.addComponent(showEventsCheckBox);

            if (UserProvider.getCurrent().hasUserRole(UserRole.NATIONAL_USER)
                    || UserProvider.getCurrent().hasUserRole(UserRole.NATIONAL_CLINICIAN)
                    || UserProvider.getCurrent().hasUserRole(UserRole.NATIONAL_OBSERVER)) {
                OptionGroup regionMapVisualizationSelect = new OptionGroup();
                regionMapVisualizationSelect.setWidth(100, Unit.PERCENTAGE);
                regionMapVisualizationSelect.addItems((Object[]) CaseMeasure.values());
                regionMapVisualizationSelect.setValue(caseMeasure);
                regionMapVisualizationSelect.addValueChangeListener(event -> {
                    caseMeasure = (CaseMeasure) event.getProperty().getValue();
                    refreshMap();
                });

                HorizontalLayout showRegionsLayout = new HorizontalLayout();
                {
                    showRegionsLayout.setMargin(false);
                    showRegionsLayout.setSpacing(false);
                    CheckBox showRegionsCheckBox = new CheckBox();
                    showRegionsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowRegions));
                    showRegionsCheckBox.setValue(showRegions);
                    showRegionsCheckBox.addValueChangeListener(e -> {
                        showRegions = (boolean) e.getProperty().getValue();
                        regionMapVisualizationSelect.setEnabled(showRegions);
                        regionMapVisualizationSelect.setValue(caseMeasure);
                        refreshMap();
                    });
                    showRegionsLayout.addComponent(showRegionsCheckBox);

                    Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
                    infoLabel.setDescription(I18nProperties.getString(Strings.infoCaseIncidence));
                    CssStyles.style(infoLabel, CssStyles.LABEL_MEDIUM, CssStyles.LABEL_SECONDARY,
                            CssStyles.HSPACE_LEFT_3);
                    infoLabel.setHeightUndefined();
                    showRegionsLayout.addComponent(infoLabel);
                    showRegionsLayout.setComponentAlignment(infoLabel, Alignment.TOP_CENTER);
                }
                layersLayout.addComponent(showRegionsLayout);
                layersLayout.addComponent(regionMapVisualizationSelect);
                regionMapVisualizationSelect.setEnabled(showRegions);
            }
        }
    }
    mapFooterLayout.addComponent(layersDropdown);
    mapFooterLayout.setComponentAlignment(layersDropdown, Alignment.MIDDLE_RIGHT);

    return mapFooterLayout;
}

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

License:Open Source License

private VerticalLayout createLegend() {
    VerticalLayout legendLayout = new VerticalLayout();
    legendLayout.setSpacing(false);//from  ww w  .j  a va 2 s. c o  m
    legendLayout.setMargin(true);
    legendLayout.setSizeUndefined();

    // Disable map key dropdown if no layers have been selected
    if (showCases || showContacts || showEvents || showRegions) {
        legendDropdown.setEnabled(true);
    } else {
        legendDropdown.setEnabled(false);
        return legendLayout;
    }

    // Health facilities

    // Cases
    if (showCases) {
        if (mapCaseDisplayMode == MapCaseDisplayMode.HEALTH_FACILITY
                || mapCaseDisplayMode == MapCaseDisplayMode.HEALTH_FACILITY_OR_CASE_ADDRESS) {
            Label facilitiesKeyLabel = new Label(I18nProperties.getCaption(Captions.dashboardHealthFacilities));
            CssStyles.style(facilitiesKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
            legendLayout.addComponent(facilitiesKeyLabel);

            HorizontalLayout facilitiesKeyLayout = new HorizontalLayout();
            {
                facilitiesKeyLayout.setSpacing(false);
                facilitiesKeyLayout.setMargin(false);
                HorizontalLayout legendEntry = buildMarkerLegendEntry(MarkerIcon.FACILITY_UNCLASSIFIED,
                        I18nProperties.getCaption(Captions.dashboardNotYetClassifiedOnly));
                CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
                facilitiesKeyLayout.addComponent(legendEntry);
                legendEntry = buildMarkerLegendEntry(MarkerIcon.FACILITY_SUSPECT,
                        I18nProperties.getCaption(Captions.dashboardGt1SuspectCases));
                CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
                facilitiesKeyLayout.addComponent(legendEntry);
                legendEntry = buildMarkerLegendEntry(MarkerIcon.FACILITY_PROBABLE,
                        I18nProperties.getCaption(Captions.dashboardGt1ProbableCases));
                CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
                facilitiesKeyLayout.addComponent(legendEntry);
                legendEntry = buildMarkerLegendEntry(MarkerIcon.FACILITY_CONFIRMED,
                        I18nProperties.getCaption(Captions.dashboardGt1ConfirmedCases));
                facilitiesKeyLayout.addComponent(legendEntry);
            }
            legendLayout.addComponent(facilitiesKeyLayout);
        }

        Label casesKeyLabel = new Label(I18nProperties.getString(Strings.entityCases));
        if (mapCaseDisplayMode == MapCaseDisplayMode.HEALTH_FACILITY
                || mapCaseDisplayMode == MapCaseDisplayMode.HEALTH_FACILITY_OR_CASE_ADDRESS) {
            CssStyles.style(casesKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
        } else {
            CssStyles.style(casesKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
        }
        legendLayout.addComponent(casesKeyLabel);

        HorizontalLayout casesKeyLayout = new HorizontalLayout();
        {
            casesKeyLayout.setSpacing(false);
            casesKeyLayout.setMargin(false);
            HorizontalLayout legendEntry = buildMarkerLegendEntry(MarkerIcon.CASE_UNCLASSIFIED,
                    I18nProperties.getCaption(Captions.dashboardNotYetClassified));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            casesKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CASE_SUSPECT,
                    I18nProperties.getCaption(Captions.dashboardSuspect));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            casesKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CASE_PROBABLE,
                    I18nProperties.getCaption(Captions.dashboardProbable));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            casesKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CASE_CONFIRMED,
                    I18nProperties.getCaption(Captions.dashboardConfirmed));
            casesKeyLayout.addComponent(legendEntry);
        }
        legendLayout.addComponent(casesKeyLayout);
    }

    // Contacts
    if (showContacts) {
        Label contactsKeyLabel = new Label(I18nProperties.getString(Strings.entityContacts));
        if (showCases) {
            CssStyles.style(contactsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
        } else {
            CssStyles.style(contactsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
        }
        legendLayout.addComponent(contactsKeyLabel);

        HorizontalLayout contactsKeyLayout = new HorizontalLayout();
        {
            contactsKeyLayout.setSpacing(false);
            contactsKeyLayout.setMargin(false);
            HorizontalLayout legendEntry = buildMarkerLegendEntry(MarkerIcon.CONTACT_OK,
                    I18nProperties.getCaption(Captions.dashboardLastVisitLt24));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            contactsKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CONTACT_OVERDUE,
                    I18nProperties.getCaption(Captions.dashboardLastVisitLt48));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            contactsKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CONTACT_LONG_OVERDUE,
                    I18nProperties.getCaption(Captions.dashboardLastVisitGt48));
            contactsKeyLayout.addComponent(legendEntry);
        }
        legendLayout.addComponent(contactsKeyLayout);
    }

    // Events
    if (showEvents) {
        Label eventsKeyLabel = new Label(I18nProperties.getString(Strings.entityEvents));
        if (showCases || showContacts) {
            CssStyles.style(eventsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
        } else {
            CssStyles.style(eventsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
        }
        legendLayout.addComponent(eventsKeyLabel);

        HorizontalLayout eventsKeyLayout = new HorizontalLayout();
        {
            eventsKeyLayout.setSpacing(false);
            eventsKeyLayout.setMargin(false);
            HorizontalLayout legendEntry = buildMarkerLegendEntry(MarkerIcon.EVENT_RUMOR,
                    EventStatus.POSSIBLE.toString());
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            eventsKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.EVENT_OUTBREAK, EventStatus.CONFIRMED.toString());
            eventsKeyLayout.addComponent(legendEntry);
        }
        legendLayout.addComponent(eventsKeyLayout);
    }

    // Districts
    if (showRegions && districtValuesLowerQuartile != null && districtValuesMedian != null
            && districtValuesUpperQuartile != null) {
        Label districtsKeyLabel = new Label(I18nProperties.getString(Strings.entityDistricts));
        if (showCases || showContacts || showEvents) {
            CssStyles.style(districtsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
        } else {
            CssStyles.style(districtsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
        }
        legendLayout.addComponent(districtsKeyLabel);
        legendLayout.addComponent(buildRegionLegend(false, caseMeasure, emptyPopulationDistrictPresent,
                districtValuesLowerQuartile, districtValuesMedian, districtValuesUpperQuartile));

        Label descLabel = new Label(I18nProperties.getString(Strings.infoDashboardIncidence));
        CssStyles.style(descLabel, CssStyles.LABEL_SMALL);
        legendLayout.addComponent(descLabel);
    }

    return legendLayout;
}

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 w w  w .  j ava 2s .  c  om*/

    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.person.PersonSelectField.java

License:Open Source License

@Override
protected Component initContent() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);/*from   w ww . j av  a 2s .  c o m*/
    layout.setSizeUndefined();
    layout.setWidth(100, Unit.PERCENTAGE);

    HorizontalLayout nameLayout = new HorizontalLayout();
    nameLayout.setSpacing(true);
    nameLayout.setWidth(100, Unit.PERCENTAGE);

    firstNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.FIRST_NAME));
    firstNameField.setWidth(100, Unit.PERCENTAGE);
    firstNameField.setRequired(true);
    nameLayout.addComponent(firstNameField);

    lastNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.LAST_NAME));
    lastNameField.setWidth(100, Unit.PERCENTAGE);
    lastNameField.setRequired(true);
    nameLayout.addComponent(lastNameField);

    CssStyles.style(searchMatchesButton, CssStyles.FORCE_CAPTION, ValoTheme.BUTTON_PRIMARY);
    searchMatchesButton.addClickListener(e -> {
        personGrid.reload(firstNameField.getValue(), lastNameField.getValue());
        selectBestMatch();
    });
    nameLayout.addComponent(searchMatchesButton);

    layout.addComponent(nameLayout);

    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);
            if (selectionChangeCallback != null) {
                selectionChangeCallback.accept(personGrid.getSelectedRow() != null);
            }
        }
    });
    layout.addComponent(selectPerson);

    initPersonGrid();
    // unselect "create new" when person is selected
    personGrid.addSelectionListener(e -> {
        if (e.getSelected().size() > 0) {
            createNewPerson.setValue(null);
        }
    });
    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));
    // unselect grid when "create new" is selected
    createNewPerson.addValueChangeListener(e -> {
        if (e.getProperty().getValue() != null) {
            selectPerson.setValue(null);
            personGrid.select(null);
            personGrid.setEnabled(false);
            if (selectionChangeCallback != null) {
                selectionChangeCallback.accept(true);
            }
        }
    });
    layout.addComponent(createNewPerson);

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

    return layout;
}