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
Modifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContext
protected ClassManager
protected List<ViewControllersConfiguration>
static final String
static final Pattern
protected ExtendedEntities
protected boolean
static final String
protected ReadWriteLock
static final String
protected Metadata
protected AnnotationScanMetadataReaderFactory
protected FlowuiProperties
protected Resources
protected com.vaadin.flow.router.RouteConfiguration
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
findViewInfo
(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 @PrimaryListView
exists, its id is used Otherwise, a view with<entity_name>.list
id is usedgetAvailableLookupViewId
(MetaClass metaClass) Returns lookup view id by entity metaclass determined by the following procedure: If a view annotated with @PrimaryLookupView
exists, its id is used Otherwise, if a view with<entity_name>.lookup
id exists, its id is used Otherwise, if a view annotated with @PrimaryListView
exists, its id is used Otherwise, a view with<entity_name>.list
id 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 String
getListViewIdInternal
(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 String
getLookupViewIdInternal
(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 String
getMetaClassViewId
(MetaClass metaClass, String suffix) getParentChain
(com.vaadin.flow.router.Route route, List<Class<? extends com.vaadin.flow.router.RouterLayout>> defaultChain) com.vaadin.flow.router.RouteConfiguration
getViewInfo
(String id) Returns view information by id.boolean
protected void
init()
protected org.springframework.core.type.classreading.MetadataReader
loadClassMetadata
(String className) loadDefinedViewClass
(String className) void
loadViewClass
(String className) Reloads a view class for hot-deploy.protected void
protected void
registerPrimaryDetailView
(ViewInfo viewInfo, org.springframework.core.type.AnnotationMetadata annotationMetadata) protected void
registerPrimaryListView
(ViewInfo viewInfo, org.springframework.core.type.AnnotationMetadata annotationMetadata) protected void
registerPrimaryLookupView
(ViewInfo viewInfo, org.springframework.core.type.AnnotationMetadata annotationMetadata) void
registerRoute
(ViewInfo viewInfo) Registers route for the passed viewInfo instance if needed.void
registerRoute
(Class<? extends View<?>> viewClass) Registers route for the passed view class if needed.protected void
registerView
(String id, ViewInfo viewInfo) void
Iterates over all registered views and registers their routes if needed.void
reset()
Make the registry to reload views on next request.void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setClassManager
(ClassManager classManager) void
setConfigurations
(List<ViewControllersConfiguration> configurations) void
setExtendedEntities
(ExtendedEntities extendedEntities) void
setMetadata
(Metadata metadata) void
setMetadataReaderFactory
(AnnotationScanMetadataReaderFactory metadataReaderFactory) void
setProperties
(FlowuiProperties properties) void
setResources
(Resources resources) void
setRouteConfiguration
(com.vaadin.flow.router.RouteConfiguration routeConfiguration)
-
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
-
views
-
-
primaryListViews
-
primaryLookupViews
-
configurations
-
initialized
protected volatile boolean initialized -
routeConfiguration
protected com.vaadin.flow.router.RouteConfiguration routeConfiguration -
lock
-
-
Constructor Details
-
ViewRegistry
public ViewRegistry()
-
-
Method Details
-
setMetadata
-
setResources
-
setClassManager
-
setProperties
-
setExtendedEntities
-
setMetadataReaderFactory
@Autowired public void setMetadataReaderFactory(AnnotationScanMetadataReaderFactory metadataReaderFactory) -
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:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
reset
public void reset()Make the registry to reload views on next request. -
checkInitialized
protected void checkInitialized() -
init
protected void init() -
loadViewConfigurations
protected void loadViewConfigurations() -
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 theViewController
annotation- Returns:
- view's registration information
-
getViewInfo
Returns view information by id.- Parameters:
id
- view id as set in theViewController
annotation- Returns:
- view's registration information
- Throws:
NoSuchViewException
- if the view with specified id is not registered
-
hasView
- Returns:
true
if 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 @
PrimaryListView
exists, its id is used - Otherwise, a view with
<entity_name>.list
id 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 @
PrimaryLookupView
exists, its id is used - Otherwise, if a view with
<entity_name>.lookup
id exists, its id is used - Otherwise, if a view annotated with @
PrimaryListView
exists, its id is used - Otherwise, a view with
<entity_name>.list
id 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
-
registerViewRoutes
public void registerViewRoutes()Iterates over all registered views and registers their routes if needed. Replaces route registration in case a newer view class is available. -
registerRoute
Registers route for the passed viewInfo instance if needed. Replaces route registration in case a newer view class is available.- Parameters:
viewInfo
- a viewInfo instance to register route
-
registerRoute
Registers route for the passed view class if needed. Replaces route registration in case a newer view class is available.- Parameters:
viewClass
- a view class to register route
-
getParentChain
-
getDefaultParentChain
-
getRouteConfiguration
public com.vaadin.flow.router.RouteConfiguration getRouteConfiguration() -
setRouteConfiguration
public void setRouteConfiguration(com.vaadin.flow.router.RouteConfiguration routeConfiguration)
-