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.editors; 029 030import org.opencms.file.CmsObject; 031import org.opencms.file.CmsResource; 032import org.opencms.file.types.CmsResourceTypeXmlContent; 033import org.opencms.file.types.I_CmsResourceType; 034import org.opencms.main.CmsLog; 035import org.opencms.main.CmsRuntimeException; 036import org.opencms.main.OpenCms; 037import org.opencms.workplace.editors.CmsWorkplaceEditorManager; 038 039import org.apache.commons.logging.Log; 040 041/** 042 * The acacia XML content editor.<p> 043 */ 044public class CmsAcaciaEditor extends A_CmsFrameEditor { 045 046 /** The serial version id. */ 047 private static final long serialVersionUID = -5498365579090634771L; 048 049 /** Log instance for this class. */ 050 private static final Log LOG = CmsLog.getLog(CmsAcaciaEditor.class); 051 052 /** 053 * @see org.opencms.ui.editors.I_CmsEditor#getPriority() 054 */ 055 public int getPriority() { 056 057 return 100; 058 } 059 060 /** 061 * @see org.opencms.ui.editors.A_CmsFrameEditor#matchesResource(org.opencms.file.CmsObject, org.opencms.file.CmsResource, boolean) 062 */ 063 @Override 064 public boolean matchesResource(CmsObject cms, CmsResource resource, boolean plainText) { 065 066 I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(resource); 067 boolean result = false; 068 069 if (!plainText && (type instanceof CmsResourceTypeXmlContent)) { 070 try { 071 result = CmsWorkplaceEditorManager.checkAcaciaEditorAvailable(cms, resource); 072 } catch (CmsRuntimeException e) { 073 LOG.error("Error evaluating XML schema for acacia editor.", e); 074 return true; 075 } 076 } 077 078 return result; 079 } 080 081 /** 082 * @see org.opencms.ui.editors.I_CmsEditor#matchesType(org.opencms.file.types.I_CmsResourceType, boolean) 083 */ 084 public boolean matchesType(I_CmsResourceType type, boolean plainText) { 085 086 boolean result = !plainText && (type instanceof CmsResourceTypeXmlContent); 087 return result; 088 } 089 090 /** 091 * @see org.opencms.ui.editors.I_CmsEditor#newInstance() 092 */ 093 public I_CmsEditor newInstance() { 094 095 return new CmsAcaciaEditor(); 096 } 097 098 /** 099 * @see org.opencms.ui.editors.A_CmsFrameEditor#getEditorUri() 100 */ 101 @Override 102 protected String getEditorUri() { 103 104 return "/system/workplace/editors/acacia/editor.jsp"; 105 } 106}