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.symeda.sormas.ui.samples.SampleListComponent.java

License:Open Source License

public SampleListComponent(CaseReferenceDto caseRef) {
    setWidth(100, Unit.PERCENTAGE);//from w  ww.j  av  a2 s .co m
    setMargin(false);
    setSpacing(false);

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

    list = new SampleList(caseRef);
    addComponent(list);
    list.reload();

    Label tasksHeader = new Label(I18nProperties.getString(Strings.entitySamples));
    tasksHeader.addStyleName(CssStyles.H3);
    componentHeader.addComponent(tasksHeader);

    if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_CREATE)) {
        createButton = new Button(I18nProperties.getCaption(Captions.sampleNewSample));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton
                .addClickListener(e -> ControllerProvider.getSampleController().create(caseRef, this::reload));
        componentHeader.addComponent(createButton);
        componentHeader.setComponentAlignment(createButton, Alignment.MIDDLE_RIGHT);
    }
}

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

License:Open Source License

public SampleListEntry(SampleIndexDto sample) {

    this.sample = sample;

    setMargin(false);/*from  ww  w .  j  a va 2s.  c om*/
    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.symeda.sormas.ui.task.TaskListComponent.java

License:Open Source License

public TaskListComponent(TaskContext context, ReferenceDto entityRef) {
    setWidth(100, Unit.PERCENTAGE);//w w w.j  av a  2s. c o  m
    setMargin(false);
    setSpacing(false);

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

    list = new TaskList(context, entityRef);
    addComponent(list);
    list.reload();

    Label tasksHeader = new Label(I18nProperties.getString(Strings.entityTasks));
    tasksHeader.addStyleName(CssStyles.H3);
    componentHeader.addComponent(tasksHeader);

    if (UserProvider.getCurrent().hasUserRight(UserRight.TASK_CREATE)) {
        createButton = new Button(I18nProperties.getCaption(Captions.taskNewTask));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(
                e -> ControllerProvider.getTaskController().create(context, entityRef, this::reload));
        componentHeader.addComponent(createButton);
        componentHeader.setComponentAlignment(createButton, Alignment.MIDDLE_RIGHT);
    }
}

From source file:de.symeda.sormas.ui.task.TaskListEntry.java

License:Open Source License

public TaskListEntry(TaskIndexDto task) {

    this.task = task;

    setMargin(false);//from   w  ww.ja v  a2 s .  c  o m
    setSpacing(true);
    setWidth(100, Unit.PERCENTAGE);
    addStyleName(CssStyles.SORMAS_LIST_ENTRY);

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

    // TOP LEFT
    VerticalLayout topLeftLayout = new VerticalLayout();

    topLeftLayout.setMargin(false);
    topLeftLayout.setSpacing(false);

    Label taskTypeLabel = new Label(DataHelper.toStringNullable(task.getTaskType()));
    CssStyles.style(taskTypeLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
    topLeftLayout.addComponent(taskTypeLabel);

    Label suggestedStartLabel = new Label(
            I18nProperties.getPrefixCaption(TaskDto.I18N_PREFIX, TaskDto.SUGGESTED_START) + ": "
                    + DateHelper.formatLocalShortDate(task.getSuggestedStart()));
    topLeftLayout.addComponent(suggestedStartLabel);

    Label dueDateLabel = new Label(I18nProperties.getPrefixCaption(TaskDto.I18N_PREFIX, TaskDto.DUE_DATE) + ": "
            + DateHelper.formatLocalShortDate(task.getDueDate()));
    topLeftLayout.addComponent(dueDateLabel);

    topLayout.addComponent(topLeftLayout);

    // TOP RIGHT
    VerticalLayout topRightLayout = new VerticalLayout();

    topRightLayout.addStyleName(CssStyles.ALIGN_RIGHT);
    topRightLayout.setMargin(false);
    topRightLayout.setSpacing(false);

    Label statusLabel = new Label(DataHelper.toStringNullable(task.getTaskStatus()));
    CssStyles.style(statusLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
    topRightLayout.addComponent(statusLabel);

    Label priorityLabel = new Label(
            DataHelper.toStringNullable(I18nProperties.getPrefixCaption(TaskDto.I18N_PREFIX, TaskDto.PRIORITY)
                    + ": " + task.getPriority()));
    if (TaskPriority.HIGH == task.getPriority()) {
        priorityLabel.addStyleName(CssStyles.LABEL_IMPORTANT);
    } else if (TaskPriority.NORMAL == task.getPriority()) {
        priorityLabel.addStyleName(CssStyles.LABEL_NEUTRAL);
    }
    topRightLayout.addComponent(priorityLabel);

    Label userLabel = new Label(I18nProperties.getPrefixCaption(TaskDto.I18N_PREFIX, TaskDto.ASSIGNEE_USER)
            + ": " + task.getAssigneeUser().getCaption());
    topRightLayout.addComponent(userLabel);

    topLayout.addComponent(topRightLayout);
    topLayout.setComponentAlignment(topRightLayout, Alignment.TOP_RIGHT);

    String statusStyle;
    switch (task.getTaskStatus()) {
    case DONE:
        statusStyle = CssStyles.LABEL_DONE;
        break;
    case NOT_EXECUTABLE:
        statusStyle = CssStyles.LABEL_NOT;
        break;
    case REMOVED:
        statusStyle = CssStyles.LABEL_DISCARDED;
        break;
    default:
        statusStyle = null;
    }

    if (statusStyle != null) {
        taskTypeLabel.addStyleName(statusStyle);
        suggestedStartLabel.addStyleName(statusStyle);
        dueDateLabel.addStyleName(statusStyle);
        statusLabel.addStyleName(statusStyle);
        priorityLabel.addStyleName(statusStyle);
        userLabel.addStyleName(statusStyle);
    }
}

From source file:de.symeda.sormas.ui.user.UserController.java

License:Open Source License

public void makeNewPassword(String userUuid) {
    String newPassword = FacadeProvider.getUserFacade().resetPassword(userUuid);

    VerticalLayout layout = new VerticalLayout();
    layout.addComponent(new Label(I18nProperties.getString(Strings.messageCopyPassword)));
    Label passwordLabel = new Label(newPassword);
    passwordLabel.addStyleName(CssStyles.H2);
    layout.addComponent(passwordLabel);//from   w w w .  ja v a 2s .c  o  m
    Window popupWindow = VaadinUiUtil.showPopupWindow(layout);
    popupWindow.setCaption(I18nProperties.getString(Strings.headingNewPassword));
    layout.setMargin(true);
}

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

License:Open Source License

/**
 * // w w  w  .ja v a 2  s.co  m
 * @param statusValues
 * @return
 * @deprecated
 */
public VerticalLayout createProjectStatusComponent(Map<String, Integer> statusValues) {
    VerticalLayout projectStatusContent = new VerticalLayout();

    Iterator<Entry<String, Integer>> it = statusValues.entrySet().iterator();
    int finishedExperiments = 0;

    while (it.hasNext()) {
        Map.Entry<String, Integer> pairs = (Map.Entry<String, Integer>) it.next();

        if ((Integer) pairs.getValue() == 0) {
            Label statusLabel = new Label(pairs.getKey() + ": " + FontAwesome.TIMES.getHtml(),
                    ContentMode.HTML);
            statusLabel.addStyleName("redicon");
            projectStatusContent.addComponent(statusLabel);
        }

        else {
            Label statusLabel = new Label(pairs.getKey() + ": " + FontAwesome.CHECK.getHtml(),
                    ContentMode.HTML);
            statusLabel.addStyleName("greenicon");

            if (pairs.getKey().equals("Project Planned")) {
                projectStatusContent.addComponentAsFirst(statusLabel);
            } else {
                projectStatusContent.addComponent(statusLabel);

            }
            finishedExperiments += (Integer) pairs.getValue();
        }
    }
    // ProgressBar progressBar = new ProgressBar();
    // progressBar.setValue((float) finishedExperiments / statusValues.keySet().size());
    // projectStatusContent.addComponent(progressBar);

    return projectStatusContent;
}

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

License:Open Source License

@Override
public void enter(ViewChangeEvent event) {
    try {/*www  .j a  v a  2 s  . c om*/
        loadProjects();
        int height = event.getNavigator().getUI().getPage().getBrowserWindowHeight();
        int width = event.getNavigator().getUI().getPage().getBrowserWindowWidth();
        buildLayout(height, width, event.getNavigator().getUI().getPage().getWebBrowser());
    } catch (Exception e) {
        LOGGER.error(String.format("failed to load projects for user %s", user), e);
        // homeview_content.removeAllComponents();
        removeAllComponents();
        Label error = new Label("Connection to database interrupted. Please try again later.");
        error.addStyleName(ValoTheme.LABEL_FAILURE);
        error.addStyleName(ValoTheme.LABEL_HUGE);
        addComponent(error);
        setComponentAlignment(error, Alignment.MIDDLE_CENTER);

        // homeview_content.addComponent(error);
        // homeview_content.setComponentAlignment(error, Alignment.MIDDLE_CENTER);
        // this.addComponent(homeview_content);
    }
}

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

License:Open Source License

/**
 * starts the querying of openbis and initializing the view
 * //from  ww  w. j  a va 2s  .  c o m
 * @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 {//  ww w . j  a  va 2 s  . co  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  w  w w  .j  a  v a 2  s. c  o m
    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)));
}