addBroadcastListener(new XmlObjectAddProperties() {
public void invoke(XmlObjectInfo object, List<Property> properties) throws Exception {
if (object instanceof WidgetInfo && object.getParent() == panel) {
WidgetInfo widget = (WidgetInfo) object;
// prepare "Cell" property
Property cellProperty = (Property) widget.getArbitraryValue(this);
if (cellProperty == null) {
cellProperty = getCellComplexProperty(widget);
widget.putArbitraryValue(this, cellProperty);
}
// add "Cell" property
properties.add(cellProperty);
}
}
private Property getCellComplexProperty(WidgetInfo widget) throws Exception {
ClassLoader editorLoader = getContext().getClassLoader();
String namespace = StringUtils.substringBefore(getElement().getTag(), ":") + ":";
// "width"
Property widthProperty;
{
ExpressionAccessor expressionAccessor = new CellExpressionAccessor(namespace, "width");
GenericPropertyDescription propertyDescription =
new GenericPropertyDescription(null, "width", String.class, expressionAccessor);
propertyDescription.setEditor(StringPropertyEditor.INSTANCE);
propertyDescription.setConverter(StringConverter.INSTANCE);
widthProperty = new GenericPropertyImpl(widget, propertyDescription);
}
// "height"
Property heightProperty;
{
ExpressionAccessor expressionAccessor = new CellExpressionAccessor(namespace, "height");
GenericPropertyDescription propertyDescription =
new GenericPropertyDescription(null, "height", String.class, expressionAccessor);
propertyDescription.setEditor(StringPropertyEditor.INSTANCE);
propertyDescription.setConverter(StringConverter.INSTANCE);
heightProperty = new GenericPropertyImpl(widget, propertyDescription);
}
// "horizontalAlignment"
Property horizontalAlignmentProperty;
{
StaticFieldPropertyEditor propertyEditor = new StaticFieldPropertyEditor();
Class<?> hasHorizontalAlignmentClass =
editorLoader.loadClass("com.google.gwt.user.client.ui.HasHorizontalAlignment");
propertyEditor.configure(hasHorizontalAlignmentClass, new String[]{
"ALIGN_LEFT",
"ALIGN_CENTER",
"ALIGN_RIGHT"});
Object defaultValue =
ReflectionUtils.getFieldObject(hasHorizontalAlignmentClass, "ALIGN_LEFT");
// create property
ExpressionAccessor expressionAccessor =
new CellExpressionAccessor(namespace, "horizontalAlignment");
GenericPropertyDescription propertyDescription =
new GenericPropertyDescription(null,
"horizontalAlignment",
String.class,
expressionAccessor);
propertyDescription.setEditor(propertyEditor);
propertyDescription.setDefaultValue(defaultValue);
horizontalAlignmentProperty = new GenericPropertyImpl(widget, propertyDescription);
}
// "verticalAlignment"
Property verticalAlignmentProperty;
{
StaticFieldPropertyEditor propertyEditor = new StaticFieldPropertyEditor();
Class<?> hasVerticalAlignmentClass =
editorLoader.loadClass("com.google.gwt.user.client.ui.HasVerticalAlignment");
propertyEditor.configure(hasVerticalAlignmentClass, new String[]{