Example usage for com.vaadin.ui Component setParent

List of usage examples for com.vaadin.ui Component setParent

Introduction

In this page you can find the example usage for com.vaadin.ui Component setParent.

Prototype

public void setParent(HasComponents parent);

Source Link

Document

Sets the parent connector of the component.

Usage

From source file:info.magnolia.ui.vaadin.magnoliashell.MagnoliaShell.java

License:Open Source License

public void setUserMenu(View view) {
    Component userMenuComponent = view.asVaadinComponent();
    userMenuComponent.setParent(this);
    getState().userMenu = userMenuComponent;
}

From source file:org.jdal.vaadin.ui.ComponentViewAdapter.java

License:Apache License

public ComponentViewAdapter(Component component) {
    if (component.getParent() != null) {
        component.setParent(null);
    }//w w  w  .  ja v a  2 s  . co m

    setCompositionRoot(component);
}

From source file:org.lucidj.renderer.DefaultObjectRenderer.java

License:Apache License

@Override // CustomComponent
protected void setCompositionRoot(Component compositionRoot) {
    if (compositionRoot == null) // Sanity please
    {//from w  ww  . ja  v  a  2  s . co m
        return;
    }

    // Avoid the greedy CustomComponent problem
    HasComponents old_parent = compositionRoot.getParent();

    if (old_parent instanceof DefaultObjectRenderer) {
        DefaultObjectRenderer greedy_parent = (DefaultObjectRenderer) old_parent;

        if (greedy_parent.getCompositionRoot() == compositionRoot) {
            // Makes the greedy CustomComponent drop the compositionRoot we need to
            // assign to another CustomComponent, otherwise we get
            // IllegalArgumentException: Content is already attached to another parent
            compositionRoot.setParent(null);
        }
    }

    // We'll catch events sent by the renderer
    compositionRoot.addListener(new Listener() {
        @Override
        public void componentEvent(Event event) {
            // Bypass all events, so the listeners can be hooked here on the
            // renderer proxy, while the renderer can be plugged in and out
            fireEvent(event);
        }
    });

    // Proceed as intended
    super.setCompositionRoot(compositionRoot);
}

From source file:org.vaadin.addons.portallayout.portal.PortalBase.java

License:Apache License

/**
 * Removes a {@link Portlet} from current layout.
 * /*from   www  . ja  v  a 2  s  . c  o m*/
 * @param portlet
 *            {@link Portlet} to be removed.
 */
public void removePortlet(Portlet portlet) {
    Component portletContent = portlet.getParent();
    getState().portlets().remove(portlet);
    if (portletContent.getParent() == this) {
        portletContent.setParent(null);
    }
}

From source file:org.vaadin.addons.portallayout.portal.PortalBase.java

License:Apache License

private void addPortletMapping(Component c, Portlet result) {
    getState().contentToPortlet.put(c, result);
    getState().portlets().add(result);/*w  w w .j a v a 2s.co  m*/

    if (c instanceof ComponentContainer) {
        for (Component parent = this; parent != null; parent = parent.getParent()) {
            if (parent == c) {
                throw new IllegalArgumentException("Component cannot be added inside it's own content");
            }
        }
    }
    c.setParent(null);
    c.setParent(this);
}

From source file:org.vaadin.addons.portallayout.portlet.Portlet.java

License:Apache License

/**
 * Adds a component to the header of the current {@link Portlet}.
 * @param header Component to be displayed in the header.
 *///from  www .  ja  v a 2  s  .  c  om
public void setHeaderComponent(Component header) {
    if (getState().headerComponent != null) {
        ((Component) getState().headerComponent).setParent(null);
    }
    getState().headerComponent = header;
    header.setParent(getParent().getParent());
}

From source file:org.vaadin.miki.itemgrid.ItemGrid.java

License:Apache License

/**
 * Recreates contents of the grid.//from  ww w .ja va  2s.  c o m
 */
protected void updateItemComponents() {
    // make sure new components are in the state
    // this.getState().items.clear();
    for (Component c : this.components.values())
        c.setParent(null);
    this.components.clear();
    Container container = this.getContainerDataSource();
    if (container != null)
        for (Object itemId : container.getItemIds()) {
            Component c = this.getComponentForItem(itemId);
            if (c == null)
                c = this.getNullComponent(itemId);
            c.setParent(this);
            this.components.put(itemId, c);
        }
    this.markAsDirty();
}