001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
016 *
017 * $Id: LayoutDefinition.java 26053 2007-10-16 01:45:43Z atchertchian $
018 */
019
020package org.nuxeo.ecm.platform.forms.layout.api;
021
022import java.io.Serializable;
023import java.util.List;
024import java.util.Map;
025
026/**
027 * Layout definition interface.
028 *
029 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
030 */
031public interface LayoutDefinition extends Serializable {
032
033    /**
034     * Returns the layout name used to identify it within the layout service.
035     */
036    String getName();
037
038    /**
039     * @since 5.5
040     */
041    void setName(String name);
042
043    /**
044     * Return the layout type, or null if not defined.
045     * <p>
046     * Since 6.0, the layout type can hold templates and properties configuration, so that layout does not need to
047     * define them again.
048     *
049     * @since 6.0
050     */
051    String getType();
052
053    /**
054     * @since 6.0
055     */
056    String getTypeCategory();
057
058    /**
059     * Returns template to use in a given mode.
060     */
061    String getTemplate(String mode);
062
063    /**
064     * Returns templates by mode
065     */
066    Map<String, String> getTemplates();
067
068    /**
069     * @since 5.5
070     */
071    void setTemplates(Map<String, String> templates);
072
073    /**
074     * Returns the widget definition with given name.
075     * <p>
076     * Returns null if a widget with this name is not found within the layout.
077     */
078    WidgetDefinition getWidgetDefinition(String name);
079
080    /**
081     * Returns the list of widget names to use at a given row.
082     * <p>
083     * For instance, this could describe a layout like: [['title'], ['description'], ['creationDate', '',
084     * 'modificationDate'], ['subject']].
085     */
086    LayoutRowDefinition[] getRows();
087
088    /**
089     * @since 5.5
090     */
091    void setRows(LayoutRowDefinition[] rows);
092
093    /**
094     * Returns the maximum number of columns.
095     */
096    int getColumns();
097
098    /**
099     * Returns a map of properties to use in a given mode.
100     */
101    Map<String, Serializable> getProperties(String layoutMode);
102
103    /**
104     * Returns a map of properties by mode.
105     */
106    Map<String, Map<String, Serializable>> getProperties();
107
108    /**
109     * @since 5.5
110     */
111    void setProperties(Map<String, Map<String, Serializable>> properties);
112
113    /**
114     * Returns the map of rendering information per mode.
115     * <p>
116     * Useful for preview management where some configuration needs to be changed: what's changed can be set as
117     * rendering information here to be displayed.
118     *
119     * @since 5.5
120     */
121    Map<String, List<RenderingInfo>> getRenderingInfos();
122
123    /**
124     * Returns the list of rendering information for given mode.
125     *
126     * @since 5.5
127     */
128    List<RenderingInfo> getRenderingInfos(String mode);
129
130    /**
131     * @since 5.5
132     */
133    void setRenderingInfos(Map<String, List<RenderingInfo>> renderingInfos);
134
135    /**
136     * Return alias names for this layout definition (useful for compatibility on old layout names).
137     *
138     * @since 6.0
139     */
140    List<String> getAliases();
141
142    /**
143     * Returns true if all widget references in this layout are empty
144     *
145     * @since 5.6
146     */
147    boolean isEmpty();
148
149    /**
150     * @since 6.0
151     */
152    boolean isDynamic();
153
154    /**
155     * Returns a clone instance of this layout definition.
156     * <p>
157     * Useful for conversion of layout definition during export.
158     *
159     * @since 5.5
160     */
161    LayoutDefinition clone();
162
163}