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.file.CmsObject; 031import org.opencms.main.OpenCms; 032import org.opencms.security.CmsRole; 033import org.opencms.util.CmsMacroResolver; 034import org.opencms.workplace.CmsWorkplace; 035import org.opencms.workplace.tools.I_CmsToolHandler; 036 037import java.util.Locale; 038 039import com.vaadin.server.ExternalResource; 040import com.vaadin.server.Resource; 041 042/** 043 * Holding configuration for legacy admin tools.<p> 044 */ 045public class CmsLegacyAppConfiguration implements I_CmsWorkplaceAppConfiguration { 046 047 /** The tool handler. */ 048 private I_CmsToolHandler m_toolHandler; 049 050 /** 051 * Constructor.<p> 052 * 053 * @param toolHandler the tool handler 054 */ 055 public CmsLegacyAppConfiguration(I_CmsToolHandler toolHandler) { 056 057 m_toolHandler = toolHandler; 058 } 059 060 /** 061 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getAppCategory() 062 */ 063 public String getAppCategory() { 064 065 return CmsWorkplaceAppManager.LEGACY_CATEGORY_ID; 066 } 067 068 /** 069 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getAppInstance() 070 */ 071 public I_CmsWorkplaceApp getAppInstance() { 072 073 return new CmsLegacyApp(m_toolHandler); 074 } 075 076 /** 077 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getButtonStyle() 078 */ 079 public String getButtonStyle() { 080 081 return I_CmsAppButtonProvider.BUTTON_STYLE_CLASSIC; 082 } 083 084 /** 085 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getHelpText(java.util.Locale) 086 */ 087 public String getHelpText(Locale locale) { 088 089 return CmsMacroResolver.newInstance().setMessages( 090 OpenCms.getWorkplaceManager().getMessages(locale)).resolveMacros(m_toolHandler.getHelpText()); 091 } 092 093 /** 094 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getIcon() 095 */ 096 public Resource getIcon() { 097 098 return new ExternalResource(CmsWorkplace.getSkinUri() + m_toolHandler.getIconPath()); 099 } 100 101 /** 102 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getId() 103 */ 104 public String getId() { 105 106 return m_toolHandler.getPath(); 107 } 108 109 /** 110 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getName(java.util.Locale) 111 */ 112 public String getName(Locale locale) { 113 114 return CmsMacroResolver.newInstance().setMessages( 115 OpenCms.getWorkplaceManager().getMessages(locale)).resolveMacros(m_toolHandler.getName()); 116 } 117 118 /** 119 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getOrder() 120 */ 121 public int getOrder() { 122 123 return 10 + Math.round(m_toolHandler.getPosition()); 124 } 125 126 /** 127 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getPriority() 128 */ 129 public int getPriority() { 130 131 return I_CmsWorkplaceAppConfiguration.DEFAULT_PRIORIY; 132 } 133 134 /** 135 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getRequiredRole() 136 */ 137 public CmsRole getRequiredRole() { 138 139 return CmsRole.WORKPLACE_USER; 140 } 141 142 /** 143 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getVisibility(org.opencms.file.CmsObject) 144 */ 145 public CmsAppVisibilityStatus getVisibility(CmsObject cms) { 146 147 boolean visible = cms.existsResource(m_toolHandler.getLink()) && m_toolHandler.isVisible(cms); 148 return new CmsAppVisibilityStatus(visible, m_toolHandler.isEnabled(cms), ""); 149 } 150 151}