Example usage for com.vaadin.ui Label setStyleName

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

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.RelatedProjectsInfoBox.java

License:Open Source License

protected void addCalculatedContent(Project project, Layout layout) {
    SearchService searchService = Services.getService(SearchService.class);
    if (searchService == null) {
        return;/*from w  w w . j a  v a 2  s  . c  o  m*/
    }
    SearchResult<Project> relatedProjects = searchService.getRelatedProjects(project, 3);
    if (relatedProjects.getResultCount() == 0) {
        createLabel(layout, HSPACE + "No matches found");
        return;
    }
    for (SearchHit<Project> hit : relatedProjects.getResult()) {
        ExternalResource externalResource = new ExternalResource("/projects/" + hit.getEntity().getProjectId());
        String content = HSPACE + "<a href=" + externalResource.getURL() + ">" + hit.getEntity().getName()
                + "*</a>";
        createLabel(layout, content);
    }
    Label label = new Label(HSPACE + "*calculated based on similarities between the projects",
            Label.CONTENT_XHTML);
    label.setStyleName("light");//$NON-NLS-1$
    layout.addComponent(label);

}

From source file:org.eclipse.skalli.view.ext.InfoBoxBase.java

License:Open Source License

protected void addLastModifiedInfo(Layout layout, String caption, String lastModified, String lastModifiedBy) {
    if (lastModified == null) {
        return;/*from  w  w  w . j  ava2  s .  c om*/
    }

    StringBuilder sb = new StringBuilder();
    sb.append("<span style=\"font-size:x-small\">");

    if (StringUtils.isNotBlank(caption)) {
        sb.append(caption);
    } else {
        sb.append(LAST_MODIFIED);
    }
    sb.append(" ");
    sb.append(lastModified);
    if (StringUtils.isNotBlank(lastModifiedBy)) {
        sb.append(" by ").append(lastModifiedBy);
    }
    sb.append("</span>");

    Label label = asLabel(sb.toString());
    label.setStyleName("light");
    label.addStyleName(STYLE_LABEL);
    layout.addComponent(label);
}

From source file:org.eclipse.skalli.view.internal.window.ProjectEditPanelEntry.java

License:Open Source License

@SuppressWarnings("serial")
private ComponentContainer createTray() {
    CssLayout layout = new CssLayout();
    layout.setStyleName(STYLE_TRAY);/*w ww .  ja va  2s  .c om*/
    layout.setMargin(true);

    HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);
    header.setStyleName(STYLE_TRAY_HEADER);
    header.setWidth("100%"); //$NON-NLS-1$

    trayIcon = new Embedded();
    trayIcon.setStyleName(STYLE_TRAY_HEADER_ICON);

    final String icon = formService.getIconPath();
    if (StringUtils.isNotBlank(icon)) {
        trayIcon.setSource(new StreamResource(new ExtensionStreamSource(formService.getClass(), icon),
                FilenameUtils.getName(icon), application));
    }
    header.addComponent(trayIcon);
    header.setComponentAlignment(trayIcon, Alignment.MIDDLE_LEFT);
    header.setExpandRatio(trayIcon, 0);

    Label captionLabel = new Label(getCaptionWithAnchor(), Label.CONTENT_XHTML);
    captionLabel.setStyleName(STYLE_TRAY_HEADER_LABEL);
    header.addComponent(captionLabel);
    header.setExpandRatio(captionLabel, 1);
    header.setComponentAlignment(captionLabel, Alignment.MIDDLE_LEFT);

    editButton = new Button();
    layoutLinkButton(editButton, header, new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            switch (state) {
            case DISABLED:
                setState(TrayState.EDITABLE_VISIBLE);
                break;
            case INHERITED_VISIBLE:
                setState(TrayState.EDITABLE_VISIBLE);
                break;
            case INHERITED_INVISIBLE:
                setState(TrayState.EDITABLE_VISIBLE);
                break;
            }
        }
    });

    inheritButton = new Button();
    layoutLinkButton(inheritButton, header, new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            form.commit();
            switch (state) {
            case DISABLED:
                setState(TrayState.INHERITED_VISIBLE);
                break;
            case EDITABLE_VISIBLE:
                setState(TrayState.INHERITED_VISIBLE);
                break;
            case EDITABLE_INVISIBLE:
                setState(TrayState.INHERITED_VISIBLE);
                break;
            }
        }
    });

    disableButton = new Button();
    layoutLinkButton(disableButton, header, new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            form.commit();
            switch (state) {
            case EDITABLE_INVISIBLE:
                setState(TrayState.DISABLED);
                break;
            case EDITABLE_VISIBLE:
                setState(TrayState.DISABLED);
                break;
            case INHERITED_INVISIBLE:
                setState(TrayState.DISABLED);
                break;
            case INHERITED_VISIBLE:
                setState(TrayState.DISABLED);
                break;
            }
        }
    });

    visibleButton = new NativeButton();
    layoutIconButton(visibleButton, header, new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            switch (state) {
            case EDITABLE_INVISIBLE:
                setState(TrayState.EDITABLE_VISIBLE);
                break;
            case EDITABLE_VISIBLE:
                setState(TrayState.EDITABLE_INVISIBLE);
                break;
            case INHERITED_INVISIBLE:
                setState(TrayState.INHERITED_VISIBLE);
                break;
            case INHERITED_VISIBLE:
                setState(TrayState.INHERITED_INVISIBLE);
                break;
            }
        }
    });

    layout.addComponent(header);

    CssLayout content = new CssLayout();
    Label descriptionLabel = new Label(extensionService.getDescription(), Label.CONTENT_XHTML);
    descriptionLabel.setStyleName(STYLE_TRAY_DESCRIPTION);
    content.addComponent(descriptionLabel);

    layout.addComponent(content);
    return layout;
}

From source file:org.escidoc.browser.controller.ContentModelView.java

License:Open Source License

private VerticalLayout bindNameToHeader() {
    VerticalLayout headerLayout = new VerticalLayout();
    headerLayout.setMargin(false);/*from www  .j a  v  a  2s  . com*/
    headerLayout.setWidth("100%");
    final Label headerContext = new Label("Content Model: " + resourceProxy.getName());
    headerContext.setStyleName("h1 fullwidth");
    headerContext.setDescription("Content Model");
    headerLayout.addComponent(headerContext);
    return headerLayout;
}

From source file:org.escidoc.browser.controller.ContentModelView.java

License:Open Source License

private HorizontalLayout bindProperties() {
    HorizontalLayout hlProperties = new HorizontalLayout();
    hlProperties.setWidth("100%");
    VerticalLayout vlLeft = new VerticalLayout();
    VerticalLayout vlRight = new VerticalLayout();
    final Label descMetadata1 = new Label("ID: " + resourceProxy.getId());

    vlLeft.addComponent(descMetadata1);/*from   w w w . jav  a 2s. c o m*/

    // RIGHT SIDE
    final Label descMetadata2 = new Label(ViewConstants.CREATED_BY + " " + resourceProxy.getCreator() + " on "
            + resourceProxy.getCreatedOn() + "<br/>", Label.CONTENT_XHTML);

    descMetadata2.setStyleName("floatright columnheight50");
    descMetadata2.setWidth("65%");
    vlRight.addComponent(descMetadata2);

    hlProperties.addComponent(vlLeft);
    hlProperties.setExpandRatio(vlLeft, 0.4f);
    hlProperties.addComponent(vlRight);
    hlProperties.setExpandRatio(vlRight, 0.6f);
    return hlProperties;
}

From source file:org.escidoc.browser.controller.ContentModelView.java

License:Open Source License

private static void addHorizontalRuler(AbstractComponentContainer contentLayout) {
    final Label descRuler = new Label("<hr />", Label.CONTENT_RAW);
    descRuler.setStyleName("hr");
    contentLayout.addComponent(descRuler);
}

From source file:org.escidoc.browser.elabsmodul.views.helpers.LabsLayoutHelper.java

License:Open Source License

public static HorizontalLayout createHorizontalLayoutWithELabsLabelAndLabelData(final String labelTxt,
        Property dataProperty, boolean required) {
    Preconditions.checkNotNull(labelTxt, "Label is null");
    Preconditions.checkNotNull(dataProperty, "DataSource is null");
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeUndefined();
    horizontalLayout.setDescription(USER_DESCR_ON_HOR_LAYOUT_TO_EDIT);
    horizontalLayout.setEnabled(true);/*  w  w  w .j  a v  a  2s  .  c  om*/
    horizontalLayout.setSpacing(true);
    horizontalLayout.setHeight(HOR_PANEL_HEIGHT);
    Label label = new Label();
    label.setWidth(LABEL_WIDTH);
    label.setValue(DIV_ALIGN_RIGHT + (required ? ELabsViewContants.REQUIRED_SIGN : "") + labelTxt + DIV_END);
    label.setContentMode(Label.CONTENT_XHTML);
    label.setDescription(USER_DESCR_ON_LABEL_TO_EDIT);
    Label textLabel = new Label(dataProperty);
    textLabel.setWidth(TEXT_WIDTH);
    textLabel.setDescription(USER_DESCR_ON_LABEL_TO_EDIT);
    textLabel.setStyleName(STYLE_ELABS_TEXT_AS_LABEL);
    horizontalLayout.setStyleName(STYLE_ELABS_HOR_PANEL);
    horizontalLayout.addComponent(label, 0);
    horizontalLayout.addComponent(textLabel, 1);
    horizontalLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    horizontalLayout.setComponentAlignment(textLabel, Alignment.MIDDLE_RIGHT);
    return horizontalLayout;
}

From source file:org.escidoc.browser.elabsmodul.views.helpers.LabsLayoutHelper.java

License:Open Source License

public static HorizontalLayout createHorizontalLayoutWithELabsLabelAndStaticComboData(final String labelTxt,
        String value, boolean required) {
    Preconditions.checkNotNull(labelTxt, "Label is null");
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeUndefined();
    horizontalLayout.setDescription(USER_DESCR_ON_HOR_LAYOUT_TO_EDIT);
    horizontalLayout.setEnabled(true);/*from w w w .j ava2 s  . c o m*/
    horizontalLayout.setSpacing(true);
    horizontalLayout.setHeight(HOR_PANEL_HEIGHT);
    Label label = new Label();
    label.setWidth(LABEL_WIDTH);
    label.setValue(DIV_ALIGN_RIGHT + (required ? ELabsViewContants.REQUIRED_SIGN : "") + labelTxt + DIV_END);
    label.setContentMode(Label.CONTENT_XHTML);
    label.setDescription(USER_DESCR_ON_LABEL_TO_EDIT);
    Label textLabel = new Label(value);
    textLabel.setWidth(TEXT_WIDTH);
    textLabel.setDescription(USER_DESCR_ON_LABEL_TO_EDIT);
    textLabel.setStyleName(STYLE_ELABS_TEXT_AS_LABEL);
    horizontalLayout.setStyleName(STYLE_ELABS_HOR_PANEL);
    horizontalLayout.addComponent(label, 0);
    horizontalLayout.addComponent(textLabel, 1);
    horizontalLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    horizontalLayout.setComponentAlignment(textLabel, Alignment.MIDDLE_RIGHT);
    return horizontalLayout;
}

From source file:org.escidoc.browser.elabsmodul.views.helpers.LabsLayoutHelper.java

License:Open Source License

public static HorizontalLayout createHorizontalLayoutWithELabsLabelAndLabelComplexData(final String labelTxt,
        String dataTxt, boolean required) {
    Preconditions.checkNotNull(labelTxt, "Label is null");
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeUndefined();
    horizontalLayout.setDescription(USER_DESCR_ON_HOR_LAYOUT_TO_EDIT);
    horizontalLayout.setEnabled(true);//from   w  w  w . j  a  v a2  s.co  m
    horizontalLayout.setSpacing(true);
    horizontalLayout.setHeight(HOR_PANEL_HEIGHT);
    Label label = new Label();
    label.setWidth(LABEL_WIDTH);
    label.setValue(DIV_ALIGN_RIGHT + (required ? ELabsViewContants.REQUIRED_SIGN : "") + labelTxt + DIV_END);
    label.setContentMode(Label.CONTENT_XHTML);
    label.setDescription(USER_DESCR_ON_LABEL_TO_EDIT);
    Label textLabel = new Label(dataTxt);
    textLabel.setWidth(TEXT_WIDTH);
    textLabel.setDescription(USER_DESCR_ON_LABEL_TO_EDIT);
    textLabel.setStyleName(STYLE_ELABS_TEXT_AS_LABEL);
    horizontalLayout.setStyleName(STYLE_ELABS_HOR_PANEL);
    horizontalLayout.addComponent(label, 0);
    horizontalLayout.addComponent(textLabel, 1);
    horizontalLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    horizontalLayout.setComponentAlignment(textLabel, Alignment.MIDDLE_RIGHT);
    return horizontalLayout;
}

From source file:org.escidoc.browser.elabsmodul.views.helpers.LabsLayoutHelper.java

License:Open Source License

public static HorizontalLayout createHorizontalLayoutWithELabsLabelAndRelatedDataForRig(final String labelTxt,
        Property dataProperty, RigBean rigBean, final IRigAction controller, LabsRigTableHelper helper,
        boolean required) {
    synchronized (LOCK_1) {
        Preconditions.checkNotNull(labelTxt, "Label is null");
        Preconditions.checkNotNull(dataProperty, "DataSource is null");
        Preconditions.checkNotNull(rigBean, "RigBean is null");
        Preconditions.checkNotNull(helper, "Helper is null");
        Preconditions.checkNotNull(controller, "Controller is null");
        HorizontalLayout horizontalLayout = new HorizontalLayout();
        horizontalLayout.setSizeUndefined();
        horizontalLayout.setEnabled(true);
        horizontalLayout.setSpacing(true);
        horizontalLayout.setStyleName(STYLE_ELABS_HOR_PANEL_FOR_TABLE);
        Label label = new Label();
        label.setWidth(LABEL_WIDTH);//from   w w w .j  av a 2 s  .c  o  m
        label.setValue(
                DIV_ALIGN_RIGHT + (required ? ELabsViewContants.REQUIRED_SIGN : "") + labelTxt + DIV_END);
        label.setContentMode(Label.CONTENT_XHTML);
        label.setDescription(USER_DESCR_ON_LABEL_TO_EDIT);
        label.setStyleName(STYLE_ELABS_HOR_PANEL);
        horizontalLayout.addComponent(label, 0);
        horizontalLayout.addComponent(helper.createTableLayoutForRig(rigBean, controller), 1);
        horizontalLayout.setComponentAlignment(label, Alignment.TOP_LEFT);
        return horizontalLayout;
    }
}