public IsRenderableInterpreter(String fieldName, UiBinderWriter writer) { this.fieldName = fieldName; this.uiWriter = writer; assert writer.useLazyWidgetBuilders(); }
/** * A convenience factory method for the most common use of this class, to work * with HTML that will eventually be rendered under a * {@link com.google.gwt.user.client.ui.UIObject} (or really, any object that * responds to <code>getElement()</code>). Uses an instance of * {@link HtmlMessageInterpreter} to process message elements. * * @param uiExpression An expression that can be evaluated at runtime to find * an object whose getElement() method can be called to get an * ancestor of all Elements generated from the interpreted HTML. */ public static HtmlInterpreter newInterpreterForUiObject(UiBinderWriter writer, String uiExpression) { String ancestorExpression = writer.useLazyWidgetBuilders() ? uiExpression : uiExpression + ".getElement()"; return new HtmlInterpreter(writer, ancestorExpression, new HtmlMessageInterpreter(writer, ancestorExpression)); }
/** * Creates an HtmlInterpreter with our specialized placeholder interpreter, * which will allow widget instances to be declared inside of ui:msg elements. */ private HtmlInterpreter makeHtmlInterpreter(final String fieldName, final UiBinderWriter uiWriter) { final String ancestorExpression = uiWriter.useLazyWidgetBuilders() ? fieldName : (fieldName + ".getElement()"); PlaceholderInterpreterProvider placeholderInterpreterProvider = new PlaceholderInterpreterProvider() { public PlaceholderInterpreter get(MessageWriter message) { return new WidgetPlaceholderInterpreter(fieldName, uiWriter, message, ancestorExpression); } }; HtmlInterpreter htmlInterpreter = new HtmlInterpreter(uiWriter, ancestorExpression, new HtmlMessageInterpreter(uiWriter, placeholderInterpreterProvider)); return htmlInterpreter; } }
private void genSetWidgetTextCall(String idHolder, String childField) { if (uiWriter.useLazyWidgetBuilders()) { if (idIsHasText.contains(idHolder)) { fieldManager.require(fieldName).addAttachStatement( "%s.setText(%s.getElementById(%s).getInnerText());", fieldManager.convertFieldToGetter(childField), fieldName, fieldManager.convertFieldToGetter(idHolder)); } else if (idIsHasHTML.contains(idHolder)) { fieldManager.require(fieldName).addAttachStatement( "%s.setHTML(%s.getElementById(%s).getInnerHTML());", fieldManager.convertFieldToGetter(childField), fieldName, fieldManager.convertFieldToGetter(idHolder)); } } else { if (idIsHasText.contains(idHolder)) { uiWriter.addInitStatement( "%s.setText(%s.getElementById(%s).getInnerText());", childField, fieldName, idHolder); } if (idIsHasHTML.contains(idHolder)) { uiWriter.addInitStatement( "%s.setHTML(%s.getElementById(%s).getInnerHTML());", childField, fieldName, idHolder); } } }
public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException { if (writer.getOwnerClass().getUiField(fieldName).isProvided()) { return; } if (!writer.useLazyWidgetBuilders()) { writer.die("LazyPanel only works with UiBinder.useLazyWidgetBuilders enabled."); } XMLElement child = elem.consumeSingleChildElement(); if (!writer.isWidgetElement(child)) { writer.die(child, "Expecting only widgets in %s", elem); } FieldWriter childField = writer.parseElementToField(child); String lazyPanelClassPath = LazyPanel.class.getName(); String widgetClassPath = Widget.class.getName(); String code = String.format(INITIALIZER_FORMAT, lazyPanelClassPath, widgetClassPath, childField.getNextReference()); writer.setFieldInitializer(fieldName, code); } }
if (uiWriter.useLazyWidgetBuilders()) {
public IsRenderableInterpreter(String fieldName, UiBinderWriter writer) { this.fieldName = fieldName; this.uiWriter = writer; assert writer.useLazyWidgetBuilders(); }
public IsRenderableInterpreter(String fieldName, UiBinderWriter writer) { this.fieldName = fieldName; this.uiWriter = writer; assert writer.useLazyWidgetBuilders(); }
public String interpretElement(XMLElement elem) throws UnableToCompleteException { if (writer.useLazyWidgetBuilders() && writer.isElementAssignableTo(elem, SafeHtml.class)) { FieldWriter childField = writer.parseElementToField(elem); return writer.tokenForSafeHtmlExpression(elem, childField.getNextReference()); } if (writer.isImportedElement(elem)) { writer.die(elem, "Not allowed in an HTML context"); } if (elem.getNamespaceUri() != null && !writer.isBinderElement(elem)) { // It's not a widget, and it's not a ui: element. writer.die(elem, "Prefix \"%s:\" has unrecognized xmlns \"%s\" (bad import?)", elem.getPrefix(), elem.getNamespaceUri()); } return pipe.interpretElement(elem); } }
elementPointer, idHolder); if (uiWriter.useLazyWidgetBuilders()) {
public void parse(XMLElement elem, String fieldName, JClassType type, final UiBinderWriter writer) throws UnableToCompleteException { assert writer.useLazyWidgetBuilders();
/** * A convenience factory method for the most common use of this class, to work * with HTML that will eventually be rendered under a * {@link com.google.gwt.user.client.ui.UIObject} (or really, any object that * responds to <code>getElement()</code>). Uses an instance of * {@link HtmlMessageInterpreter} to process message elements. * * @param uiExpression An expression that can be evaluated at runtime to find * an object whose getElement() method can be called to get an * ancestor of all Elements generated from the interpreted HTML. */ public static HtmlInterpreter newInterpreterForUiObject(UiBinderWriter writer, String uiExpression) { String ancestorExpression = writer.useLazyWidgetBuilders() ? uiExpression : uiExpression + ".getElement()"; return new HtmlInterpreter(writer, ancestorExpression, new HtmlMessageInterpreter(writer, ancestorExpression)); }
/** * A convenience factory method for the most common use of this class, to work * with HTML that will eventually be rendered under a * {@link com.google.gwt.user.client.ui.UIObject} (or really, any object that * responds to <code>getElement()</code>). Uses an instance of * {@link HtmlMessageInterpreter} to process message elements. * * @param uiExpression An expression that can be evaluated at runtime to find * an object whose getElement() method can be called to get an * ancestor of all Elements generated from the interpreted HTML. */ public static HtmlInterpreter newInterpreterForUiObject(UiBinderWriter writer, String uiExpression) { String ancestorExpression = writer.useLazyWidgetBuilders() ? uiExpression : uiExpression + ".getElement()"; return new HtmlInterpreter(writer, ancestorExpression, new HtmlMessageInterpreter(writer, ancestorExpression)); }
/** * Creates an HtmlInterpreter with our specialized placeholder interpreter, * which will allow widget instances to be declared inside of ui:msg elements. */ private HtmlInterpreter makeHtmlInterpreter(final String fieldName, final UiBinderWriter uiWriter) { final String ancestorExpression = uiWriter.useLazyWidgetBuilders() ? fieldName : (fieldName + ".getElement()"); PlaceholderInterpreterProvider placeholderInterpreterProvider = new PlaceholderInterpreterProvider() { public PlaceholderInterpreter get(MessageWriter message) { return new WidgetPlaceholderInterpreter(fieldName, uiWriter, message, ancestorExpression); } }; HtmlInterpreter htmlInterpreter = new HtmlInterpreter(uiWriter, ancestorExpression, new HtmlMessageInterpreter(uiWriter, placeholderInterpreterProvider)); return htmlInterpreter; } }
/** * Creates an HtmlInterpreter with our specialized placeholder interpreter, * which will allow widget instances to be declared inside of ui:msg elements. */ private HtmlInterpreter makeHtmlInterpreter(final String fieldName, final UiBinderWriter uiWriter) { final String ancestorExpression = uiWriter.useLazyWidgetBuilders() ? fieldName : (fieldName + ".getElement()"); PlaceholderInterpreterProvider placeholderInterpreterProvider = new PlaceholderInterpreterProvider() { public PlaceholderInterpreter get(MessageWriter message) { return new WidgetPlaceholderInterpreter(fieldName, uiWriter, message, ancestorExpression); } }; HtmlInterpreter htmlInterpreter = new HtmlInterpreter(uiWriter, ancestorExpression, new HtmlMessageInterpreter(uiWriter, placeholderInterpreterProvider)); return htmlInterpreter; } }
public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException { if (writer.getOwnerClass().getUiField(fieldName).isProvided()) { return; } if (!writer.useLazyWidgetBuilders()) { writer.die("LazyPanel only works with UiBinder.useLazyWidgetBuilders enabled."); } XMLElement child = elem.consumeSingleChildElement(); if (!writer.isWidgetElement(child)) { writer.die(child, "Expecting only widgets in %s", elem); } FieldWriter childField = writer.parseElementToField(child); String lazyPanelClassPath = LazyPanel.class.getName(); String widgetClassPath = Widget.class.getName(); String code = String.format(INITIALIZER_FORMAT, lazyPanelClassPath, widgetClassPath, childField.getNextReference()); writer.setFieldInitializer(fieldName, code); } }
private void genSetWidgetTextCall(String idHolder, String childField) { if (uiWriter.useLazyWidgetBuilders()) { if (idIsHasText.contains(idHolder)) { fieldManager.require(fieldName).addAttachStatement( "%s.setText(%s.getElementById(%s).getInnerText());", fieldManager.convertFieldToGetter(childField), fieldName, fieldManager.convertFieldToGetter(idHolder)); } else if (idIsHasHTML.contains(idHolder)) { fieldManager.require(fieldName).addAttachStatement( "%s.setHTML(%s.getElementById(%s).getInnerHTML());", fieldManager.convertFieldToGetter(childField), fieldName, fieldManager.convertFieldToGetter(idHolder)); } } else { if (idIsHasText.contains(idHolder)) { uiWriter.addInitStatement( "%s.setText(%s.getElementById(%s).getInnerText());", childField, fieldName, idHolder); } if (idIsHasHTML.contains(idHolder)) { uiWriter.addInitStatement( "%s.setHTML(%s.getElementById(%s).getInnerHTML());", childField, fieldName, idHolder); } } }
public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException { if (writer.getOwnerClass().getUiField(fieldName).isProvided()) { return; } if (!writer.useLazyWidgetBuilders()) { writer.die("LazyPanel only works with UiBinder.useLazyWidgetBuilders enabled."); } XMLElement child = elem.consumeSingleChildElement(); if (!writer.isWidgetElement(child)) { writer.die(child, "Expecting only widgets in %s", elem); } FieldWriter childField = writer.parseElementToField(child); String lazyPanelClassPath = LazyPanel.class.getName(); String widgetClassPath = Widget.class.getName(); String code = String.format(INITIALIZER_FORMAT, lazyPanelClassPath, widgetClassPath, childField.getNextReference()); writer.setFieldInitializer(fieldName, code); } }
public String interpretElement(XMLElement elem) throws UnableToCompleteException { if (writer.useLazyWidgetBuilders() && writer.isElementAssignableTo(elem, SafeHtml.class)) { FieldWriter childField = writer.parseElementToField(elem); return writer.tokenForSafeHtmlExpression(elem, childField.getNextReference()); } if (writer.isImportedElement(elem)) { writer.die(elem, "Not allowed in an HTML context"); } if (elem.getNamespaceUri() != null && !writer.isBinderElement(elem)) { // It's not a widget, and it's not a ui: element. writer.die(elem, "Prefix \"%s:\" has unrecognized xmlns \"%s\" (bad import?)", elem.getPrefix(), elem.getNamespaceUri()); } return pipe.interpretElement(elem); } }
public String interpretElement(XMLElement elem) throws UnableToCompleteException { if (writer.useLazyWidgetBuilders() && writer.isElementAssignableTo(elem, SafeHtml.class)) { FieldWriter childField = writer.parseElementToField(elem); return writer.tokenForSafeHtmlExpression(elem, childField.getNextReference()); } if (writer.isImportedElement(elem)) { writer.die(elem, "Not allowed in an HTML context"); } if (elem.getNamespaceUri() != null && !writer.isBinderElement(elem)) { // It's not a widget, and it's not a ui: element. writer.die(elem, "Prefix \"%s:\" has unrecognized xmlns \"%s\" (bad import?)", elem.getPrefix(), elem.getNamespaceUri()); } return pipe.interpretElement(elem); } }