public interface FieldWriter
A field can have a custom initialization statement, set via
setInitializer(java.lang.String)
. Without one it will be initialized via a
GWT.create(java.lang.Class<?>)
call. (In the rare case that
you need a field not to be initialized, initialize it to "null".)
Dependencies can be declared between fields via needs(com.google.gwt.uibinder.rebind.FieldWriter)
, to ensure
that one can be initialized via reference to another. Circular references are
not supported, nor detected.
Modifier and Type | Method and Description |
---|---|
void |
addAttachStatement(String format,
Object... args)
Add a statement to be executed right after the current field is attached.
|
void |
addDetachStatement(String format,
Object... args)
Add a statement to be executed right after the current field is detached.
|
void |
addStatement(String format,
Object... args)
Add a statement for the given field, executed right after its creation.
|
com.google.gwt.core.ext.typeinfo.JClassType |
getAssignableType()
Returns the type of this field, or for generated types the type it extends.
|
int |
getBuildPrecedence()
Gets this field builder precedence.
|
FieldWriterType |
getFieldType()
Gets the type of this field.
|
String |
getHtml()
Returns the string html representation of the field.
|
String |
getInitializer()
Returns the custom initializer for this field, or null if it is not set.
|
com.google.gwt.core.ext.typeinfo.JClassType |
getInstantiableType()
Returns the type of this field, or null if this field is of a type that has
not yet been generated.
|
String |
getName()
Get the name of the field.
|
String |
getNextReference()
Returns the expression that to evaluate to get the contents of this field.
|
String |
getQualifiedSourceName()
Returns the qualified source name of this type.
|
com.google.gwt.core.ext.typeinfo.JType |
getReturnType(String[] path,
MonitoredLogger logger)
Returns the return type found at the end of the given method call
path, which must begin with the receiver's name, or null if the
path is invalid.
|
String |
getSafeHtml()
Returns the string SafeHtml representation of the field.
|
void |
needs(FieldWriter f)
Declares that the receiver depends upon the given field.
|
void |
setBuildPrecedence(int precedence)
Sets the precedence of this field builder.
|
void |
setHtml(String html)
Sets the html representation of the field for applicable field types.
|
void |
setInitializer(String initializer)
Used to provide an initializer string to use instead of a
GWT.create(java.lang.Class<?>) call. |
void |
write(IndentedWriter w)
Write the field declaration.
|
void |
writeFieldBuilder(IndentedWriter w,
int getterCount,
OwnerField ownerField)
Write this field builder in the Widgets inner class.
|
void |
writeFieldDefinition(IndentedWriter w,
com.google.gwt.core.ext.typeinfo.TypeOracle typeOracle,
OwnerField ownerField,
DesignTimeUtils designTime,
int getterCount,
boolean useLazyWidgetBuilders)
Output the getter and builder definitions for the given field.
|
void addAttachStatement(String format, Object... args)
HTMLPanel panel = new HTMLPanel( "..."); // statement section. widgetX.setStyleName("someCss"); widgetX.setVisible(true); // attach section. UiBinderUtil.TempAttachment attachRecord = UiBinderUtil.attachToDom(panel.getElement()); get_domId0Element().get(); get_domId1Element().get(); // detach section. attachRecord.detach(); panel.addAndReplaceElement(get_someWidget(), get_domId0Element().get()); panel.addAndReplaceElement(get_otherWidget(), get_domId1Element().get());
void addDetachStatement(String format, Object... args)
addAttachStatement(java.lang.String, java.lang.Object...)
.void addStatement(String format, Object... args)
WidgetX widgetX = GWT.create(WidgetX.class); // statement section. widgetX.setStyleName("someCss"); widgetX.setVisible(true);
com.google.gwt.core.ext.typeinfo.JClassType getAssignableType()
int getBuildPrecedence()
FieldWriterType getFieldType()
String getHtml()
String getInitializer()
com.google.gwt.core.ext.typeinfo.JClassType getInstantiableType()
String getName()
String getNextReference()
String getQualifiedSourceName()
com.google.gwt.core.ext.typeinfo.JType getReturnType(String[] path, MonitoredLogger logger)
String getSafeHtml()
void needs(FieldWriter f)
void setBuildPrecedence(int precedence)
void setHtml(String html)
void setInitializer(String initializer)
GWT.create(java.lang.Class<?>)
call. Note that this is an
RHS expression. Don't include the leading '=', and don't end it with ';'.IllegalStateException
- on second attempt to set the initializervoid write(IndentedWriter w) throws com.google.gwt.core.ext.UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
void writeFieldBuilder(IndentedWriter w, int getterCount, OwnerField ownerField) throws com.google.gwt.core.ext.UnableToCompleteException
com.google.gwt.uibinder.rebind.FieldWriter#writeFieldGetter
.com.google.gwt.core.ext.UnableToCompleteException
void writeFieldDefinition(IndentedWriter w, com.google.gwt.core.ext.typeinfo.TypeOracle typeOracle, OwnerField ownerField, DesignTimeUtils designTime, int getterCount, boolean useLazyWidgetBuilders) throws com.google.gwt.core.ext.UnableToCompleteException
Example for widgets called only once:
private WidgetX get_widgetX() { return build_widgetX(); } private WidgetX build_widgetX() { widget = GWT.create(WidgetX.class); widget.setStyleName("css"); return widgetX; }Notice that there's no field and the getter just fallback to the builder.
Example for widgets called more than once:
private WidgetX widgetX; private WidgetX get_widgetX() { return widgetX; } private WidgetX build_widgetX() { widget = GWT.create(WidgetX.class); widget.setStyleName("css"); return widgetX; }Notice that the getter just returns the field. The builder is called in the Widgets ctor.
com.google.gwt.core.ext.UnableToCompleteException
Copyright © 2016. All rights reserved.