@Override public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) { ComponentConnector oldChild = null; ComponentConnector newChild = getContent(); for (ComponentConnector c : event.getOldChildren()) { if (!(c instanceof WindowConnector)) { oldChild = c; break; } } if (oldChild != newChild) { if (childStateChangeHandlerRegistration != null) { childStateChangeHandlerRegistration.removeHandler(); childStateChangeHandlerRegistration = null; } if (newChild != null) { getWidget().setWidget(newChild.getWidget()); childStateChangeHandlerRegistration = newChild.addStateChangeHandler(childStateChangeHandler); // Must handle new child here as state change events are already // fired onChildSizeChange(); } else { getWidget().setWidget(null); } } for (ComponentConnector c : getChildComponents()) { if (c instanceof WindowConnector) { WindowConnector wc = (WindowConnector) c; wc.setWindowOrderAndPosition(); } } // Close removed sub windows for (ComponentConnector c : event.getOldChildren()) { if (c.getParent() != this && c instanceof WindowConnector) { ((WindowConnector) c).getWidget().hide(); } } }
@Override public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) { // super.onConnectorHierarchyChange(event); // Remove old children for (ComponentConnector child : event.getOldChildren()) { if (child.getParent() != this) { Widget widget = child.getWidget(); if (widget.isAttached()) { getWidget().remove(widget); } } } // Add or move children int index = 0; for (ComponentConnector child : getChildComponents()) { getWidget().addOrMove(child.getWidget(), index); ++index; } }