Example usage for com.vaadin.ui Label setCaption

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

Introduction

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

Prototype

@Override
    public void setCaption(String caption) 

Source Link

Usage

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

private void addDatum(String cap, String val, Object container) {

    Label lb = new Label();
    lb.setImmediate(true);//from  w  w  w  .jav a 2 s. c o m
    lb.setStyleName("label_ud");
    lb.setCaption(cap + ": ");
    lb.setValue(val);
    if (container instanceof HorizontalLayout) {
        ((HorizontalLayout) container).addComponent(lb);
    } else if (container instanceof FormLayout) {
        ((FormLayout) container).addComponent(lb);
        ((FormLayout) container).setSpacing(false);
    } else {
        ((VerticalLayout) container).addComponent(lb);
        ((VerticalLayout) container).setSpacing(false);
    }

}

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

private HorizontalLayout getPC() {

    VerticalLayout cAgentInfo = new VerticalLayout();
    final HorizontalLayout cPlaceholder = new HorizontalLayout();
    cAgentInfo.setMargin(new MarginInfo(true, true, true, true));
    cAgentInfo.setStyleName("c_details_test");

    final VerticalLayout cLBody = new VerticalLayout();

    cLBody.setStyleName("c_body_visible");
    tb = new Table("Linked child accounts");
    // addLinksTable();

    final VerticalLayout cAllProf = new VerticalLayout();

    HorizontalLayout cProfActions = new HorizontalLayout();
    final FormLayout cProfName = new FormLayout();

    cProfName.setStyleName("frm_profile_name");
    cProfName.setSizeUndefined();//from   www. j  av a2s. c  o  m

    final Label lbProf = new Label();
    final TextField tFProf = new TextField();

    lbProf.setCaption("Profile Name: ");
    lbProf.setValue("Certified Authorized User.");

    tFProf.setCaption(lbProf.getCaption());
    cProfName.addComponent(lbProf);

    final Button btnEdit = new Button();
    btnEdit.setIcon(FontAwesome.EDIT);
    btnEdit.setStyleName("btn_link");
    btnEdit.setDescription("Edit profile name");

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

    Button btnAdd = new Button("+");
    // btnAdd.setIcon(FontAwesome.EDIT);
    btnAdd.setStyleName("btn_link");
    btnAdd.setDescription("Set new profile");

    Button btnRemove = new Button("-");
    // btnRemove.setIcon(FontAwesome.EDIT);
    btnRemove.setStyleName("btn_link");
    btnRemove.setDescription("Remove current profile");

    // cProf.addComponent(cProfName);
    cProfActions.addComponent(btnEdit);
    cProfActions.addComponent(btnCancel);
    cProfActions.addComponent(btnAdd);
    cProfActions.addComponent(btnRemove);

    btnCancel.setVisible(false);

    cAllProf.addComponent(cProfName);
    cAllProf.addComponent(cProfActions);
    cAllProf.setComponentAlignment(cProfActions, Alignment.TOP_CENTER);

    cLBody.addComponent(cAllProf);

    // cLBody.addComponent(tb);

    tb.setSelectable(true);

    cAgentInfo.addComponent(cLBody);

    btnLink = new Button("Add New Link");
    btnLink.setIcon(FontAwesome.LINK);
    btnLink.setDescription("Link new account.");

    // cLBody.addComponent(btnLink);
    // cLBody.setComponentAlignment(btnLink, Alignment.TOP_LEFT);
    btnLink.addClickListener(new LinkClickHandler());

    cPlaceholder.setVisible(false);
    addLinkUserContainer();
    cPlaceholder.setWidth("100%");

    cLBody.addComponent(cPlaceholder);
    cLBody.setComponentAlignment(cPlaceholder, Alignment.TOP_CENTER);
    HorizontalLayout c = new HorizontalLayout();
    c.addComponent(cAgentInfo);

    btnEdit.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -8427226211153164650L;

        @Override
        public void buttonClick(ClickEvent event) {

            if (btnEdit.getIcon().equals(FontAwesome.EDIT)) {

                tFProf.setValue(lbProf.getValue());
                tFProf.selectAll();
                cProfName.replaceComponent(lbProf, tFProf);
                btnEdit.setIcon(FontAwesome.SAVE);
                btnCancel.setVisible(true);
                return;

            } else if (btnEdit.getIcon().equals(FontAwesome.SAVE)) {

                lbProf.setValue(tFProf.getValue());
                cProfName.replaceComponent(tFProf, lbProf);
                btnEdit.setIcon(FontAwesome.EDIT);
                btnCancel.setVisible(false);

                return;
            }
            lbProf.setValue(tFProf.getValue());
            cProfName.replaceComponent(tFProf, lbProf);
            btnEdit.setIcon(FontAwesome.EDIT);
            btnCancel.setVisible(false);

        }
    });

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

        @Override
        public void buttonClick(ClickEvent event) {
            cProfName.replaceComponent(tFProf, lbProf);
            btnEdit.setIcon(FontAwesome.EDIT);
            btnCancel.setVisible(false);

        }
    });

    btnAdd.addClickListener(new AddProfileHandler(cAllProf, cPlaceholder));

    btnRemove.addClickListener(new RemoveProfileHandler(pop));

    return c;

}

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

public void displayErrorMessage(Exception ex, String title, String message) {

    VerticalLayout info = new VerticalLayout();
    errorInfo.addComponent(info);/*from  w  w w.j a v a2  s. c  om*/
    errorInfo.setComponentAlignment(info, Alignment.TOP_LEFT);
    info.setStyleName("error-page-information");

    if (title != null) {

    }

    if (message != null) {

    }

    if (ex != null) {
        Label label = new Label();
        label.setContentMode(Label.CONTENT_XHTML);
        label.setCaption(ex.getLocalizedMessage());
        info.addComponent(label);

        Label stacktraceLabel = new Label("Stacktrace");
        info.addComponent(stacktraceLabel);

        Label stacktrace = new Label();
        stacktrace.setWidth("50%");
        stacktrace.setStyleName("error-page-stacktrace");
        stacktrace.setCaptionAsHtml(true);
        StringWriter errors = new StringWriter();
        ex.printStackTrace(new PrintWriter(errors));
        stacktrace.setCaption(errors.toString());
        info.addComponent(stacktrace);
    }
}

From source file:de.akquinet.engineering.vaadinator.timesheet.ui.std.view.TimesheetChangeViewImplEx.java

License:Apache License

@Override
public void setProjectSum(String projectName, float sumValue) {
    // add to section basisdaten
    if (!projectSumLabels.containsKey(projectName)) {
        Label newLabel = new Label(twoDigitsFormat.format(0.0));
        newLabel.setCaption("Sum 4 " + projectName);
        sectionBasisdaten.addComponent(newLabel);
        projectSumLabels.put(projectName, newLabel);
    }//from   ww w . j  av  a  2s . c o  m
    projectSumLabels.get(projectName).setValue(twoDigitsFormat.format(sumValue));
}

From source file:de.catma.ui.tagmanager.TagsetTree.java

License:Open Source License

private void initComponents() {
    setSizeFull();//  w  ww  .java  2  s. co m

    tagTree = new EndorsedTreeTable();
    tagTree.setImmediate(true);
    tagTree.setSizeFull();
    tagTree.setSelectable(true);
    tagTree.setMultiSelect(false);

    tagTree.setContainerDataSource(new HierarchicalContainer());

    tagTree.addContainerProperty(TagTreePropertyName.caption, String.class, null);
    tagTree.setColumnHeader(TagTreePropertyName.caption, "Tagsets");

    tagTree.addContainerProperty(TagTreePropertyName.icon, Resource.class, null);

    tagTree.setItemCaptionPropertyId(TagTreePropertyName.caption);
    tagTree.setItemIconPropertyId(TagTreePropertyName.icon);
    tagTree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_PROPERTY);

    tagTree.setVisibleColumns(new Object[] { TagTreePropertyName.caption });

    if (colorButtonListener != null) {
        tagTree.addGeneratedColumn(TagTreePropertyName.color,
                new ColorButtonColumnGenerator(colorButtonListener));
        tagTree.setColumnReorderingAllowed(true);
    } else {
        tagTree.addGeneratedColumn(TagTreePropertyName.color, new ColorLabelColumnGenerator());
    }
    tagTree.setColumnHeader(TagTreePropertyName.color, "Tag Color");
    addComponent(tagTree);
    setExpandRatio(tagTree, 2);

    GridLayout buttonGrid = new GridLayout(1, 19);
    buttonGrid.setMargin(true);
    buttonGrid.setSpacing(true);

    buttonGrid.addStyleName("taglibrary-action-grid");
    int buttonGridRowCount = 0;

    if (withTagsetButtons) {
        btReload = new Button("");
        btReload.setIcon(new ClassResource("ui/resources/icon-reload.gif", getApplication()));
        btReload.addStyleName("icon-button");
        buttonGrid.addComponent(btReload);
        buttonGrid.setComponentAlignment(btReload, Alignment.MIDDLE_RIGHT);
        buttonGridRowCount++;

        Label tagsetLabel = new Label();
        tagsetLabel.setIcon(new ClassResource("ui/tagmanager/resources/grndiamd.gif", application));
        tagsetLabel.setCaption("Tagset");

        buttonGrid.addComponent(tagsetLabel);
        buttonGridRowCount++;

        btInsertTagset = new Button("Create Tagset");
        btInsertTagset.setEnabled(true);
        btInsertTagset.setWidth("100%");
        buttonGrid.addComponent(btInsertTagset);
        buttonGridRowCount++;

        btRemoveTagset = new Button("Remove Tagset");
        btRemoveTagset.setWidth("100%");
        buttonGrid.addComponent(btRemoveTagset);
        buttonGridRowCount++;

        btEditTagset = new Button("Edit Tagset");
        btEditTagset.setWidth("100%");
        buttonGrid.addComponent(btEditTagset);
        buttonGridRowCount++;
    }

    Label tagLabel = new Label();
    tagLabel.setIcon(new ClassResource("ui/tagmanager/resources/reddiamd.gif", application));
    tagLabel.setCaption("Tag");

    buttonGrid.addComponent(tagLabel, 0, buttonGridRowCount, 0, buttonGridRowCount + 4);
    buttonGridRowCount += 5;

    buttonGrid.setComponentAlignment(tagLabel, Alignment.BOTTOM_LEFT);

    btInsertTag = new Button("Create Tag");
    btInsertTag.setWidth("100%");
    if (withTagsetButtons) {
        btInsertTag.setEnabled(true);
    }
    buttonGrid.addComponent(btInsertTag);
    buttonGridRowCount++;

    btRemoveTag = new Button("Remove Tag");
    btRemoveTag.setWidth("100%");
    buttonGrid.addComponent(btRemoveTag);
    buttonGridRowCount++;

    btEditTag = new Button("Edit Tag");
    btEditTag.setWidth("100%");
    buttonGrid.addComponent(btEditTag);
    buttonGridRowCount++;

    Label propertyLabel = new Label();
    propertyLabel.setIcon(new ClassResource("ui/tagmanager/resources/ylwdiamd.gif", application));
    propertyLabel.setCaption("Property");

    buttonGrid.addComponent(propertyLabel, 0, buttonGridRowCount, 0, buttonGridRowCount + 4);
    buttonGridRowCount += 5;

    buttonGrid.setComponentAlignment(propertyLabel, Alignment.BOTTOM_LEFT);

    btInsertProperty = new Button("Create Property");
    btInsertProperty.setWidth("100%");
    buttonGrid.addComponent(btInsertProperty);
    buttonGridRowCount++;

    btRemoveProperty = new Button("Remove Property");
    // commented out on purpose: somehow this forces all the other buttons to 
    // show up in natural size...
    //      btRemoveProperty.setWidth("100%");
    buttonGrid.addComponent(btRemoveProperty);
    buttonGridRowCount++;

    btEditProperty = new Button("Edit Property");
    btEditProperty.setWidth("100%");
    buttonGrid.addComponent(btEditProperty);
    buttonGridRowCount++;

    addComponent(buttonGrid);
    setExpandRatio(buttonGrid, 0);

    if (!withButtonPanel) {
        buttonGrid.setVisible(false);
    }

}

From source file:de.fatalix.bookery.view.admin.ServerSettingsLayout.java

License:Open Source License

private Label[] generateStatusFields() {
    statusFields = new ArrayList<>();
    Label solrStatus = new Label("Offline " + FontAwesome.TIMES_CIRCLE.getHtml(), ContentMode.HTML);
    solrStatus.addStyleName("red-icon");
    solrStatus.setCaption("Status");
    statusFields.add(solrStatus);/*from w w  w.  j a v  a 2s  .  co m*/
    Label numberOfDocs = new Label("100");
    numberOfDocs.setCaption("Library");
    statusFields.add(numberOfDocs);
    Label sizeOnDisk = new Label("73MB");
    sizeOnDisk.setCaption("Size");
    statusFields.add(sizeOnDisk);

    Label[] result = new Label[statusFields.size()];
    return statusFields.toArray(result);
}

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

License:Open Source License

@Override
protected void addFields() {
    if (person == null || disease == null) {
        return;/*  www.  j av  a 2s. c o  m*/
    }

    // Add fields
    addFields(CaseDataDto.UUID, CaseDataDto.REPORT_DATE, CaseDataDto.REPORTING_USER,
            CaseDataDto.DISTRICT_LEVEL_DATE, CaseDataDto.REGION_LEVEL_DATE, CaseDataDto.NATIONAL_LEVEL_DATE,
            CaseDataDto.CLASSIFICATION_DATE, CaseDataDto.CLASSIFICATION_USER,
            CaseDataDto.CLASSIFICATION_COMMENT, CaseDataDto.NOTIFYING_CLINIC,
            CaseDataDto.NOTIFYING_CLINIC_DETAILS, CaseDataDto.CLINICIAN_NAME, CaseDataDto.CLINICIAN_PHONE,
            CaseDataDto.CLINICIAN_EMAIL);

    // Button to automatically assign a new epid number
    Button assignNewEpidNumberButton = new Button(
            I18nProperties.getCaption(Captions.actionAssignNewEpidNumber));
    CssStyles.style(assignNewEpidNumberButton, ValoTheme.BUTTON_PRIMARY, CssStyles.FORCE_CAPTION);
    getContent().addComponent(assignNewEpidNumberButton, ASSIGN_NEW_EPID_NUMBER_LOC);
    assignNewEpidNumberButton.setVisible(false);

    TextField epidField = addField(CaseDataDto.EPID_NUMBER, TextField.class);
    epidField.setInvalidCommitted(true);
    CssStyles.style(epidField, CssStyles.ERROR_COLOR_PRIMARY);

    assignNewEpidNumberButton.addClickListener(e -> {
        epidField.setValue(FacadeProvider.getCaseFacade().generateEpidNumber(getValue().toReference()));
    });

    addField(CaseDataDto.CASE_CLASSIFICATION, OptionGroup.class);
    addField(CaseDataDto.INVESTIGATION_STATUS, OptionGroup.class);
    addField(CaseDataDto.OUTCOME, OptionGroup.class);
    addField(CaseDataDto.SEQUELAE, OptionGroup.class);
    addFields(CaseDataDto.INVESTIGATED_DATE, CaseDataDto.OUTCOME_DATE, CaseDataDto.SEQUELAE_DETAILS);

    ComboBox diseaseField = addDiseaseField(CaseDataDto.DISEASE, false);
    addField(CaseDataDto.DISEASE_DETAILS, TextField.class);
    addField(CaseDataDto.PLAGUE_TYPE, OptionGroup.class);
    addField(CaseDataDto.DENGUE_FEVER_TYPE, OptionGroup.class);

    addField(CaseDataDto.CASE_ORIGIN, TextField.class);
    TextField healthFacilityDetails = addField(CaseDataDto.HEALTH_FACILITY_DETAILS, TextField.class);
    addField(CaseDataDto.REGION, ComboBox.class);
    addField(CaseDataDto.DISTRICT, ComboBox.class);
    addField(CaseDataDto.COMMUNITY, ComboBox.class);
    addField(CaseDataDto.HEALTH_FACILITY, ComboBox.class);
    ComboBox surveillanceOfficerField = addField(CaseDataDto.SURVEILLANCE_OFFICER, ComboBox.class);
    surveillanceOfficerField.setNullSelectionAllowed(true);
    addField(CaseDataDto.POINT_OF_ENTRY, ComboBox.class);
    addField(CaseDataDto.POINT_OF_ENTRY_DETAILS, TextField.class);

    addFields(CaseDataDto.PREGNANT, CaseDataDto.VACCINATION, CaseDataDto.VACCINATION_DOSES,
            CaseDataDto.VACCINATION_INFO_SOURCE, CaseDataDto.SMALLPOX_VACCINATION_SCAR,
            CaseDataDto.SMALLPOX_VACCINATION_RECEIVED, CaseDataDto.VACCINATION_DATE);

    // Set initial visibilities

    initializeVisibilitiesAndAllowedVisibilities(disease, viewMode);

    // Set requirements that don't need visibility changes and read only status

    setRequired(true, CaseDataDto.REPORT_DATE, CaseDataDto.CASE_CLASSIFICATION,
            CaseDataDto.INVESTIGATION_STATUS, CaseDataDto.OUTCOME, CaseDataDto.DISEASE);
    setSoftRequired(true, CaseDataDto.INVESTIGATED_DATE, CaseDataDto.OUTCOME_DATE, CaseDataDto.PLAGUE_TYPE,
            CaseDataDto.SURVEILLANCE_OFFICER);
    FieldHelper.setReadOnlyWhen(getFieldGroup(), CaseDataDto.INVESTIGATED_DATE,
            CaseDataDto.INVESTIGATION_STATUS, Arrays.asList(InvestigationStatus.PENDING), false);
    setReadOnly(true, CaseDataDto.UUID, CaseDataDto.REPORTING_USER, CaseDataDto.CLASSIFICATION_USER,
            CaseDataDto.CLASSIFICATION_DATE, CaseDataDto.REGION, CaseDataDto.DISTRICT, CaseDataDto.COMMUNITY,
            CaseDataDto.HEALTH_FACILITY, CaseDataDto.HEALTH_FACILITY_DETAILS, CaseDataDto.POINT_OF_ENTRY,
            CaseDataDto.POINT_OF_ENTRY_DETAILS, CaseDataDto.CASE_ORIGIN);
    setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_CHANGE_DISEASE), CaseDataDto.DISEASE);
    setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_INVESTIGATE),
            CaseDataDto.INVESTIGATION_STATUS, CaseDataDto.INVESTIGATED_DATE);
    setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_CLASSIFY),
            CaseDataDto.CASE_CLASSIFICATION, CaseDataDto.OUTCOME, CaseDataDto.OUTCOME_DATE);

    // Set conditional visibilities - ALWAYS call isVisibleAllowed before
    // dynamically setting the visibility

    if (isVisibleAllowed(CaseDataDto.PREGNANT)) {
        setVisible(person.getSex() == Sex.FEMALE, CaseDataDto.PREGNANT);
    }
    if (isVisibleAllowed(CaseDataDto.VACCINATION_DOSES)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.VACCINATION_DOSES, CaseDataDto.VACCINATION,
                Arrays.asList(Vaccination.VACCINATED), true);
    }
    if (isVisibleAllowed(CaseDataDto.VACCINATION_INFO_SOURCE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.VACCINATION_INFO_SOURCE,
                CaseDataDto.VACCINATION, Arrays.asList(Vaccination.VACCINATED), true);
    }
    if (isVisibleAllowed(CaseDataDto.DISEASE_DETAILS)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.DISEASE_DETAILS),
                CaseDataDto.DISEASE, Arrays.asList(Disease.OTHER), true);
        FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.DISEASE,
                Arrays.asList(CaseDataDto.DISEASE_DETAILS), Arrays.asList(Disease.OTHER));
    }
    if (isVisibleAllowed(CaseDataDto.PLAGUE_TYPE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.PLAGUE_TYPE), CaseDataDto.DISEASE,
                Arrays.asList(Disease.PLAGUE), true);
    }
    if (isVisibleAllowed(CaseDataDto.SMALLPOX_VACCINATION_SCAR)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SMALLPOX_VACCINATION_SCAR,
                CaseDataDto.SMALLPOX_VACCINATION_RECEIVED, Arrays.asList(YesNoUnknown.YES), true);
    }
    if (isVisibleAllowed(CaseDataDto.VACCINATION_DATE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.VACCINATION_DATE,
                CaseDataDto.SMALLPOX_VACCINATION_RECEIVED, Arrays.asList(YesNoUnknown.YES), true);
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.VACCINATION_DATE, CaseDataDto.VACCINATION,
                Arrays.asList(Vaccination.VACCINATED), true);
    }
    if (isVisibleAllowed(CaseDataDto.OUTCOME_DATE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.OUTCOME_DATE, CaseDataDto.OUTCOME,
                Arrays.asList(CaseOutcome.DECEASED, CaseOutcome.RECOVERED, CaseOutcome.UNKNOWN), true);
    }
    if (isVisibleAllowed(CaseDataDto.SEQUELAE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SEQUELAE, CaseDataDto.OUTCOME,
                Arrays.asList(CaseOutcome.RECOVERED, CaseOutcome.UNKNOWN), true);
    }
    if (isVisibleAllowed(CaseDataDto.SEQUELAE_DETAILS)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SEQUELAE_DETAILS, CaseDataDto.SEQUELAE,
                Arrays.asList(YesNoUnknown.YES), true);
    }
    if (isVisibleAllowed(CaseDataDto.NOTIFYING_CLINIC_DETAILS)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.NOTIFYING_CLINIC_DETAILS,
                CaseDataDto.NOTIFYING_CLINIC, Arrays.asList(HospitalWardType.OTHER), true);
    }
    setVisible(UserProvider.getCurrent().hasUserRight(UserRight.CASE_MANAGEMENT_ACCESS),
            CaseDataDto.CLINICIAN_NAME, CaseDataDto.CLINICIAN_PHONE, CaseDataDto.CLINICIAN_EMAIL);

    // Other initializations

    if (disease == Disease.MONKEYPOX) {
        Image smallpoxVaccinationScarImg = new Image(null,
                new ThemeResource("img/smallpox-vaccination-scar.jpg"));
        CssStyles.style(smallpoxVaccinationScarImg, CssStyles.VSPACE_3);
        getContent().addComponent(smallpoxVaccinationScarImg, SMALLPOX_VACCINATION_SCAR_IMG);

        // Set up initial image visibility
        getContent().getComponent(SMALLPOX_VACCINATION_SCAR_IMG).setVisible(getFieldGroup()
                .getField(CaseDataDto.SMALLPOX_VACCINATION_RECEIVED).getValue() == YesNoUnknown.YES);

        // Set up image visibility listener
        getFieldGroup().getField(CaseDataDto.SMALLPOX_VACCINATION_RECEIVED).addValueChangeListener(e -> {
            getContent().getComponent(SMALLPOX_VACCINATION_SCAR_IMG)
                    .setVisible(e.getProperty().getValue() == YesNoUnknown.YES);
        });
    }

    List<String> medicalInformationFields = Arrays.asList(CaseDataDto.PREGNANT, CaseDataDto.VACCINATION,
            CaseDataDto.SMALLPOX_VACCINATION_RECEIVED);

    for (String medicalInformationField : medicalInformationFields) {
        if (getFieldGroup().getField(medicalInformationField).isVisible()) {
            Label medicalInformationCaptionLabel = new Label(
                    I18nProperties.getString(Strings.headingMedicalInformation));
            medicalInformationCaptionLabel.addStyleName(CssStyles.H3);
            getContent().addComponent(medicalInformationCaptionLabel, MEDICAL_INFORMATION_LOC);
            break;
        }
    }

    Label paperFormDatesLabel = new Label(I18nProperties.getString(Strings.headingPaperFormDates));
    paperFormDatesLabel.addStyleName(CssStyles.H3);
    getContent().addComponent(paperFormDatesLabel, PAPER_FORM_DATES_LOC);

    // Automatic case classification rules button - invisible for other diseases
    if (disease != Disease.OTHER) {
        Button classificationRulesButton = new Button(I18nProperties.getCaption(Captions.info),
                VaadinIcons.INFO_CIRCLE);
        CssStyles.style(classificationRulesButton, ValoTheme.BUTTON_PRIMARY, CssStyles.FORCE_CAPTION);
        classificationRulesButton.addClickListener(e -> {
            ControllerProvider.getCaseController().openClassificationRulesPopup(getValue());
        });
        getContent().addComponent(classificationRulesButton, CLASSIFICATION_RULES_LOC);
    }

    addValueChangeListener(e -> {
        diseaseField.addValueChangeListener(new DiseaseChangeListener(diseaseField, getValue().getDisease()));

        // Replace classification user if case has been automatically classified
        if (getValue().getClassificationDate() != null && getValue().getClassificationUser() == null) {
            getField(CaseDataDto.CLASSIFICATION_USER).setVisible(false);
            Label classifiedBySystemLabel = new Label(I18nProperties.getCaption(Captions.system));
            classifiedBySystemLabel.setCaption(
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CLASSIFIED_BY));
            getContent().addComponent(classifiedBySystemLabel, CLASSIFIED_BY_SYSTEM_LOC);
        }

        setEpidNumberError(epidField, assignNewEpidNumberButton, getValue().getEpidNumber());

        epidField.addValueChangeListener(f -> {
            setEpidNumberError(epidField, assignNewEpidNumberButton, (String) f.getProperty().getValue());
        });

        // Set health facility details visibility and caption
        if (getValue().getHealthFacility() != null) {
            boolean otherHealthFacility = getValue().getHealthFacility().getUuid()
                    .equals(FacilityDto.OTHER_FACILITY_UUID);
            boolean noneHealthFacility = getValue().getHealthFacility().getUuid()
                    .equals(FacilityDto.NONE_FACILITY_UUID);
            boolean detailsVisible = otherHealthFacility || noneHealthFacility;

            if (isVisibleAllowed(healthFacilityDetails)) {
                healthFacilityDetails.setVisible(detailsVisible);
            }

            if (otherHealthFacility) {
                healthFacilityDetails.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX,
                        CaseDataDto.HEALTH_FACILITY_DETAILS));
            }
            if (noneHealthFacility) {
                healthFacilityDetails.setCaption(
                        I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, NONE_HEALTH_FACILITY_DETAILS));
            }
        } else {
            setVisible(false, CaseDataDto.CLINICIAN_NAME, CaseDataDto.CLINICIAN_PHONE,
                    CaseDataDto.CLINICIAN_EMAIL);
        }

        // Set health facility/point of entry visibility based on case origin
        if (getValue().getCaseOrigin() == CaseOrigin.POINT_OF_ENTRY) {
            setVisible(true, CaseDataDto.POINT_OF_ENTRY);
            setVisible(getValue().getPointOfEntry().isOtherPointOfEntry(), CaseDataDto.POINT_OF_ENTRY_DETAILS);

            if (getValue().getHealthFacility() == null) {
                setVisible(false, CaseDataDto.COMMUNITY, CaseDataDto.HEALTH_FACILITY,
                        CaseDataDto.HEALTH_FACILITY_DETAILS);
            }
        } else {
            setVisible(false, CaseDataDto.POINT_OF_ENTRY, CaseDataDto.POINT_OF_ENTRY_DETAILS);
        }

        // Hide case origin from port health users
        if (UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) {
            setVisible(false, CaseDataDto.CASE_ORIGIN);
        }
    });
}

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

License:Open Source License

private static Label addDescLabel(AbstractLayout layout, Object content, String caption) {
    String contentString = content != null ? content.toString() : "";
    Label label = new Label(contentString);
    label.setCaption(caption);
    layout.addComponent(label);/*from  www .j a v  a 2s . com*/
    return label;
}

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  ww. j  av a 2  s.  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.uni_tuebingen.qbic.qbicmainportlet.SearchResultsView.java

License:Open Source License

void buildLayout(int browserHeight, int browserWidth, WebBrowser browser) {
    // this.setMargin(new MarginInfo(true, true, false, false));
    // clean up first
    searchResultsLayout.removeAllComponents();
    searchResultsLayout.setWidth("100%");
    // searchResultsLayout.setSpacing(true);

    searchResultsLayout.setCaption("Search results for query '" + queryString + "'");
    // Label header = new Label("Search results for query '" + queryString + "':");
    // searchResultsLayout.addComponent(header);

    // updateView(browserWidth, browserWidth, browser);

    VerticalLayout viewContent = new VerticalLayout();
    viewContent.setWidth("100%");
    viewContent.setSpacing(true);//  w  ww  .  j a va2  s .  co m
    viewContent.setMargin(new MarginInfo(true, false, false, false));

    List<String> showOptions = datahandler.getShowOptions();

    if (showOptions.contains("Projects")) {
        projectGrid = new Grid(projBeanContainer);
        projectGrid.setCaption("Found Projects");
        projectGrid.setColumnOrder("projectID", "description");
        projectGrid.setSizeFull();

        projectGrid.setHeightMode(HeightMode.ROW);
        projectGrid.setHeightByRows(5);
        projectGrid.setSelectionMode(SelectionMode.SINGLE);

        projectGrid.addItemClickListener(new ItemClickListener() {

            @Override
            public void itemClick(ItemClickEvent event) {
                // TODO Auto-generated method stub
                String cellType = new String(event.getPropertyId().toString());

                if (cellType.equals("projectID")) {
                    String cellContent = new String(
                            projBeanContainer.getContainerProperty(event.getItemId(), event.getPropertyId())
                                    .getValue().toString());

                    State state = (State) UI.getCurrent().getSession().getAttribute("state");
                    ArrayList<String> message = new ArrayList<String>();
                    message.add("clicked");
                    message.add(cellContent);
                    message.add("project");
                    state.notifyObservers(message);
                }
            }
        });

        if (projBeanContainer.size() == 0) {
            Label noSamples = new Label("no projects were found");
            noSamples.setCaption("Found Projects");
            viewContent.addComponent(noSamples);
        } else {
            viewContent.addComponent(projectGrid);
        }
    }

    if (showOptions.contains("Experiments")) {
        // expGrid = new Grid(expBeanContainer);
        expGrid = new Grid(expBeanContainer);
        expGrid.setCaption("Found Experiments");
        expGrid.setColumnOrder("experimentID", "experimentName", "matchedField");
        expGrid.setSizeFull();

        expGrid.getColumn("experimentID").setExpandRatio(0);
        expGrid.getColumn("experimentName").setExpandRatio(1);
        expGrid.getColumn("matchedField").setExpandRatio(1);

        expGrid.setHeightMode(HeightMode.ROW);
        expGrid.setHeightByRows(5);
        expGrid.setSelectionMode(SelectionMode.SINGLE);

        expGrid.addItemClickListener(new ItemClickListener() {
            @Override
            public void itemClick(ItemClickEvent event) {
                String cellType = new String(event.getPropertyId().toString());

                if (cellType.equals("experimentID")) {
                    String cellContent = new String(
                            expBeanContainer.getContainerProperty(event.getItemId(), event.getPropertyId())
                                    .getValue().toString());

                    State state = (State) UI.getCurrent().getSession().getAttribute("state");
                    ArrayList<String> message = new ArrayList<String>();
                    message.add("clicked");
                    message.add(cellContent);
                    message.add("experiment");
                    state.notifyObservers(message);
                }
            }
        });

        if (expBeanContainer.size() == 0) {
            Label noExps = new Label("no experiments were found");
            noExps.setCaption("Found Experiments");
            viewContent.addComponent(noExps);
        } else {
            viewContent.addComponent(expGrid);
        }

    }

    if (showOptions.contains("Samples")) {
        sampleGrid = new Grid(sampleBeanContainer);
        sampleGrid.setCaption("Found Samples");
        sampleGrid.setColumnOrder("sampleID", "sampleName", "matchedField");
        sampleGrid.setSizeFull();

        sampleGrid.getColumn("sampleID").setExpandRatio(0);
        sampleGrid.getColumn("sampleName").setExpandRatio(1);
        sampleGrid.getColumn("matchedField").setExpandRatio(1);

        sampleGrid.setHeightMode(HeightMode.ROW);
        sampleGrid.setHeightByRows(5);
        sampleGrid.setSelectionMode(SelectionMode.SINGLE);

        sampleGrid.addItemClickListener(new ItemClickListener() {
            @Override
            public void itemClick(ItemClickEvent event) {
                String cellType = new String(event.getPropertyId().toString());

                if (cellType.equals("sampleID")) {
                    String cellContent = new String(
                            sampleBeanContainer.getContainerProperty(event.getItemId(), event.getPropertyId())
                                    .getValue().toString());

                    State state = (State) UI.getCurrent().getSession().getAttribute("state");
                    ArrayList<String> message = new ArrayList<String>();
                    message.add("clicked");
                    message.add(cellContent);
                    message.add("sample");
                    state.notifyObservers(message);
                }
            }
        });

        if (sampleBeanContainer.size() == 0) {
            Label noSamples = new Label("no samples were found");
            noSamples.setCaption("Found Samples");
            viewContent.addComponent(noSamples);
        } else {
            viewContent.addComponent(sampleGrid);
        }
    }

    searchResultsLayout.addComponent(viewContent);

    this.addComponent(searchResultsLayout);
}