On 2011/11/29 20:47:56, stephenh wrote:
> should "&& !designTime.isDesignTime()" be added to the test?
Dunno, good question; I added Konstantin as a reviewer.
Konstantin, do you think the assertion in this patch should be skipped
during
design time (the assertion is supposed to warn the user when they've
marked
fields as provided=true but left them null, as without this assertion
the
resulting NPE is somewhat cryptic).
In general at design time we want to be forgiving about field related
problems.
And for @UiField we actually ask DesignTimeUtils about field value.
See
com.google.gwt.uibinder.rebind.UiBinderWriter.writeGwtFields(IndentedWriter):
private void writeGwtFields(IndentedWriter niceWriter) throws
UnableToCompleteException {
// For each provided field in the owner class, initialize from the
owner
Collection<OwnerField> ownerFields = getOwnerClass().getUiFields();
for (OwnerField ownerField : ownerFields) {
if (ownerField.isProvided()) {
String fieldName = ownerField.getName();
FieldWriter fieldWriter = fieldManager.lookup(fieldName);
// TODO why can this be null?
if (fieldWriter != null) {
String initializer;
if (designTime.isDesignTime()) {
String typeName =
ownerField.getType().getRawType().getQualifiedSourceName();
initializer = designTime.getProvidedField(typeName,
ownerField.getName());
} else {
initializer = formatCode("owner.%1$s", fieldName);
}
fieldManager.lookup(fieldName).setInitializer(initializer);
}
}
}
fieldManager.writeGwtFieldsDeclaration(niceWriter);
}
http://gwt-code-reviews.appspot.com/1604803/
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors