throws Exception {
// add new LayoutData - remove existing one
if (parent instanceof WidgetInfo
&& child instanceof LayoutDataInfo
&& isActiveOnContainer(parent.getParent())) {
WidgetInfo widget = (WidgetInfo) parent;
LayoutDataInfo existingLayoutData = getLayoutData(widget);
if (existingLayoutData != null) {
widget.removeChild(existingLayoutData);
}
}
}
});
addBroadcastListener(new ObjectInfoChildAddAfter() {
public void invoke(ObjectInfo parent, ObjectInfo child) throws Exception {
ContainerInfo container = getContainer();
// add this layout
if (child == m_this) {
// implicit layouts are bound to its parent
if (getCreationSupport() instanceof IImplicitCreationSupport) {
targetBroadcastListener(parent);
}
// create virtual LayoutData's
for (WidgetInfo widget : container.getChildrenWidgets()) {
ensureLayoutData(widget);
}
}
}
});
addBroadcastListener(new ObjectInfoDelete() {
@Override
public void before(ObjectInfo parent, ObjectInfo child) throws Exception {
// delete this layout
if (child == m_this) {
onDelete();
}
// delete Widget_Info from this container
if (isActiveOnContainer(parent) && child instanceof WidgetInfo) {
onWidgetRemoveBefore((WidgetInfo) child);
}
}
@Override
public void after(ObjectInfo parent, ObjectInfo child) throws Exception {
// LayoutData was deleted - create virtual
if (parent instanceof WidgetInfo
&& child instanceof LayoutDataInfo
&& shouldCreateLayoutData((WidgetInfo) parent)
&& isActiveOnContainer(parent.getParent())) {
WidgetInfo widget = (WidgetInfo) parent;
ensureLayoutData(widget);
}
// Widget_Info was deleted
if (isActiveOnContainer(parent) && child instanceof WidgetInfo) {
WidgetInfo widget = (WidgetInfo) child;
if (widget.isDeleted()) {
onWidgetRemoveAfter(widget);
}
}
}
});
addBroadcastListener(new JavaEventListener() {
@Override
public void addAfter(JavaInfo parent, JavaInfo child) throws Exception {
// new Widget_Info added, ensure layout data
if (isActiveOnContainer(parent) && child instanceof WidgetInfo) {
ensureLayoutData((WidgetInfo) child);
}
}
@Override
public void moveBefore(JavaInfo child, ObjectInfo oldParent, JavaInfo newParent)
throws Exception {
// move Widget_Info FROM this container
if (isActiveOnContainer(oldParent) && child instanceof WidgetInfo && newParent != oldParent) {
WidgetInfo widget = (WidgetInfo) child;
onWidgetRemoveBefore(widget);
deleteLayoutData(widget);
}
}