Example usage for com.google.gwt.uibinder.rebind XMLElement consumeSingleChildElement

List of usage examples for com.google.gwt.uibinder.rebind XMLElement consumeSingleChildElement

Introduction

In this page you can find the example usage for com.google.gwt.uibinder.rebind XMLElement consumeSingleChildElement.

Prototype

public XMLElement consumeSingleChildElement() throws UnableToCompleteException 

Source Link

Document

Consumes a single child element, ignoring any text nodes and throwing an exception if no child is found, or more than one child element is found.

Usage

From source file:com.jhickman.web.gwt.gxtuibinder.elementparsers.ContentPanelParser.java

License:Apache License

protected void handleTopBottomComponents(XMLElement elem, String fieldName, UiBinderWriter writer)
        throws UnableToCompleteException {
    Interpreter<Boolean> topBottomComponentInterpreter = new TopBottomComponentInterpreter(
            elem.getNamespaceUri());/* ww w . j  av  a2s  .  c  om*/

    for (XMLElement child : elem.consumeChildElements(topBottomComponentInterpreter)) {
        XMLElement widget = child.consumeSingleChildElement();

        if (!isComponentElement(writer, widget)) {
            writer.die(elem, "%s must contain a GXT Component, but found %s", child, widget);
        }

        String widgetName = writer.parseElementToField(widget);
        String methodName = SupportedChildLocalNames.valueOf(child.getLocalName()).getMethodName();
        writer.addStatement("%s.%s(%s);", fieldName, methodName, widgetName);
    }
}

From source file:com.jhickman.web.gwt.gxtuibinder.elementparsers.form.AdapterFieldParser.java

License:Apache License

@Override
public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer)
        throws UnableToCompleteException {

    XMLElement childElement = elem.consumeSingleChildElement();
    String childField = writer.parseElementToField(childElement);

    writer.setFieldInitializerAsConstructor(fieldName, type, childField);
}

From source file:com.jhickman.web.gwt.gxtuibinder.elementparsers.menu.AdapterMenuItemParser.java

License:Apache License

public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer)
        throws UnableToCompleteException {

    XMLElement childElement = elem.consumeSingleChildElement();
    if (!writer.isWidgetElement(childElement)) {
        writer.die(elem, "Child element must be a widget type. Found: %s", childElement);
    }/* ww w  .j  a  v  a2s  .  c  o  m*/

    String widget = writer.parseElementToField(childElement);
    writer.setFieldInitializerAsConstructor(fieldName, type, widget);
}

From source file:com.jhickman.web.gwt.gxtuibinder.elementparsers.menu.MenuBarItemParser.java

License:Apache License

public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer)
        throws UnableToCompleteException {
    XMLElement menu = elem.consumeSingleChildElement();

    if (!isMenuElement(writer, menu)) {
        writer.die(elem, "%s must contain a Menu, but found %s", elem, menu);
    }/*from   ww  w  . j ava  2  s .  co m*/

    String menuItemText = elem.consumeStringAttribute("text");
    String menuFieldName = writer.parseElementToField(menu);

    writer.setFieldInitializerAsConstructor(fieldName, type, menuItemText, menuFieldName);
}