Creating a State Policy aware UI plugin class
Creating a State Policy aware UI plugin class
You must add the com.elasticpath.cmclient.policy plugin to the Required Plug-ins list in your plugin's Dependencies.
UI plugins that need State Policies support must extend AbstractPolicyAwareUIPlugin. Only one method must be implemented:
- getPluginId()
The plugin ID provided is ued is used by the State Policy Extension Retriever to get state policies from the plugin extension point. It is responsible for ensuring that the State Policy Contributions from the Change Set plugin are included when the Change Sets feature is enabled. (If the Change Sets feature is disabled, the state policy contributions from the Change Set plugin are ignored.)
The State Policy Resolver is responsible for merging all State Policy Contributions into a single State Policy that can be applied to the relevant State Policy Targets.
AbstractPolicyAwareUIPlugin.getStatePolicyResolver() returns a default PriorityStatePolicyResolver object. PriorityStatePolicyResolver uses the priority of the State Policy Contributions to determine which rules take precedence (highest priority wins). If two policies have the same priority, the policies will be combined with a logical AND to determine editability.
A plugin which is State Policy aware can choose to use its own resolver, or request the default one from the Policy plugin. To use a different resolver as the default, modify the extension in the Policy plugin's statePolicyResolver extension point.