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.galleries.shared;
029
030import org.opencms.ade.galleries.shared.I_CmsGalleryProviderConstants.GalleryMode;
031import org.opencms.ade.galleries.shared.I_CmsGalleryProviderConstants.GalleryTabId;
032
033import java.util.List;
034
035import com.google.gwt.user.client.rpc.IsSerializable;
036
037/**
038 * The gallery configuration.<p>
039 */
040public class CmsGalleryConfiguration implements I_CmsGalleryConfiguration, IsSerializable {
041
042    /** The current element. */
043    private String m_currentElement;
044
045    /** Flag to enable selection of galleries in the gallery tab. */
046    private boolean m_galleriesSelectable;
047
048    /** The gallery mode. */
049    private GalleryMode m_galleryMode;
050
051    /** The gallery path. */
052    private String m_galleryPath;
053
054    /** The prefix for the key used to store the last selected gallery. */
055    private String m_galleryStoragePrefix;
056
057    /** The gallery type name. */
058    private String m_galleryTypeName;
059
060    /** The gallery types. */
061    private String[] m_galleryTypes;
062
063    /** The image format names. */
064    private String m_imageFormatNames;
065
066    /** The image formats. */
067    private String m_imageFormats;
068
069    /** The content locale. */
070    private String m_locale;
071
072    /** The reference path. */
073    private String m_referencePath;
074
075    /** The resource types. */
076    private List<String> m_resourceTypes;
077
078    /** Flag which disables selection of results when set to false. */
079    private boolean m_resultsSelectable;
080
081    /** The search types. */
082    private List<String> m_searchTypes;
083
084    /** The show site selector flag. */
085    private boolean m_showSiteSelector;
086
087    /** The start folder. */
088    private String m_startFolder;
089
090    /** The start site. */
091    private String m_startSite;
092
093    /** The tab configuration. */
094    private CmsGalleryTabConfiguration m_tabConfiguration;
095
096    /** The tree token. */
097    private String m_treeToken;
098
099    /** The upload folder. */
100    private String m_uploadFolder;
101
102    /** The use formats flag. */
103    private boolean m_useFormats;
104
105    /** The page id. */
106    private String m_pageId;
107
108    /**
109     * Constructor.<p>
110     */
111    public CmsGalleryConfiguration() {
112
113        // set defaults
114        m_showSiteSelector = true;
115    }
116
117    /**
118     * Constructor.<p>
119     *
120     * @param configuration the initial configuration
121     */
122    public CmsGalleryConfiguration(I_CmsGalleryConfiguration configuration) {
123
124        m_currentElement = configuration.getCurrentElement();
125        m_galleryMode = configuration.getGalleryMode();
126        m_galleryPath = configuration.getGalleryPath();
127        m_galleryTypes = configuration.getGalleryTypes();
128        m_imageFormatNames = configuration.getImageFormatNames();
129        m_imageFormats = configuration.getImageFormats();
130        m_locale = configuration.getLocale();
131        m_referencePath = configuration.getReferencePath();
132        m_resourceTypes = configuration.getResourceTypes();
133        m_searchTypes = configuration.getSearchTypes();
134        m_showSiteSelector = configuration.isShowSiteSelector();
135        m_startFolder = configuration.getStartFolder();
136        m_startSite = configuration.getStartSite();
137        m_tabConfiguration = configuration.getTabConfiguration();
138        m_useFormats = configuration.isUseFormats();
139        m_treeToken = configuration.getTreeToken();
140        m_galleryStoragePrefix = configuration.getGalleryStoragePrefix();
141        m_galleriesSelectable = configuration.isGalleriesSelectable();
142        m_resultsSelectable = configuration.isResultsSelectable();
143    }
144
145    /**
146     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getCurrentElement()
147     */
148    public String getCurrentElement() {
149
150        return m_currentElement;
151    }
152
153    /**
154     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getGalleryMode()
155     */
156    public GalleryMode getGalleryMode() {
157
158        if (m_galleryMode == null) {
159            return GalleryMode.widget;
160        }
161        return m_galleryMode;
162    }
163
164    /**
165     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getGalleryPath()
166     */
167    public String getGalleryPath() {
168
169        return m_galleryPath;
170    }
171
172    /**
173     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getGalleryStoragePrefix()
174     */
175    public String getGalleryStoragePrefix() {
176
177        return m_galleryStoragePrefix;
178    }
179
180    /**
181     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getGalleryTypeName()
182     */
183    public String getGalleryTypeName() {
184
185        return m_galleryTypeName;
186    }
187
188    /**
189     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getGalleryTypes()
190     */
191    public String[] getGalleryTypes() {
192
193        return m_galleryTypes;
194    }
195
196    /**
197     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getImageFormatNames()
198     */
199    public String getImageFormatNames() {
200
201        return m_imageFormatNames;
202    }
203
204    /**
205     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getImageFormats()
206     */
207    public String getImageFormats() {
208
209        return m_imageFormats;
210    }
211
212    /**
213     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getLocale()
214     */
215    public String getLocale() {
216
217        return m_locale;
218    }
219
220    /**
221     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getPageId()
222     */
223    public String getPageId() {
224
225        return m_pageId;
226    }
227
228    /**
229     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getReferencePath()
230     */
231    public String getReferencePath() {
232
233        return m_referencePath;
234    }
235
236    /**
237     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getResourceTypes()
238     */
239    public List<String> getResourceTypes() {
240
241        return m_resourceTypes;
242    }
243
244    /**
245     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getSearchTypes()
246     */
247    public List<String> getSearchTypes() {
248
249        return m_searchTypes;
250    }
251
252    /**
253     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getStartFolder()
254     */
255    public String getStartFolder() {
256
257        return m_startFolder;
258    }
259
260    /**
261     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getStartSite()
262     */
263    public String getStartSite() {
264
265        return m_startSite;
266    }
267
268    /**
269     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getTabConfiguration()
270     */
271    public CmsGalleryTabConfiguration getTabConfiguration() {
272
273        return m_tabConfiguration;
274    }
275
276    /**
277     * Gets the array of tab ids.<p>
278     *
279     * @return the tab ids
280     */
281    public GalleryTabId[] getTabIds() {
282
283        if (m_tabConfiguration == null) {
284            return null;
285        }
286        return m_tabConfiguration.getTabs().toArray(new GalleryTabId[] {});
287    }
288
289    /**
290     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getTreeToken()
291     */
292    public String getTreeToken() {
293
294        return m_treeToken;
295    }
296
297    /**
298     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#getUploadFolder()
299     */
300    public String getUploadFolder() {
301
302        return m_uploadFolder;
303    }
304
305    /**
306     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#isGalleriesSelectable()
307     */
308    public boolean isGalleriesSelectable() {
309
310        return m_galleriesSelectable;
311    }
312
313    /**
314     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#isIncludeFiles()
315     */
316    public boolean isIncludeFiles() {
317
318        return getTabConfiguration().getTabs().contains(GalleryTabId.cms_tab_results);
319    }
320
321    /**
322     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#isResultsSelectable()
323     */
324    public boolean isResultsSelectable() {
325
326        return m_resultsSelectable;
327    }
328
329    /**
330     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#isShowSiteSelector()
331     */
332    public boolean isShowSiteSelector() {
333
334        return m_showSiteSelector;
335    }
336
337    /**
338     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#isUseFormats()
339     */
340    public boolean isUseFormats() {
341
342        return m_useFormats;
343    }
344
345    /**
346     * @see org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration#setCurrentElement(java.lang.String)
347     */
348    public void setCurrentElement(String currentElement) {
349
350        m_currentElement = currentElement;
351    }
352
353    /**
354     * Enables or disables selection of galleries in the gallery tab.<p>
355     *
356     * @param galleriesSelectable true if the galleries should be made selectable
357     */
358    public void setGalleriesSelectable(boolean galleriesSelectable) {
359
360        m_galleriesSelectable = galleriesSelectable;
361    }
362
363    /**
364     * Sets the galleryMode.<p>
365     *
366     * @param galleryMode the galleryMode to set
367     */
368    public void setGalleryMode(GalleryMode galleryMode) {
369
370        m_galleryMode = galleryMode;
371    }
372
373    /**
374     * Sets the galleryPath.<p>
375     *
376     * @param galleryPath the galleryPath to set
377     */
378    public void setGalleryPath(String galleryPath) {
379
380        m_galleryPath = galleryPath;
381    }
382
383    /**
384     * Sets the prefix for the key used to store the last selected gallery.<p>
385     *
386     * @param prefix the new prefix
387     */
388    public void setGalleryStoragePrefix(String prefix) {
389
390        m_galleryStoragePrefix = prefix;
391    }
392
393    /**
394     * Sets the gallery type name.<p>
395     *
396     * @param galleryTypeName the gallery type name
397     */
398    public void setGalleryTypeName(String galleryTypeName) {
399
400        m_galleryTypeName = galleryTypeName;
401    }
402
403    /**
404     * Sets the galleryTypes.<p>
405     *
406     * @param galleryTypes the galleryTypes to set
407     */
408    public void setGalleryTypes(String... galleryTypes) {
409
410        m_galleryTypes = galleryTypes;
411    }
412
413    /**
414     * Sets the image format names.<p>
415     *
416     * @param imageFormatNames the imageFormatNames to set
417     */
418    public void setImageFormatNames(String imageFormatNames) {
419
420        m_imageFormatNames = imageFormatNames;
421    }
422
423    /**
424     * Sets the image formats.<p>
425     *
426     * @param imageFormats the image formats to set
427     */
428    public void setImageFormats(String imageFormats) {
429
430        m_imageFormats = imageFormats;
431    }
432
433    /**
434     * Sets the locale.<p>
435     *
436     * @param locale the locale to set
437     */
438    public void setLocale(String locale) {
439
440        m_locale = locale;
441    }
442
443    /**
444     * Sets the page id.
445     *
446     * @param pageId the page id
447     */
448    public void setPageId(String pageId) {
449
450        m_pageId = pageId;
451    }
452
453    /**
454     * Sets the referencePath.<p>
455     *
456     * @param referencePath the referencePath to set
457     */
458    public void setReferencePath(String referencePath) {
459
460        m_referencePath = referencePath;
461    }
462
463    /**
464     * Sets the resourceTypes.<p>
465     *
466     * @param resourceTypes the resourceTypes to set
467     */
468    public void setResourceTypes(List<String> resourceTypes) {
469
470        m_resourceTypes = resourceTypes;
471    }
472
473    /**
474     * Disables selection of results if the given parameter is 'false'.<p>
475     *
476     * @param resultsSelectable false if result selection should be disabled
477     */
478    public void setResultsSelectable(boolean resultsSelectable) {
479
480        m_resultsSelectable = resultsSelectable;
481
482    }
483
484    /**
485     * Sets the searchTypes.<p>
486     *
487     * @param searchTypes the searchTypes to set
488     */
489    public void setSearchTypes(List<String> searchTypes) {
490
491        m_searchTypes = searchTypes;
492    }
493
494    /**
495     * Sets the showSiteSelector.<p>
496     *
497     * @param showSiteSelector the showSiteSelector to set
498     */
499    public void setShowSiteSelector(boolean showSiteSelector) {
500
501        m_showSiteSelector = showSiteSelector;
502    }
503
504    /**
505     * Sets the start folder.<p>
506     *
507     * @param startFolder the start folder
508     */
509    public void setStartFolder(String startFolder) {
510
511        m_startFolder = startFolder;
512    }
513
514    /**
515     * Sets the startSite.<p>
516     *
517     * @param startSite the startSite to set
518     */
519    public void setStartSite(String startSite) {
520
521        m_startSite = startSite;
522    }
523
524    /**
525     * Sets the tab configuration.<p>
526     *
527     * @param tabConfig the gallery tab configuration
528     */
529    public void setTabConfiguration(CmsGalleryTabConfiguration tabConfig) {
530
531        m_tabConfiguration = tabConfig;
532    }
533
534    /**
535     * Sets the upload folder.<p>
536     *
537     * @param uploadFolder the upload folder
538     */
539    public void setUploadFolder(String uploadFolder) {
540
541        m_uploadFolder = uploadFolder;
542    }
543
544    /**
545     * Sets the use formats flag.<p>
546     *
547     * @param useFormats the use formats flag to set
548     */
549    public void setUseFormats(boolean useFormats) {
550
551        m_useFormats = useFormats;
552    }
553}