Example usage for com.vaadin.ui.declarative DesignContext readDesign

List of usage examples for com.vaadin.ui.declarative DesignContext readDesign

Introduction

In this page you can find the example usage for com.vaadin.ui.declarative DesignContext readDesign.

Prototype

public Component readDesign(Element componentDesign) 

Source Link

Document

Reads the given design node and creates the corresponding component tree.

Usage

From source file:org.opencms.ui.components.CmsBasicDialog.java

License:Open Source License

/**
 * @see com.vaadin.ui.AbstractOrderedLayout#readDesign(org.jsoup.nodes.Element, com.vaadin.ui.declarative.DesignContext)
 *//*  ww  w .j av a 2 s . com*/
@Override
public void readDesign(Element design, DesignContext designContext) {

    for (Element child : design.children()) {
        boolean contentRead = false;
        boolean buttonsRead = false;
        boolean aboveRead = false;
        boolean belowRead = false;
        if ("content".equals(child.tagName()) && !contentRead) {
            Component content = designContext.readDesign(child.child(0));
            setContent(content);
            contentRead = true;
        } else if ("buttons".equals(child.tagName()) && !buttonsRead) {
            for (Element buttonElement : child.children()) {
                Component button = designContext.readDesign(buttonElement);
                Attributes attr = buttonElement.attributes();
                addButton(button, !attr.hasKey(":left"));
            }
            buttonsRead = true;
        } else if ("above".equals(child.tagName()) && !aboveRead) {
            Component aboveContent = designContext.readDesign(child.child(0));
            setAbove(aboveContent);
            aboveRead = true;
        } else if ("below".equals(child.tagName()) && !belowRead) {
            Component belowContent = designContext.readDesign(child.child(0));
            setBelow(belowContent);
            belowRead = true;
        }
    }
}