001
002package org.opencms.ui.client;
003
004import com.google.gwt.dom.client.Element;
005import com.google.gwt.user.client.DOM;
006import com.google.gwt.user.client.ui.SimplePanel;
007import com.google.gwt.user.client.ui.Widget;
008
009/**
010 * Client-side implementation for the ExternalLayout addon. A simple, single-component panel
011 * that renders the contained component in the given element.<p>
012 *
013 * @author Risto Yrjänä / Vaadin Ltd.
014 */
015public class CmsExternalLayout extends SimplePanel {
016
017    /** The CSS class name. */
018    private static final String CLASSNAME = "v-externallayout";
019
020    /** The target element. */
021    private Element m_renderTargetElement;
022
023    /**
024     * Constructor.<p>
025     */
026    public CmsExternalLayout() {
027        m_renderTargetElement = getElement();
028    }
029
030    /**
031     * Returns the target element.<p>
032     *
033     * @return the target element
034     */
035    public Element getRenderTargetElement() {
036
037        return m_renderTargetElement;
038    }
039
040    /**
041     * Sets the target element.<p>
042     *
043     * @param renderTargetElement the target element
044     */
045    public void setRenderTargetElement(Element renderTargetElement) {
046
047        this.m_renderTargetElement = renderTargetElement;
048        renderTargetElement.setClassName(CLASSNAME);
049    }
050
051    /**
052     * This is overridden so that {@link #setWidget(Widget)} uses the specified
053     * external element.
054     */
055    @Override
056    @SuppressWarnings("deprecation")
057    //have to use old Element here because of superclass
058    protected com.google.gwt.user.client.Element getContainerElement() {
059
060        return DOM.asOld(getRenderTargetElement());
061    }
062}