@Override
  public String interpretElement(XMLElement elem) throws UnableToCompleteException {

    if (!uiWriter.isWidgetElement(elem)) {
      return super.interpretElement(elem);
    }

    JClassType type = uiWriter.findFieldType(elem);
    TypeOracle oracle = uiWriter.getOracle();

    MessagesWriter mw = uiWriter.getMessages();
    String name = mw.consumeMessageAttribute("ph", elem);
    if ("".equals(name)) {
      name = "widget" + (++serial);
    }

    String idHolder = uiWriter.declareDomIdHolder(null);
    idToWidgetElement.put(idHolder, elem);

    if (oracle.findType(HasHTML.class.getName()).isAssignableFrom(type)) {
      return handleHasHTMLPlaceholder(elem, name, idHolder);
    }

    if (oracle.findType(HasText.class.getName()).isAssignableFrom(type)) {
      return handleHasTextPlaceholder(elem, name, idHolder);
    }

    return handleOpaqueWidgetPlaceholder(elem, name, idHolder);
  }
示例#2
0
  private void generateOnce(
      JClassType interfaceType,
      String implName,
      PrintWriter binderPrintWriter,
      TreeLogger treeLogger,
      TypeOracle oracle,
      ResourceOracle resourceOracle,
      PropertyOracle propertyOracle,
      PrintWriterManager writerManager,
      DesignTimeUtils designTime)
      throws UnableToCompleteException {

    MortalLogger logger = new MortalLogger(treeLogger);
    String templatePath = deduceTemplateFile(logger, interfaceType);
    MessagesWriter messages =
        new MessagesWriter(
            oracle,
            BINDER_URI,
            logger,
            templatePath,
            interfaceType.getPackage().getName(),
            implName);

    boolean useLazyWidgetBuilders =
        useLazyWidgetBuilders(logger, propertyOracle) && !designTime.isDesignTime();

    FieldManager fieldManager =
        getFieldManager(oracle, logger, propertyOracle, useLazyWidgetBuilders); // MODIFICATION

    UiBinderWriter uiBinderWriter =
        new UiBinderWriter(
            interfaceType,
            implName,
            templatePath,
            oracle,
            logger,
            fieldManager,
            messages,
            designTime,
            uiBinderCtx,
            useSafeHtmlTemplates(logger, propertyOracle),
            useLazyWidgetBuilders,
            BINDER_URI);

    Document doc = getW3cDoc(logger, designTime, resourceOracle, templatePath);
    designTime.rememberPathForElements(doc);

    uiBinderWriter.parseDocument(doc, binderPrintWriter);

    if (messages.hasMessages()) {
      messages.write(writerManager.makePrintWriterFor(messages.getMessagesClassName()));
    }

    ImplicitClientBundle bundleClass = uiBinderWriter.getBundleClass();
    new BundleWriter(bundleClass, writerManager, oracle, logger).write();

    writerManager.commit();
  }