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.modules; 029 030import org.opencms.file.CmsObject; 031import org.opencms.main.OpenCms; 032import org.opencms.security.CmsRole; 033import org.opencms.ui.apps.A_CmsWorkplaceAppConfiguration; 034import org.opencms.ui.apps.CmsAppVisibilityStatus; 035import org.opencms.ui.apps.CmsWorkplaceAppManager; 036import org.opencms.ui.apps.I_CmsWorkplaceApp; 037import org.opencms.ui.apps.Messages; 038 039import java.util.Locale; 040 041import com.vaadin.server.Resource; 042 043/** 044 * App configuration for the module maanger app.<p> 045 */ 046public class CmsModuleAppConfiguration extends A_CmsWorkplaceAppConfiguration { 047 048 /** The app id. */ 049 public static final String APP_ID = "modules"; 050 051 /** 052 * @see org.opencms.ui.apps.A_CmsWorkplaceAppConfiguration#getAppCategory() 053 */ 054 @Override 055 public String getAppCategory() { 056 057 return CmsWorkplaceAppManager.ADMINISTRATION_CATEGORY_ID; 058 } 059 060 /** 061 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getAppInstance() 062 */ 063 public I_CmsWorkplaceApp getAppInstance() { 064 065 return new CmsModuleApp(); 066 } 067 068 /** 069 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getButtonStyle() 070 */ 071 @Override 072 public String getButtonStyle() { 073 074 return null; 075 } 076 077 /** 078 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getIcon() 079 */ 080 public Resource getIcon() { 081 082 return CmsModuleApp.Icons.APP; 083 } 084 085 /** 086 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getId() 087 */ 088 public String getId() { 089 090 return APP_ID; 091 } 092 093 /** 094 * @see org.opencms.ui.apps.A_CmsWorkplaceAppConfiguration#getName(java.util.Locale) 095 */ 096 @Override 097 public String getName(Locale locale) { 098 099 return org.opencms.ui.apps.Messages.get().getBundle(locale).key(Messages.GUI_MODULES_APP_NAME_0); 100 } 101 102 /** 103 * @see org.opencms.ui.apps.A_CmsWorkplaceAppConfiguration#getRequiredRole() 104 */ 105 @Override 106 public CmsRole getRequiredRole() { 107 108 return CmsRole.DATABASE_MANAGER; 109 } 110 111 /** 112 * @see org.opencms.ui.apps.A_CmsWorkplaceAppConfiguration#getVisibility(org.opencms.file.CmsObject) 113 */ 114 @Override 115 public CmsAppVisibilityStatus getVisibility(CmsObject cms) { 116 117 if (!OpenCms.getRoleManager().hasRole(cms, getRequiredRole())) { 118 return CmsAppVisibilityStatus.INVISIBLE; 119 } 120 121 if (cms.getRequestContext().getCurrentProject().isOnlineProject()) { 122 return new CmsAppVisibilityStatus( 123 true, 124 false, 125 org.opencms.ui.apps.Messages.get().getBundle(OpenCms.getWorkplaceManager().getWorkplaceLocale(cms)).key( 126 Messages.GUI_MODULES_ONLINE_DISABLED_0)); 127 } 128 return CmsAppVisibilityStatus.ACTIVE; 129 } 130 131}