Example usage for com.vaadin.ui Layout setStyleName

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

Introduction

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

Prototype

public void setStyleName(String style);

Source Link

Document

Sets one or more user-defined style names of the component, replacing any previous user-defined styles.

Usage

From source file:com.ocs.dynamo.ui.composite.form.ModelBasedEditForm.java

License:Apache License

/**
 * Constructs the main layout of the screen
 * /* ww  w  .  jav a  2  s .c  o m*/
 * @param entityModel
 * @return
 */
protected VerticalLayout buildMainLayout(EntityModel<T> entityModel) {
    VerticalLayout layout = new VerticalLayout();

    titleLabels.put(isViewMode(), constructTitleLabel());

    // horizontal layout that contains title label and buttons

    titleBars.put(isViewMode(), new DefaultHorizontalLayout(false, true, true));
    titleBars.get(isViewMode()).addComponent(titleLabels.get(isViewMode()));

    HorizontalLayout buttonBar = constructButtonBar();
    buttonBar.setSizeUndefined();
    titleBars.get(isViewMode()).addComponent(buttonBar);
    layout.addComponent(titleBars.get(isViewMode()));

    Layout form = null;
    if (entityModel.usesDefaultGroupOnly()) {
        form = new FormLayout();
    } else {
        form = new DefaultVerticalLayout(false, true);
    }

    // in case of vertical layout (the default), don't use the entire screen
    if (ScreenMode.VERTICAL.equals(getFormOptions().getScreenMode())) {
        form.setStyleName(DynamoConstants.CSS_CLASS_HALFSCREEN);
    }

    int count = 0;
    if (!entityModel.usesDefaultGroupOnly()) {
        // display the attributes in groups

        TabSheet tabSheet = null;
        boolean tabs = AttributeGroupMode.TABSHEET.equals(getFormOptions().getAttributeGroupMode());
        if (tabs) {
            tabSheet = new TabSheet();
            form.addComponent(tabSheet);
        }

        if (getParentGroupHeaders() != null && getParentGroupHeaders().length > 0) {
            // extra layer of grouping
            for (String parentGroupHeader : getParentGroupHeaders()) {
                Layout innerForm = constructAttributeGroupLayout(form, tabs, tabSheet, parentGroupHeader,
                        false);

                // add a tab sheet on the inner level if needed
                TabSheet innerTabSheet = null;
                boolean innerTabs = !tabs;
                if (innerTabs) {
                    innerTabSheet = new TabSheet();
                    innerForm.addComponent(innerTabSheet);
                }

                // add all appropriate inner groups
                int tempCount = processParentHeaderGroup(parentGroupHeader, innerForm, innerTabs, innerTabSheet,
                        count);
                count += tempCount;
            }
        } else {
            // just one layer of attribute groups
            for (String attributeGroup : entityModel.getAttributeGroups()) {
                if (entityModel.isAttributeGroupVisible(attributeGroup, viewMode)) {
                    Layout innerForm = constructAttributeGroupLayout(form, tabs, tabSheet,
                            getAttributeGroupCaption(attributeGroup), true);

                    for (AttributeModel attributeModel : entityModel
                            .getAttributeModelsForGroup(attributeGroup)) {
                        addField(innerForm, entityModel, attributeModel, count);
                        count++;
                    }
                }
            }
        }
    } else {
        // iterate over the attributes and add them to the form (without any
        // grouping)
        for (AttributeModel attributeModel : entityModel.getAttributeModels()) {
            addField(form, entityModel, attributeModel, count);
            count++;
        }
    }

    layout.addComponent(form);

    if (firstField != null) {
        firstField.focus();
    }

    buttonBar = constructButtonBar();
    buttonBar.setSizeUndefined();
    layout.addComponent(buttonBar);
    checkSaveButtonState();

    return layout;
}

From source file:nz.co.senanque.vaadinsupport.tableeditor.EditorWindowImpl.java

License:Apache License

public void initialize(List<String> fields) {
    Layout main = new VerticalLayout();
    setLayout(main);//w ww.  j av a 2  s  . co m
    main.setWidth(getWindowWidth());
    main.setStyleName(Panel.STYLE_LIGHT);

    setFields(fields);
    m_form.setSizeFull();

    main.addComponent(m_form);

    save = m_form.createButton("save", new SubmitButtonPainter(m_maduraSessionManager), this);
    delete = m_form.createButton("delete", new SimpleButtonPainter(m_maduraSessionManager), this);
    close = m_form.createButton("close", new SimpleButtonPainter(m_maduraSessionManager), this);

    extraFields();
    HorizontalLayout actions = new HorizontalLayout();
    actions.addComponent(save);

    save.addListener(this);

    actions.addComponent(delete);
    delete.addListener(this);
    close.addListener(this);
    actions.addComponent(close);

    main.addComponent(actions);
}

From source file:org.ripla.web.RiplaApplication.java

License:Open Source License

private Layout createBody() {
    final Layout outBody = new VerticalLayout();
    outBody.setStyleName("ripla-body");
    outBody.setSizeFull();//from www . j  a v  a 2  s .c om
    return outBody;
}

From source file:pl.exsio.frameset.vaadin.ui.support.component.data.common.DataComponent.java

License:Open Source License

private Layout buildForm(final I item, final C container, final Window formWindow, final int mode) {
    F form = this.instantiateForm(item, container, formWindow, mode);
    this.formatForm(form);
    VerticalLayout mainLayout = new VerticalLayout();
    Layout formLayout = this.decorateForm(form, item, mode);
    formLayout.setSizeUndefined();// ww  w  .j a  va 2  s  .  c o  m
    formLayout.setStyleName("frameset-dc-window-form-wrapper");
    if (formLayout instanceof MarginHandler) {
        ((MarginHandler) formLayout).setMargin(new MarginInfo(false, true, false, true));
    }
    Layout controls = this.decorateFormControls(
            this.createFormControls(item, form, container, formWindow, mode), item, form, container, formWindow,
            mode);
    mainLayout.addComponent(formLayout);
    mainLayout.addComponent(controls);
    mainLayout.setExpandRatio(formLayout, 10);
    mainLayout.setExpandRatio(controls, 1);
    mainLayout.setSizeUndefined();
    return mainLayout;

}