Esempio n. 1
0
        /// <summary>
        /// Disposes of the component.  Calls {@code exitDocument}, which is expected to
        /// remove event handlers and clean up the component.  Propagates the call to
        /// the component's children, if any. Removes the component's DOM from the
        /// document unless it was decorated.
        /// </summary>
        public override void disposeInternal()
        {
            if (this.inDocument_)
            {
                this.exitDocument();
            }

            if (this.googUiComponentHandler_ != null)
            {
                this.googUiComponentHandler_.dispose();
                Script.Delete(ref this.googUiComponentHandler_);
            }

            // Disposes of the component's children, if any.
            this.forEachChild((child) => { child.dispose(); });

            // Detach the component's element from the DOM, unless it was decorated.
            if (!this.wasDecorated_ && this.element_ != null)
            {
                goog.dom.removeNode(this.element_);
            }

            this.children_   = null;
            this.childIndex_ = null;
            this.element_    = null;
            this.model_      = null;
            this.parent_     = null;

            base.disposeInternal();
        }
Esempio n. 2
0
        /// <summary>
        /// Sets the parent of this component to use for event bubbling.  Throws an error
        /// if the component already has a parent or if an attempt is made to add a
        /// component to itself as a child.  Callers must use {@code removeChild}
        /// or {@code removeChildAt} to remove components from their containers before
        /// calling this method.
        /// @see goog.ui.Component#removeChild
        /// @see goog.ui.Component#removeChildAt
        /// </summary>
        /// <param name="parent">The parent component.</param>
        public void setParent(Component parent)
        {
            if (this == parent)
            {
                // Attempting to add a child to itself is an error.
                throw new Exception(goog.ui.Component.Error.PARENT_UNABLE_TO_BE_SET);
            }

            if (parent != null && this.parent_ != null && this.id_ != null && this.parent_.getChild(this.id_) != null &&
                this.parent_ != parent)
            {
                // This component is already the child of some parent, so it should be
                // removed using removeChild/removeChildAt first.
                throw new Exception(goog.ui.Component.Error.PARENT_UNABLE_TO_BE_SET);
            }

            this.parent_ = parent;
            base.setParentEventTarget(parent);
        }