Example usage for com.vaadin.ui Label addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:de.fatalix.lighty.web.component.LightyHeader.java

public LightyHeader() {
    addStyleName(LightyTheme.HEADER_BACKGROUND);
    setWidth(100, Unit.PERCENTAGE);//w  w  w . j  a va  2 s  .c  om
    Image image = new Image(null, new ThemeResource("img/lighty-icon.png"));
    image.setWidth(64, Unit.PIXELS);
    image.setHeight(64, Unit.PIXELS);
    Label headerTitle = new Label("Lighty App");
    headerTitle.addStyleName(LightyLabels.TITLE_CAPTION);
    addComponents(image, headerTitle);
    setExpandRatio(headerTitle, 1.0f);
    setComponentAlignment(headerTitle, Alignment.MIDDLE_LEFT);
}

From source file:de.gedoplan.webclients.vaadin.views.CustomerDetailView.java

public void init() {
    Double discount = customerService.calculateCustomerDiscount(customer.getCustomerID()).getDiscount();
    Label name = new Label(new PropertyFormatter(form.getProperty(Customer_.companyName)) {
        @Override/*from w  w  w  .  j  av a 2s. c  o m*/
        public String format(Object value) {
            return value + " (" + customer.getCustomerID() + ")";
        }

        @Override
        public Object parse(String formattedValue) throws Exception {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    name.setStyleName(ValoTheme.LABEL_BOLD);
    Label rabattLabel = new Label(Messages.customer_discount.value());
    rabattLabel.setStyleName(ValoTheme.LABEL_BOLD);
    rabattLabel.setSizeUndefined();
    Label rabatt = new Label(new DecimalFormat("#0.00").format(discount) + "%");
    rabatt.setSizeUndefined();
    rabatt.addStyleName(ValoTheme.LABEL_COLORED);
    rabatt.addStyleName(ValoTheme.LABEL_BOLD);
    HorizontalLayout headline = new HorizontalLayout(name, rabattLabel, rabatt);
    headline.setComponentAlignment(rabatt, Alignment.TOP_RIGHT);
    headline.setExpandRatio(name, 1);
    headline.setWidth(100, Unit.PERCENTAGE);
    headline.setSpacing(true);
    headline.setStyleName(ValoTheme.LAYOUT_WELL);
    headline.setMargin(new MMarginInfo(false, true));
    Panel panel = new Panel();
    panel.setContent(form);
    setMargin(true);
    setSpacing(true);
    addComponents(headline, panel);
}

From source file:de.kaiserpfalzEdv.vaadin.menu.impl.MenuImpl.java

License:Apache License

@Inject
public MenuImpl(final Authenticator accessControl, final EventBus bus, final I18NHandler i18n,
        final List<View> allViews) {
    this.accessControl = accessControl;
    this.bus = bus;
    this.i18n = i18n;
    this.allViews = allViews;

    setPrimaryStyleName(ValoTheme.MENU_ROOT);
    menuPart = new CssLayout();
    menuPart.addStyleName(ValoTheme.MENU_PART);

    // header of the menu
    final HorizontalLayout top = new HorizontalLayout();
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName(ValoTheme.MENU_TITLE);
    top.setSpacing(true);/*from  w ww.  j a v a2  s  .c  o  m*/
    Label title = new Label(translate("application.name"));
    title.addStyleName(ValoTheme.LABEL_H3);
    title.setSizeUndefined();
    Image image = new Image(null, new ThemeResource("img/table-logo.png"));
    image.setStyleName("logo");
    top.addComponent(image);
    top.addComponent(title);
    menuPart.addComponent(top);

    // logout menu item
    MenuBar logoutMenu = new MenuBar();
    logoutMenu.addItem(translate("button.logout.caption"), FontAwesome.valueOf(translate("button.logout.icon")),
            selectedItem -> {
                VaadinSession.getCurrent().getSession().invalidate();
                Page.getCurrent().reload();
            });

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

    // button for toggling the visibility of the menu when on a small screen
    final Button showMenu = new Button(translate("application.name"), new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) {
                menuPart.removeStyleName(VALO_MENU_VISIBLE);
            } else {
                menuPart.addStyleName(VALO_MENU_VISIBLE);
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName(VALO_MENU_TOGGLE);
    showMenu.setIcon(FontAwesome.NAVICON);
    menuPart.addComponent(showMenu);

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

    addComponent(menuPart);
}

From source file:de.sebastianrothbucher.vaadin.meetup.ui.std.view.FirstPageViewImplEx.java

License:Apache License

@Override
public void showImprint(String imprintHtml) {
    popover = new Popover();
    popover.setSizeFull();/*from w  w  w .j a v a 2  s.co m*/
    popover.setModal(false);
    VerticalLayout imprintLayout = new VerticalLayout();
    Label imprintLabel = new Label(imprintHtml, ContentMode.HTML);
    imprintLabel.addStyleName("styleid-FirstPageViewImplEx-imprintLabel");
    imprintLayout.addComponent(imprintLabel);
    Button closeButton = new Button("Schlieen");
    closeButton.addClickListener(new ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            popoverSchliessen();
        }
    });
    imprintLayout.addComponent(closeButton);
    popover.setContent(imprintLayout);
    UI.getCurrent().addWindow(popover);
}

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

License:Open Source License

public AccessDeniedView() {
    setMargin(true);/*from   w w  w.  j a  v a  2  s  .co m*/
    setSpacing(true);

    Label header = new Label(I18nProperties.getString(Strings.headingAccessDenied));
    header.addStyleName(ValoTheme.LABEL_H1);
    addComponent(header);
    addComponent(explanation = new Label());
}

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

License:Open Source License

@Override
protected void addFields() {
    if (person == null || disease == null) {
        return;//  ww w.  j ava 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.dashboard.map.DashboardMapComponent.java

License:Open Source License

private static HorizontalLayout buildLegendEntry(AbstractComponent icon, String labelCaption) {
    HorizontalLayout entry = new HorizontalLayout();
    entry.setSpacing(false);/*w w w  .  j  av  a2s .  c  o m*/
    entry.setSizeUndefined();
    CssStyles.style(icon, CssStyles.HSPACE_RIGHT_4);
    entry.addComponent(icon);
    Label label = new Label(labelCaption);
    label.setSizeUndefined();
    label.addStyleName(ValoTheme.LABEL_SMALL);
    entry.addComponent(label);
    return entry;
}

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

License:Open Source License

public ErrorView() {
    setMargin(true);/*from ww w.ja v a  2 s . c o m*/
    setSpacing(true);

    Label header = new Label(I18nProperties.getString(Strings.headingViewNotFound));
    header.addStyleName(ValoTheme.LABEL_H1);
    addComponent(header);
    addComponent(explanation = new Label());
}

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

License:Open Source License

public PathogenTestListComponent(SampleReferenceDto sampleRef,
        BiConsumer<PathogenTestResultType, Boolean> testChangedCallback) {
    setWidth(100, Unit.PERCENTAGE);/*from   w w  w .  j  ava2s .  co m*/

    HorizontalLayout componentHeader = new HorizontalLayout();
    componentHeader.setWidth(100, Unit.PERCENTAGE);
    addComponent(componentHeader);

    list = new PathogenTestList(sampleRef, testChangedCallback);
    addComponent(list);
    list.reload();

    Label testsHeader = new Label(I18nProperties.getString(Strings.headingTests));
    testsHeader.addStyleName(CssStyles.H3);
    componentHeader.addComponent(testsHeader);

    if (UserProvider.getCurrent().hasUserRight(UserRight.PATHOGEN_TEST_CREATE)) {
        createButton = new Button(I18nProperties.getCaption(Captions.pathogenTestNewTest));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(e -> ControllerProvider.getPathogenTestController().create(sampleRef, 0,
                list::reload, testChangedCallback));
        componentHeader.addComponent(createButton);
        componentHeader.setComponentAlignment(createButton, Alignment.MIDDLE_RIGHT);
    }
}

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

License:Open Source License

public PathogenTestListEntry(PathogenTestDto pathogenTest) {
    setSpacing(true);//from   w  ww .ja  v  a2 s. c o  m
    setMargin(false);
    setWidth(100, Unit.PERCENTAGE);
    addStyleName(CssStyles.SORMAS_LIST_ENTRY);
    this.pathogenTest = pathogenTest;

    VerticalLayout labelLayout = new VerticalLayout();
    labelLayout.setSpacing(false);
    labelLayout.setMargin(false);
    labelLayout.setWidth(100, Unit.PERCENTAGE);
    addComponent(labelLayout);
    setExpandRatio(labelLayout, 1);

    HorizontalLayout topLabelLayout = new HorizontalLayout();
    topLabelLayout.setSpacing(false);
    topLabelLayout.setMargin(false);
    topLabelLayout.setWidth(100, Unit.PERCENTAGE);
    labelLayout.addComponent(topLabelLayout);
    Label labelTopLeft = new Label(
            PathogenTestType.toString(pathogenTest.getTestType(), pathogenTest.getTestTypeText()));
    CssStyles.style(labelTopLeft, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
    topLabelLayout.addComponent(labelTopLeft);

    if (pathogenTest.getTestResultVerified()) {
        Label labelTopRight = new Label(VaadinIcons.CHECK_CIRCLE.getHtml(), ContentMode.HTML);
        labelTopRight.setSizeUndefined();
        labelTopRight.addStyleName(CssStyles.LABEL_LARGE);
        labelTopRight.setDescription(I18nProperties.getPrefixCaption(PathogenTestDto.I18N_PREFIX,
                PathogenTestDto.TEST_RESULT_VERIFIED));
        topLabelLayout.addComponent(labelTopRight);
        topLabelLayout.setComponentAlignment(labelTopRight, Alignment.TOP_RIGHT);
    }

    if (!DataHelper.isNullOrEmpty(pathogenTest.getTestResultText())) {
        Label resultTextLabel = new Label(pathogenTest.getTestResultText());
        labelLayout.addComponent(resultTextLabel);
    }

    HorizontalLayout middleLabelLayout = new HorizontalLayout();
    middleLabelLayout.setSpacing(false);
    middleLabelLayout.setMargin(false);
    middleLabelLayout.setWidth(100, Unit.PERCENTAGE);
    labelLayout.addComponent(middleLabelLayout);
    Label labelLeft = new Label(DataHelper.toStringNullable(
            DiseaseHelper.toString(pathogenTest.getTestedDisease(), pathogenTest.getTestedDiseaseDetails())));
    middleLabelLayout.addComponent(labelLeft);

    Label labelRight = new Label(DateHelper.formatLocalShortDateTime(pathogenTest.getTestDateTime()));
    labelRight.addStyleName(CssStyles.ALIGN_RIGHT);
    middleLabelLayout.addComponent(labelRight);
    middleLabelLayout.setComponentAlignment(labelRight, Alignment.TOP_RIGHT);

    Label labelBottom = new Label(DataHelper.toStringNullable(pathogenTest.getTestResult()));
    CssStyles.style(labelBottom, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
    if (pathogenTest.getTestResult() == PathogenTestResultType.POSITIVE)
        CssStyles.style(labelBottom, CssStyles.LABEL_CRITICAL);
    else
        CssStyles.style(labelBottom, CssStyles.LABEL_WARNING);
    labelLayout.addComponent(labelBottom);
}