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.runtime.i18n.I18nizableText; 022import org.ametys.runtime.model.CategorizedElementDefinitionWrapper; 023import org.ametys.runtime.model.ElementDefinitionParser; 024import org.ametys.runtime.model.type.ElementType; 025import org.ametys.runtime.parameter.Validator; 026import org.ametys.runtime.plugin.component.AbstractThreadSafeComponentExtensionPoint; 027import org.ametys.runtime.plugin.component.ThreadSafeComponentManager; 028 029/** 030 * Parser for {@link CategorizedElementDefinitionWrapper} parameter. 031 */ 032public class SkinParameterParser extends ElementDefinitionParser 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 enumeratorManager the enumerator component manager. 040 * @param validatorManager the validator component manager. 041 * @param i18nCatalogueLocation the path of the i18n folder of the skin 042 */ 043 public SkinParameterParser(AbstractThreadSafeComponentExtensionPoint<? extends ElementType> elementTypeExtensionPoint, 044 ThreadSafeComponentManager<org.ametys.runtime.model.Enumerator> enumeratorManager, ThreadSafeComponentManager<Validator> validatorManager, String i18nCatalogueLocation) 045 { 046 super(elementTypeExtensionPoint, enumeratorManager, validatorManager); 047 _i18nCatalogueLocation = i18nCatalogueLocation; 048 } 049 050 @Override 051 protected String _getNameConfigurationAttribute() 052 { 053 return "id"; 054 } 055 056 @Override 057 protected I18nizableText _parseI18nizableText(Configuration config, String catalog, String name) throws ConfigurationException 058 { 059 return I18nizableText.parseI18nizableText(config.getChild(name), _i18nCatalogueLocation, "messages", null); 060 } 061}