001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (C) Alkacon Software (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;
029
030import org.opencms.acacia.shared.CmsEntity;
031import org.opencms.acacia.shared.CmsTabInfo;
032import org.opencms.gwt.client.ui.CmsTabbedPanel;
033
034import java.util.List;
035
036import com.google.gwt.user.client.ui.FlowPanel;
037import com.google.gwt.user.client.ui.Panel;
038
039/**
040 * Renders an entity into a widget.<p>
041 */
042public interface I_CmsEntityRenderer {
043
044    /**
045     * Returns a copy of this renderer which has been configured with the given configuration string.<p>
046     *
047     * @param configuration the configuration string
048     *
049     * @return the configured copy of the renderer
050     */
051    I_CmsEntityRenderer configure(String configuration);
052
053    /**
054     * Gets the name of the renderer (should be unique for each renderer class).<p>
055     *
056     * @return the renderer name
057     */
058    String getName();
059
060    /**
061     * Renders a single attribute value. Used for inline editing to show a fragment of the form.<p>
062     *
063     * @param parentEntity the parent entity
064     * @param attributeHandler the attribute handler
065     * @param attributeIndex the value index
066     * @param context the parent widget
067     */
068    void renderAttributeValue(
069        CmsEntity parentEntity,
070        CmsAttributeHandler attributeHandler,
071        int attributeIndex,
072        Panel context);
073
074    /**
075     * Renders the given entity into a form with tabs.<p>
076     *
077     * @param entity the entity to render
078     * @param tabInfos the tab infos
079     * @param context the context widget panel
080     * @param parentHandler the parent attribute handler
081     * @param attributeIndex the attribute index
082     *
083     * @return the tabbed panel
084     */
085    CmsTabbedPanel<FlowPanel> renderForm(
086        CmsEntity entity,
087        List<CmsTabInfo> tabInfos,
088        Panel context,
089        I_CmsAttributeHandler parentHandler,
090        int attributeIndex);
091
092    /**
093     * Renders the given entity into a form.<p>
094     *
095     * @param entity the entity to render
096     * @param context the context widget panel
097     * @param parentHandler the parent attribute handler
098     * @param attributeIndex the attribute index
099     */
100    void renderForm(CmsEntity entity, Panel context, I_CmsAttributeHandler parentHandler, int attributeIndex);
101
102    /**
103     * Injects editing widgets into the given DOM context to enable editing of the given entity.<p>
104     *
105     * @param entity the entity to render
106     * @param formParent formParent the form parent widget
107     * @param updateHandler handles updates on the HTML required  due to entity data changes
108     * @param parentHandler the parent attribute handler
109     * @param attributeIndex the attribute index
110     */
111    void renderInline(
112        CmsEntity entity,
113        I_CmsInlineFormParent formParent,
114        I_CmsInlineHtmlUpdateHandler updateHandler,
115        I_CmsAttributeHandler parentHandler,
116        int attributeIndex);
117
118    /**
119     * Injects editing widgets into the given DOM context to enable editing of the given entity attribute.<p>
120     *
121     * @param parentEntity the parent entity
122     * @param attributeName the attribute name
123     * @param formParent the form parent widget
124     * @param updateHandler handles updates on the HTML required  due to entity data changes
125     * @param parentHandler the parent attribute handler
126     * @param attributeIndex the attribute index
127     * @param minOccurrence the minimum occurrence of this attribute
128     * @param maxOccurrence the maximum occurrence of this attribute
129     */
130    void renderInline(
131        CmsEntity parentEntity,
132        String attributeName,
133        I_CmsInlineFormParent formParent,
134        I_CmsInlineHtmlUpdateHandler updateHandler,
135        I_CmsAttributeHandler parentHandler,
136        int attributeIndex,
137        int minOccurrence,
138        int maxOccurrence);
139}