Package org.ametys.core.ui
Class RibbonConfigurationManager
- java.lang.Object
-
- org.ametys.core.ui.RibbonConfigurationManager
-
public class RibbonConfigurationManager extends Object
This class handles the ribbon configuration needed for client side display.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RibbonConfigurationManager.CONTROLSIZE
Size constants for controlsstatic class
RibbonConfigurationManager.LAYOUTALIGN
Size constants for controls
-
Field Summary
Fields Modifier and Type Field Description protected Set<String>
_controlsReferences
The controls referenced by the ribbonprivate boolean
_initialized
private static org.slf4j.Logger
_logger
private static Pattern
_PLUGINNAMEPATTERN
protected SourceResolver
_resolver
The excalibur source resolverprotected RibbonConfiguration
_ribbonConfig
The ribbon configuration, as read from the configuration sourceprotected RibbonControlsManager
_ribbonControlManager
The ribbon controls managerprotected RibbonImportManager
_ribbonImportManager
The ribbon import managerprotected RibbonManager
_ribbonManager
The ribbon control managerprotected RibbonManagerCache
_ribbonManagerCache
The ribbon manager Cacheprotected RibbonTabsManager
_ribbonTabManager
The ribbon tab extension pointprotected SAXClientSideElementHelper
_saxClientSideElementHelper
The sax clientside element helperprotected Set<String>
_tabsReferences
The tabs referenced by the ribbon
-
Constructor Summary
Constructors Constructor Description RibbonConfigurationManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
_checkLayoutsConsistency(List<Layout> layoutsBuffer, GroupSize group)
private void
_checkLayoutsMerge(List<Layout> layoutsBuffer, int elementsPerLayout, Layout layout, List<Element> elements, int layoutSize, GroupSize group)
private Layout
_checkLayoutsOverflow(RibbonConfigurationManager.CONTROLSIZE size, int elementsPerLayout, Layout layout, List<Element> elements, int currentSize)
private void
_checkTabConsistency(Map<Tab,List<Group>> tabGroups)
private void
_checkTabConsistency(GroupSize group)
private void
_configure(RibbonConfigurationSource ribbonConfigurationSource, ClientSideElementDependenciesManager dependenciesManager, String workspaceName)
private void
_configureExcluded(Configuration configuration, Map<String,Map<String,Object>> imports, Map<RibbonExclude.EXCLUDETYPE,List<RibbonExclude>> excluded, String workspaceName)
private void
_configureExcludeFromImports(String url, Map<String,Map<String,Object>> imports, Map<RibbonExclude.EXCLUDETYPE,List<RibbonExclude>> excluded)
private void
_configureExcludeFromImports(Configuration configuration, Map<String,Map<String,Object>> imports, Map<RibbonExclude.EXCLUDETYPE,List<RibbonExclude>> excluded)
private void
_configureImport(ClientSideElementDependenciesManager dependenciesManager, Map<String,Long> importValidity, String url, Map<String,Map<String,Object>> imports, Map<RibbonExclude.EXCLUDETYPE,List<RibbonExclude>> excludedList)
private void
_configureRibbon(Configuration configuration, ClientSideElementDependenciesManager dependenciesManager, Map<String,Map<String,Object>> imports, Map<String,Long> importValidity, Map<RibbonExclude.EXCLUDETYPE,List<RibbonExclude>> excludedList, String url)
private void
_configureRibbonMenu(Configuration configuration, RibbonMenu ribbonMenu, List<RibbonExclude> excludedList, Map<String,Object> properties, String url)
private void
_configureTabOrder(Map<String,Tab> labelMapping)
private void
_configureTabOverride(Map<String,Tab> labelMapping)
private Group
_createGroupForUser(Group ribbonGroup, Map<String,Object> contextualParameters)
Create a contextualised group for the current user, based on the ribbon configuration groupprivate void
_generateGroupSizes(List<Element> largeElements, List<Element> groupSizeElements, boolean generateSmallSize, int groupTotalSize)
private Map<Tab,List<Group>>
_generateTabGroups(Map<String,Object> contextualParameters)
Generate the tab groups for the current user and contextual parameters, based on the ribbon configured tab list _tabs.private List<ClientSideElement>
_getMenuControls(MenuClientSideElement menu)
private boolean
_isFileExcluded(Map<String,Object> properties, List<RibbonExclude> excludedList, String url)
private boolean
_isTabExcluded(Tab tab, Map<RibbonExclude.EXCLUDETYPE,List<RibbonExclude>> excludedList)
private void
_lazyInitialize()
Check that the configuration was correctprivate void
_lazyInitialize(List<Element> elements)
private void
_lazyInitialize(GroupSize groupSize)
private void
_processControlRefsQueue(List<ControlRef> controlsQueue, List<Element> groupSizeElements, int groupTotalSize, boolean generateSmallSize)
private void
_removeExcludedControls(List<Element> elements, List<String> excludedList)
private void
_removeExcludedControls(Tab tab, List<String> excludedList)
private List<Element>
_resolveReferences(Map<String,Object> contextualParameters, List<Element> elements)
Resolve all the controls references into the real ids for the contextual parameters, and the current user rights.private void
_saxReferencedControl(MenuClientSideElement menu, ContentHandler handler, Map<String,Object> contextualParameters)
void
configure(RibbonManager ribbonManager, ClientSideElementDependenciesManager dependenciesManager, RibbonConfigurationSource config, String workspaceName)
Configure the manager after being setup, to read and load the ribbons filesList<ClientSideElement>
getControls()
Retrieve the list of controls referenced by the ribbonList<ClientSideElement>
getTabs()
Retrieve the list of tabs referenced by the ribbonvoid
saxRibbonDefinition(ContentHandler handler, Map<String,Object> contextualParameters)
Sax the the initial configuration of the ribbon.void
setup(RibbonControlsManager ribbonControlManager, RibbonTabsManager ribbonTabManager, RibbonImportManager ribbonImportManager, SAXClientSideElementHelper saxClientSideElementHelper, SourceResolver resolver, RibbonManagerCache ribbonManagerCache)
Setup the ribbon configuration manager with the required components.
-
-
-
Field Detail
-
_logger
private static org.slf4j.Logger _logger
-
_PLUGINNAMEPATTERN
private static Pattern _PLUGINNAMEPATTERN
-
_ribbonManager
protected RibbonManager _ribbonManager
The ribbon control manager
-
_ribbonTabManager
protected RibbonTabsManager _ribbonTabManager
The ribbon tab extension point
-
_saxClientSideElementHelper
protected SAXClientSideElementHelper _saxClientSideElementHelper
The sax clientside element helper
-
_resolver
protected SourceResolver _resolver
The excalibur source resolver
-
_ribbonConfig
protected RibbonConfiguration _ribbonConfig
The ribbon configuration, as read from the configuration source
-
_controlsReferences
protected Set<String> _controlsReferences
The controls referenced by the ribbon
-
_tabsReferences
protected Set<String> _tabsReferences
The tabs referenced by the ribbon
-
_ribbonControlManager
protected RibbonControlsManager _ribbonControlManager
The ribbon controls manager
-
_ribbonImportManager
protected RibbonImportManager _ribbonImportManager
The ribbon import manager
-
_ribbonManagerCache
protected RibbonManagerCache _ribbonManagerCache
The ribbon manager Cache
-
_initialized
private boolean _initialized
-
-
Constructor Detail
-
RibbonConfigurationManager
public RibbonConfigurationManager()
-
-
Method Detail
-
setup
public void setup(RibbonControlsManager ribbonControlManager, RibbonTabsManager ribbonTabManager, RibbonImportManager ribbonImportManager, SAXClientSideElementHelper saxClientSideElementHelper, SourceResolver resolver, RibbonManagerCache ribbonManagerCache)
Setup the ribbon configuration manager with the required components.- Parameters:
ribbonControlManager
- The ribbon control managerribbonTabManager
- the ribbon tab managerribbonImportManager
- The ribbon import managersaxClientSideElementHelper
- the helper to SAX client side elementresolver
- the excalibur source resolverribbonManagerCache
- The ribbon manager cache helper
-
configure
public void configure(RibbonManager ribbonManager, ClientSideElementDependenciesManager dependenciesManager, RibbonConfigurationSource config, String workspaceName)
Configure the manager after being setup, to read and load the ribbons files- Parameters:
ribbonManager
- The ribbon manager for this configdependenciesManager
- The dependencies managerconfig
- the ribbon configurationworkspaceName
- The current workspace name- Throws:
RuntimeException
- if an error occurred
-
_configure
private void _configure(RibbonConfigurationSource ribbonConfigurationSource, ClientSideElementDependenciesManager dependenciesManager, String workspaceName) throws Exception
- Throws:
Exception
-
_configureExcluded
private void _configureExcluded(Configuration configuration, Map<String,Map<String,Object>> imports, Map<RibbonExclude.EXCLUDETYPE,List<RibbonExclude>> excluded, String workspaceName) throws ConfigurationException
- Throws:
ConfigurationException
-
_configureExcludeFromImports
private void _configureExcludeFromImports(String url, Map<String,Map<String,Object>> imports, Map<RibbonExclude.EXCLUDETYPE,List<RibbonExclude>> excluded) throws ConfigurationException
- Throws:
ConfigurationException
-
_configureExcludeFromImports
private void _configureExcludeFromImports(Configuration configuration, Map<String,Map<String,Object>> imports, Map<RibbonExclude.EXCLUDETYPE,List<RibbonExclude>> excluded) throws ConfigurationException
- Throws:
ConfigurationException
-
_configureRibbon
private void _configureRibbon(Configuration configuration, ClientSideElementDependenciesManager dependenciesManager, Map<String,Map<String,Object>> imports, Map<String,Long> importValidity, Map<RibbonExclude.EXCLUDETYPE,List<RibbonExclude>> excludedList, String url) throws ConfigurationException
- Throws:
ConfigurationException
-
_configureRibbonMenu
private void _configureRibbonMenu(Configuration configuration, RibbonMenu ribbonMenu, List<RibbonExclude> excludedList, Map<String,Object> properties, String url) throws ConfigurationException
- Throws:
ConfigurationException
-
_configureImport
private void _configureImport(ClientSideElementDependenciesManager dependenciesManager, Map<String,Long> importValidity, String url, Map<String,Map<String,Object>> imports, Map<RibbonExclude.EXCLUDETYPE,List<RibbonExclude>> excludedList) throws ConfigurationException
- Throws:
ConfigurationException
-
_isFileExcluded
private boolean _isFileExcluded(Map<String,Object> properties, List<RibbonExclude> excludedList, String url)
-
_isTabExcluded
private boolean _isTabExcluded(Tab tab, Map<RibbonExclude.EXCLUDETYPE,List<RibbonExclude>> excludedList)
-
_removeExcludedControls
private void _removeExcludedControls(Tab tab, List<String> excludedList)
-
_removeExcludedControls
private void _removeExcludedControls(List<Element> elements, List<String> excludedList)
-
_configureTabOverride
private void _configureTabOverride(Map<String,Tab> labelMapping)
-
_configureTabOrder
private void _configureTabOrder(Map<String,Tab> labelMapping)
-
_lazyInitialize
private void _lazyInitialize()
Check that the configuration was correct- Throws:
IllegalStateException
- if an item does not exist
-
_lazyInitialize
private void _lazyInitialize(GroupSize groupSize)
-
_lazyInitialize
private void _lazyInitialize(List<Element> elements)
-
getControls
public List<ClientSideElement> getControls()
Retrieve the list of controls referenced by the ribbon- Returns:
- The list of controls
-
getTabs
public List<ClientSideElement> getTabs()
Retrieve the list of tabs referenced by the ribbon- Returns:
- The list of tabs
-
_getMenuControls
private List<ClientSideElement> _getMenuControls(MenuClientSideElement menu)
-
saxRibbonDefinition
public void saxRibbonDefinition(ContentHandler handler, Map<String,Object> contextualParameters) throws SAXException
Sax the the initial configuration of the ribbon.- Parameters:
handler
- The content handler where to saxcontextualParameters
- Contextuals parameters transmitted by the environment.- Throws:
SAXException
- if an error occurs
-
_generateTabGroups
private Map<Tab,List<Group>> _generateTabGroups(Map<String,Object> contextualParameters)
Generate the tab groups for the current user and contextual parameters, based on the ribbon configured tab list _tabs.- Parameters:
contextualParameters
- The contextual parameters- Returns:
- The list of groups for the current user, mapped by tab
-
_checkTabConsistency
private void _checkTabConsistency(Map<Tab,List<Group>> tabGroups)
-
_checkTabConsistency
private void _checkTabConsistency(GroupSize group)
-
_checkLayoutsConsistency
private void _checkLayoutsConsistency(List<Layout> layoutsBuffer, GroupSize group)
-
_checkLayoutsOverflow
private Layout _checkLayoutsOverflow(RibbonConfigurationManager.CONTROLSIZE size, int elementsPerLayout, Layout layout, List<Element> elements, int currentSize)
-
_checkLayoutsMerge
private void _checkLayoutsMerge(List<Layout> layoutsBuffer, int elementsPerLayout, Layout layout, List<Element> elements, int layoutSize, GroupSize group)
-
_createGroupForUser
private Group _createGroupForUser(Group ribbonGroup, Map<String,Object> contextualParameters)
Create a contextualised group for the current user, based on the ribbon configuration group- Parameters:
ribbonGroup
- The group form the initial ribbon configurationcontextualParameters
- The contextual parameters- Returns:
- The group for the current user
-
_resolveReferences
private List<Element> _resolveReferences(Map<String,Object> contextualParameters, List<Element> elements)
Resolve all the controls references into the real ids for the contextual parameters, and the current user rights.- Parameters:
contextualParameters
- The contextual parameterselements
- The elements to resolve- Returns:
- The list of resolved elements
-
_generateGroupSizes
private void _generateGroupSizes(List<Element> largeElements, List<Element> groupSizeElements, boolean generateSmallSize, int groupTotalSize)
-
_processControlRefsQueue
private void _processControlRefsQueue(List<ControlRef> controlsQueue, List<Element> groupSizeElements, int groupTotalSize, boolean generateSmallSize)
-
_saxReferencedControl
private void _saxReferencedControl(MenuClientSideElement menu, ContentHandler handler, Map<String,Object> contextualParameters) throws SAXException
- Throws:
SAXException
-
-