// Get the stack element.
if (!isElementType(elem, child, STACK_ELEM)) {
writer.die("In %s, Only <stack> children are allowed.", elem);
}
XMLElement headerElem = null, widgetElem = null;
for (XMLElement stackChild : child.consumeChildElements()) {
// Get the header.
if (isElementType(elem, stackChild, HEADER_ELEM)) {
if (headerElem != null) {
writer.die("In %s, Only one <header> allowed per <stack>", elem);
}
headerElem = stackChild;
continue;
}
// Get the widget.
if (widgetElem != null) {
writer.die("In %s, Only one child widget allowed per <stack>", elem);
}
widgetElem = stackChild;
}
String size = headerElem.consumeDoubleAttribute("size");
XMLElement headerWidgetElem = headerElem.consumeSingleChildElement();
String headerFieldName = writer.parseElementToField(headerWidgetElem);
String childFieldName = writer.parseElementToField(widgetElem);
writer.addStatement("%s.add(%s, %s, %s);", fieldName, childFieldName,
headerFieldName, size);