Example usage for com.vaadin.ui AbstractSingleComponentContainer removeFromParent

List of usage examples for com.vaadin.ui AbstractSingleComponentContainer removeFromParent

Introduction

In this page you can find the example usage for com.vaadin.ui AbstractSingleComponentContainer removeFromParent.

Prototype


public static void removeFromParent(Component content) throws IllegalArgumentException 

Source Link

Document

Utility method for removing a component from its parent (if possible).

Usage

From source file:com.explicatis.ext_token_field.ExtTokenField.java

License:Apache License

/**
 * copied from AbstractComponentContainer
 * //from w w  w.  j  a v  a  2  s.  co  m
 * @param c
 */
public void addComponent(Component c) {
    // Make sure we're not adding the component inside it's own content
    if (isOrHasAncestor(c)) {
        throw new IllegalArgumentException("Component cannot be added inside it's own content");
    }

    if (c.getParent() != null) {
        // If the component already has a parent, try to remove it
        AbstractSingleComponentContainer.removeFromParent(c);
    }

    c.setParent(this);
    fireComponentAttachEvent(c);
    markAsDirty();
}

From source file:com.haulmont.cuba.web.widgets.addons.popupbutton.PopupButton.java

License:Apache License

/**
 * Shows or hides popup./*from   w  w w .  j a va 2 s  .  c  o  m*/
 *
 * @param popupVisible
 *            if true, popup is set to visible, otherwise popup is hidden.
 */
public void setPopupVisible(boolean popupVisible) {
    if (getState().popupVisible != popupVisible) {
        getState().popupVisible = popupVisible;

        if (component == null) {
            return;
        }

        if (popupVisible) {
            if (component.getParent() != null && component.getParent() != this) {
                // If the component already has a parent, try to remove it
                AbstractSingleComponentContainer.removeFromParent(component);
            }
            component.setParent(this);
        } else {
            if (component.getParent() == this) {
                component.setParent(null);
            }
        }
        fireEvent(new PopupVisibilityEvent(this));
        markAsDirty();
    }
}

From source file:info.magnolia.ui.vaadin.dialog.BaseDialog.java

License:Open Source License

/**
 * Sets a Component//from  w w  w .j  a va 2  s  .  c o m
 * <p>
 * The composition root must be set to non-null value before the component can be used. The composition root can only be set once.
 * </p>
 *
 * @param newContent
 * the root of the composition component tree.
 */
protected void adoptComponent(Component newContent) {
    if (newContent != null) {
        // set new component
        if (newContent.getParent() != null) {
            if (newContent.getParent() == this) {
                newContent.setParent(null);
            } else {
                // If the component already has a parent, try to remove it
                AbstractSingleComponentContainer.removeFromParent(newContent);
            }
        }
        newContent.setParent(this);
    }
    markAsDirty();

}