Class StaticConfigurableScriptBinding
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.core.ui.script.StaticConfigurableScriptBinding
-
- All Implemented Interfaces:
ScriptBinding
,LogEnabled
,PluginAware
,Configurable
,Contextualizable
,Serviceable
- Direct Known Subclasses:
CmsScriptBinding
,RepositoryScriptBinding
,RuntimeScriptBinding
,WebScriptBinding
public class StaticConfigurableScriptBinding extends AbstractLogEnabled implements ScriptBinding, Configurable, Serviceable, PluginAware, Contextualizable
Static implementation of the ScriptBinding that can read the functions from an xml file
-
-
Field Summary
Fields Modifier and Type Field Description protected Context
_context
The avalon contextprotected List<String>
_functions
List of functions per configuration fileprotected Map<String,ScriptBindingDocumentation>
_functionsDescriptions
List of function descriptionsprotected String
_pluginName
The plugin nameprotected SourceResolver
_sourceResolver
Source Resolverprotected Map<I18nizableText,ScriptBindingDocumentation>
_tutorials
List of tutorialsprotected Map<String,ScriptBindingDocumentation>
_variablesDescriptions
List of variable descriptionsprotected List<String>
_variablesScripts
List of variables per configuration fileprotected Pattern
_workspacePattern
The pattern corresponding to the script binding
-
Constructor Summary
Constructors Constructor Description StaticConfigurableScriptBinding()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_configureFunctions(String pluginName, String filePath, Configuration configuration)
Configure the function partprivate List<ScriptBindingDocumentation.Argument>
_configureSubtype(Configuration configuration, String pluginName)
protected void
_configureTutorials(String pluginName, String filePath, Configuration configuration)
Configure the tutorial partprotected void
_configureVariables(String pluginName, String filePath, Configuration configuration)
Configure the variable partprivate Configuration
_getConfiguration(String uri)
private String
_getContent(String pluginName, String filePath, Configuration initialConfiguration)
private Configuration
_getFileConfiguration(String uri, Configuration initialConfiguration)
private String
_getRelativeFileContent(String pluginName, String filePath, String relativeTo)
private String
_getURI(String pluginName, String filePath, String relativeTo)
private ScriptBindingDocumentation.Argument
_parseArgument(Configuration argumentConfiguration, String pluginName)
private ScriptBindingDocumentation
_parseDocumentation(String pluginName, String filePath, Configuration initialConfiguration)
void
cleanVariables(Map<String,Object> variables)
Allows clean up of variables created during the getVariables call.void
configure(Configuration configuration)
void
contextualize(Context context)
String
getFunctions()
Returns the JavaScript functions to inject at the start of the script, in the form of a single String prepended to the script.Map<String,ScriptBindingDocumentation>
getFunctionsDescriptions()
Returns the list of functions descriptions, mapped by function name.Map<I18nizableText,ScriptBindingDocumentation>
getTutorials()
Returns the list of tutorialsMap<String,Object>
getVariables(ScriptExecArguments execArgs)
Returns the list of variables this ScriptBinding provides, mapped by variable name.Map<String,ScriptBindingDocumentation>
getVariablesDescriptions()
Returns the list of variables descriptions, mapped by variable name.String
getVariablesScripts()
Returns the JavaScript variables script to inject at the start of the script, in the form of a single String prepended to the script.Pattern
getWorkspacePattern()
Return the pattern of the workspace corresponding to this script binding.void
service(ServiceManager manager)
void
setPluginInfo(String pluginName, String featureName, String id)
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_sourceResolver
protected SourceResolver _sourceResolver
Source Resolver
-
_variablesScripts
protected List<String> _variablesScripts
List of variables per configuration file
-
_functions
protected List<String> _functions
List of functions per configuration file
-
_functionsDescriptions
protected Map<String,ScriptBindingDocumentation> _functionsDescriptions
List of function descriptions
-
_variablesDescriptions
protected Map<String,ScriptBindingDocumentation> _variablesDescriptions
List of variable descriptions
-
_pluginName
protected String _pluginName
The plugin name
-
_workspacePattern
protected Pattern _workspacePattern
The pattern corresponding to the script binding
-
_tutorials
protected Map<I18nizableText,ScriptBindingDocumentation> _tutorials
List of tutorials
-
-
Constructor Detail
-
StaticConfigurableScriptBinding
public StaticConfigurableScriptBinding()
-
-
Method Detail
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
_configureFunctions
protected void _configureFunctions(String pluginName, String filePath, Configuration configuration) throws ConfigurationException, IOException
Configure the function part- Parameters:
pluginName
- Current pluginfilePath
- The conf file pathconfiguration
- the function- Throws:
IOException
- If an error occurredConfigurationException
- If an error occurred
-
_configureVariables
protected void _configureVariables(String pluginName, String filePath, Configuration configuration) throws ConfigurationException, IOException
Configure the variable part- Parameters:
pluginName
- Current pluginfilePath
- The conf file pathconfiguration
- the variable- Throws:
IOException
- If an error occurredConfigurationException
- If an error occurred
-
_configureTutorials
protected void _configureTutorials(String pluginName, String filePath, Configuration configuration) throws ConfigurationException, IOException
Configure the tutorial part- Parameters:
pluginName
- Current pluginfilePath
- The conf file pathconfiguration
- the tutorial- Throws:
IOException
- If an error occurredConfigurationException
- If an error occurred
-
_parseDocumentation
private ScriptBindingDocumentation _parseDocumentation(String pluginName, String filePath, Configuration initialConfiguration) throws ConfigurationException, IOException
- Throws:
ConfigurationException
IOException
-
_configureSubtype
private List<ScriptBindingDocumentation.Argument> _configureSubtype(Configuration configuration, String pluginName)
-
_parseArgument
private ScriptBindingDocumentation.Argument _parseArgument(Configuration argumentConfiguration, String pluginName)
-
_getContent
private String _getContent(String pluginName, String filePath, Configuration initialConfiguration) throws ConfigurationException, IOException
- Throws:
ConfigurationException
IOException
-
_getFileConfiguration
private Configuration _getFileConfiguration(String uri, Configuration initialConfiguration)
-
_getRelativeFileContent
private String _getRelativeFileContent(String pluginName, String filePath, String relativeTo) throws IOException
- Throws:
IOException
-
_getConfiguration
private Configuration _getConfiguration(String uri) throws ConfigurationException, SAXException, IOException
-
getWorkspacePattern
public Pattern getWorkspacePattern()
Description copied from interface:ScriptBinding
Return the pattern of the workspace corresponding to this script binding.- Specified by:
getWorkspacePattern
in interfaceScriptBinding
- Returns:
- The pattern to match
-
getFunctions
public String getFunctions()
Description copied from interface:ScriptBinding
Returns the JavaScript functions to inject at the start of the script, in the form of a single String prepended to the script.- Specified by:
getFunctions
in interfaceScriptBinding
- Returns:
- The functions text, or null if no function is provided.
-
getVariablesScripts
public String getVariablesScripts()
Description copied from interface:ScriptBinding
Returns the JavaScript variables script to inject at the start of the script, in the form of a single String prepended to the script.- Specified by:
getVariablesScripts
in interfaceScriptBinding
- Returns:
- The functions text, or null if no function is provided.
-
getFunctionsDescriptions
public Map<String,ScriptBindingDocumentation> getFunctionsDescriptions()
Description copied from interface:ScriptBinding
Returns the list of functions descriptions, mapped by function name. This list does not have to match the functions returned by getFunctions, but the description is used to inform the user of the existence and usability of each function.- Specified by:
getFunctionsDescriptions
in interfaceScriptBinding
- Returns:
- The list of functions descriptions, or null if no description is provided.
-
getTutorials
public Map<I18nizableText,ScriptBindingDocumentation> getTutorials()
Description copied from interface:ScriptBinding
Returns the list of tutorials- Specified by:
getTutorials
in interfaceScriptBinding
- Returns:
- The list of tutorials, or null if no tutorial is provided.
-
getVariables
public Map<String,Object> getVariables(ScriptExecArguments execArgs)
Description copied from interface:ScriptBinding
Returns the list of variables this ScriptBinding provides, mapped by variable name.- Specified by:
getVariables
in interfaceScriptBinding
- Parameters:
execArgs
- The The arguments for script execution- Returns:
- The list of variables, or null if no variable is provided.
-
getVariablesDescriptions
public Map<String,ScriptBindingDocumentation> getVariablesDescriptions()
Description copied from interface:ScriptBinding
Returns the list of variables descriptions, mapped by variable name. This list does not have to match the getVariables return value, but the description is used to inform the user of the existence and usability of each variable.- Specified by:
getVariablesDescriptions
in interfaceScriptBinding
- Returns:
- The list of variables descriptions, or null if no description is provided.
-
cleanVariables
public void cleanVariables(Map<String,Object> variables)
Description copied from interface:ScriptBinding
Allows clean up of variables created during the getVariables call.- Specified by:
cleanVariables
in interfaceScriptBinding
- Parameters:
variables
- The map of variables.
-
-