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.ui.I_CmsDialogContext;
033
034import java.util.List;
035import java.util.Locale;
036
037/**
038 * Interface for workplace context menu items.<p>
039 *
040 */
041public interface I_CmsContextMenuItem extends I_CmsHasMenuItemVisibility, I_CmsContextMenuAction {
042
043    /**
044     * Executes the context menu action given a dialog context.<p>
045     *
046     * @param context the dialog context
047     */
048    void executeAction(I_CmsDialogContext context);
049
050    /**
051     * Gets the id.<p>
052     *
053     * The id does not need to be unique among all context menu items which are in use in the system, but
054     * when multiple menu items with the same id are available for a given context menu, only one of them
055     * will be picked, based on the priority (a higher priority context menu item will be preferred to one with
056     * a lower priority.<p>
057     *
058     * @return the id
059     */
060    String getId();
061
062    /**
063     * Integer attribute which is used to order menu items.<p>
064     *
065     * Items with a higher 'order' value will appear after items with a lower order at the same tree level.<p>
066     *
067     * @return the order
068     */
069    float getOrder();
070
071    /**
072     * Gets the id of the parent entry.<p>
073     *
074     * If this returns null, the context menu item will be inserted at the root level of the context menu,
075     * otherwise, it will be added I_CmsContextMenuActionas a sub-entry of the context menu entry with the given id (if such an
076     * entry exists; otherwise, the child entry will be ignored).
077     *
078     * @return the parent id
079     */
080    String getParentId();
081
082    /**
083     * Gets the priority.<p>
084     *
085     * If multiple context menu items with the same id are available for a menu, the one with the highest priority will be picked.<p>
086     *
087     * @return the priority
088     */
089    int getPriority();
090
091    /**
092     * Gets the title.<p>
093     *
094     * @param locale the locale
095     *
096     * @return the title
097     */
098    String getTitle(Locale locale);
099
100    /**
101     * Computes the visibility for this context menu items with the given CMS context and resources.<p>
102     *
103     * @param cms the current CMS context
104     * @param resources the resources for which the context menu is being opened
105     *
106     * @return the visibility of the context menu item
107     */
108    CmsMenuItemVisibilityMode getVisibility(CmsObject cms, List<CmsResource> resources);
109
110    /**
111     * Returns true if this is a leaf item, i.e. an item which has no child items.<p>
112     *
113     * @return true if this is a leaf item
114     */
115    boolean isLeafItem();
116}