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

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

Introduction

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

Prototype

public String consumeRequiredRawAttribute(String name) throws UnableToCompleteException 

Source Link

Document

Consumes the named attribute, or dies if it is missing.

Usage

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

License:Apache License

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

    Interpreter<Boolean> formButtonBindingInterpreter = new SimpleInterpreter(elem.getNamespaceUri(),
            "formButtonBinding");
    for (XMLElement child : elem.consumeChildElements(formButtonBindingInterpreter)) {
        String buttonField = child.consumeRequiredRawAttribute("buttonField");

        String bindingField = writer.declareField(GxtClassnameConstants.FORMBUTTONBINDING, child);
        // set to null temporarily.  We'll initialize it as a statement. 
        //Need to make sure the FormPanel is initialized first.
        writer.setFieldInitializer(bindingField, "null");

        writer.addStatement("%s = new %s(%s);", bindingField, GxtClassnameConstants.FORMBUTTONBINDING,
                fieldName);/*  ww  w . jav a2 s. c  om*/
        writer.addStatement("%s.addButton(%s);", bindingField, buttonField);
    }

}

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

License:Apache License

private boolean consumeLayout(XMLElement elem, String layoutContainerFieldName, JClassType type,
        UiBinderWriter writer) throws UnableToCompleteException {
    boolean layoutFound = false;
    // locate child Element
    for (XMLElement layoutChild : elem
            .consumeChildElements(new SimpleInterpreter(elem.getNamespaceUri(), "layout"))) {
        if (layoutFound) {
            writer.die(elem,//from  www  .j  av  a  2 s.  c o  m
                    "LayoutContainer's and subclasses can contain only a single <%s:layout /> child.  Found multiple.",
                    elem.getPrefix());
        }

        String layoutType = layoutChild.consumeRequiredRawAttribute("type");

        LayoutParser layoutParser = LayoutParserFactory.findLayoutParserBySimpleName(elem, layoutType, writer);
        layoutParser.parse(layoutChild, elem, layoutContainerFieldName, type, writer);

        layoutFound = true;
    }

    // first, check attribute
    XMLAttribute layoutAttribute = elem.getAttribute("layout");
    if (layoutAttribute != null) {
        if (layoutFound) {
            writer.die(elem,
                    "LayoutContainer can contain either a layout attribute or a single nested <%s:layout /> child.  Not both.",
                    elem.getPrefix());
        }
        String layoutType = layoutAttribute.consumeRawValue();

        LayoutParser layoutParser = LayoutParserFactory.findLayoutParserBySimpleName(elem, layoutType, writer);
        layoutParser.parse(elem, layoutContainerFieldName, type, writer);
        layoutFound = true;
    }

    return layoutFound;
}

From source file:com.jhickman.web.gwt.gxtuibinder.resourceparsers.XTemplateParser.java

License:Apache License

@Override
public void parse(XMLElement elem, FieldManager fieldManager, UiBinderWriter writer)
        throws UnableToCompleteException {
    String resourceName = elem.consumeRequiredRawAttribute("name");

    //fieldManager.registerField(fieldType, fieldName);
    JClassType xtemplateType = writer.getOracle().findType("com.extjs.gxt.ui.client.core.XTemplate");

    String innerHtml = elem.consumeInnerHtml(new TextInterpreter(writer));
    String text = UiBinderWriter.escapeTextForJavaStringLiteral(innerHtml);

    FieldWriter fieldWriter = fieldManager.registerField(xtemplateType, resourceName);
    fieldWriter.setInitializer("com.extjs.gxt.ui.client.core.XTemplate.create(\"" + text + "\")");
}