}
private BoundWidget createCellWidget(Binding rowBinding, int colIndex,
SourcesPropertyChangeEvents target) {
try {
final BoundWidget widget;
Field col = this.columns[colIndex];
BoundWidget[] rowWidgets = (BoundWidget[]) widgetCache.get(target);
if (rowWidgets == null) {
rowWidgets = new BoundWidget[this.columns.length];
widgetCache.put(target, rowWidgets);
}
if (rowWidgets[colIndex] != null) {
widget = rowWidgets[colIndex];
BoundTable.LOG.log(Level.SPAM,
"Using cache widget for " + target + "."
+ col.getPropertyName(), null);
} else {
if (col.getCellProvider() != null) {
widget = col.getCellProvider().get();
} else {
final Property p = Introspector.INSTANCE.getDescriptor(target).getProperty(col.getPropertyName());
widget = this.factory.getWidgetProvider(col.getPropertyName(),
p.getType()).get();
// TODO Figure out some way to make this read only.
}
assert widget != null : target + "." + col.getPropertyName() + " did not get a widget.";
rowWidgets[colIndex] = widget;
BoundTable.LOG.log(Level.SPAM,
"Creating widget for " + target + "." + col.getPropertyName(),
null);
}
Binding[] bindings = (Binding[]) this.bindingCache.get(target);
if (bindings == null) {
bindings = new Binding[this.columns.length];
this.bindingCache.put(target, bindings);
}
if (bindings[colIndex] == null) {
try {
bindings[colIndex] = new Binding(widget, "value",
col.getValidator(), col.getFeedback(), target,
col.getPropertyName(), null, null);
BoundTable.LOG.log(Level.SPAM,
"Created binding " + bindings[colIndex], null);
} catch (Throwable e) {
throw new RuntimeException("Error creating " + col.getPropertyName(), e);
}
}
widget.setModel(target);
rowBinding.getChildren().add(bindings[colIndex]);
return widget;
} catch (Exception e) {
GWT.log(null, e);