public class UiBinderWriter extends Object implements com.google.gwt.uibinder.rebind.Statements
Constructor and Description |
---|
UiBinderWriter(com.google.gwt.core.ext.typeinfo.JClassType baseClass,
String implClassName,
String templatePath,
com.google.gwt.core.ext.typeinfo.TypeOracle oracle,
com.google.gwt.uibinder.rebind.MortalLogger logger,
com.google.gwt.uibinder.rebind.FieldManager fieldManager,
com.google.gwt.uibinder.rebind.messages.MessagesWriter messagesWriter,
com.google.gwt.uibinder.rebind.DesignTimeUtils designTime,
com.google.gwt.uibinder.rebind.UiBinderContext uiBinderCtx,
boolean useSafeHtmlTemplates,
boolean useLazyWidgetBuilders,
String binderUri,
com.google.gwt.dev.resource.ResourceOracle resourceOracle,
com.google.gwt.resources.rg.GssResourceGenerator.GssOptions gssOptions) |
Modifier and Type | Method and Description |
---|---|
void |
addDetachStatement(String format,
Object... args)
Add a statement to be executed right after the current attached element is
detached.
|
void |
addInitStatement(String format,
Object... params)
Add a statement to be run after everything has been instantiated, in the
style of
String.format(java.lang.String, java.lang.Object...) . |
void |
addStatement(String format,
Object... args)
Adds a statement to the block run after fields are declared, in the style
of
String.format(java.lang.String, java.lang.Object...) . |
static String |
asCommaSeparatedList(String... args) |
void |
beginAttachedSection(String element)
Begin a section where a new attachable element is being parsed--that is,
one that will be constructed as a big innerHTML string, and then briefly
attached to the dom to allow fields accessing its to be filled (at the
moment, HasHTMLParser, HTMLPanelParser, and DomElementParser.).
|
String |
declareDomField(XMLElement source,
String fieldName,
String ancestorField)
Declare a field that will hold an Element instance.
|
String |
declareDomIdHolder(String fieldName)
Declare a variable that will be filled at runtime with a unique id, safe
for use as a dom element's id attribute.
|
String |
declareFieldIfNeeded(XMLElement elem)
If this element has a gwt:field attribute, create a field for it of the
appropriate type, and return the field name.
|
String |
declareRenderableStamper()
Declare a
RenderableStamper instance that will be filled at runtime
with a unique token. |
String |
declareTemplateCall(String html,
String fieldName)
Writes a new SafeHtml template to the generated BinderImpl.
|
String |
detokenate(String betokened)
Given a string containing tokens returned by
tokenForStringExpression(com.google.gwt.uibinder.rebind.XMLElement, java.lang.String) , tokenForSafeHtmlExpression(com.google.gwt.uibinder.rebind.XMLElement, java.lang.String) or
declareDomField(com.google.gwt.uibinder.rebind.XMLElement, java.lang.String, java.lang.String) , return a string with those tokens replaced by the
appropriate expressions. |
void |
die(String message)
Post an error message and halt processing.
|
void |
die(String message,
Object... params)
Post an error message and halt processing.
|
void |
die(XMLElement context,
String message,
Object... params)
Post an error message about a specific XMLElement and halt processing.
|
void |
endAttachedSection()
End the current attachable section.
|
void |
ensureAttached()
Ensure that the specified element is attached to the DOM.
|
void |
ensureCurrentFieldAttached()
Ensure that the specified field is attached to the DOM.
|
static String |
escapeAttributeText(String text)
Escape text that will be part of a string literal to be interpreted at
runtime as an HTML attribute value.
|
static String |
escapeText(String text,
boolean preserveWhitespace)
Escape text that will be part of a string literal to be interpreted at
runtime as HTML, optionally preserving whitespace.
|
static String |
escapeTextForJavaStringLiteral(String text)
Escape characters that would mess up interpretation of this string as a
string literal in generated code (that is, protect \, \n and " ).
|
com.google.gwt.core.ext.typeinfo.JClassType |
findFieldType(XMLElement elem)
Finds the JClassType that corresponds to this XMLElement, which must be a
Widget or an Element.
|
void |
genPropertySet(String fieldName,
String propName,
String value)
Generates the code to set a property value (assumes that 'value' is a valid
Java expression).
|
void |
genStringPropertySet(String fieldName,
String propName,
String value)
Generates the code to set a string property.
|
com.google.gwt.core.ext.typeinfo.JClassType |
getBaseClass()
The type we have been asked to generated, e.g.
|
com.google.gwt.uibinder.rebind.model.ImplicitClientBundle |
getBundleClass() |
com.google.gwt.uibinder.rebind.DesignTimeUtils |
getDesignTime()
Returns the
DesignTimeUtils , not null . |
com.google.gwt.uibinder.rebind.FieldManager |
getFieldManager() |
com.google.gwt.uibinder.rebind.MortalLogger |
getLogger()
Returns the logger, at least until we get get it handed off to parsers via
constructor args.
|
com.google.gwt.uibinder.rebind.messages.MessagesWriter |
getMessages()
Get the
MessagesWriter for this UI, generating it if necessary. |
com.google.gwt.core.ext.typeinfo.TypeOracle |
getOracle()
Gets the type oracle.
|
com.google.gwt.uibinder.rebind.model.OwnerClass |
getOwnerClass() |
String |
getUiFieldAttributeName() |
boolean |
isBinderElement(XMLElement elem) |
boolean |
isElementAssignableTo(XMLElement elem,
Class<?> possibleSuperclass) |
boolean |
isElementAssignableTo(XMLElement elem,
com.google.gwt.core.ext.typeinfo.JClassType possibleSupertype) |
boolean |
isImportedElement(XMLElement elem) |
boolean |
isOwnerFieldLazyDomElement(String fieldName)
Checks whether the given owner field name is a LazyDomElement or not.
|
boolean |
isRenderableElement(XMLElement elem) |
boolean |
isRenderer() |
boolean |
isWidgetElement(XMLElement elem) |
com.google.gwt.uibinder.rebind.FieldWriter |
parseElementToField(XMLElement elem)
Parses the object associated with the specified element, and returns the
field writer that will hold it.
|
void |
setFieldInitializer(String fieldName,
String factoryMethod)
Gives the writer the initializer to use for this field instead of the
default GWT.create call.
|
void |
setFieldInitializerAsConstructor(String fieldName,
String... args)
Instructs the writer to initialize the field with a specific constructor
invocation, instead of the default GWT.create call.
|
String |
tokenForSafeConstant(XMLElement source,
String expression)
Like
tokenForStringExpression(com.google.gwt.uibinder.rebind.XMLElement, java.lang.String) , but used for runtime expressions
that we trust to be safe to interpret at runtime as HTML without escaping,
like translated messages with simple formatting. |
String |
tokenForSafeHtmlExpression(XMLElement source,
String expression)
Like
tokenForStringExpression(com.google.gwt.uibinder.rebind.XMLElement, java.lang.String) , but used for runtime
SafeHtml instances. |
String |
tokenForSafeUriExpression(XMLElement source,
String expression)
Like
tokenForStringExpression(com.google.gwt.uibinder.rebind.XMLElement, java.lang.String) , but used for runtime
SafeUri instances. |
String |
tokenForStringExpression(XMLElement source,
String expression)
Returns a string token that can be used in place the given expression
inside any string literals.
|
boolean |
useLazyWidgetBuilders() |
boolean |
useSafeHtmlTemplates() |
void |
warn(String message)
Post a warning message.
|
void |
warn(String message,
Object... params)
Post a warning message.
|
void |
warn(XMLElement context,
String message,
Object... params)
Post a warning message.
|
public UiBinderWriter(com.google.gwt.core.ext.typeinfo.JClassType baseClass, String implClassName, String templatePath, com.google.gwt.core.ext.typeinfo.TypeOracle oracle, com.google.gwt.uibinder.rebind.MortalLogger logger, com.google.gwt.uibinder.rebind.FieldManager fieldManager, com.google.gwt.uibinder.rebind.messages.MessagesWriter messagesWriter, com.google.gwt.uibinder.rebind.DesignTimeUtils designTime, com.google.gwt.uibinder.rebind.UiBinderContext uiBinderCtx, boolean useSafeHtmlTemplates, boolean useLazyWidgetBuilders, String binderUri, com.google.gwt.dev.resource.ResourceOracle resourceOracle, com.google.gwt.resources.rg.GssResourceGenerator.GssOptions gssOptions) throws com.google.gwt.core.ext.UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
public static String escapeAttributeText(String text)
public static String escapeText(String text, boolean preserveWhitespace)
public static String escapeTextForJavaStringLiteral(String text)
public void addDetachStatement(String format, Object... args)
addDetachStatement
in interface com.google.gwt.uibinder.rebind.Statements
format
- args
- beginAttachedSection(String)
public void addInitStatement(String format, Object... params)
String.format(java.lang.String, java.lang.Object...)
.addInitStatement
in interface com.google.gwt.uibinder.rebind.Statements
public void addStatement(String format, Object... args)
String.format(java.lang.String, java.lang.Object...)
.addStatement
in interface com.google.gwt.uibinder.rebind.Statements
public void beginAttachedSection(String element)
Succeeding calls made to ensureAttached()
and
ensureCurrentFieldAttached()
must refer to children of this element,
until endAttachedSection()
is called.
element
- Java expression for the generated code that will return the
dom element to be attached.public String declareDomField(XMLElement source, String fieldName, String ancestorField) throws com.google.gwt.core.ext.UnableToCompleteException
In the generated code, this token will be replaced by an expression to generate a unique dom id at runtime. Further code will be generated to be run after widgets are instantiated, to use that dom id in a getElementById call and assign the Element instance to its field.
fieldName
- The name of the field being declaredancestorField
- The name of fieldName parentcom.google.gwt.core.ext.UnableToCompleteException
public String declareDomIdHolder(String fieldName) throws com.google.gwt.core.ext.UnableToCompleteException
UiRenderer
based code,
elements corresponding to a ui:field, need and id initialized to a value
that depends on the fieldName
. For all other cases let
fieldName
be null
.fieldName
- name of the field corresponding to this variable.com.google.gwt.core.ext.UnableToCompleteException
public String declareFieldIfNeeded(XMLElement elem) throws com.google.gwt.core.ext.UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
public String declareRenderableStamper() throws com.google.gwt.core.ext.UnableToCompleteException
RenderableStamper
instance that will be filled at runtime
with a unique token. This instance can then be used to stamp a single
IsRenderable
.com.google.gwt.core.ext.UnableToCompleteException
public String declareTemplateCall(String html, String fieldName) throws IllegalArgumentException
IllegalArgumentException
public String detokenate(String betokened)
tokenForStringExpression(com.google.gwt.uibinder.rebind.XMLElement, java.lang.String)
, tokenForSafeHtmlExpression(com.google.gwt.uibinder.rebind.XMLElement, java.lang.String)
or
declareDomField(com.google.gwt.uibinder.rebind.XMLElement, java.lang.String, java.lang.String)
, return a string with those tokens replaced by the
appropriate expressions. (It is not normally necessary for an
XMLElement.Interpreter
or ElementParser
to make this call,
as the tokens are typically replaced by the TemplateWriter itself.)public void die(String message) throws com.google.gwt.core.ext.UnableToCompleteException
UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
public void die(String message, Object... params) throws com.google.gwt.core.ext.UnableToCompleteException
UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
public void die(XMLElement context, String message, Object... params) throws com.google.gwt.core.ext.UnableToCompleteException
UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
public void endAttachedSection()
beginAttachedSection(String)
public void ensureAttached()
beginAttachedSection(String)
public void ensureCurrentFieldAttached()
ensureAttached()
(field + ".getElement()")
.beginAttachedSection(String)
public com.google.gwt.core.ext.typeinfo.JClassType findFieldType(XMLElement elem) throws com.google.gwt.core.ext.UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
- If no such widget class existsRuntimeException
- if asked to handle a non-widget, non-DOM elementpublic void genPropertySet(String fieldName, String propName, String value)
public void genStringPropertySet(String fieldName, String propName, String value)
public com.google.gwt.core.ext.typeinfo.JClassType getBaseClass()
public com.google.gwt.uibinder.rebind.model.ImplicitClientBundle getBundleClass()
public com.google.gwt.uibinder.rebind.DesignTimeUtils getDesignTime()
DesignTimeUtils
, not null
.public com.google.gwt.uibinder.rebind.FieldManager getFieldManager()
public com.google.gwt.uibinder.rebind.MortalLogger getLogger()
public com.google.gwt.uibinder.rebind.messages.MessagesWriter getMessages()
MessagesWriter
for this UI, generating it if necessary.public com.google.gwt.core.ext.typeinfo.TypeOracle getOracle()
public com.google.gwt.uibinder.rebind.model.OwnerClass getOwnerClass()
public String getUiFieldAttributeName()
public boolean isBinderElement(XMLElement elem)
public boolean isElementAssignableTo(XMLElement elem, Class<?> possibleSuperclass) throws com.google.gwt.core.ext.UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
public boolean isElementAssignableTo(XMLElement elem, com.google.gwt.core.ext.typeinfo.JClassType possibleSupertype) throws com.google.gwt.core.ext.UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
public boolean isImportedElement(XMLElement elem)
public boolean isOwnerFieldLazyDomElement(String fieldName)
public boolean isRenderableElement(XMLElement elem) throws com.google.gwt.core.ext.UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
public boolean isRenderer()
public boolean isWidgetElement(XMLElement elem) throws com.google.gwt.core.ext.UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
public com.google.gwt.uibinder.rebind.FieldWriter parseElementToField(XMLElement elem) throws com.google.gwt.core.ext.UnableToCompleteException
elem
- the xml element to be parsedcom.google.gwt.core.ext.UnableToCompleteException
public void setFieldInitializer(String fieldName, String factoryMethod)
IllegalStateException
- if an initializer has already been setpublic void setFieldInitializerAsConstructor(String fieldName, String... args)
fieldName
- the field to initializeargs
- arguments to the constructor callpublic String tokenForSafeConstant(XMLElement source, String expression)
tokenForStringExpression(com.google.gwt.uibinder.rebind.XMLElement, java.lang.String)
, but used for runtime expressions
that we trust to be safe to interpret at runtime as HTML without escaping,
like translated messages with simple formatting. Wrapped in a call to
SafeHtmlUtils.fromSafeConstant(java.lang.String)
to
keep the expression from being escaped by the SafeHtml template.expression
- must resolve to trusted HTML stringpublic String tokenForSafeHtmlExpression(XMLElement source, String expression)
tokenForStringExpression(com.google.gwt.uibinder.rebind.XMLElement, java.lang.String)
, but used for runtime
SafeHtml
instances.expression
- must resolve to SafeHtml objectpublic String tokenForSafeUriExpression(XMLElement source, String expression)
tokenForStringExpression(com.google.gwt.uibinder.rebind.XMLElement, java.lang.String)
, but used for runtime
SafeUri
instances.expression
- must resolve to SafeUri objectpublic String tokenForStringExpression(XMLElement source, String expression)
expression
- must resolve to Stringpublic boolean useLazyWidgetBuilders()
public boolean useSafeHtmlTemplates()
public void warn(String message)
public void warn(XMLElement context, String message, Object... params)
Copyright © 2018. All Rights Reserved.