Example usage for com.vaadin.ui Label setContentMode

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

Introduction

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

Prototype

public void setContentMode(ContentMode contentMode) 

Source Link

Document

Sets the content mode of the label.

Usage

From source file:de.fzi.fhemapi.view.vaadin.ui.ServerDetailsForm.java

License:Apache License

public ServerDetailsForm() {
    FormLayout layout = new FormLayout();
    setCompositionRoot(layout);//from   www  .  j  a va  2s. c o m

    Label title = new Label("<h1> Server Details</h1>");
    title.setContentMode(Label.CONTENT_XHTML);
    layout.addComponent(title);

    final TextField serverIP = new TextField("Server IP");

    serverIP.setWidth(COMMON_FIELD_WIDTH);
    layout.addComponent(serverIP);

    final TextField port = new TextField("Port");
    port.setWidth(COMMON_FIELD_WIDTH);
    layout.addComponent(port);

    Button applyButton = new Button("Apply");
    layout.addComponent(applyButton);

    applyButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                //               Window mainWindow = new Window();
                FHEMServer server = new FHEMServer((String) serverIP.getValue(),
                        Integer.parseInt((String) port.getValue()));
                getWindow().setContent(new HWindow(server));
                //               VaadinServletResponse response = 
                //                        (VaadinServletResponse) VaadinService.getCurrentResponse();
                //                     Cookie ipCookie = new Cookie("ip", (String)serverIP.getValue());
                //                     Cookie portCookie = new Cookie("port", (String) port.getValue());
                //                     ipCookie.setMaxAge(30 * 24 * 60 * 60);
                //                     ipCookie.setPath("/HWC");
                //                     portCookie.setMaxAge(30 * 24 * 60 * 60);
                //                     portCookie.setPath("/HWC");
                //                     response.addCookie(ipCookie);
                //                     response.addCookie(portCookie);
            } catch (ConnectException e) {
                getWindow().setContent(new Window("Could not connect to FHEM!\n Cause: " + e.getMessage()));
                getWindow().showNotification("Error!", e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    //
    //       VaadinServletRequest request = 
    //                (VaadinServletRequest) VaadinService.getCurrentRequest();
    //       if(request != null){
    //             Cookie[] cookies = request.getCookies();
    //             for (Cookie cookie : cookies) {
    //                if (cookie.getName().equals("ip")) {
    //                   serverIP.setValue(cookie.getValue());
    //                }else if(cookie.getName().equals("port")){
    //                   port.setValue(cookie.getValue());
    //                }
    //             }
    //       }

}

From source file:de.fzi.fhemapi.view.vaadin.ui.UIHelper.java

License:Apache License

/**
 * Builds a rich text field.//from w  w  w  .ja  v  a2 s .  c  o  m
 * @param text
 * @return
 */
public static Label buildRichTextField(String text) {
    Label label = new Label();
    label.setImmediate(false);
    label.setWidth("-1px");
    label.setHeight("-1px");
    label.setValue(text);
    label.setContentMode(Label.CONTENT_XHTML);
    return label;
}

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

public Label generateImageLabel(ThemeResource resource) {
    Label label = new Label();
    label.setContentMode(Label.CONTENT_XHTML);
    label.setIcon(resource);/*from ww  w .j  a v a2 s. co  m*/
    label.setValue("<img src=\"" + this.getThemeURI() + resource.getResourceId() + "\" />");
    return (label);
}

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

public void refreshFooterLabel(Label label, ThemeResource resource, int count) {
    label.setContentMode(Label.CONTENT_XHTML);
    label.setValue("<img src=\"" + this.getThemeURI() + resource.getResourceId() + "\" align=\"top\"/>"
            + String.valueOf(count));
}

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

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

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

License:Open Source License

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

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

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

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

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

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

License:Open Source License

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

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

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

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

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

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

    setExpandRatio(lineLabel, 1);
}

From source file:de.symeda.sormas.ui.epidata.EpiDataForm.java

License:Open Source License

@Override
protected void addFields() {
    if (disease == null) {
        return;/*from w w  w .j a  v a2 s  .c  om*/
    }

    addFields(EpiDataDto.DIRECT_CONTACT_CONFIRMED_CASE, EpiDataDto.DIRECT_CONTACT_PROBABLE_CASE,
            EpiDataDto.CLOSE_CONTACT_PROBABLE_CASE, EpiDataDto.AREA_CONFIRMED_CASES,
            EpiDataDto.PROCESSING_CONFIRMED_CASE_FLUID_UNSAFE, EpiDataDto.PERCUTANEOUS_CASE_BLOOD,
            EpiDataDto.DIRECT_CONTACT_DEAD_UNSAFE, EpiDataDto.PROCESSING_SUSPECTED_CASE_SAMPLE_UNSAFE);

    OptionGroup burialAttendedField = addField(EpiDataDto.BURIAL_ATTENDED, OptionGroup.class);
    CssStyles.style(burialAttendedField, CssStyles.ERROR_COLOR_PRIMARY);
    EpiDataBurialsField burialsField = addField(EpiDataDto.BURIALS, EpiDataBurialsField.class);
    OptionGroup gatheringAttendedField = addField(EpiDataDto.GATHERING_ATTENDED, OptionGroup.class);
    CssStyles.style(gatheringAttendedField, CssStyles.ERROR_COLOR_PRIMARY);
    EpiDataGatheringsField gatheringsField = addField(EpiDataDto.GATHERINGS, EpiDataGatheringsField.class);
    OptionGroup traveledField = addField(EpiDataDto.TRAVELED, OptionGroup.class);
    CssStyles.style(traveledField, CssStyles.ERROR_COLOR_PRIMARY);
    EpiDataTravelsField travelsField = addField(EpiDataDto.TRAVELS, EpiDataTravelsField.class);

    addFields(EpiDataDto.AREA_INFECTED_ANIMALS, EpiDataDto.SICK_DEAD_ANIMALS,
            EpiDataDto.SICK_DEAD_ANIMALS_DETAILS, EpiDataDto.SICK_DEAD_ANIMALS_DATE,
            EpiDataDto.SICK_DEAD_ANIMALS_LOCATION, EpiDataDto.EATING_RAW_ANIMALS_IN_INFECTED_AREA,
            EpiDataDto.EATING_RAW_ANIMALS, EpiDataDto.EATING_RAW_ANIMALS_DETAILS, EpiDataDto.RODENTS,
            EpiDataDto.BATS, EpiDataDto.BIRDS, EpiDataDto.PRIMATES, EpiDataDto.SWINE, EpiDataDto.CATTLE,
            EpiDataDto.OTHER_ANIMALS, EpiDataDto.OTHER_ANIMALS_DETAILS, EpiDataDto.ANIMAL_CONDITION,
            EpiDataDto.DATE_OF_LAST_EXPOSURE, EpiDataDto.PLACE_OF_LAST_EXPOSURE);

    addFields(EpiDataDto.WATER_BODY, EpiDataDto.WATER_BODY_DETAILS, EpiDataDto.WATER_SOURCE,
            EpiDataDto.WATER_SOURCE_OTHER, EpiDataDto.TICK_BITE, EpiDataDto.FLEA_BITE);

    initializeVisibilitiesAndAllowedVisibilities(disease, viewMode);

    FieldHelper.setVisibleWhen(getFieldGroup(),
            Arrays.asList(EpiDataDto.SICK_DEAD_ANIMALS_DETAILS, EpiDataDto.SICK_DEAD_ANIMALS_DATE,
                    EpiDataDto.SICK_DEAD_ANIMALS_LOCATION),
            EpiDataDto.SICK_DEAD_ANIMALS, Arrays.asList(YesNoUnknown.YES), true, EpiDataDto.class, disease);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EpiDataDto.EATING_RAW_ANIMALS_DETAILS),
            EpiDataDto.EATING_RAW_ANIMALS, Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), EpiDataDto.OTHER_ANIMALS_DETAILS, EpiDataDto.OTHER_ANIMALS,
            Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), EpiDataDto.WATER_SOURCE_OTHER, EpiDataDto.WATER_SOURCE,
            Arrays.asList(WaterSource.OTHER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), EpiDataDto.WATER_BODY_DETAILS, EpiDataDto.WATER_BODY,
            Arrays.asList(YesNoUnknown.YES), true);

    FieldHelper.setVisibleWhen(getFieldGroup(), EpiDataDto.BURIALS, EpiDataDto.BURIAL_ATTENDED,
            Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), EpiDataDto.GATHERINGS, EpiDataDto.GATHERING_ATTENDED,
            Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), EpiDataDto.TRAVELS, EpiDataDto.TRAVELED,
            Arrays.asList(YesNoUnknown.YES), true);

    List<String> epiDataFields = Arrays.asList(EpiDataDto.BURIAL_ATTENDED, EpiDataDto.GATHERING_ATTENDED,
            EpiDataDto.TRAVELED);

    for (String epiDataField : epiDataFields) {
        if (getFieldGroup().getField(epiDataField).isVisible()) {
            String epiDataCaptionLayout = LayoutUtil.h3(I18nProperties.getCaption(EpiDataDto.I18N_PREFIX))
                    + LayoutUtil.divsCss(CssStyles.VSPACE_3,
                            I18nProperties.getString(Strings.messageEpiDataHint));
            Label epiDataCaptionLabel = new Label(epiDataCaptionLayout);
            epiDataCaptionLabel.setContentMode(ContentMode.HTML);
            getContent().addComponent(epiDataCaptionLabel, EPI_DATA_CAPTION_LOC);
            break;
        }
    }

    List<String> animalContacts = Arrays.asList(EpiDataDto.RODENTS, EpiDataDto.BATS, EpiDataDto.PRIMATES,
            EpiDataDto.SWINE, EpiDataDto.CATTLE, EpiDataDto.OTHER_ANIMALS, EpiDataDto.SICK_DEAD_ANIMALS,
            EpiDataDto.EATING_RAW_ANIMALS_IN_INFECTED_AREA, EpiDataDto.EATING_RAW_ANIMALS);

    for (String animalContact : animalContacts) {
        if (getFieldGroup().getField(animalContact).isVisible()) {
            String animalCaptionLayout = LayoutUtil.h3(I18nProperties.getString(Strings.headingAnimalContacts))
                    + LayoutUtil.divsCss(CssStyles.VSPACE_3,
                            I18nProperties.getString(Strings.messageAnimalContactsHint));
            Label animalCaptionLabel = new Label(animalCaptionLayout);
            animalCaptionLabel.setContentMode(ContentMode.HTML);
            getContent().addComponent(animalCaptionLabel, ANIMAL_CAPTION_LOC);
            break;
        }
    }

    List<String> environmentalExposures = Arrays.asList(EpiDataDto.WATER_SOURCE, EpiDataDto.WATER_BODY,
            EpiDataDto.TICK_BITE, EpiDataDto.FLEA_BITE);

    for (String environmentalExp : environmentalExposures) {
        if (getFieldGroup().getField(environmentalExp).isVisible()) {
            String environmentalCaptionLayout = LayoutUtil
                    .h3(I18nProperties.getString(Strings.headingEnvironmentalExposure));
            Label environmentalCaptionLabel = new Label(environmentalCaptionLayout);
            environmentalCaptionLabel.setContentMode(ContentMode.HTML);
            getContent().addComponent(environmentalCaptionLabel, ENVIRONMENTAL_LOC);
            break;
        }
    }

    burialAttendedField.addValueChangeListener(e -> {
        updateBurialsHint(burialAttendedField, burialsField);
    });
    burialsField.addValueChangeListener(e -> {
        updateBurialsHint(burialAttendedField, burialsField);
        burialAttendedField.setEnabled(burialsField.getValue() == null || burialsField.getValue().size() == 0);
    });
    gatheringAttendedField.addValueChangeListener(e -> {
        updateGatheringsHint(gatheringAttendedField, gatheringsField);
    });
    gatheringsField.addValueChangeListener(e -> {
        updateGatheringsHint(gatheringAttendedField, gatheringsField);
        gatheringAttendedField
                .setEnabled(gatheringsField.getValue() == null || gatheringsField.getValue().size() == 0);
    });
    traveledField.addValueChangeListener(e -> {
        updateTravelsHint(traveledField, travelsField);
    });
    travelsField.addValueChangeListener(e -> {
        updateTravelsHint(traveledField, travelsField);
        traveledField.setEnabled(travelsField.getValue() == null || travelsField.getValue().size() == 0);
    });
}

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

License:Open Source License

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

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

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

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

    loginSidebarLayout.addComponent(htmlLabel);
    return loginSidebarLayout;
}

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

License:Open Source License

private CssLayout buildLoginDetailsLayout() {
    CssLayout loginDetailsLayout = new CssLayout();
    loginDetailsLayout.setStyleName("login-details");

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

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

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

    loginDetailsLayout.addComponent(htmlLabel);
    return loginDetailsLayout;
}