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.escidoc.browser.elabsmodul.views.helpers.LabsLayoutHelper.java

License:Open Source License

public static HorizontalLayout createHorizontalLayoutWithPublicationDataForStudy(final String labelTxt,
        Property dataProperty, boolean isMotNotResPublication, LabsStudyTableHelper helper, boolean required) {
    synchronized (LOCK_2) {
        Preconditions.checkNotNull(labelTxt, "Label is null");
        Preconditions.checkNotNull(dataProperty, "DataSource is null");
        Preconditions.checkNotNull(helper, "Helper 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);// w  w w  . ja v a2 s  . c om
        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);
        if (isMotNotResPublication) {
            horizontalLayout.addComponent(helper.createTableLayoutForMotPublications(), 1);
        } else {
            horizontalLayout.addComponent(helper.createTableLayoutForResPublications(), 1);
        }
        horizontalLayout.setComponentAlignment(label, Alignment.TOP_LEFT);
        return horizontalLayout;
    }
}

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

License:Open Source License

/**
 * Returns with a label based on the edited field.
 * //ww  w. ja va 2  s  .c  om
 * @param property
 * @return boolean an element switch happened or not
 */
public static boolean switchToLabelFromEditedField(HorizontalLayout parentLayout) {
    Preconditions.checkNotNull(parentLayout, "ParentLayout on DynamicLayout is null");
    Component staticLabelComponent = null, dataComponent = null;
    try {
        staticLabelComponent = parentLayout.getComponent(0);
        dataComponent = parentLayout.getComponent(1);
    } catch (IndexOutOfBoundsException e) {
        LOG.error("This layout should contain only 2 components!");
        return false;
    }
    Property dataProperty = null;
    Label label = null;
    if (dataComponent instanceof TextField) {
        dataProperty = ((TextField) dataComponent).getPropertyDataSource();
        label = new Label(dataProperty);
    } else if (dataComponent instanceof ComboBox) {
        if (((ComboBox) dataComponent).getValue() instanceof String) {
            dataProperty = ((ComboBox) dataComponent).getPropertyDataSource();
            if (dataProperty == null) {
                label = new Label((String) ((ComboBox) dataComponent).getValue());
            } else {
                label = new Label(dataProperty);
            }
        } else if (((ComboBox) dataComponent).getValue() instanceof RigBean) {
            label = new Label(((RigBean) ((ComboBox) dataComponent).getValue()).getComplexId());
        } else if (((ComboBox) dataComponent).getValue() instanceof UserBean) {
            label = new Label(((UserBean) ((ComboBox) dataComponent).getValue()).getComplexId());
        } else if (((ComboBox) dataComponent).getValue() instanceof OrgUnitBean) {
            label = new Label(((OrgUnitBean) ((ComboBox) dataComponent).getValue()).getComplexId());
        } else if (((ComboBox) dataComponent).getValue() instanceof FileFormatBean) {
            label = new Label(((FileFormatBean) ((ComboBox) dataComponent).getValue()).getTitle());
        } else {
            LOG.error("Incorrect data type at the switch to label");
        }
    } else if (dataComponent instanceof Label) {
        label = (Label) dataComponent;
    } else if (dataComponent instanceof CheckBox || dataComponent instanceof VerticalLayout) {
        return true;
    }

    if (label == null) {
        LOG.debug("The wrong dataComponent is " + dataComponent.toString());
        return false;
    }
    label.setWidth(TEXT_WIDTH);
    label.setStyleName(STYLE_ELABS_TEXT_AS_LABEL);
    label.setDescription(USER_DESCR_ON_LABEL_TO_EDIT);
    parentLayout.replaceComponent(dataComponent, label);
    parentLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    ((Label) staticLabelComponent).setDescription(USER_DESCR_ON_LABEL_TO_EDIT);
    parentLayout.setDescription(USER_DESCR_ON_HOR_LAYOUT_TO_EDIT);
    return true;
}

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

License:Open Source License

public Panel generatePropertiesView() {
    // Item title
    String resourceType = resourceProxy.getType().toString();
    if (this.type != null && this.type.length() > 0) {
        resourceType = this.type;
    }// ww w .java 2 s . c  o  m
    final Label titleLabel = new Label(resourceType.substring(0, 1).toUpperCase()
            + resourceType.substring(1).toLowerCase() + ": " + resourceProxy.getName());
    titleLabel.setDescription("header");
    titleLabel.setStyleName("h2 fullwidth");

    // HR Ruler
    final Label descRuler = new Label("<hr/>", Label.CONTENT_RAW);
    descRuler.setStyleName("hr");

    // ItemProperties View
    final CssLayout propertiesView = new CssLayout();
    propertiesView.setWidth("100%");
    propertiesView.setHeight("100%");

    final Label descMetadata1 = new Label("ID: " + resourceProxy.getId());
    final Label descMetadata2 = new Label(
            LAST_MODIFIED_BY + " " + resourceProxy.getModifier() + " on " + resourceProxy.getModifiedOn(),
            Label.CONTENT_XHTML);

    final Panel pnlPropertiesLeft = buildLeftPanel();
    pnlPropertiesLeft.setWidth("40%");
    pnlPropertiesLeft.setHeight("20px");
    pnlPropertiesLeft.setStyleName(FLOAT_LEFT);
    pnlPropertiesLeft.addStyleName(Runo.PANEL_LIGHT);
    pnlPropertiesLeft.getLayout().setMargin(false);
    pnlPropertiesLeft.addComponent(descMetadata1);

    final Panel pnlPropertiesRight = buildRightPanel();
    pnlPropertiesRight.setWidth("60%");
    pnlPropertiesRight.setHeight("20px");
    pnlPropertiesRight.setStyleName(FLOAT_RIGHT);
    pnlPropertiesRight.addStyleName(Runo.PANEL_LIGHT);
    pnlPropertiesRight.getLayout().setMargin(false);
    pnlPropertiesRight.addComponent(descMetadata2);

    propertiesView.addComponent(pnlPropertiesLeft);
    propertiesView.addComponent(pnlPropertiesRight);

    Panel viewHandler = buildmainView();

    new BreadCrumbMenu(viewHandler, breadCrumbModel, serviceLocation);

    viewHandler.addComponent(titleLabel);
    viewHandler.addComponent(descRuler);
    viewHandler.addComponent(propertiesView);

    return viewHandler;
}

From source file:org.escidoc.browser.ui.helper.ViewHelper.java

License:Open Source License

public static Label buildCreateAndModifyLabel(ResourceProxy resourceProxy) {
    final Label createAndMofidyLabel = new Label(ViewConstants.CREATED_BY + " " + resourceProxy.getCreator()
            + " on " + resourceProxy.getCreatedOn() + "<br/>" + ViewConstants.LAST_MODIFIED_BY + " "
            + resourceProxy.getModifier() + " on " + resourceProxy.getModifiedOn(), Label.CONTENT_XHTML);

    createAndMofidyLabel.setStyleName("floatright columnheight50");
    createAndMofidyLabel.setWidth("65%");

    return createAndMofidyLabel;
}

From source file:org.escidoc.browser.ui.maincontent.ContainerMetadataRecordsView.java

License:Open Source License

private static void buildPanelHeader(CssLayout cssLayout, String name) {
    cssLayout.addStyleName("v-accordion-item-caption v-caption v-captiontext");
    cssLayout.setWidth("100%");
    cssLayout.setMargin(false);//from  w ww.ja  va2  s  . c om

    final Label nameofPanel = new Label(name, Label.CONTENT_RAW);
    nameofPanel.setStyleName("accordion v-captiontext");
    nameofPanel.setWidth("70%");
    cssLayout.addComponent(nameofPanel);
}

From source file:org.escidoc.browser.ui.maincontent.ContainerView.java

License:Open Source License

private static void addHorizontalRuler(CssLayout cssLayout) {
    final Label descRuler = new Label("<hr />", Label.CONTENT_RAW);
    descRuler.setStyleName("hr");
    cssLayout.addComponent(descRuler);/*  w w w  .j  a v a 2  s . c  om*/
}

From source file:org.escidoc.browser.ui.maincontent.ContainerView.java

License:Open Source License

private void bindDescription(CssLayout cssLayout) {
    final Label description = new Label(ViewConstants.DESCRIPTION_LBL + resourceProxy.getDescription());
    description.setStyleName(ViewConstants.FULLWIDHT_STYLE_NAME);
    cssLayout.addComponent(description);
}

From source file:org.escidoc.browser.ui.maincontent.ContainerView.java

License:Open Source License

/**
 * Building the Header Element that shows the title of the Container
 *///from  w  w w  . java2 s  . c o m
private void bindNameToHeader(CssLayout cssLayout) {
    final Label headerContext = new Label(ViewConstants.RESOURCE_NAME_CONTAINER + resourceProxy.getName());
    headerContext.setStyleName("h1 fullwidth floatleft");
    headerContext.setWidth("80%");
    headerContext.setDescription(ViewConstants.DESC_HEADER);
    cssLayout.addComponent(headerContext);
}

From source file:org.escidoc.browser.ui.maincontent.ContextView.java

License:Open Source License

private VerticalLayout bindNameToHeader() {
    headerLayout = new VerticalLayout();
    headerLayout.setMargin(false);/*from w w  w. j a v  a2s  .co  m*/
    headerLayout.setWidth("100%");
    final Label headerContext = new Label(ViewConstants.RESOURCE_NAME_CONTEXT + resourceProxy.getName());
    headerContext.setStyleName("h1 fullwidth");
    headerContext.setDescription(ViewConstants.RESOURCE_NAME_CONTEXT);
    headerLayout.addComponent(headerContext);
    return headerLayout;
}

From source file:org.escidoc.browser.ui.maincontent.ContextView.java

License:Open Source License

private VerticalLayout bindDescription() {
    VerticalLayout descLayout = new VerticalLayout();
    descLayout.setMargin(false);//from   w  ww . ja va  2 s.  c  om
    descLayout.setWidth("100%");
    final Label headerContext = new Label(ViewConstants.DESCRIPTION_LBL + resourceProxy.getDescription());
    headerContext.setStyleName("fullwidth");

    descLayout.addComponent(headerContext);
    return descLayout;
}