001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://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: https://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: https://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
070        m_id = id;
071        m_parentId = parentId;
072        m_title = title;
073        m_order = order;
074        m_priority = priority;
075    }
076
077    /**
078     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#executeAction(org.opencms.ui.I_CmsDialogContext)
079     */
080    @Override
081    public void executeAction(I_CmsDialogContext context) {
082
083        // do nothing
084    }
085
086    /**
087     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#getId()
088     */
089    public String getId() {
090
091        return m_id;
092    }
093
094    /**
095     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#getOrder()
096     */
097    public float getOrder() {
098
099        return m_order;
100
101    }
102
103    /**
104     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#getParentId()
105     */
106    public String getParentId() {
107
108        return m_parentId;
109    }
110
111    /**
112     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#getPriority()
113     */
114    public int getPriority() {
115
116        return m_priority;
117    }
118
119    /**
120     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#getTitle(java.util.Locale)
121     */
122    public String getTitle(Locale locale) {
123
124        CmsMacroResolver resolver = new CmsMacroResolver();
125        resolver.setMessages(OpenCms.getWorkplaceManager().getMessages(locale));
126        if (m_title == null) {
127            return "";
128        }
129        return resolver.resolveMacros(m_title);
130    }
131
132    /**
133     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#getVisibility(org.opencms.file.CmsObject, java.util.List)
134     */
135    public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, List<CmsResource> resources) {
136
137        return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE;
138    }
139
140    /**
141     * @see org.opencms.ui.contextmenu.I_CmsHasMenuItemVisibility#getVisibility(org.opencms.ui.I_CmsDialogContext)
142     */
143    public CmsMenuItemVisibilityMode getVisibility(I_CmsDialogContext context) {
144
145        return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE;
146    }
147
148    /**
149     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItem#isLeafItem()
150     */
151    public boolean isLeafItem() {
152
153        return false;
154    }
155}