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;
029
030import org.opencms.main.CmsLog;
031import org.opencms.ui.actions.CmsAboutDialogAction;
032import org.opencms.ui.actions.CmsAvailabilityDialogAction;
033import org.opencms.ui.actions.CmsCategoriesDialogAction;
034import org.opencms.ui.actions.CmsChangeTypeDialogAction;
035import org.opencms.ui.actions.CmsContextMenuActionItem;
036import org.opencms.ui.actions.CmsCopyDialogAction;
037import org.opencms.ui.actions.CmsCopyToProjectDialogAction;
038import org.opencms.ui.actions.CmsDeleteDialogAction;
039import org.opencms.ui.actions.CmsDirectPublishDialogAction;
040import org.opencms.ui.actions.CmsDisplayAction;
041import org.opencms.ui.actions.CmsEditCodeDialogAction;
042import org.opencms.ui.actions.CmsEditContentAction;
043import org.opencms.ui.actions.CmsEditDialogAction;
044import org.opencms.ui.actions.CmsEditPageAction;
045import org.opencms.ui.actions.CmsEditPointerAction;
046import org.opencms.ui.actions.CmsEditPropertyAction;
047import org.opencms.ui.actions.CmsEditSmallElementsAction;
048import org.opencms.ui.actions.CmsFormEditDialogAction;
049import org.opencms.ui.actions.CmsGalleryDialogAction;
050import org.opencms.ui.actions.CmsHistoryDialogAction;
051import org.opencms.ui.actions.CmsLinkLocaleVariantAction;
052import org.opencms.ui.actions.CmsLockAction;
053import org.opencms.ui.actions.CmsLockedResourcesAction;
054import org.opencms.ui.actions.CmsLogoutAction;
055import org.opencms.ui.actions.CmsMoveDialogAction;
056import org.opencms.ui.actions.CmsPermissionDialogAction;
057import org.opencms.ui.actions.CmsPreviewAction;
058import org.opencms.ui.actions.CmsProjectDialogAction;
059import org.opencms.ui.actions.CmsPropertiesDialogAction;
060import org.opencms.ui.actions.CmsPublishQueueDialogAction;
061import org.opencms.ui.actions.CmsPublishScheduledDialogAction;
062import org.opencms.ui.actions.CmsRenameAction;
063import org.opencms.ui.actions.CmsReplaceDialogAction;
064import org.opencms.ui.actions.CmsResourceInfoAction;
065import org.opencms.ui.actions.CmsRestoreDeletedAction;
066import org.opencms.ui.actions.CmsSecureExportDialogAction;
067import org.opencms.ui.actions.CmsSelectElementViewAction;
068import org.opencms.ui.actions.CmsSeoAction;
069import org.opencms.ui.actions.CmsShowLocaleAction;
070import org.opencms.ui.actions.CmsSiteDialogAction;
071import org.opencms.ui.actions.CmsSitemapAliasAction;
072import org.opencms.ui.actions.CmsSitemapEditConfigAction;
073import org.opencms.ui.actions.CmsSitemapOpenParentAction;
074import org.opencms.ui.actions.CmsSitemapRefreshAction;
075import org.opencms.ui.actions.CmsStealLockAction;
076import org.opencms.ui.actions.CmsTemplateContextsAction;
077import org.opencms.ui.actions.CmsTouchDialogAction;
078import org.opencms.ui.actions.CmsUndeleteDialogAction;
079import org.opencms.ui.actions.CmsUndoDialogAction;
080import org.opencms.ui.actions.CmsUnlinkLocaleVariantAction;
081import org.opencms.ui.actions.CmsUnlockAction;
082import org.opencms.ui.actions.CmsViewInExplorerAction;
083import org.opencms.ui.actions.CmsViewOnlineAction;
084import org.opencms.ui.actions.CmsWorkplaceAction;
085import org.opencms.ui.components.CmsResourceTableProperty;
086import org.opencms.ui.contextmenu.CmsSubmenu;
087import org.opencms.ui.contextmenu.I_CmsContextMenuItem;
088import org.opencms.ui.contextmenu.I_CmsContextMenuItemProvider;
089import org.opencms.xml.templatemapper.CmsTemplateMapperAction;
090
091import java.util.Arrays;
092import java.util.Collections;
093import java.util.List;
094
095import org.apache.commons.logging.Log;
096
097/**
098 * Default implementation of menu item provider.<p>
099 */
100public class CmsDefaultMenuItemProvider implements I_CmsContextMenuItemProvider {
101
102    /** The advanced menu id. */
103    public static final String ADVANCED_MENU_ID = "advanced";
104
105    /** Logger instance for this class. */
106    static final Log LOG = CmsLog.getLog(CmsDefaultMenuItemProvider.class);
107
108    /** The menu items. */
109    private static final List<I_CmsContextMenuItem> MENU_ITEMS;
110
111    static {
112        CmsSubmenu advanced = new CmsSubmenu(ADVANCED_MENU_ID, null, "%(key.GUI_EXPLORER_CONTEXT_ADVANCED_0)", 2400, 0);
113        // the entries in this list will be sorted by there order property
114        // for better readability please place additional entries  according to this sort order
115        List<I_CmsContextMenuItem> items = Arrays.<I_CmsContextMenuItem> asList(
116            new CmsContextMenuActionItem(new CmsSiteDialogAction(), null, 10, 0),
117            new CmsContextMenuActionItem(new CmsEditPageAction(), null, 10, 0),
118            new CmsContextMenuActionItem(new CmsEditDialogAction(), null, 50, 0),
119            new CmsContextMenuActionItem(new CmsEditPointerAction(), null, 50, 0),
120            new CmsContextMenuActionItem(new CmsGalleryDialogAction(), null, 50, 0),
121            new CmsContextMenuActionItem(new CmsViewOnlineAction(), null, 75, 0),
122            new CmsContextMenuActionItem(new CmsEditContentAction(), null, 75, 0),
123            new CmsContextMenuActionItem(new CmsPreviewAction(), null, 75, 0),
124            new CmsContextMenuActionItem(new CmsDisplayAction(), null, 75, 0),
125            new CmsContextMenuActionItem(new CmsSitemapOpenParentAction(), null, 75, 0),
126            new CmsContextMenuActionItem(new CmsSitemapRefreshAction(), null, 100, 0),
127            new CmsContextMenuActionItem(new CmsLockAction(), null, 100, 0),
128            new CmsContextMenuActionItem(new CmsUnlockAction(), null, 100, 0),
129            new CmsContextMenuActionItem(new CmsStealLockAction(), null, 100, 0),
130            new CmsContextMenuActionItem(new CmsLockedResourcesAction(), null, 120, 0),
131            new CmsContextMenuActionItem(new CmsCopyToProjectDialogAction(), null, 150, 0),
132            new CmsContextMenuActionItem(new CmsViewInExplorerAction(), null, 200, 0),
133            new CmsContextMenuActionItem(new CmsDirectPublishDialogAction(), null, 300, 0),
134            new CmsContextMenuActionItem(new CmsPublishScheduledDialogAction(), null, 400, 0),
135            new CmsContextMenuActionItem(new CmsCopyDialogAction(), null, 900, 0),
136            new CmsContextMenuActionItem(new CmsMoveDialogAction(), null, 1000, 0),
137            new CmsContextMenuActionItem(
138                new CmsEditPropertyAction(
139                    CmsResourceTableProperty.PROPERTY_RESOURCE_NAME,
140                    Messages.GUI_EXPLORER_RENAME_0),
141                null,
142                1100,
143                0),
144            new CmsContextMenuActionItem(new CmsRenameAction(), null, 1100, 0),
145            new CmsContextMenuActionItem(new CmsDeleteDialogAction(), null, 1700, 0),
146            new CmsContextMenuActionItem(new CmsReplaceDialogAction(), null, 1800, 0),
147            new CmsContextMenuActionItem(new CmsUndoDialogAction(), null, 1900, 0),
148            new CmsContextMenuActionItem(new CmsShowLocaleAction(), null, 1925, 0),
149            new CmsContextMenuActionItem(new CmsSelectElementViewAction(), null, 1950, 0),
150            new CmsContextMenuActionItem(new CmsTemplateContextsAction(), null, 1975, 0),
151            new CmsContextMenuActionItem(new CmsEditSmallElementsAction(), null, 2000, 0),
152            new CmsContextMenuActionItem(new CmsUndeleteDialogAction(), null, 2100, 0),
153            new CmsContextMenuActionItem(new CmsResourceInfoAction(), null, 2200, 0),
154            new CmsContextMenuActionItem(new CmsCategoriesDialogAction(), null, 2300, 0),
155            new CmsContextMenuActionItem(new CmsPermissionDialogAction(), null, 2400, 0),
156
157            advanced,
158            new CmsContextMenuActionItem(new CmsTouchDialogAction(), advanced.getId(), 170, 0),
159            new CmsContextMenuActionItem(new CmsAvailabilityDialogAction(), advanced.getId(), 300, 0),
160            new CmsContextMenuActionItem(new CmsSecureExportDialogAction(), advanced.getId(), 500, 0),
161            new CmsContextMenuActionItem(new CmsChangeTypeDialogAction(), advanced.getId(), 700, 0),
162            new CmsContextMenuActionItem(new CmsFormEditDialogAction(), advanced.getId(), 800, 0),
163            new CmsContextMenuActionItem(new CmsEditCodeDialogAction(), advanced.getId(), 900, 0),
164            new CmsContextMenuActionItem(new CmsRestoreDeletedAction(), advanced.getId(), 1000, 0),
165
166            new CmsContextMenuActionItem(new CmsLinkLocaleVariantAction(), advanced.getId(), 1100, 0),
167            new CmsContextMenuActionItem(new CmsUnlinkLocaleVariantAction(), advanced.getId(), 1150, 0),
168            new CmsContextMenuActionItem(new CmsSeoAction(), advanced.getId(), 1200, 0),
169            new CmsContextMenuActionItem(new CmsWorkplaceAction(), advanced.getId(), 1300, 0),
170            new CmsContextMenuActionItem(new CmsSitemapAliasAction(), advanced.getId(), 1500, 0),
171            new CmsContextMenuActionItem(new CmsSitemapEditConfigAction(), advanced.getId(), 1600, 0),
172            new CmsContextMenuActionItem(new CmsTemplateMapperAction(), advanced.getId(), 1700, 0),
173
174            new CmsContextMenuActionItem(new CmsHistoryDialogAction(), null, 2450, 0),
175            new CmsContextMenuActionItem(new CmsPropertiesDialogAction(), null, 2500, 0),
176
177            // toolbar menu entries
178            new CmsContextMenuActionItem(new CmsProjectDialogAction(), null, 3100, 0),
179            new CmsContextMenuActionItem(new CmsPublishQueueDialogAction(), null, 3500, 0),
180            new CmsContextMenuActionItem(new CmsAboutDialogAction(), null, 3900, 0),
181            new CmsContextMenuActionItem(new CmsLogoutAction(), null, 4100, 0));
182        MENU_ITEMS = Collections.unmodifiableList(items);
183    }
184
185    /**
186     * Creates a new instance.<p>
187     */
188    public CmsDefaultMenuItemProvider() {
189        // default constructor, do nothing
190    }
191
192    /**
193     * @see org.opencms.ui.contextmenu.I_CmsContextMenuItemProvider#getMenuItems()
194     */
195    public List<I_CmsContextMenuItem> getMenuItems() {
196
197        return MENU_ITEMS;
198    }
199}