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.ui.apps.user;
029
030import org.opencms.file.CmsObject;
031import org.opencms.ui.CmsCssIcon;
032import org.opencms.ui.CmsVaadinUtils;
033import org.opencms.ui.apps.Messages;
034import org.opencms.ui.components.OpenCmsTheme;
035
036/**Type of element.*/
037public enum CmsOuTreeType implements I_CmsOuTreeType {
038
039    /**Group. */
040    GROUP(Messages.GUI_USERMANAGEMENT_GROUPS_0, "g", true, new CmsCssIcon(OpenCmsTheme.ICON_GROUP),
041    Messages.GUI_USERMANAGEMENT_NO_GROUPS_0),
042    /**OU. */
043    OU(Messages.GUI_USERMANAGEMENT_USER_OU_0, "o", true, new CmsCssIcon(OpenCmsTheme.ICON_OU), ""),
044    /**Role. */
045    ROLE(Messages.GUI_USERMANAGEMENT_ROLES_0, "r", true, new CmsCssIcon(OpenCmsTheme.ICON_ROLE),
046    Messages.GUI_USERMANAGEMENT_NO_USER_0),
047    /**User.*/
048    USER(Messages.GUI_USERMANAGEMENT_USERS_0, "u", false, new CmsCssIcon(OpenCmsTheme.ICON_USER),
049    Messages.GUI_USERMANAGEMENT_NO_USER_0);
050
051    /**Bundle key for empty message.*/
052    private String m_emptyMessageKey;
053
054    /**Icon for type. */
055    private CmsCssIcon m_icon;
056
057    /**ID for entry. */
058    private String m_id;
059
060    /**Is expandable?*/
061    private boolean m_isExpandable;
062
063    /**Name of entry. */
064    private String m_name;
065
066    /**
067     * constructor.<p>
068     *
069     * @param name name
070     * @param id id
071     * @param isExpandable boolean
072     * @param icon icon
073     * @param empty empty string
074     */
075    CmsOuTreeType(String name, String id, boolean isExpandable, CmsCssIcon icon, String empty) {
076
077        m_name = name;
078        m_id = id;
079        m_isExpandable = isExpandable;
080        m_icon = icon;
081        m_emptyMessageKey = empty;
082    }
083
084    /**
085     * Returns the key for the empty-message.<p>
086     *
087     * @return key as string
088     */
089    public String getEmptyMessageKey() {
090
091        return m_emptyMessageKey;
092    }
093
094    /**
095     * Get the icon.<p>
096     *
097     * @return CmsCssIcon
098     */
099    public CmsCssIcon getIcon() {
100
101        return m_icon;
102    }
103
104    /**
105     * Gets the id of the type.<p>
106     *
107     * @return id string
108     */
109    public String getId() {
110
111        return m_id;
112    }
113
114    /**
115     * Gets the name of the element.<p>
116     *
117     * @return name
118     */
119    public String getName() {
120
121        return CmsVaadinUtils.getMessageText(m_name);
122    }
123
124    /**
125     * Checks if type is expandable.<p>
126     *
127     * @return true if expandable
128     */
129    public boolean isExpandable() {
130
131        return m_isExpandable;
132    }
133
134    /**
135     * @see org.opencms.ui.apps.user.I_CmsOuTreeType#isGroup()
136     */
137    public boolean isGroup() {
138
139        return GROUP.equals(this);
140    }
141
142    /**
143     * @see org.opencms.ui.apps.user.I_CmsOuTreeType#isOrgUnit()
144     */
145    public boolean isOrgUnit() {
146
147        return OU.equals(this);
148    }
149
150    /**
151     * @see org.opencms.ui.apps.user.I_CmsOuTreeType#isRole()
152     */
153    public boolean isRole() {
154
155        return ROLE.equals(this);
156    }
157
158    /**
159     * @see org.opencms.ui.apps.user.I_CmsOuTreeType#isUser()
160     */
161    public boolean isUser() {
162
163        return USER.equals(this);
164    }
165
166    /**
167     * @see org.opencms.ui.apps.user.I_CmsOuTreeType#isValidForOu(org.opencms.file.CmsObject, java.lang.String)
168     */
169    public boolean isValidForOu(CmsObject cms, String ou) {
170
171        return true;
172    }
173
174    /**
175     * @see org.opencms.ui.apps.user.I_CmsOuTreeType#showInOuTable()
176     */
177    public boolean showInOuTable() {
178
179        return !(OU.equals(this));
180    }
181}