Example usage for com.vaadin.ui Component getExtensions

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

Introduction

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

Prototype

public Collection<Extension> getExtensions();

Source Link

Document

Get a read-only collection of all extensions attached to this connector.

Usage

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

License:Apache License

/**
 * Finds or creates a Portlet based on the Component. In case there is no
 * Portlet existing for the given Component - a new Portlet is created, if
 * there is a Portlet but it belongs to a different PortalLayout, current
 * Portal steals the Component from it./*from   w w  w.  java2  s . c  o m*/
 * 
 * @param c
 *            content Component.
 * @return either Portlet instance from own mapping, other portlets mapping
 *         or a newly created instance.
 */
protected Portlet getOrCreatePortletForComponent(Component c) {
    Portlet result = (Portlet) getState().contentToPortlet.get(c);
    if (result != null) {
        return result;
    } else {
        for (Extension extension : c.getExtensions()) {
            if (extension instanceof Portlet) {
                addPortletMapping(c, (Portlet) extension);
                return (Portlet) extension;
            }
        }
    }
    result = createPortlet(c);
    return result;
}