001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.acacia.client.widgets.complex;
029
030import org.opencms.acacia.client.CmsAttributeHandler;
031import org.opencms.acacia.client.I_CmsAttributeHandler;
032import org.opencms.acacia.client.I_CmsEntityRenderer;
033import org.opencms.acacia.client.I_CmsInlineFormParent;
034import org.opencms.acacia.client.I_CmsInlineHtmlUpdateHandler;
035import org.opencms.acacia.client.css.I_CmsLayoutBundle;
036import org.opencms.acacia.shared.CmsEntity;
037import org.opencms.acacia.shared.CmsTabInfo;
038import org.opencms.gwt.client.ui.CmsTabbedPanel;
039import org.opencms.gwt.shared.CmsDataViewConstants;
040import org.opencms.gwt.shared.CmsGwtConstants;
041
042import java.util.List;
043
044import com.google.gwt.user.client.ui.FlowPanel;
045import com.google.gwt.user.client.ui.Panel;
046
047/**
048 * Special renderer for DataView widgets.<p>
049 */
050public class CmsDataViewWidgetRenderer implements I_CmsEntityRenderer {
051
052    /** The entity CSS class. */
053    public static final String ENTITY_CLASS = I_CmsLayoutBundle.INSTANCE.form().entity();
054
055    /** The attribute label CSS class. */
056    public static final String LABEL_CLASS = I_CmsLayoutBundle.INSTANCE.form().label();
057
058    /** The widget holder CSS class. */
059    public static final String WIDGET_HOLDER_CLASS = I_CmsLayoutBundle.INSTANCE.form().widgetHolder();
060
061    /** The configuration string. */
062    private String m_configuration;
063
064    /**
065     * Default constructor.<p>
066     */
067    public CmsDataViewWidgetRenderer() {
068
069    }
070
071    /**
072     * Creates a new configured instance.<p>
073     *
074     * @param configuration the configuration string
075     */
076    public CmsDataViewWidgetRenderer(String configuration) {
077
078        m_configuration = configuration;
079        if (m_configuration == null) {
080            m_configuration = "";
081        }
082    }
083
084    /**
085     * @see org.opencms.acacia.client.I_CmsEntityRenderer#configure(java.lang.String)
086     */
087    public CmsDataViewWidgetRenderer configure(String configuration) {
088
089        return new CmsDataViewWidgetRenderer(configuration);
090    }
091
092    /**
093     * @see org.opencms.acacia.client.I_CmsEntityRenderer#getName()
094     */
095    public String getName() {
096
097        return CmsDataViewConstants.RENDERER_ID;
098    }
099
100    /**
101     * @see org.opencms.acacia.client.I_CmsEntityRenderer#renderAttributeValue(org.opencms.acacia.shared.CmsEntity, org.opencms.acacia.client.CmsAttributeHandler, int, com.google.gwt.user.client.ui.Panel)
102     */
103    public void renderAttributeValue(
104        CmsEntity parentEntity,
105        CmsAttributeHandler attributeHandler,
106        int attributeIndex,
107        Panel context) {
108
109        // ignore
110
111    }
112
113    /**
114     * @see org.opencms.acacia.client.I_CmsEntityRenderer#renderForm(org.opencms.acacia.shared.CmsEntity, java.util.List, com.google.gwt.user.client.ui.Panel, org.opencms.acacia.client.I_CmsAttributeHandler, int)
115     */
116    public CmsTabbedPanel<FlowPanel> renderForm(
117        CmsEntity entity,
118        List<CmsTabInfo> tabInfos,
119        Panel context,
120        I_CmsAttributeHandler parentHandler,
121        int attributeIndex) {
122
123        return null;
124
125    }
126
127    /**
128     * @see org.opencms.acacia.client.I_CmsEntityRenderer#renderForm(org.opencms.acacia.shared.CmsEntity, com.google.gwt.user.client.ui.Panel, org.opencms.acacia.client.I_CmsAttributeHandler, int)
129     */
130    public void renderForm(
131        final CmsEntity entity,
132        Panel context,
133        final I_CmsAttributeHandler parentHandler,
134        final int attributeIndex) {
135
136        context.addStyleName(ENTITY_CLASS);
137        context.getElement().setAttribute("typeof", entity.getTypeName());
138        context.getElement().setAttribute(CmsGwtConstants.ATTR_DATA_ID, entity.getId());
139        CmsDataViewValueAccessor accessor = new CmsDataViewValueAccessor(entity, parentHandler, attributeIndex);
140        context.add(new CmsDataViewClientWidget(accessor, m_configuration));
141    }
142
143    /**
144     * @see org.opencms.acacia.client.I_CmsEntityRenderer#renderInline(org.opencms.acacia.shared.CmsEntity, org.opencms.acacia.client.I_CmsInlineFormParent, org.opencms.acacia.client.I_CmsInlineHtmlUpdateHandler, org.opencms.acacia.client.I_CmsAttributeHandler, int)
145     */
146    public void renderInline(
147        CmsEntity entity,
148        I_CmsInlineFormParent formParent,
149        I_CmsInlineHtmlUpdateHandler updateHandler,
150        I_CmsAttributeHandler parentHandler,
151        int attributeIndex) {
152
153        // ignore
154    }
155
156    /**
157     * @see org.opencms.acacia.client.I_CmsEntityRenderer#renderInline(org.opencms.acacia.shared.CmsEntity, java.lang.String, org.opencms.acacia.client.I_CmsInlineFormParent, org.opencms.acacia.client.I_CmsInlineHtmlUpdateHandler, org.opencms.acacia.client.I_CmsAttributeHandler, int, int, int)
158     */
159    public void renderInline(
160        CmsEntity parentEntity,
161        String attributeName,
162        I_CmsInlineFormParent formParent,
163        I_CmsInlineHtmlUpdateHandler updateHandler,
164        I_CmsAttributeHandler parentHandler,
165        int attributeIndex,
166        int minOccurrence,
167        int maxOccurrence) {
168
169        // ignore
170    }
171}