com.extjs.gxt.ui.client.core.MarkupBase.java Source code

Java tutorial

Introduction

Here is the source code for com.extjs.gxt.ui.client.core.MarkupBase.java

Source

/*
 * Sencha GXT 2.3.1 - Sencha for GWT
 * Copyright(c) 2007-2013, Sencha, Inc.
 * licensing@sencha.com
 * 
 * http://www.sencha.com/products/gxt/license/
 */
package com.extjs.gxt.ui.client.core;

import com.extjs.gxt.ui.client.GXT;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;

public class MarkupBase implements Markup {

    static {
        GXT.init();
    }

    private String html;
    private Element rootElement;

    public static Element createRootElement(String html) {
        Element rootElement = DOM.createDiv();
        rootElement.setInnerHTML(html);
        if (rootElement.getFirstChild() != null) {
            rootElement = rootElement.getFirstChildElement().cast();
        }
        return rootElement;
    }

    public String getHtml() {
        return html;
    }

    /**
     * for use by the generator only
     */
    public void init(String html, Element rootElement) {
        this.html = html;
        this.rootElement = rootElement;
    }

    public Element select(String selector) {
        assert rootElement != null : "rootElement is null";
        return DomQuery.selectNode(selector, rootElement);
    }

    public Element getRootElement() {
        return rootElement;
    }

}