Package com.google.gwt.uibinder.rebind

Examples of com.google.gwt.uibinder.rebind.FieldManager$FieldAndSource


      throws UnableToCompleteException {
    if (!uiWriter.isWidgetElement(elem)) {
      return null;
    }

    FieldManager fieldManager = uiWriter.getFieldManager();
    FieldWriter fieldWriter = fieldManager.require(fieldName);

    // Allocate a local variable to hold the dom id for this widget. Note
    // that idHolder is a local variable reference, not a string id. We
    // have to generate the ids at runtime, not compile time, or else
    // we'll reuse ids for any template rendered more than once.
    String idHolder = uiWriter.declareDomIdHolder(null);
    uiWriter.ensureCurrentFieldAttached();

    FieldWriter childFieldWriter = uiWriter.parseElementToField(elem);
    String elementPointer = idHolder + "Element";
    uiWriter.addInitStatement(
        "Element %s = com.google.gwt.dom.client.Document.get().getElementById(%s);",
        elementPointer, idHolder);

    if (uiWriter.useLazyWidgetBuilders()) {

      // Register a DOM id field.
      String lazyDomElementPath = LazyDomElement.class.getCanonicalName();
      FieldWriter elementWriter = fieldManager.registerField(lazyDomElementPath, elementPointer);
      elementWriter.setInitializer(String.format("new %s<Element>(%s)",
          lazyDomElementPath, fieldManager.convertFieldToGetter(idHolder)));

      // Add attach/detach sections for this element.
      fieldWriter.addAttachStatement("%s.get();",
                                     fieldManager.convertFieldToGetter(elementPointer));
      fieldWriter.addDetachStatement(
          "%s.addAndReplaceElement(%s, %s.get());",
          fieldName,
          fieldManager.convertFieldToGetter(childFieldWriter.getName()),
          fieldManager.convertFieldToGetter(elementPointer));
    } else {

      // Delay replacing the placeholders with the widgets until after
      // detachment so as not to end up attaching the widget to the DOM
      // unnecessarily
      uiWriter.addDetachStatement(
          "%1$s.addAndReplaceElement(%2$s, %3$s);",
          fieldName,
          childFieldWriter.getName(),
          elementPointer);
    }

    // Create an element to hold the widget.
    String tag = getLegalPlaceholderTag(elem);
    idHolder = fieldManager.convertFieldToGetter(idHolder);
    if (uiWriter.useSafeHtmlTemplates()) {
      idHolder = uiWriter.tokenForStringExpression(elem, idHolder);
    } else {
      idHolder = "\" + " + idHolder + " + \"";
    }
View Full Code Here


    types = state.getTypeOracle();

    elemProvider = new XMLElementProviderImpl(new AttributeParsers(types, null,
        logger), types, logger, DesignTimeUtilsStub.EMPTY);

    fieldManager = new FieldManager(types, logger, false);
    JClassType baseType = types.findType("my.Ui.BaseClass");
    MessagesWriter messages = new MessagesWriter(types, BINDER_URI, logger,
        templatePath, baseType.getPackage().getName(), implName);

    writer = new MockUiBinderWriter(baseType, implName, templatePath, types,
View Full Code Here

      throws UnableToCompleteException {
    if (!uiWriter.isWidgetElement(elem)) {
      return null;
    }

    FieldManager fieldManager = uiWriter.getFieldManager();
    FieldWriter fieldWriter = fieldManager.require(fieldName);

    // Allocate a local variable to hold the dom id for this widget. Note
    // that idHolder is a local variable reference, not a string id. We
    // have to generate the ids at runtime, not compile time, or else
    // we'll reuse ids for any template rendered more than once.
    String idHolder = uiWriter.declareDomIdHolder();
    uiWriter.ensureCurrentFieldAttached();

    FieldWriter childFieldWriter = uiWriter.parseElementToFieldWriter(elem);
    String elementPointer = idHolder + "Element";
    uiWriter.addInitStatement(
        "com.google.gwt.user.client.Element %s = " +
        "com.google.gwt.dom.client.Document.get().getElementById(%s).cast();",
        elementPointer, idHolder);

    if (uiWriter.useLazyWidgetBuilders()) {

      // Register a DOM id field.
      String lazyDomElementPath = LazyDomElement.class.getCanonicalName();
      FieldWriter elementWriter = fieldManager.registerField(lazyDomElementPath, elementPointer);
      elementWriter.setInitializer(String.format("new %s<Element>(%s)",
          lazyDomElementPath, fieldManager.convertFieldToGetter(idHolder)));

      // Add attach/detach sections for this element.
      fieldWriter.addAttachStatement("%s.get();",
                                     fieldManager.convertFieldToGetter(elementPointer));
      fieldWriter.addDetachStatement(
          "%s.addAndReplaceElement(%s, %s.get());",
          fieldName,
          fieldManager.convertFieldToGetter(childFieldWriter.getName()),
          fieldManager.convertFieldToGetter(elementPointer));
    } else {

      // Delay replacing the placeholders with the widgets until after
      // detachment so as not to end up attaching the widget to the DOM
      // unnecessarily
      uiWriter.addDetachStatement(
          "%1$s.addAndReplaceElement(%2$s, %3$s);",
          fieldName,
          childFieldWriter.getName(),
          elementPointer);
    }

    // Create an element to hold the widget.
    String tag = getLegalPlaceholderTag(elem);
    idHolder = fieldManager.convertFieldToGetter(idHolder);
    if (uiWriter.useSafeHtmlTemplates()) {
      idHolder = uiWriter.tokenForStringExpression(idHolder);
    } else {
      idHolder = "\" + " + idHolder + " + \"";
    }
View Full Code Here

    if (!uiWriter.isRenderableElement(elem)) {
      return null;
    }

    String idHolder = uiWriter.declareDomIdHolder();
    FieldManager fieldManager = uiWriter.getFieldManager();
    FieldWriter fieldWriter = fieldManager.require(fieldName);

    FieldWriter childFieldWriter = uiWriter.parseElementToFieldWriter(elem);

    String elementPointer = idHolder + "Element";
    fieldWriter.addAttachStatement(
        "com.google.gwt.user.client.Element %s = " +
        "com.google.gwt.dom.client.Document.get().getElementById(%s).cast();",
        elementPointer, fieldManager.convertFieldToGetter(idHolder));
    fieldWriter.addAttachStatement(
        "%s.wrapElement(%s);",
        fieldManager.convertFieldToGetter(childFieldWriter.getName()),
        elementPointer);

    // Some operations are more efficient when the Widget isn't attached to
    // the document. Perform them here.
    fieldWriter.addDetachStatement(
        "%s.performDetachedInitialization();",
        fieldManager.convertFieldToGetter(childFieldWriter.getName()));

    fieldWriter.addDetachStatement(
        "%s.logicalAdd(%s);",
        fieldManager.convertFieldToGetter(fieldName),
        fieldManager.convertFieldToGetter(childFieldWriter.getName()));

    // TODO(rdcastro): use the render() call that receives the SafeHtmlBuilder
    String elementHtml = fieldManager.convertFieldToGetter(childFieldWriter.getName()) + ".render("
        + fieldManager.convertFieldToGetter(idHolder) + ")";
    return uiWriter.tokenForSafeHtmlExpression(elementHtml);
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.uibinder.rebind.FieldManager$FieldAndSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.