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

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

Introduction

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

Prototype

public String consumeRawAttribute(String name, String defaultValue) 

Source Link

Document

Consumes the given attribute and returns its trimmed value, or the given default value if it was unset.

Usage

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

License:Apache License

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

    String parameterizedType = elem.consumeRawAttribute("type", "java.lang.String");
    JClassType valueType = writer.getOracle().findType(parameterizedType);
    if (valueType == null) {
        writer.die(elem, "Found type attribute, but unable to resolve the value: %s", parameterizedType);
    }/*from   w w w.  j ava2s .c  om*/

    for (XMLElement child : elem.consumeChildElements()) {
        if (!child.getNamespaceUri().equals(elem.getNamespaceUri())) {
            writer.die(elem,
                    "Children of SimpleComboBox must be in the same namespace.  Expected '%s' but found '%s'",
                    elem.getPrefix(), child.getPrefix());
        }

        String data = parseChildElement(child, valueType, writer);

        writer.addStatement("%s.add(%s);", fieldName, data);
    }

    if (elem.getAttribute("simpleValue") != null) {
        writer.addStatement("%s.setSimpleValue(%s);", fieldName,
                elem.consumeAttribute("simpleValue", valueType));
    }
}