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 GmbH & Co. KG, 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.workplace.editors; 029 030import org.opencms.configuration.CmsParameterConfiguration; 031import org.opencms.file.CmsResource; 032import org.opencms.file.types.I_CmsResourceType; 033import org.opencms.loader.CmsLoaderException; 034import org.opencms.main.OpenCms; 035import org.opencms.workplace.CmsDialog; 036 037/** 038 * Defines an action to be performed before the workplace editor is opened for the first time.<p> 039 * 040 * Implements the basic methods to handle the resource type.<p> 041 * 042 * @since 6.5.4 043 */ 044public abstract class A_CmsPreEditorActionDefinition implements I_CmsPreEditorActionDefinition { 045 046 /** Configuration parameters. */ 047 protected CmsParameterConfiguration m_configuration; 048 049 /** The resource type for which the action should be performed. */ 050 private I_CmsResourceType m_resourceType; 051 052 /** The resource type name for which the action should be performed. */ 053 private String m_resourceTypeName; 054 055 /** 056 * Constructor, without parameters.<p> 057 */ 058 public A_CmsPreEditorActionDefinition() { 059 060 // empty constructor, needed for initialization 061 m_configuration = new CmsParameterConfiguration(); 062 } 063 064 /** 065 * @see org.opencms.configuration.I_CmsConfigurationParameterHandler#addConfigurationParameter(java.lang.String, java.lang.String) 066 */ 067 public void addConfigurationParameter(String paramName, String paramValue) { 068 069 m_configuration.add(paramName, paramValue); 070 } 071 072 /** 073 * @see org.opencms.workplace.editors.I_CmsPreEditorActionDefinition#doPreAction(org.opencms.file.CmsResource, org.opencms.workplace.CmsDialog, java.lang.String) 074 */ 075 public abstract boolean doPreAction(CmsResource resource, CmsDialog dialog, String originalParams) throws Exception; 076 077 /** 078 * @see org.opencms.configuration.I_CmsConfigurationParameterHandler#getConfiguration() 079 */ 080 public CmsParameterConfiguration getConfiguration() { 081 082 return m_configuration; 083 } 084 085 /** 086 * @see org.opencms.workplace.editors.I_CmsPreEditorActionDefinition#getResourceType() 087 */ 088 public I_CmsResourceType getResourceType() { 089 090 if (m_resourceType == null) { 091 try { 092 m_resourceType = OpenCms.getResourceManager().getResourceType(m_resourceTypeName); 093 } catch (CmsLoaderException e) { 094 // should not happen, ignore 095 } 096 } 097 return m_resourceType; 098 } 099 100 /** 101 * @see org.opencms.workplace.editors.I_CmsPreEditorActionDefinition#getResourceTypeName() 102 */ 103 public String getResourceTypeName() { 104 105 return m_resourceTypeName; 106 } 107 108 /** 109 * @see org.opencms.configuration.I_CmsConfigurationParameterHandler#initConfiguration() 110 */ 111 public final void initConfiguration() { 112 113 // final since subclasses should NOT implement this 114 } 115 116 /** 117 * @see org.opencms.workplace.editors.I_CmsPreEditorActionDefinition#setResourceTypeName(java.lang.String) 118 */ 119 public void setResourceTypeName(String resourceTypeName) { 120 121 m_resourceTypeName = resourceTypeName; 122 } 123 124}