Example usage for com.vaadin.ui Label setValue

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

Introduction

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

Prototype

public void setValue(String value) 

Source Link

Document

Sets the text to be shown in the label.

Usage

From source file:de.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 {/*from  ww w  .j  a v a 2s.  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;
}

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

License:Open Source License

@Override
public void refreshMenu(SubMenu menu, Label infoLabel, Label infoLabelSub, String params) {
    sampleRef = FacadeProvider.getSampleFacade().getReferenceByUuid(params);
    CaseReferenceDto caseRef = FacadeProvider.getSampleFacade().getSampleByUuid(params).getAssociatedCase();

    menu.removeAllViews();/*w  w  w.  j  av  a  2s . c  om*/
    menu.addView(SamplesView.VIEW_NAME, I18nProperties.getCaption(Captions.sampleSamplesList));
    if (caseRef != null && UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) {
        menu.addView(CaseDataView.VIEW_NAME, I18nProperties.getString(Strings.entityCase), caseRef.getUuid(),
                true);
    }
    menu.addView(SampleDataView.VIEW_NAME, I18nProperties.getCaption(SampleDto.I18N_PREFIX), params);
    infoLabel.setValue(sampleRef.getCaption());
    infoLabelSub.setValue(DataHelper.getShortUuid(sampleRef.getUuid()));
}

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

License:Open Source License

public SampleListEntry(SampleIndexDto sample) {

    this.sample = sample;

    setMargin(false);//from   w w  w . j  a  v  a  2  s.co  m
    setSpacing(true);
    setWidth(100, Unit.PERCENTAGE);
    addStyleName(CssStyles.SORMAS_LIST_ENTRY);

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

    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth(100, Unit.PERCENTAGE);
    topLayout.setMargin(false);
    topLayout.setSpacing(false);
    mainLayout.addComponent(topLayout);

    VerticalLayout topLeftLayout = new VerticalLayout();
    {
        topLeftLayout.setMargin(false);
        topLeftLayout.setSpacing(false);

        Label materialLabel = new Label(DataHelper.toStringNullable(sample.getSampleMaterial()));
        CssStyles.style(materialLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
        topLeftLayout.addComponent(materialLabel);

        Label dateTimeLabel = new Label(
                I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, SampleDto.SAMPLE_DATE_TIME) + ": "
                        + DateHelper.formatLocalShortDate(sample.getSampleDateTime()));
        topLeftLayout.addComponent(dateTimeLabel);

        Label labLabel = new Label(DataHelper.toStringNullable(sample.getLab()));
        topLeftLayout.addComponent(labLabel);
    }
    topLayout.addComponent(topLeftLayout);

    VerticalLayout topRightLayout = new VerticalLayout();
    {
        topRightLayout.addStyleName(CssStyles.ALIGN_RIGHT);
        topRightLayout.setMargin(false);
        topRightLayout.setSpacing(false);

        Label resultLabel = new Label();
        CssStyles.style(resultLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
        if (sample.getPathogenTestResult() != null) {
            resultLabel.setValue(DataHelper.toStringNullable(sample.getPathogenTestResult()));
            if (sample.getPathogenTestResult() == PathogenTestResultType.POSITIVE) {
                resultLabel.addStyleName(CssStyles.LABEL_CRITICAL);
            } else if (sample.getPathogenTestResult() == PathogenTestResultType.INDETERMINATE) {
                resultLabel.addStyleName(CssStyles.LABEL_WARNING);
            }
        } else if (sample.getSpecimenCondition() == SpecimenCondition.NOT_ADEQUATE) {
            resultLabel.setValue(DataHelper.toStringNullable(sample.getSpecimenCondition()));
            resultLabel.addStyleName(CssStyles.LABEL_WARNING);
        }
        topRightLayout.addComponent(resultLabel);

        Label referredLabel = new Label();
        CssStyles.style(referredLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
        if (sample.isReferred()) {
            referredLabel.setValue(I18nProperties.getCaption(Captions.sampleReferredShort));
            referredLabel.addStyleName(CssStyles.LABEL_NOT);
        } else if (sample.isReceived()) {
            referredLabel.setValue(I18nProperties.getCaption(Captions.sampleReceived) + " "
                    + DateHelper.formatLocalShortDate(sample.getReceivedDate()));
        } else if (sample.isShipped()) {
            referredLabel.setValue(I18nProperties.getCaption(Captions.sampleShipped) + " "
                    + DateHelper.formatLocalShortDate(sample.getShipmentDate()));
        } else {
            referredLabel.setValue(I18nProperties.getCaption(Captions.sampleNotShippedLong));
        }
        topRightLayout.addComponent(referredLabel);
    }
    topLayout.addComponent(topRightLayout);
    topLayout.setComponentAlignment(topRightLayout, Alignment.TOP_RIGHT);

    if (UserProvider.getCurrent().hasUserRight(UserRight.ADDITIONAL_TEST_VIEW)) {
        Label labelAdditionalTests = new Label(I18nProperties.getString(Strings.entityAdditionalTests) + " "
                + sample.getAdditionalTestingStatus().toString().toLowerCase());
        mainLayout.addComponent(labelAdditionalTests);
    }
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.QbicmainportletUI.java

License:Open Source License

/**
 * starts the querying of openbis and initializing the view
 * /*from www.  j ava 2  s.  c om*/
 * @param request
 */
protected void initProgressBarAndThreading(VaadinRequest request) {
    final VerticalLayout layout = new VerticalLayout();

    this.setContent(layout);

    // TODO so this function uses the same error as above, but doesn't call
    // OpenbisConnectionErrorLayout...we might want to change that
    final Label status = new Label("Connecting to database.");
    status.addStyleName(ValoTheme.LABEL_HUGE);
    status.addStyleName(ValoTheme.LABEL_LIGHT);
    layout.addComponent(status);
    layout.setComponentAlignment(status, Alignment.MIDDLE_RIGHT);
    try {
        buildMainLayout(datahandler, request, LiferayAndVaadinUtils.getUser().getScreenName());
    } catch (Exception e) {
        if (datahandler.getOpenBisClient().loggedin()) {
            LOGGER.error("User not known?", e);
            buildUserUnknownError(request);
        } else {
            LOGGER.error("exception thrown during initialization.", e);
            status.setValue(
                    "An error occured, while trying to connect to the database. Please try again later, or contact your project manager.");
        }
    }
}

From source file:dhbw.clippinggorilla.userinterface.views.ArchiveView.java

public void createClippingViewByProfile(Clipping clipping) {
    clippingArticlesLayout.removeAllComponents();
    if (clipping.getArticles().keySet().isEmpty() && clipping.getArticlesFromGroup().keySet().isEmpty()) {
        Label labelNoProfile = new Label();
        Language.setCustom(Word.NO_PROFILE_PRESENT, s -> labelNoProfile.setValue(s));
        labelNoProfile.addStyleName(ValoTheme.LABEL_H2);
        clippingArticlesLayout.addComponent(labelNoProfile);
    } else {//from   ww w.  j av  a  2s. c o  m
        clipping.getArticles().entrySet().stream().forEach(p -> {
            VerticalLayout layoutProfile = new VerticalLayout();
            layoutProfile.setSpacing(true);
            layoutProfile.setMargin(true);
            layoutProfile.addStyleName("tags");
            layoutProfile.setWidth("100%");
            if (p.getValue().isEmpty()) {
                Label labelNoArticles = new Label();
                Language.setCustom(Word.NO_ARTICLES_PRESENT, s -> labelNoArticles.setValue(s));
                labelNoArticles.addStyleName(ValoTheme.LABEL_H3);
                layoutProfile.addComponent(labelNoArticles);
            } else {
                p.getValue().forEach(a -> layoutProfile.addComponent(createClippingRow(a)));
            }
            Panel panelProfile = new Panel(p.getKey().getName(), layoutProfile);
            clippingArticlesLayout.addComponent(panelProfile);
        });
        clipping.getArticlesFromGroup().entrySet().stream().forEach(p -> {
            VerticalLayout layoutProfile = new VerticalLayout();
            layoutProfile.setSpacing(true);
            layoutProfile.setMargin(true);
            layoutProfile.addStyleName("tags");
            layoutProfile.setWidth("100%");
            if (p.getValue().isEmpty()) {
                Label labelNoArticles = new Label();
                Language.setCustom(Word.NO_ARTICLES_PRESENT, s -> labelNoArticles.setValue(s));
                labelNoArticles.addStyleName(ValoTheme.LABEL_H3);
                layoutProfile.addComponent(labelNoArticles);
            } else {
                p.getValue().forEach(a -> layoutProfile.addComponent(createClippingRow(a)));
            }
            Panel panelProfile = new Panel(Language.get(Word.GROUP) + " " + p.getKey().getGroup().getName()
                    + ": " + p.getKey().getName(), layoutProfile);
            Language.setCustom(Word.GROUP, s -> panelProfile
                    .setCaption(s + " " + p.getKey().getGroup().getName() + ": " + p.getKey().getName()));
            clippingArticlesLayout.addComponent(panelProfile);
        });
    }
}

From source file:dhbw.clippinggorilla.userinterface.views.ArchiveView.java

public void createClippingViewByDate(Clipping clipping) {
    clippingArticlesLayout.removeAllComponents();
    if (ClippingUtils.isEmpty(clipping)) {
        Label labelNoArticles = new Label();
        Language.setCustom(Word.NO_ARTICLES_PRESENT, s -> labelNoArticles.setValue(s));
        labelNoArticles.addStyleName(ValoTheme.LABEL_H3);
        clippingArticlesLayout.addComponent(labelNoArticles);
    }//from  www  .j  a  v a  2 s  .  c om
    clipping.getArticles().entrySet().stream().flatMap(e -> e.getValue().stream()).sorted(
            (a1, a2) -> (-1) * a1.getPublishedAtAsLocalDateTime().compareTo(a2.getPublishedAtAsLocalDateTime()))
            .forEach(a -> clippingArticlesLayout.addComponent(createClippingRow(a)));
    clipping.getArticlesFromGroup().entrySet().stream().flatMap(e -> e.getValue().stream()).sorted(
            (a1, a2) -> (-1) * a1.getPublishedAtAsLocalDateTime().compareTo(a2.getPublishedAtAsLocalDateTime()))
            .forEach(a -> clippingArticlesLayout.addComponent(createClippingRow(a)));
}

From source file:dhbw.clippinggorilla.userinterface.views.ArchiveView.java

public void createClippingViewBySource(Clipping clipping) {
    clippingArticlesLayout.removeAllComponents();
    if (ClippingUtils.isEmpty(clipping)) {
        Label labelNoArticles = new Label();
        Language.setCustom(Word.NO_ARTICLES_PRESENT, s -> labelNoArticles.setValue(s));
        labelNoArticles.addStyleName(ValoTheme.LABEL_H3);
        clippingArticlesLayout.addComponent(labelNoArticles);
    }// w  w w.  j  a  va2s . co m
    clipping.getArticles().entrySet().stream().flatMap(e -> e.getValue().stream()).sorted(
            (a1, a2) -> a1.getSourceAsSource().getName().compareToIgnoreCase(a2.getSourceAsSource().getName()))
            .forEach(a -> clippingArticlesLayout.addComponent(createClippingRow(a)));
    clipping.getArticlesFromGroup().entrySet().stream().flatMap(e -> e.getValue().stream()).sorted(
            (a1, a2) -> a1.getSourceAsSource().getName().compareToIgnoreCase(a2.getSourceAsSource().getName()))
            .forEach(a -> clippingArticlesLayout.addComponent(createClippingRow(a)));
}

From source file:dhbw.clippinggorilla.userinterface.views.ArchiveView.java

public Component createClippingRow(Article a) {
    Image imageNewsImage = new Image();
    String url = a.getUrlToImage();
    if (url == null || url.isEmpty()) {
        url = a.getSourceAsSource().getLogo().toExternalForm();
    }//from  ww w . j a v  a 2s  .  c  om
    imageNewsImage.setSource(new ExternalResource(url));
    imageNewsImage.addStyleName("articleimage");

    VerticalLayout layoutNewsImage = new VerticalLayout(imageNewsImage);
    layoutNewsImage.setMargin(false);
    layoutNewsImage.setSpacing(false);
    layoutNewsImage.setWidth("200px");
    layoutNewsImage.setHeight("150px");
    layoutNewsImage.setComponentAlignment(imageNewsImage, Alignment.MIDDLE_CENTER);

    Label labelHeadLine = new Label(a.getTitle(), ContentMode.HTML);
    labelHeadLine.addStyleName(ValoTheme.LABEL_H2);
    labelHeadLine.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    labelHeadLine.setWidth("100%");

    Label labelDescription = new Label(a.getDescription(), ContentMode.HTML);
    labelDescription.setWidth("100%");

    Image imageSource = new Image();
    Source s = a.getSourceAsSource();
    URL logo;
    if (s != null) {
        logo = s.getLogo();
    } else {
        Log.error("Source is null: " + a.getSource());
        return new Label("INTERNAL ERROR");
    }
    if (logo != null) {
        imageSource.setSource(new ExternalResource(logo));
    } else {
        Log.error("Sourcelogo is null: " + s.getName());
    }
    imageSource.setHeight("30px");
    Label labelSource = new Label(a.getSourceAsSource().getName());
    labelSource.addStyleName(ValoTheme.LABEL_SMALL);

    LocalDateTime time = a.getPublishedAtAsLocalDateTime();
    DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG);
    formatter.withZone(ZoneId.of("Europe/Berlin"));
    Label labelDate = new Label(time.format(formatter));
    labelDate.addStyleName(ValoTheme.LABEL_SMALL);

    Label labelAuthor = new Label();
    labelAuthor.addStyleName(ValoTheme.LABEL_SMALL);
    labelAuthor.setWidth("100%");
    if (a.getAuthor() != null && !a.getAuthor().isEmpty()) {
        labelAuthor.setValue(a.getAuthor());
    }

    Button openWebsite = new Button(VaadinIcons.EXTERNAL_LINK);
    openWebsite.addClickListener(e -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false));

    HorizontalLayout layoutArticleOptions = new HorizontalLayout();
    layoutArticleOptions.setWidth("100%");
    layoutArticleOptions.addComponents(imageSource, labelSource, labelDate, labelAuthor, openWebsite);
    layoutArticleOptions.setComponentAlignment(imageSource, Alignment.MIDDLE_CENTER);
    layoutArticleOptions.setComponentAlignment(labelSource, Alignment.MIDDLE_CENTER);
    layoutArticleOptions.setComponentAlignment(labelDate, Alignment.MIDDLE_CENTER);
    layoutArticleOptions.setComponentAlignment(labelAuthor, Alignment.MIDDLE_LEFT);
    layoutArticleOptions.setComponentAlignment(openWebsite, Alignment.MIDDLE_CENTER);
    layoutArticleOptions.setExpandRatio(labelAuthor, 5);

    VerticalLayout layoutNewsText = new VerticalLayout(labelHeadLine, labelDescription, layoutArticleOptions);
    layoutNewsText.setMargin(false);
    layoutNewsText.setWidth("100%");

    HorizontalLayout layoutClipping = new HorizontalLayout();
    layoutClipping.setWidth("100%");
    layoutClipping.setMargin(true);
    layoutClipping.addComponents(layoutNewsImage, layoutNewsText);
    layoutClipping.setComponentAlignment(layoutNewsImage, Alignment.MIDDLE_CENTER);
    layoutClipping.setExpandRatio(layoutNewsText, 5);
    layoutClipping.addStyleName(ValoTheme.LAYOUT_CARD);
    layoutClipping.addStyleName("tags");
    return layoutClipping;
}

From source file:dhbw.clippinggorilla.userinterface.views.ClippingView.java

public ClippingView(Clipping clipping) {
    User user = UserUtils.getCurrent();/*from ww w .j av a 2 s .com*/

    clippingArticlesLayout = new VerticalLayout();
    clippingArticlesLayout.setSpacing(true);
    clippingArticlesLayout.setMargin(false);
    clippingArticlesLayout.setSizeFull();

    HorizontalLayout clippingOptionsLayout = new HorizontalLayout();
    clippingOptionsLayout.setSpacing(true);
    clippingOptionsLayout.setMargin(false);
    clippingOptionsLayout.setWidth("100%");

    ComboBox<SortOptions> comboBoxSortOptions = new ComboBox<>(Language.get(Word.SORT_BY));
    Language.setCustom(Word.SORT_BY, s -> {
        comboBoxSortOptions.setCaption(s);
        comboBoxSortOptions.getDataProvider().refreshAll();
    });
    comboBoxSortOptions.setItems(EnumSet.allOf(SortOptions.class));
    comboBoxSortOptions.setItemCaptionGenerator(s -> s.getName());
    comboBoxSortOptions.setItemIconGenerator(s -> s.getIcon());
    comboBoxSortOptions.setValue(SortOptions.BYPROFILE);
    comboBoxSortOptions.setTextInputAllowed(false);
    comboBoxSortOptions.setEmptySelectionAllowed(false);
    comboBoxSortOptions.addStyleName("comboboxsort");
    comboBoxSortOptions.addValueChangeListener(e -> {
        switch (e.getValue()) {
        case BYDATE:
            createClippingViewByDate(clipping);
            break;
        case BYPROFILE:
            createClippingViewByProfile(clipping);
            break;
        case BYSOURCE:
            createClippingViewBySource(clipping);
            break;
        }
    });

    Button buttonRegenerateClipping = new Button(VaadinIcons.REFRESH);
    buttonRegenerateClipping.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonRegenerateClipping.addClickListener(ce -> {
        user.setLastClipping(ClippingUtils.generateClipping(user, false));
        ClippingGorillaUI.getCurrent().setMainContent(ClippingView.getCurrent());
    });

    clippingOptionsLayout.addComponents(comboBoxSortOptions, buttonRegenerateClipping);
    clippingOptionsLayout.setExpandRatio(comboBoxSortOptions, 5);
    clippingOptionsLayout.setComponentAlignment(buttonRegenerateClipping, Alignment.BOTTOM_CENTER);

    addComponents(clippingOptionsLayout, clippingArticlesLayout);

    createClippingViewByProfile(clipping);
    if (clipping.getArticles().keySet().isEmpty() && clipping.getArticlesFromGroup().keySet().isEmpty()) {
        Label labelNoProfile = new Label();
        Language.setCustom(Word.NO_PROFILE_PRESENT, s -> labelNoProfile.setValue(s));
        labelNoProfile.addStyleName(ValoTheme.LABEL_H2);
        clippingArticlesLayout.addComponent(labelNoProfile);
    }
}

From source file:dhbw.clippinggorilla.userinterface.views.ClippingView.java

public void createClippingViewByProfile(Clipping clipping) {
    clippingArticlesLayout.removeAllComponents();
    clipping.getArticles().entrySet().stream().forEach(p -> {
        VerticalLayout layoutProfile = new VerticalLayout();
        layoutProfile.setSpacing(true);// w  ww .jav  a  2 s  .com
        layoutProfile.setMargin(true);
        layoutProfile.addStyleName("tags");
        layoutProfile.setWidth("100%");
        if (p.getValue().isEmpty()) {
            Label labelNoArticles = new Label();
            Language.setCustom(Word.NO_ARTICLES_PRESENT, s -> labelNoArticles.setValue(s));
            labelNoArticles.addStyleName(ValoTheme.LABEL_H3);
            layoutProfile.addComponent(labelNoArticles);
        } else {
            p.getValue().forEach(a -> layoutProfile.addComponent(createClippingRow(a)));
        }
        Panel panelProfile = new Panel(p.getKey().getName(), layoutProfile);
        clippingArticlesLayout.addComponent(panelProfile);
    });
    clipping.getArticlesFromGroup().entrySet().stream().forEach(p -> {
        VerticalLayout layoutProfile = new VerticalLayout();
        layoutProfile.setSpacing(true);
        layoutProfile.setMargin(true);
        layoutProfile.addStyleName("tags");
        layoutProfile.setWidth("100%");
        if (p.getValue().isEmpty()) {
            Label labelNoArticles = new Label();
            Language.setCustom(Word.NO_ARTICLES_PRESENT, s -> labelNoArticles.setValue(s));
            labelNoArticles.addStyleName(ValoTheme.LABEL_H3);
            layoutProfile.addComponent(labelNoArticles);
        } else {
            p.getValue().forEach(a -> layoutProfile.addComponent(createClippingRow(a)));
        }
        Panel panelProfile = new Panel(
                Language.get(Word.GROUP) + " " + p.getKey().getGroup().getName() + ": " + p.getKey().getName(),
                layoutProfile);
        Language.setCustom(Word.GROUP, s -> panelProfile
                .setCaption(s + " " + p.getKey().getGroup().getName() + ": " + p.getKey().getName()));
        clippingArticlesLayout.addComponent(panelProfile);
    });
}