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.plugins.core.ui.glyph; 017 018import java.util.HashMap; 019import java.util.Map; 020 021import org.apache.avalon.framework.configuration.Configurable; 022import org.apache.avalon.framework.configuration.Configuration; 023import org.apache.avalon.framework.configuration.ConfigurationException; 024 025import org.ametys.runtime.plugin.component.AbstractLogEnabled; 026import org.ametys.runtime.plugin.component.PluginAware; 027 028/** 029 * Static implementation of a {@link GlyphProvider} based on a static configuration 030 * 031 */ 032public class StaticGlyphProvider extends AbstractLogEnabled implements GlyphProvider, Configurable, PluginAware 033{ 034 /** The name of the plugin that declared the provider */ 035 protected String _pluginName; 036 /** The name of the feature that declared the provider */ 037 protected String _featureName; 038 /** The files declared */ 039 protected Map<String, String> _cssFiles; 040 041 public void setPluginInfo(String pluginName, String featureName, String id) 042 { 043 _pluginName = pluginName; 044 _featureName = featureName; 045 } 046 047 @Override 048 public void configure(Configuration configuration) throws ConfigurationException 049 { 050 _cssFiles = new HashMap<>(); 051 052 for (Configuration fileConfiguration : configuration.getChildren("file")) 053 { 054 String path = "plugin:" + _pluginName + "://" + fileConfiguration.getValue(); 055 String prefix = fileConfiguration.getAttribute("prefix", ""); 056 _cssFiles.put(path, prefix); 057 } 058 } 059 060 @Override 061 public Map<String, String> getCSSFiles() 062 { 063 return _cssFiles; 064 } 065 066}