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.gwt.shared.CmsListInfoBean;
031import org.opencms.gwt.shared.sort.I_CmsHasPath;
032import org.opencms.util.CmsUUID;
033
034import java.util.ArrayList;
035
036/**
037 * Represents a gallery folder.<p>
038 *
039 * @since 8.0.0
040 */
041public class CmsGalleryFolderBean extends CmsListInfoBean implements I_CmsHasPath {
042
043    /** A list with content types corresponding to this gallery type. */
044    private ArrayList<String> m_contentTypes;
045
046    /** Flag to indicate if the user has write permissions to the gallery folder. */
047    private boolean m_editable;
048
049    /** The gallery group. */
050    private CmsGalleryGroup m_group;
051
052    /** The label for the gallery group. */
053    private String m_groupLabel;
054
055    /** The structure id of the gallery. */
056    private CmsUUID m_id;
057
058    /** Can use the 'optimize gallery' dialog. */
059    private boolean m_optimizable;
060
061    /** The folder site-path. */
062    private String m_path;
063
064    /** The name of the JavaScript method to get an upload button provider object. */
065    private String m_uploadAction;
066
067    /**
068     * Returns the content types which can be used within this gallery type.<p>
069     *
070     * @return the contentTypes
071     */
072    public ArrayList<String> getContentTypes() {
073
074        return m_contentTypes;
075    }
076
077    /**
078     * Gets the gallery group.
079     *
080     * @return the gallery group
081     */
082    public CmsGalleryGroup getGroup() {
083
084        return m_group;
085    }
086
087    /**
088     * Gets the label for the gallery group.
089     *
090     * @return the label for the gallery group
091     */
092    public String getGroupLabel() {
093
094        return m_groupLabel;
095    }
096
097    /**
098     * Gets the structure id.
099     *
100     * @return the structure id
101     */
102    public CmsUUID getId() {
103
104        return m_id;
105    }
106
107    /**
108     * Returns the description.<p>
109     *
110     * @return the description
111     */
112    public String getPath() {
113
114        return m_path;
115    }
116
117    /**
118     * @see org.opencms.gwt.shared.CmsListInfoBean#getSubTitle()
119     */
120    @Override
121    public String getSubTitle() {
122
123        return getPath();
124    }
125
126    /**
127     * Gets the upload action.
128     *
129     * @return the upload action
130     */
131    public String getUploadAction() {
132
133        return m_uploadAction;
134    }
135
136    /**
137     * Returns the editable flag. Indicate if the user has write permissions to the gallery folder.<p>
138     *
139     * @return the editable flag
140     */
141    public boolean isEditable() {
142
143        return m_editable;
144    }
145
146    /**
147     * User can use the 'optimize gallery' dialog.
148     *
149     * <p>This does not necessarily mean the user has write permissions on the gallery.
150     *
151     * @return true if the user can use the 'optimize gallery' dialog
152     */
153    public boolean isOptimizable() {
154
155        return m_optimizable;
156    }
157
158    /**
159     * Returns if the gallery matches the given filter.<p>
160     *
161     * @param filter the filter to match
162     *
163     * @return <code>true</code> if the gallery matches the given filter.<p>
164     */
165    public boolean matchesFilter(String filter) {
166
167        filter = filter.toLowerCase();
168        return getTitle().toLowerCase().contains(filter) || m_path.toLowerCase().contains(filter);
169    }
170
171    /**
172     * Sets the content types which can be used within this gallery type.<p>
173     *
174     * @param contentTypes the contentTypes to set
175     */
176    public void setContentTypes(ArrayList<String> contentTypes) {
177
178        m_contentTypes = contentTypes;
179    }
180
181    /**
182     * Sets if the user has write permissions to the gallery folder.<p>
183     *
184     * @param editable <code>true</code> if the user has write permissions to the gallery folder
185     */
186    public void setEditable(boolean editable) {
187
188        m_editable = editable;
189    }
190
191    /**
192     * Sets the gallery group.
193     *
194     * @param group the gallery group
195     */
196    public void setGroup(CmsGalleryGroup group) {
197
198        m_group = group;
199    }
200
201    /**
202     * Sets the gallery group label.
203     *
204     * @param groupLabel the gallery group label
205     */
206    public void setGroupLabel(String groupLabel) {
207
208        m_groupLabel = groupLabel;
209    }
210
211    /**
212     * Sets the structure id.
213     *
214     * @param structureId the structure id
215     */
216    public void setId(CmsUUID structureId) {
217
218        m_id = structureId;
219
220    }
221
222    /**
223     * Enables / disables 'optimize gallery' dialog.
224     *
225     * @param optimizable true if the 'optimize gallery' dialog should be enabled
226     */
227    public void setOptimizable(boolean optimizable) {
228
229        m_optimizable = optimizable;
230
231    }
232
233    /**
234     * Sets the description.<p>
235     *
236     * @param path the description to set
237     */
238    public void setPath(String path) {
239
240        m_path = path;
241    }
242
243    /**
244     * Sets the upload action.<p>
245     *
246     * @param jsFunctionName the name of the JavaScript function to call when the upload button is pressed.
247     */
248    public void setUploadAction(String jsFunctionName) {
249
250        m_uploadAction = jsFunctionName;
251    }
252
253}