Package org.ametys.cms.clientsideelement
Class ContentTypesGallery
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.ui.StaticFileImportsClientSideElement
-
- org.ametys.core.ui.StaticClientSideElement
-
- org.ametys.core.ui.SimpleMenu
-
- org.ametys.cms.clientsideelement.ContentTypesGallery
-
- All Implemented Interfaces:
ClientSideElement
,MenuClientSideElement
,LogEnabled
,PluginAware
,Configurable
,Serviceable
- Direct Known Subclasses:
ContentTypesGallery
,MixinContentTypesGallery
,ReferenceTablesGallery
public class ContentTypesGallery extends SimpleMenu
This element creates a menu with one gallery item per content type classified by category (default mode). This element supports an alternative display, to display content types into sub menu items (root menu items will be the categories), if 'show-in-menu' parameters is set to 'true'. This mode should be privileged if the number of content types is important (> 30) The user rights are checked.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
ContentTypesGallery.ContentTypeClientSideElementComparator
Comparator used to order the content types in the categories We use the translated labels to make it easier to find a content type But the order will be different for each language-
Nested classes/interfaces inherited from class org.ametys.core.ui.SimpleMenu
SimpleMenu.GalleryGroup, SimpleMenu.GalleryItem, SimpleMenu.UnresolvedItem
-
Nested classes/interfaces inherited from interface org.ametys.core.ui.ClientSideElement
ClientSideElement.Script, ClientSideElement.ScriptFile
-
-
Field Summary
Fields Modifier and Type Field Description private Set<String>
_addedComponents
protected ContentTypeExtensionPoint
_contentTypeExtensionPoint
The list of content typesprivate boolean
_contentTypesInitialized
protected I18nUtils
_i18nUtils
The i18n utilsprotected LanguagesManager
_languagesManager
The language managerprotected RootContentHelper
_rootContentHelper
Helper for root content-
Fields inherited from class org.ametys.core.ui.SimpleMenu
_galleryItems, _menuItemManager, _menuItems, _primaryMenuItem, _ribbonControlManager, _smanager, _unresolvedMenuItems
-
Fields inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_currentUserProvider, _dependencies, _featureName, _id, _pluginName, _rightManager, _rights, _rightsMode, _script
-
-
Constructor Summary
Constructors Constructor Description ContentTypesGallery()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_addContentTypeConfiguration(DefaultConfiguration rootConf, ContentType cType)
Get the configuration of the content type itemprotected void
_addContentTypeIconsConfiguration(DefaultConfiguration classConf, ContentType cType)
Add configuration for content type's icons and/or glyphesprotected void
_addGroupContentTypeConfiguration(DefaultConfiguration rootConf, I18nizableText groupLabel, Set<ContentType> cTypes)
Get the configuration of the content type itemprotected void
_addRightsOnContentTypeConfiguration(DefaultConfiguration rootConf)
Get the 'rights' configuration of the content type itemprotected ClientSideElement.Script
_configureScript(Configuration configuration)
Configure the scriptprotected Map<I18nizableText,Set<ContentType>>
_getContentTypesByGroup()
Get the list of content types classified by groupsprotected void
_getGalleryItems(Map<String,Object> parameters, Map<String,Object> contextualParameters)
Get the gallery itemsprotected DefaultConfiguration
_getI18nizableTextConfiguration(String tagName, I18nizableText i18nText)
Get the configuration for an i18nizable textprivate void
_lazyInitializeContentTypeGallery()
private void
_lazyInitializeContentTypeMenu()
private boolean
_showInMenu()
protected void
addContentType(ContentType contentType, Map<I18nizableText,Set<ContentType>> groups)
Add content to groupsList<ClientSideElement.Script>
getScripts(boolean ignoreRights, Map<String,Object> contextParameters)
This method return the scripts that will be used on client side.protected boolean
hasRight(ContentType cType)
Test if the current user has the right needed by the content type to create a content.protected boolean
isValidContentType(ContentType contentType)
Determines if the content type is a valid content type for the galleryvoid
service(ServiceManager smanager)
-
Methods inherited from class org.ametys.core.ui.SimpleMenu
_addDependencies, _configureClass, _configureGalleries, _configureGroupGallery, _configureItemsMenu, _getGalleryItemManager, _getGalleryItems, _getMenuItems, configure, getReferencedClientSideElements, getRights
-
Methods inherited from class org.ametys.core.ui.StaticClientSideElement
_configureParameters, configureInitialParameters
-
Methods inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_configureDependencies, _configureImports, _configureRights, _configureRightsMode, getDependencies, getId, getPluginName, getScripts, hasRight, setPluginInfo, toString
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_contentTypeExtensionPoint
protected ContentTypeExtensionPoint _contentTypeExtensionPoint
The list of content types
-
_languagesManager
protected LanguagesManager _languagesManager
The language manager
-
_i18nUtils
protected I18nUtils _i18nUtils
The i18n utils
-
_rootContentHelper
protected RootContentHelper _rootContentHelper
Helper for root content
-
_contentTypesInitialized
private boolean _contentTypesInitialized
-
_addedComponents
private Set<String> _addedComponents
-
-
Constructor Detail
-
ContentTypesGallery
public ContentTypesGallery()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classSimpleMenu
- Throws:
ServiceException
-
_configureScript
protected ClientSideElement.Script _configureScript(Configuration configuration) throws ConfigurationException
Description copied from class:StaticFileImportsClientSideElement
Configure the script- Overrides:
_configureScript
in classStaticClientSideElement
- Parameters:
configuration
- the global configuration- Returns:
- The script created
- Throws:
ConfigurationException
- The configuration is incorrect
-
_getGalleryItems
protected void _getGalleryItems(Map<String,Object> parameters, Map<String,Object> contextualParameters)
Description copied from class:SimpleMenu
Get the gallery items- Overrides:
_getGalleryItems
in classSimpleMenu
- Parameters:
parameters
- Contextual the parameters given to the control script class.contextualParameters
- Contextual parameters transmitted by the environment.
-
_showInMenu
private boolean _showInMenu()
-
_lazyInitializeContentTypeGallery
private void _lazyInitializeContentTypeGallery() throws ConfigurationException
- Throws:
ConfigurationException
-
_lazyInitializeContentTypeMenu
private void _lazyInitializeContentTypeMenu()
-
_addGroupContentTypeConfiguration
protected void _addGroupContentTypeConfiguration(DefaultConfiguration rootConf, I18nizableText groupLabel, Set<ContentType> cTypes)
Get the configuration of the content type item- Parameters:
rootConf
- The root configurationgroupLabel
- The group's labelcTypes
- The content types of the group
-
_addContentTypeConfiguration
protected void _addContentTypeConfiguration(DefaultConfiguration rootConf, ContentType cType)
Get the configuration of the content type item- Parameters:
rootConf
- The root configurationcType
- The content type
-
_getI18nizableTextConfiguration
protected DefaultConfiguration _getI18nizableTextConfiguration(String tagName, I18nizableText i18nText)
Get the configuration for an i18nizable text- Parameters:
tagName
- the tag namei18nText
- the i18n text- Returns:
- the configuration for i18nizable text
-
_addRightsOnContentTypeConfiguration
protected void _addRightsOnContentTypeConfiguration(DefaultConfiguration rootConf)
Get the 'rights' configuration of the content type item- Parameters:
rootConf
- The root configuration
-
_addContentTypeIconsConfiguration
protected void _addContentTypeIconsConfiguration(DefaultConfiguration classConf, ContentType cType)
Add configuration for content type's icons and/or glyphes- Parameters:
classConf
- the class configurationcType
- the content type
-
_getContentTypesByGroup
protected Map<I18nizableText,Set<ContentType>> _getContentTypesByGroup()
Get the list of content types classified by groups- Returns:
- The content types
-
addContentType
protected void addContentType(ContentType contentType, Map<I18nizableText,Set<ContentType>> groups)
Add content to groups- Parameters:
contentType
- The content typegroups
- The groups
-
getScripts
public List<ClientSideElement.Script> getScripts(boolean ignoreRights, Map<String,Object> contextParameters)
Description copied from interface:ClientSideElement
This method return the scripts that will be used on client side. This class will be parametrized by initial and current parameters.- Specified by:
getScripts
in interfaceClientSideElement
- Overrides:
getScripts
in classSimpleMenu
- Parameters:
ignoreRights
- True to ignore the rights verification.contextParameters
- Contextuals parameters transmitted by the environment.- Returns:
- The list of scripts or an empty list.
-
isValidContentType
protected boolean isValidContentType(ContentType contentType)
Determines if the content type is a valid content type for the gallery- Parameters:
contentType
- The coentent- Returns:
- true if it is a valid content type
-
hasRight
protected boolean hasRight(ContentType cType)
Test if the current user has the right needed by the content type to create a content.- Parameters:
cType
- the content type- Returns:
- true if the user has the right needed, false otherwise.
-
-