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.actions; 029 030import org.opencms.file.CmsResource; 031import org.opencms.file.types.CmsResourceTypeXmlContainerPage; 032import org.opencms.file.types.CmsResourceTypeXmlContent; 033import org.opencms.file.types.I_CmsResourceType; 034import org.opencms.gwt.shared.CmsCoreData.AdeContext; 035import org.opencms.main.OpenCms; 036import org.opencms.ui.I_CmsDialogContext; 037import org.opencms.ui.Messages; 038import org.opencms.ui.contextmenu.CmsMenuItemVisibilityMode; 039import org.opencms.ui.contextmenu.CmsStandardVisibilityCheck; 040 041import java.util.Arrays; 042import java.util.List; 043import java.util.Set; 044 045import com.google.common.collect.Sets; 046 047/** 048 * Action to logout.<p> 049 * Used within the ADE context only.<p> 050 */ 051public class CmsEditContentAction extends A_CmsEditFileAction { 052 053 /** The action id. */ 054 public static final String ACTION_ID = "ade_editcontent"; 055 056 /** 057 * @see org.opencms.ui.actions.I_CmsWorkplaceAction#getId() 058 */ 059 public String getId() { 060 061 return ACTION_ID; 062 } 063 064 /** 065 * @see org.opencms.ui.actions.A_CmsWorkplaceAction#getVisibility(org.opencms.ui.I_CmsDialogContext) 066 */ 067 @Override 068 public CmsMenuItemVisibilityMode getVisibility(I_CmsDialogContext context) { 069 070 Set<String> validContexts = Sets.newHashSet(); 071 for (AdeContext adecontext : Arrays.asList(AdeContext.gallery, AdeContext.resourceinfo)) { 072 validContexts.add(adecontext.name()); 073 } 074 if (!validContexts.contains(context.getAppId())) { 075 return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE; 076 } 077 List<CmsResource> resources = context.getResources(); 078 CmsResource resource = resources.get(0); 079 if (OpenCms.getADEManager().isEditorRestricted(context.getCms(), resource)) { 080 return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE; 081 } 082 I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(resource); 083 if ((type instanceof CmsResourceTypeXmlContent) && !CmsResourceTypeXmlContainerPage.isContainerPage(resource)) { 084 return CmsStandardVisibilityCheck.DEFAULT.getSingleVisibility(context.getCms(), resource); 085 } else { 086 return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE; 087 } 088 } 089 090 /** 091 * @see org.opencms.ui.actions.A_CmsEditFileAction#getFileParam() 092 */ 093 @Override 094 protected String getFileParam() { 095 096 return "%(file)"; 097 } 098 099 /** 100 * @see org.opencms.ui.actions.A_CmsWorkplaceAction#getTitleKey() 101 */ 102 @Override 103 protected String getTitleKey() { 104 105 return Messages.GUI_ACTION_EDIT_CONTENT_0; 106 } 107}