public class SkinFactoryComponent extends AbstractLogEnabled implements Component, ThreadSafe, Serviceable
Modifier and Type | Class and Description |
---|---|
(package private) class |
SkinFactoryComponent.SkinDirectoryFilter |
Modifier and Type | Field and Description |
---|---|
private static Pattern |
__I18N_CATALOG_LANGUAGE |
private Map<String,String> |
_modelsHash |
private SkinModelsManager |
_modelsManager |
private Map<String,Map<String,AbstractSkinParameter>> |
_modelsParameters |
private SourceResolver |
_resolver |
static Pattern |
CSS_PARAM_PATTERN
Pattern for CSS parameters.
|
static Pattern |
I18N_PARAM_PATTERN
Pattern for i18n text parameters.
|
static String |
ROLE
Avalon role
|
static Pattern |
TXT_PARAM_PATTERN
Pattern for text parameters.
|
Constructor and Description |
---|
SkinFactoryComponent() |
Modifier and Type | Method and Description |
---|---|
private I18nizableText |
_configureI18nizableText(Configuration configuration,
String modelName) |
private void |
_configureImage(File imageFile,
ImageParameter param,
String modelName) |
private void |
_configureVariant(File variantFile,
VariantParameter param,
String modelName) |
private void |
_findImagesParameters(File modelDir,
File imagesDir,
File file,
Map<String,ImageParameter> params,
String modelName) |
private void |
_findVariantsParameters(File variantsDir,
Map<String,VariantParameter> params,
String modelName) |
private String |
_getCatalogLanguage(String string,
String fileName) |
private Map<String,CSSParameter> |
_getCSSParameters(File modelDir,
String modelName) |
private Map<String,String> |
_getI18nOtherDefaultValues(File defaultCatalog,
String i18nKey) |
private Map<String,I18nizableTextParameter> |
_getI18nTextParameters(File modelDir,
String modelName) |
private Map<String,ImageParameter> |
_getImageParameters(File modelDir,
String modelName) |
private Map<String,TextParameter> |
_getTextParameters(File modelDir,
String modelName) |
private Object |
_getValue(SkinModel model,
AbstractSkinParameter param,
Map<String,Object> values,
Map<String,String> defaultValues) |
private Map<String,VariantParameter> |
_getVariantParameters(File modelDir,
String modelName) |
private List<Variant> |
_getVariantValues(File variant,
String modelName) |
private List<File> |
_listCSSFiles(File file) |
private List<File> |
_listXSLFiles(File file) |
private void |
_parseCSSFile(Map<String,CSSParameter> cssParams,
String modelName,
File cssFile) |
private Map<String,I18nizableTextParameter> |
_parseI18nFile(String skinName,
File i18nFile) |
private I18nizableText |
_parseI18nizableText(String label,
String modelName) |
private Map<String,TextParameter> |
_parseXSLFile(String skinName,
File xslFile) |
void |
applyColorTheme(String modelName,
File skinDir)
Apply new color theme
|
void |
applyModelParameters(String modelName,
File skinDir)
Apply model parameters in given skin
|
void |
applyModelParameters(String modelName,
File skinDir,
Map<String,Object> values)
Apply model parameters in given skin
|
void |
applyParameter(AbstractSkinParameter parameter,
File skinDir,
String modelName,
Object value,
String lang)
Apply parameter
|
void |
clearModelsParametersCache()
Remove all model parameters from cache
|
String |
getColorTheme(File skinDir)
Get the current theme
|
AbstractSkinParameter |
getModelParamater(String modelName,
String paramId)
Get the skin parameter of the given model
|
Map<String,AbstractSkinParameter> |
getModelParameters(String modelName)
Get the skin parameters of a model
|
Object |
getParameterValue(File skinDir,
String modelName,
String id)
Get the parameter's value
|
Map<String,Object> |
getParameterValues(File skinDir,
String modelName)
Get all parameters' values
|
Map<String,Object> |
getParameterValues(File skinDir,
String modelName,
List<String> ids)
Get the parameters' values
|
boolean |
isModelUpToDate(String modelName)
Determines if the model was changed
|
boolean |
saveColorTheme(File skinDir,
String themeId)
Modify the color theme
|
boolean |
saveParameter(File skinDir,
String id,
Object value)
Modify a skin parameter's value
|
boolean |
saveParameters(File skinDir,
Map<String,Object> parameters)
Save skin parameters
|
void |
service(ServiceManager smanager) |
void |
updateHash(File xmlFile,
String hash)
Update hash
|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
public static final Pattern CSS_PARAM_PATTERN
public static final Pattern I18N_PARAM_PATTERN
public static final Pattern TXT_PARAM_PATTERN
private static final Pattern __I18N_CATALOG_LANGUAGE
private final Map<String,Map<String,AbstractSkinParameter>> _modelsParameters
private final Map<String,String> _modelsHash
private SkinModelsManager _modelsManager
private SourceResolver _resolver
public SkinFactoryComponent()
public void service(ServiceManager smanager) throws ServiceException
service
in interface Serviceable
ServiceException
public void clearModelsParametersCache()
public AbstractSkinParameter getModelParamater(String modelName, String paramId)
modelName
- The model nameparamId
- The id of the parameternull
if it doesn't existpublic boolean isModelUpToDate(String modelName)
modelName
- The model nametrue
if the model was changedpublic Map<String,AbstractSkinParameter> getModelParameters(String modelName)
modelName
- the model nameprivate Map<String,VariantParameter> _getVariantParameters(File modelDir, String modelName)
private void _findVariantsParameters(File variantsDir, Map<String,VariantParameter> params, String modelName)
private List<Variant> _getVariantValues(File variant, String modelName)
private void _configureVariant(File variantFile, VariantParameter param, String modelName)
private Map<String,ImageParameter> _getImageParameters(File modelDir, String modelName)
private void _findImagesParameters(File modelDir, File imagesDir, File file, Map<String,ImageParameter> params, String modelName)
private void _configureImage(File imageFile, ImageParameter param, String modelName)
private Map<String,CSSParameter> _getCSSParameters(File modelDir, String modelName)
private List<File> _listCSSFiles(File file)
private void _parseCSSFile(Map<String,CSSParameter> cssParams, String modelName, File cssFile)
private Map<String,TextParameter> _getTextParameters(File modelDir, String modelName)
private List<File> _listXSLFiles(File file)
private Map<String,TextParameter> _parseXSLFile(String skinName, File xslFile)
private Map<String,I18nizableTextParameter> _getI18nTextParameters(File modelDir, String modelName)
private Map<String,I18nizableTextParameter> _parseI18nFile(String skinName, File i18nFile)
private String _getCatalogLanguage(String string, String fileName)
private Map<String,String> _getI18nOtherDefaultValues(File defaultCatalog, String i18nKey)
private I18nizableText _parseI18nizableText(String label, String modelName)
public Object getParameterValue(File skinDir, String modelName, String id)
skinDir
- The skin directory (could be in temp, work or skin)modelName
- The model nameid
- The parameter idpublic Map<String,Object> getParameterValues(File skinDir, String modelName, List<String> ids)
skinDir
- The skin directory (could be in temp, work or skin)modelName
- The model nameids
- The parameters' idpublic String getColorTheme(File skinDir)
skinDir
- The skin directory (could be in temp, work or skin)public Map<String,Object> getParameterValues(File skinDir, String modelName)
skinDir
- The skin directory (could be in temp, work or skin)modelName
- The model namepublic boolean saveColorTheme(File skinDir, String themeId)
skinDir
- The skin directory (could be in temp, work or skin)themeId
- The id of the theme. Can be null to clear theme.true
is modification successpublic boolean saveParameter(File skinDir, String id, Object value)
skinDir
- The skin directory (could be in temp, work or skin)id
- the id of the parametervalue
- the new valuetrue
is modification successpublic boolean saveParameters(File skinDir, Map<String,Object> parameters)
skinDir
- The skin directory (could be in temp, work or skin)parameters
- The skins parameters to savetrue
is modification successpublic void applyModelParameters(String modelName, File skinDir)
modelName
- The model nameskinDir
- The skin directory (could be temp, work or skins)public void applyModelParameters(String modelName, File skinDir, Map<String,Object> values)
modelName
- The model nameskinDir
- The skin directoryvalues
- The values to setprivate Object _getValue(SkinModel model, AbstractSkinParameter param, Map<String,Object> values, Map<String,String> defaultValues)
public void updateHash(File xmlFile, String hash) throws IOException
xmlFile
- the xml File
hash
- the new hash of the fileIOException
- if an error occurs while manipulating the filepublic void applyParameter(AbstractSkinParameter parameter, File skinDir, String modelName, Object value, String lang)
parameter
- the skin parameterskinDir
- the skin directory (could be temp, work or skins)modelName
- the model namevalue
- the parameter valuelang
- The languagepublic void applyColorTheme(String modelName, File skinDir)
skinDir
- the skin directory (could be temp, work or skins)modelName
- the model nameprivate I18nizableText _configureI18nizableText(Configuration configuration, String modelName) throws ConfigurationException
ConfigurationException