Package io.jmix.flowui.view
Class ViewRegistry
java.lang.Object
io.jmix.flowui.view.ViewRegistry
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
@Component("flowui_ViewRegistry")
public class ViewRegistry
extends Object
implements org.springframework.context.ApplicationContextAware
Provides information about all registered views.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContextprotected ClassManagerprotected List<ViewControllersConfiguration> static final Stringstatic final Patternprotected ExtendedEntitiesprotected booleanstatic final Stringprotected ReadWriteLockstatic final Stringprotected Metadataprotected AnnotationScanMetadataReaderFactoryprotected UiPropertiesprotected Resourcesprotected com.vaadin.flow.router.RouteConfigurationprotected com.vaadin.flow.server.VaadinContextprotected ViewControllersConfigurationSorterprotected ViewTemplateDefinitions -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidfindViewInfo(String id) Returns view information by id.getAnnotationValue(org.springframework.core.type.AnnotationMetadata annotationMetadata, Class<?> annotationClass) getAvailableListViewId(MetaClass metaClass) Returns list view id by entity metaclass determined by the following procedure: If a view annotated with @PrimaryListViewexists, its id is used Otherwise, a view with<entity_name>.listid is usedgetAvailableLookupViewId(MetaClass metaClass) Returns lookup view id by entity metaclass determined by the following procedure: If a view annotated with @PrimaryLookupViewexists, its id is used Otherwise, if a view with<entity_name>.lookupid exists, its id is used Otherwise, if a view annotated with @PrimaryListViewexists, its id is used Otherwise, a view with<entity_name>.listid is usedgetDetailViewId(MetaClass metaClass) Returns standard id of the detail view for an entity, for exampleCustomer.detail.getDetailViewInfo(MetaClass metaClass) Returns detail view information by entity metaclass.getDetailViewInfo(Class<?> entityClass) Returns detail view information by entity class.getDetailViewInfo(Object entity) Returns detail view information by entity instance.getListViewId(MetaClass metaClass) Returns standard id of the list view for an entity, for exampleCustomer.list.protected StringgetListViewIdInternal(MetaClass metaClass) getListViewInfo(MetaClass metaClass) Returns list or lookup view information by entity metaclass.getListViewInfo(Class<?> entityClass) Returns list or lookup view information by entity class.getListViewInfo(Object entity) Returns list or lookup view information by entity instance.getLookupViewId(MetaClass metaClass) Returns standard id of the lookup view for an entity, for exampleCustomer.lookup.protected StringgetLookupViewIdInternal(MetaClass metaClass) getLookupViewInfo(MetaClass metaClass) Returns lookup or list view information by entity metaclass.getLookupViewInfo(Class<?> entityClass) Returns lookup or list view information by entity class.getLookupViewInfo(Object entity) Returns lookup or list view information by entity instance.protected StringgetMetaClassViewId(MetaClass metaClass, String suffix) getParentChain(Class<? extends com.vaadin.flow.router.RouterLayout> layout, List<Class<? extends com.vaadin.flow.router.RouterLayout>> defaultChain) com.vaadin.flow.router.RouteConfigurationКуегкты the route configuration associated with the registry.getViewInfo(String id) Returns view information by id.booleanhasPrimaryDetailView(Class<?> entityClass) Returnstrueif a primary detail view is registered for the given entity class.booleanhasPrimaryListView(Class<?> entityClass) Returnstrueif a primary list view is registered for the given entity class.booleanprotected voidinit()protected voidSame ascheckInitialized()but assumes the caller holds the write lock.protected org.springframework.core.type.classreading.MetadataReaderloadClassMetadata(String className) loadDefinedViewClass(String className) voidloadViewClass(String className) Reloads a view class for hot-deploy.protected voidprotected voidprotected voidprotected voidregisterPrimaryDetailView(ViewInfo viewInfo, org.springframework.core.type.AnnotationMetadata annotationMetadata) protected voidregisterPrimaryListView(ViewInfo viewInfo, org.springframework.core.type.AnnotationMetadata annotationMetadata) protected voidregisterPrimaryLookupView(ViewInfo viewInfo, org.springframework.core.type.AnnotationMetadata annotationMetadata) voidregisterRoute(ViewInfo viewInfo) Registers route for the passed viewInfo instance.voidregisterRoute(Class<? extends View<?>> viewClass) Registers route for the passed view class.protected voidregisterRoute(String routePath, com.vaadin.flow.router.RouteConfiguration routeConfiguration, Class<? extends com.vaadin.flow.router.RouterLayout> layout, Class<? extends View<?>> viewClass) protected voidregisterTemplatePrimaryView(ViewTemplateDefinition definition, ViewInfo viewInfo) protected voidregisterView(String id, ViewInfo viewInfo) voidIterates over all registered views and registers their routes.booleanremovePrimaryDetailView(Class<?> entityClass) Removes the primary detail view registration for the given entity class.booleanremovePrimaryListView(Class<?> entityClass) Removes the primary list view registration for the given entity class.voidreset()Make the registry to reload views on next request.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetClassManager(ClassManager classManager) voidsetConfigurations(List<ViewControllersConfiguration> configurations) voidsetExtendedEntities(ExtendedEntities extendedEntities) voidsetMetadata(Metadata metadata) voidsetMetadataReaderFactory(AnnotationScanMetadataReaderFactory metadataReaderFactory) voidsetPrimaryDetailView(Class<?> entityClass, ViewInfo viewInfo) Registers a primary detail view for the given entity class.voidsetPrimaryListView(Class<?> entityClass, ViewInfo viewInfo) Registers a primary list view for the given entity class.voidsetProperties(UiProperties properties) voidsetResources(Resources resources) voidsetRouteConfiguration(com.vaadin.flow.router.RouteConfiguration routeConfiguration) Sets the route configuration for the view registry.voidsetViewControllersConfigurationSorter(ViewControllersConfigurationSorter viewControllersConfigurationSorter) voidsetViewTemplateDefinitions(ViewTemplateDefinitions viewTemplateDefinitions) Sets template-generated view definitions that should be exposed by the registry.booleanunloadViewClass(String className) Removes a view class previously registered vialoadViewClass(String).protected voidunregisterRoute(Class<? extends View<?>> viewClass) Unregisters the route and route aliases declared on the given view class.
-
Field Details
-
ENTITY_VIEW_PATTERN
-
DETAIL_VIEW_SUFFIX
- See Also:
-
LIST_VIEW_SUFFIX
- See Also:
-
LOOKUP_VIEW_SUFFIX
- See Also:
-
metadata
-
resources
-
classManager
-
properties
-
extendedEntities
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
metadataReaderFactory
-
vaadinContext
protected com.vaadin.flow.server.VaadinContext vaadinContext -
views
-
-
primaryListViews
-
primaryLookupViews
-
configurations
-
initialized
protected volatile boolean initialized -
routeConfiguration
protected com.vaadin.flow.router.RouteConfiguration routeConfiguration -
viewControllersConfigurationSorter
-
viewTemplateDefinitions
-
lock
-
-
Constructor Details
-
ViewRegistry
public ViewRegistry()
-
-
Method Details
-
setMetadata
-
setResources
-
setClassManager
-
setProperties
-
setExtendedEntities
-
setMetadataReaderFactory
@Autowired public void setMetadataReaderFactory(AnnotationScanMetadataReaderFactory metadataReaderFactory) -
setViewControllersConfigurationSorter
@Autowired public void setViewControllersConfigurationSorter(ViewControllersConfigurationSorter viewControllersConfigurationSorter) -
setViewTemplateDefinitions
Sets template-generated view definitions that should be exposed by the registry.- Parameters:
viewTemplateDefinitions- template view definitions
-
setConfigurations
@Autowired(required=false) public void setConfigurations(List<ViewControllersConfiguration> configurations) -
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
postConstruct
@PostConstruct protected void postConstruct() -
reset
public void reset()Make the registry to reload views on next request. -
checkInitialized
protected void checkInitialized() -
initIfNeeded
protected void initIfNeeded()Same ascheckInitialized()but assumes the caller holds the write lock. -
init
protected void init() -
loadViewConfigurations
protected void loadViewConfigurations() -
loadViewTemplateConfigurations
protected void loadViewTemplateConfigurations() -
registerTemplatePrimaryView
-
registerView
-
registerPrimaryDetailView
protected void registerPrimaryDetailView(ViewInfo viewInfo, org.springframework.core.type.AnnotationMetadata annotationMetadata) -
registerPrimaryListView
protected void registerPrimaryListView(ViewInfo viewInfo, org.springframework.core.type.AnnotationMetadata annotationMetadata) -
registerPrimaryLookupView
protected void registerPrimaryLookupView(ViewInfo viewInfo, org.springframework.core.type.AnnotationMetadata annotationMetadata) -
getAnnotationValue
-
loadClassMetadata
protected org.springframework.core.type.classreading.MetadataReader loadClassMetadata(String className) -
loadDefinedViewClass
-
findViewInfo
Returns view information by id.- Parameters:
id- view id as set in theViewControllerannotation- Returns:
- view's registration information
-
getViewInfo
Returns view information by id.- Parameters:
id- view id as set in theViewControllerannotation- Returns:
- view's registration information
- Throws:
NoSuchViewException- if the view with specified id is not registered
-
hasView
- Returns:
trueif the registry contains a view with provided id
-
getViewInfos
- Returns:
- registration info of all known views
-
getMetaClassViewId
-
getListViewId
Returns standard id of the list view for an entity, for exampleCustomer.list.- Parameters:
metaClass- entity metaclass
-
getLookupViewId
Returns standard id of the lookup view for an entity, for exampleCustomer.lookup.- Parameters:
metaClass- entity metaclass
-
getDetailViewId
Returns standard id of the detail view for an entity, for exampleCustomer.detail.- Parameters:
metaClass- entity metaclass
-
getDetailViewInfo
Returns detail view information by entity metaclass.- Parameters:
metaClass- entity metaclass- Returns:
- view's registration information
- Throws:
NoSuchViewException- if the detail view with the standard id is not registered for the entity
-
getDetailViewInfo
Returns detail view information by entity class.- Parameters:
entityClass- entity class- Returns:
- view's registration information
- Throws:
NoSuchViewException- if the detail view with the standard id is not registered for the entity
-
getDetailViewInfo
Returns detail view information by entity instance.- Parameters:
entity- entity instance- Returns:
- view's registration information
- Throws:
NoSuchViewException- if the detail view with the standard id is not registered for the entity
-
getListViewInfo
Returns list or lookup view information by entity metaclass.- Parameters:
metaClass- entity metaclass- Returns:
- view's registration information
- Throws:
NoSuchViewException- if the list or lookup view with the standard id is not registered for the entity
-
getListViewInfo
Returns list or lookup view information by entity class.- Parameters:
entityClass- entity class- Returns:
- view's registration information
- Throws:
NoSuchViewException- if the list or lookup view with the standard id is not registered for the entity
-
getListViewInfo
Returns list or lookup view information by entity instance.- Parameters:
entity- entity instance- Returns:
- view's registration information
- Throws:
NoSuchViewException- if the list or lookup view with the standard id is not registered for the entity
-
getLookupViewInfo
Returns lookup or list view information by entity metaclass.- Parameters:
metaClass- entity metaclass- Returns:
- view's registration information
- Throws:
NoSuchViewException- if the lookup or list view with the standard id is not registered for the entity
-
getLookupViewInfo
Returns lookup or list view information by entity class.- Parameters:
entityClass- entity class- Returns:
- view's registration information
- Throws:
NoSuchViewException- if the lookup or list view with the standard id is not registered for the entity
-
getLookupViewInfo
Returns lookup or list view information by entity instance.- Parameters:
entity- entity instance- Returns:
- view's registration information
- Throws:
NoSuchViewException- if the lookup or list view with the standard id is not registered for the entity
-
getAvailableListViewId
Returns list view id by entity metaclass determined by the following procedure:- If a view annotated with @
PrimaryListViewexists, its id is used - Otherwise, a view with
<entity_name>.listid is used
- Parameters:
metaClass- entity metaclass- Returns:
- view's id
- If a view annotated with @
-
getAvailableLookupViewId
Returns lookup view id by entity metaclass determined by the following procedure:- If a view annotated with @
PrimaryLookupViewexists, its id is used - Otherwise, if a view with
<entity_name>.lookupid exists, its id is used - Otherwise, if a view annotated with @
PrimaryListViewexists, its id is used - Otherwise, a view with
<entity_name>.listid is used
- Parameters:
metaClass- entity metaclass- Returns:
- view's id
- If a view annotated with @
-
getListViewIdInternal
-
getLookupViewIdInternal
-
loadViewClass
Reloads a view class for hot-deploy.- Parameters:
className- view class name
-
unloadViewClass
Removes a view class previously registered vialoadViewClass(String). Removes the explicitViewControllersConfigurationentry holding the class, unregisters the view's Vaadin route, and resets the registry so the next access reloads view definitions.- Parameters:
className- fully qualified controller class name- Returns:
trueif a matching configuration was found and removed
-
setPrimaryListView
Registers a primary list view for the given entity class.- Parameters:
entityClass- entity classviewInfo- view info to associate as the primary list view
-
setPrimaryDetailView
Registers a primary detail view for the given entity class.- Parameters:
entityClass- entity classviewInfo- view info to associate as the primary detail view
-
hasPrimaryListView
Returnstrueif a primary list view is registered for the given entity class.- Parameters:
entityClass- entity class
-
hasPrimaryDetailView
Returnstrueif a primary detail view is registered for the given entity class.- Parameters:
entityClass- entity class
-
removePrimaryListView
Removes the primary list view registration for the given entity class.- Parameters:
entityClass- entity class- Returns:
trueif a primary list view was registered for the entity class
-
removePrimaryDetailView
Removes the primary detail view registration for the given entity class.- Parameters:
entityClass- entity class- Returns:
trueif a primary detail view was registered for the entity class
-
registerViewRoutes
public void registerViewRoutes()Iterates over all registered views and registers their routes. -
registerRoute
Registers route for the passed viewInfo instance.- Parameters:
viewInfo- a viewInfo instance to register route
-
registerRoute
Registers route for the passed view class.- Parameters:
viewClass- a view class to register route
-
registerRoute
-
unregisterRoute
Unregisters the route and route aliases declared on the given view class.- Parameters:
viewClass- a view class whose routes should be removed
-
getParentChain
-
getDefaultParentChain
-
getRouteConfiguration
public com.vaadin.flow.router.RouteConfiguration getRouteConfiguration()Куегкты the route configuration associated with the registry.- Returns:
- the route configuration instance
- Throws:
IllegalStateException- if the route configuration is not initialized
-
setRouteConfiguration
public void setRouteConfiguration(com.vaadin.flow.router.RouteConfiguration routeConfiguration) Sets the route configuration for the view registry.- Parameters:
routeConfiguration- the route configuration to set
-