@Override public void setParent(HasComponents parent) { // If the parent is not changed, don't do anything if (parent == null ? this.parent == null : parent.equals(this.parent)) { return; } if (parent != null && this.parent != null) { throw new IllegalStateException( getClass().getName() + " already has a parent."); } ClientConnector oldParent = getParent(); // Send a detach event if the component is currently attached if (isAttached()) { detach(); } // Connect to new parent this.parent = parent; // Send attach event if the component is now attached if (isAttached()) { attach(); } if (oldParent != null) { oldParent.markAsDirty(); } }
/** * Actually sets the parent and calls required listeners. * * @since 7.1 * @param parent * The parent to set */ private void internalSetParent(ClientConnector parent) { ClientConnector oldParent = getParent(); // Send a detach event if the component is currently attached if (isAttached()) { detach(); } // Connect to new parent this.parent = parent; // Send attach event if the component is now attached if (isAttached()) { attach(); } if (oldParent != null) { oldParent.markAsDirty(); } }