private String consumeFormat(XMLElement elem, UiBinderWriter writer)
      throws UnableToCompleteException {
    String format =
        elem.consumeAttribute(
            "format", writer.getOracle().findType(DateTimeFormat.class.getCanonicalName()));
    String predefinedFormat =
        elem.consumeAttribute(
            "predefinedFormat",
            writer.getOracle().findType(PredefinedFormat.class.getCanonicalName()));
    String customFormat = elem.consumeStringAttribute("customFormat");

    if (format != null) {
      if (predefinedFormat != null || customFormat != null) {
        writer.die(elem, AT_MOST_ONE_SPECIFIED_FORMAT);
      }
      return format;
    }
    if (predefinedFormat != null) {
      if (customFormat != null) {
        writer.die(elem, AT_MOST_ONE_SPECIFIED_FORMAT);
      }
      return makeGetFormat(predefinedFormat);
    }
    if (customFormat != null) {
      return makeGetFormat(customFormat);
    }
    return null;
  }
Esempio n. 2
0
 private static String getLegalPlaceholderTag(XMLElement elem) {
   XMLElement parent = elem.getParent();
   String tag = null;
   if (parent != null) {
     tag = LEGAL_CHILD_ELEMENTS.get(parent.getLocalName());
   }
   if (tag == null) {
     tag = DEFAULT_CHILD_ELEMENT;
   }
   return tag;
 }
  public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer)
      throws UnableToCompleteException {
    // Generate instantiation (Vertical MenuBars require a ctor param).
    if (elem.hasAttribute("vertical")) {
      String vertical = elem.consumeBooleanAttribute("vertical");
      writer.setFieldInitializerAsConstructor(
          fieldName, writer.getOracle().findType(MenuBar.class.getName()), vertical);
    }

    // Parse children.
    for (XMLElement child : elem.consumeChildElements()) {
      // MenuBar can only contain MenuItem elements.
      {
        String ns = child.getNamespaceUri();
        String tagName = child.getLocalName();

        if (!elem.getNamespaceUri().equals(ns) || !tagName.equals(TAG_MENUITEM)) {
          writer.die(
              "In %s, only <%s:%s> are valid children", elem, elem.getPrefix(), TAG_MENUITEM);
        }
      }

      String itemFieldName = writer.parseElementToField(child);

      writer.addStatement("%1$s.addItem(%2$s);", fieldName, itemFieldName);
    }
  }
 private String consumeTimeZone(XMLElement elem, UiBinderWriter writer)
     throws UnableToCompleteException {
   String timeZone =
       elem.consumeAttribute(
           "timezone", writer.getOracle().findType(TimeZone.class.getCanonicalName()));
   String timeZoneOffset = elem.consumeAttribute("timezoneOffset", getIntType(writer.getOracle()));
   if (timeZone != null && timeZoneOffset != null) {
     writer.die(elem, AT_MOST_ONE_SPECIFIED_TIME_ZONE);
   }
   if (timeZone != null) {
     return timeZone;
   }
   if (timeZoneOffset != null) {
     return TimeZone.class.getCanonicalName() + ".createTimeZone(" + timeZoneOffset + ")";
   }
   return null;
 }
  private String handleHasTextPlaceholder(XMLElement elem, String name, String idHolder)
      throws UnableToCompleteException {
    idIsHasText.add(idHolder);
    String openPlaceholder = genOpenTag(elem, name, idHolder);

    String body = elem.consumeInnerText(new TextPlaceholderInterpreter(uiWriter, message));
    String bodyToken = tokenator.nextToken(body);

    String closePlaceholder = genCloseTag(name);
    return openPlaceholder + bodyToken + closePlaceholder;
  }
Esempio n. 6
0
  public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer)
      throws UnableToCompleteException {

    HtmlInterpreter interpreter = HtmlInterpreter.newInterpreterForUiObject(writer, fieldName);
    writer.beginAttachedSection(fieldName + ".getElement()");
    String html = elem.consumeInnerHtml(interpreter);
    writer.endAttachedSection();
    // TODO(jgw): throw an error if there's a conflicting 'html' attribute.
    if (html.trim().length() > 0) {
      writer.genStringPropertySet(fieldName, "HTML", html);
    }
  }
 private boolean hasTimeZone(XMLElement elem) {
   return elem.hasAttribute("timezone") || elem.hasAttribute("timezoneOffset");
 }