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.ade.containerpage.shared;
029
030import org.opencms.util.CmsStringUtil;
031import org.opencms.xml.content.CmsXmlContentProperty;
032
033import java.util.Map;
034import java.util.Set;
035
036import com.google.gwt.user.client.rpc.IsSerializable;
037
038/**
039 * Formatter configuration data.<p>
040 */
041public class CmsFormatterConfig implements IsSerializable {
042
043    /** Key for the formatter configuration id setting. Append the container name to the key, to store container depending values. */
044    public static final String FORMATTER_SETTINGS_KEY = "formatterSettings#";
045
046    /** Id used for schema based formatters. */
047    public static final String SCHEMA_FORMATTER_ID = "schema_formatter";
048
049    /** The required css resources. */
050    private Set<String> m_cssResources;
051
052    /** The formatter configuration id. */
053    private String m_id;
054
055    /** The inline CSS. */
056    private String m_inlineCss;
057
058    /** The formatter root path. */
059    private String m_jspRootPath;
060
061    /** The formatter label. */
062    private String m_label;
063
064    /** Contains the nested formatters prefixes and their labels. */
065    private Map<String, String> m_nestedFormatterPrefixes;
066
067    /** The setting for this container element. */
068    private Map<String, CmsXmlContentProperty> m_settingConfig;
069
070    /** The description. */
071    private String m_description;
072
073    /**
074     * Constructor.<p>
075     *
076     * @param id the formatter id
077     */
078    public CmsFormatterConfig(String id) {
079
080        m_id = id;
081    }
082
083    /**
084     * Constructor for serialization only.<p>
085     */
086    protected CmsFormatterConfig() {
087
088        // nothing to to
089    }
090
091    /**
092     * Returns the formatter configuration settings key for the given container name.<p>
093     *
094     * @param containerName the container name
095     *
096     * @return the settings key
097     */
098    public static String getSettingsKeyForContainer(String containerName) {
099
100        return FORMATTER_SETTINGS_KEY + containerName;
101    }
102
103    /**
104     * Returns the required CSS resources.<p>
105     *
106     * @return the CSS resources
107     */
108    public Set<String> getCssResources() {
109
110        return m_cssResources;
111    }
112
113    /**
114     * Gets the description.<p>
115     *
116     * @return the description
117     */
118    public String getDescription() {
119
120        return m_description;
121    }
122
123    /**
124     * Returns the formatter configuration id.<p>
125     *
126     * @return the configuration id
127     */
128    public String getId() {
129
130        return m_id;
131    }
132
133    /**
134     * Returns the inline CSS.<p>
135     *
136     * @return the inline CSS
137     */
138    public String getInlineCss() {
139
140        return m_inlineCss;
141    }
142
143    /**
144     * Returns the formatter root path.<p>
145     *
146     * @return the formatter root path
147     */
148    public String getJspRootPath() {
149
150        return m_jspRootPath;
151    }
152
153    /**
154     * Returns the formatter label.<p>
155     *
156     * @return the label
157     */
158    public String getLabel() {
159
160        return m_label;
161    }
162
163    /**
164     * Returns the nested formatters prefixes and their labels.<p>
165     *
166     * @return the nested formatters prefixes and their labels
167     */
168    public Map<String, String> getNestedFormatterPrefixes() {
169
170        return m_nestedFormatterPrefixes;
171    }
172
173    /**
174     * Returns the settings configuration.<p>
175     *
176     * @return the settings configuration
177     */
178    public Map<String, CmsXmlContentProperty> getSettingConfig() {
179
180        return m_settingConfig;
181    }
182
183    /**
184     * Returns if the formatter has inline CSS.<p>
185     *
186     * @return <code>true</code> if the formatter has inline CSS
187     */
188    public boolean hasInlineCss() {
189
190        return CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_inlineCss);
191    }
192
193    /**
194     * Sets the required CSS resources.<p>
195     *
196     * @param cssResources the CSS resources
197     */
198    public void setCssResources(Set<String> cssResources) {
199
200        m_cssResources = cssResources;
201    }
202
203    /**
204     * Sets the description.<p>
205     *
206     * @param description the description
207     */
208    public void setDescription(String description) {
209
210        m_description = description;
211    }
212
213    /**
214     * Sets the inline CSS.<p>
215     *
216     * @param inlineCss the inline CSS
217     */
218    public void setInlineCss(String inlineCss) {
219
220        m_inlineCss = inlineCss;
221    }
222
223    /**
224     * Sets the formatter root path.<p>
225     *
226     * @param jspRootPath the formatter root path
227     */
228    public void setJspRootPath(String jspRootPath) {
229
230        m_jspRootPath = jspRootPath;
231    }
232
233    /**
234     * Sets the formatter label.<p>
235     *
236     * @param label the label
237     */
238    public void setLabel(String label) {
239
240        m_label = label;
241    }
242
243    /**
244     * Sets the nested formatters prefixes and their labels.<p>
245     *
246     * @param nestedFormatterPrefixes the nested formatters prefixes and their labels to set
247     */
248    public void setNestedFormatterPrefixes(Map<String, String> nestedFormatterPrefixes) {
249
250        m_nestedFormatterPrefixes = nestedFormatterPrefixes;
251    }
252
253    /**
254     * Sets the settings configuration.<p>
255     *
256     * @param settingConfig the settings configuration
257     */
258    public void setSettingConfig(Map<String, CmsXmlContentProperty> settingConfig) {
259
260        m_settingConfig = settingConfig;
261    }
262}