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.contextmenu;
029
030import org.opencms.file.CmsObject;
031import org.opencms.file.CmsResource;
032import org.opencms.main.OpenCms;
033import org.opencms.ui.I_CmsDialogContext;
034import org.opencms.util.CmsMacroResolver;
035
036import java.util.List;
037import java.util.Locale;
038
039/**
040 * Menu item which acts only as a container for nested menu items.<p>
041 */
042public class CmsSubmenu implements I_CmsContextMenuItem {
043
044    /** The item id. */
045    protected String m_id;
046
047    /** The parent item id. */
048    protected String m_parentId;
049
050    /** The order. */
051    protected float m_order;
052
053    /** The priority. */
054    protected int m_priority;
055
056    /** The title (may contain localization macros). */
057    private String m_title;
058
059    /**
060     * Creates a new instance.<p>
061     *
062     * @param id the id
063     * @param parentId the parent id
064     * @param title the title
065     * @param order the order
066     * @param priority the priority
067     */
068    public CmsSubmenu(String id, String parentId, String title, float order, int priority) {
069        m_id = id;
070        m_parentId = parentId;
071        m_title = title;
072        m_order = order;
073        m_priority = priority;
074    }
075
076    /**
077     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#executeAction(org.opencms.ui.I_CmsDialogContext)
078     */
079    @Override
080    public void executeAction(I_CmsDialogContext context) {
081        // do nothing
082    }
083
084    /**
085     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#getId()
086     */
087    public String getId() {
088
089        return m_id;
090    }
091
092    /**
093     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#getOrder()
094     */
095    public float getOrder() {
096
097        return m_order;
098
099    }
100
101    /**
102     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#getParentId()
103     */
104    public String getParentId() {
105
106        return m_parentId;
107    }
108
109    /**
110     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#getPriority()
111     */
112    public int getPriority() {
113
114        return m_priority;
115    }
116
117    /**
118     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#getTitle(java.util.Locale)
119     */
120    public String getTitle(Locale locale) {
121
122        CmsMacroResolver resolver = new CmsMacroResolver();
123        resolver.setMessages(OpenCms.getWorkplaceManager().getMessages(locale));
124        if (m_title == null) {
125            return "";
126        }
127        return resolver.resolveMacros(m_title);
128    }
129
130    /**
131     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#getVisibility(org.opencms.file.CmsObject, java.util.List)
132     */
133    public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, List<CmsResource> resources) {
134
135        return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE;
136    }
137
138    /**
139     * @see org.opencms.ui.contextmenu.I_CmsHasMenuItemVisibility#getVisibility(org.opencms.ui.I_CmsDialogContext)
140     */
141    public CmsMenuItemVisibilityMode getVisibility(I_CmsDialogContext context) {
142
143        return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE;
144    }
145
146    /**
147     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#isLeafItem()
148     */
149    public boolean isLeafItem() {
150
151        return false;
152    }
153}