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;
032
033import java.util.ArrayList;
034
035/**
036 * Represents a gallery folder.<p>
037 *
038 * @since 8.0.0
039 */
040public class CmsGalleryFolderBean extends CmsListInfoBean implements I_CmsHasPath {
041
042    /** The gallery group. */
043    private CmsGalleryGroup m_group;
044
045    /** A list with content types corresponding to this gallery type. */
046    private ArrayList<String> m_contentTypes;
047
048    /** Flag to indicate if the user has write permissions to the gallery folder. */
049    private boolean m_editable;
050
051    /** The folder site-path. */
052    private String m_path;
053
054    /** The name of the JavaScript method to get an upload button provider object. */
055    private String m_uploadAction;
056
057    /** The label for the gallery group. */
058    private String m_groupLabel;
059
060    /**
061     * Returns the content types which can be used within this gallery type.<p>
062     *
063     * @return the contentTypes
064     */
065    public ArrayList<String> getContentTypes() {
066
067        return m_contentTypes;
068    }
069
070    /**
071     * Gets the gallery group.
072     *
073     * @return the gallery group
074     */
075    public CmsGalleryGroup getGroup() {
076
077        return m_group;
078    }
079
080    /**
081     * Gets the label for the gallery group.
082     *
083     * @return the label for the gallery group
084     */
085    public String getGroupLabel() {
086
087        return m_groupLabel;
088    }
089
090    /**
091     * Returns the description.<p>
092     *
093     * @return the description
094     */
095    public String getPath() {
096
097        return m_path;
098    }
099
100    /**
101     * @see org.opencms.gwt.shared.CmsListInfoBean#getSubTitle()
102     */
103    @Override
104    public String getSubTitle() {
105
106        return getPath();
107    }
108
109    /**
110     * Gets the upload action.
111     *
112     * @return the upload action
113     */
114    public String getUploadAction() {
115
116        return m_uploadAction;
117    }
118
119    /**
120     * Returns the editable flag. Indicate if the user has write permissions to the gallery folder.<p>
121     *
122     * @return the editable flag
123     */
124    public boolean isEditable() {
125
126        return m_editable;
127    }
128
129    /**
130     * Returns if the gallery matches the given filter.<p>
131     *
132     * @param filter the filter to match
133     *
134     * @return <code>true</code> if the gallery matches the given filter.<p>
135     */
136    public boolean matchesFilter(String filter) {
137
138        filter = filter.toLowerCase();
139        return getTitle().toLowerCase().contains(filter) || m_path.toLowerCase().contains(filter);
140    }
141
142    /**
143     * Sets the content types which can be used within this gallery type.<p>
144     *
145     * @param contentTypes the contentTypes to set
146     */
147    public void setContentTypes(ArrayList<String> contentTypes) {
148
149        m_contentTypes = contentTypes;
150    }
151
152    /**
153     * Sets if the user has write permissions to the gallery folder.<p>
154     *
155     * @param editable <code>true</code> if the user has write permissions to the gallery folder
156     */
157    public void setEditable(boolean editable) {
158
159        m_editable = editable;
160    }
161
162    /**
163     * Sets the gallery group.
164     *
165     * @param group the gallery group
166     */
167    public void setGroup(CmsGalleryGroup group) {
168
169        m_group = group;
170    }
171
172    /**
173     * Sets the gallery group label.
174     *
175     * @param groupLabel the gallery group label
176     */
177    public void setGroupLabel(String groupLabel) {
178
179        m_groupLabel = groupLabel;
180    }
181
182    /**
183     * Sets the description.<p>
184     *
185     * @param path the description to set
186     */
187    public void setPath(String path) {
188
189        m_path = path;
190    }
191
192    /**
193     * Sets the upload action.<p>
194     *
195     * @param jsFunctionName the name of the JavaScript function to call when the upload button is pressed.
196     */
197    public void setUploadAction(String jsFunctionName) {
198
199        m_uploadAction = jsFunctionName;
200    }
201
202}