001/* 002 * Copyright 2018 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.web.skin; 017 018import org.apache.avalon.framework.configuration.Configuration; 019import org.apache.avalon.framework.configuration.ConfigurationException; 020 021import org.ametys.cms.model.AbstractElementDefinitionParser; 022import org.ametys.runtime.i18n.I18nizableText; 023import org.ametys.runtime.model.CategorizedElementDefinitionWrapper; 024import org.ametys.runtime.model.disableconditions.DisableConditions; 025import org.ametys.runtime.parameter.Validator; 026import org.ametys.runtime.plugin.component.ThreadSafeComponentManager; 027import org.ametys.web.data.type.ModelItemTypeExtensionPoint; 028 029/** 030 * Parser for {@link CategorizedElementDefinitionWrapper} parameter. 031 */ 032public class SkinParameterParser extends AbstractElementDefinitionParser 033{ 034 private String _i18nCatalogueLocation; 035 036 /** 037 * Creates a categorized element definition parser for the skin. 038 * @param elementTypeExtensionPoint the extension point to use to get available element types 039 * @param disableConditionsManager the disable conditions component manager 040 * @param enumeratorManager the enumerator component manager. 041 * @param validatorManager the validator component manager. 042 * @param i18nCatalogueLocation the path of the i18n folder of the skin 043 */ 044 public SkinParameterParser(ModelItemTypeExtensionPoint elementTypeExtensionPoint, 045 ThreadSafeComponentManager<DisableConditions> disableConditionsManager, ThreadSafeComponentManager<org.ametys.runtime.model.Enumerator> enumeratorManager, ThreadSafeComponentManager<Validator> validatorManager, String i18nCatalogueLocation) 046 { 047 super(elementTypeExtensionPoint, disableConditionsManager, enumeratorManager, validatorManager); 048 _i18nCatalogueLocation = i18nCatalogueLocation; 049 } 050 051 @Override 052 protected String _getNameConfigurationAttribute() 053 { 054 return "id"; 055 } 056 057 @Override 058 protected I18nizableText _parseI18nizableText(Configuration config, String catalog, String name) throws ConfigurationException 059 { 060 return I18nizableText.parseI18nizableText(config.getChild(name), _i18nCatalogueLocation, "messages", null); 061 } 062 063 @Override 064 protected Class< ? extends DisableConditions> getDisableConditionsClass() 065 { 066 return SkinDisableConditions.class; 067 } 068}