private boolean hasCurrency(XMLElement elem) { return elem.hasAttribute("currencyData") || elem.hasAttribute("currencyCode"); }
private boolean hasTimeZone(XMLElement elem) { return elem.hasAttribute("timezone") || elem.hasAttribute("timezoneOffset"); }
public String interpretElement(XMLElement elem) throws UnableToCompleteException { String fieldName = writer.declareFieldIfNeeded(elem); if (fieldName != null) { String token = writer.declareDomField(elem, fieldName, element); if (elem.hasAttribute("id")) { writer.die(elem, String.format( "Cannot declare id=\"%s\" and %s=\"%s\" on the same element", elem.consumeRawAttribute("id"), writer.getUiFieldAttributeName(), fieldName)); } elem.setAttribute("id", token); } /* * Return null because we don't want to replace the dom element with any * particular string (though we may have consumed its id or gwt:field) */ return null; } }
if (cellElem.hasAttribute(HALIGN_ATTR)) { String value = cellElem.consumeAttribute(HALIGN_ATTR, hAlignConstantType); writer.addStatement("%1$s.setCellHorizontalAlignment(%2$s, %3$s);", if (cellElem.hasAttribute(VALIGN_ATTR)) { String value = cellElem.consumeAttribute(VALIGN_ATTR, vAlignConstantType); writer.addStatement("%1$s.setCellVerticalAlignment(%2$s, %3$s);", if (cellElem.hasAttribute(WIDTH_ATTR)) { String value = cellElem.consumeStringAttribute(WIDTH_ATTR); writer.addStatement("%1$s.setCellWidth(%2$s, %3$s);", fieldName, if (cellElem.hasAttribute(HEIGHT_ATTR)) { String value = cellElem.consumeStringAttribute(HEIGHT_ATTR); writer.addStatement("%1$s.setCellHeight(%2$s, %3$s);", fieldName,
public Boolean interpretElement(XMLElement child) throws UnableToCompleteException { // CustomButton can only contain Face elements. String ns = child.getNamespaceUri(); String faceName = child.getLocalName(); if (!ns.equals(elem.getNamespaceUri())) { writer.die(elem, "Invalid child namespace: %s", ns); } if (!faceNames.contains(faceName)) { writer.die(elem, "Invalid CustomButton face: %s:%s", ns, faceName); } HtmlInterpreter interpreter = HtmlInterpreter.newInterpreterForUiObject( writer, fieldName); String innerHtml = child.consumeInnerHtml(interpreter); if (innerHtml.length() > 0) { writer.addStatement("%s.%s().setHTML(%s);", fieldName, faceNameGetter(faceName), writer.declareTemplateCall(innerHtml, fieldName)); } if (child.hasAttribute("image")) { String image = child.consumeImageResourceAttribute("image"); writer.addStatement("%s.%s().setImage(new %s(%s));", fieldName, faceNameGetter(faceName), IMAGE_CLASS, image); } return true; // We consumed it } });
public String interpretElement(XMLElement elem) throws UnableToCompleteException { // Must be in the format: <ui:string from="{myMsg.message}" /> if (writer.isBinderElement(elem) && getLocalName().equals(elem.getLocalName())) { if (!elem.hasAttribute("from")) { logger.die(elem, "Attribute 'from' not found."); } if (!elem.getAttribute("from").hasComputedValue()) { logger.die(elem, "Attribute 'from' does not have a computed value"); } // Make sure all computed attributes are interpreted first computedAttributeInterpreter.interpretElement(elem); String fieldRef = elem.consumeStringAttribute("from"); // Make sure that "from" was the only attribute elem.assertNoAttributes(); return "\" + " + fieldRef + " + \""; } return null; }
if (!child.hasAttribute("direction")) { writer.die(elem, "Dock must specify the 'direction' attribute");
private boolean hasCurrency(XMLElement elem) { return elem.hasAttribute("currencyData") || elem.hasAttribute("currencyCode"); }
private boolean hasCurrency(XMLElement elem) { return elem.hasAttribute("currencyData") || elem.hasAttribute("currencyCode"); }
private boolean hasTimeZone(XMLElement elem) { return elem.hasAttribute("timezone") || elem.hasAttribute("timezoneOffset"); }
if (elem.hasAttribute("vertical")) { String vertical = elem.consumeBooleanAttribute("vertical"); writer.setFieldInitializerAsConstructor(fieldName, vertical);
private boolean hasTimeZone(XMLElement elem) { return elem.hasAttribute("timezone") || elem.hasAttribute("timezoneOffset"); }
public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException { // Parse children. for (XMLElement child : elem.consumeChildElements()) { if (!writer.isWidgetElement(child)) { writer.die(child, "Widget required"); } // Stack panel label comes from the StackPanel-text attribute of the child String stackItemLabel = null; String variableAttributeName = elem.getPrefix() + ":" + ATTRIBUTE_TEXT; if (child.hasAttribute(variableAttributeName)) { stackItemLabel = child.consumeRawAttribute(variableAttributeName); } FieldWriter childField = writer.parseElementToField(child); if (stackItemLabel == null) { writer.addStatement("%1$s.add(%2$s);", fieldName, childField.getNextReference()); } else { writer.addStatement("%1$s.add(%2$s, \"%3$s\");", fieldName, childField.getNextReference(), stackItemLabel); } } } }
public boolean isConsumed() { return !xmlElem.hasAttribute(w3cAttr.getName()); }
public boolean isConsumed() { return !xmlElem.hasAttribute(w3cAttr.getName()); }
/** * Confirm existence of an m:blah attribute on a non-message element, e.g. * {@code <span ui:ph="fnord"/>} */ public boolean hasMessageAttribute(String attName, XMLElement elem) { String fullAttName = getMessagesPrefix() + ":" + attName; return elem.hasAttribute(fullAttName); }
/** * Confirm existence of an m:blah attribute on a non-message element, e.g. * {@code <span ui:ph="fnord"/>} */ public boolean hasMessageAttribute(String attName, XMLElement elem) { String fullAttName = getMessagesPrefix() + ":" + attName; return elem.hasAttribute(fullAttName); }
private JClassType consumeTypeAttribute(XMLElement elem) throws UnableToCompleteException { if (!elem.hasAttribute(TYPE_ATTRIBUTE)) { return null; } String resourceTypeName = elem.consumeRawAttribute(TYPE_ATTRIBUTE); JClassType resourceType = oracle.findType(resourceTypeName); if (resourceType == null) { writer.die(elem, "No such type %s", resourceTypeName); } return resourceType; }
private JClassType consumeTypeAttribute(XMLElement elem) throws UnableToCompleteException { if (!elem.hasAttribute(TYPE_ATTRIBUTE)) { return null; } String resourceTypeName = elem.consumeRawAttribute(TYPE_ATTRIBUTE); JClassType resourceType = oracle.findType(resourceTypeName); if (resourceType == null) { writer.die(elem, "No such type %s", resourceTypeName); } return resourceType; }
/** * Like {@link #consumeAttributeWithDefault(String, String, JType)}, but * accommodates more complex type signatures. */ public String consumeAttributeWithDefault(String name, String defaultValue, JType... types) throws UnableToCompleteException { if (!hasAttribute(name)) { if (defaultValue != null) { designTime.putAttribute(this, name + ".default", defaultValue); } return defaultValue; } AttributeParser parser = attributeParsers.getParser(types); return consumeAttributeWithParser(name, parser); }