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 Details

  • Constructor Details

    • ViewRegistry

      public ViewRegistry()
  • Method Details

    • setMetadata

      @Autowired public void setMetadata(Metadata metadata)
    • setResources

      @Autowired public void setResources(Resources resources)
    • setClassManager

      @Autowired public void setClassManager(ClassManager classManager)
    • setProperties

      @Autowired public void setProperties(UiProperties properties)
    • setExtendedEntities

      @Autowired public void setExtendedEntities(ExtendedEntities extendedEntities)
    • setMetadataReaderFactory

      @Autowired public void setMetadataReaderFactory(AnnotationScanMetadataReaderFactory metadataReaderFactory)
    • setViewControllersConfigurationSorter

      @Autowired public void setViewControllersConfigurationSorter(ViewControllersConfigurationSorter viewControllersConfigurationSorter)
    • setViewTemplateDefinitions

      @Autowired public void setViewTemplateDefinitions(ViewTemplateDefinitions viewTemplateDefinitions)
      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:
      setApplicationContext in interface org.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 as checkInitialized() but assumes the caller holds the write lock.
    • init

      protected void init()
    • loadViewConfigurations

      protected void loadViewConfigurations()
    • loadViewTemplateConfigurations

      protected void loadViewTemplateConfigurations()
    • registerTemplatePrimaryView

      protected void registerTemplatePrimaryView(ViewTemplateDefinition definition, ViewInfo viewInfo)
    • registerView

      protected void registerView(String id, ViewInfo viewInfo)
    • 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

      protected Optional<Class<?>> getAnnotationValue(org.springframework.core.type.AnnotationMetadata annotationMetadata, Class<?> annotationClass)
    • loadClassMetadata

      protected org.springframework.core.type.classreading.MetadataReader loadClassMetadata(String className)
    • loadDefinedViewClass

      protected Class<? extends View<?>> loadDefinedViewClass(String className)
    • findViewInfo

      public Optional<ViewInfo> findViewInfo(String id)
      Returns view information by id.
      Parameters:
      id - view id as set in the ViewController annotation
      Returns:
      view's registration information
    • getViewInfo

      public ViewInfo getViewInfo(String id)
      Returns view information by id.
      Parameters:
      id - view id as set in the ViewController annotation
      Returns:
      view's registration information
      Throws:
      NoSuchViewException - if the view with specified id is not registered
    • hasView

      public boolean hasView(String id)
      Returns:
      true if the registry contains a view with provided id
    • getViewInfos

      public Collection<ViewInfo> getViewInfos()
      Returns:
      registration info of all known views
    • getMetaClassViewId

      protected String getMetaClassViewId(MetaClass metaClass, String suffix)
    • getListViewId

      public String getListViewId(MetaClass metaClass)
      Returns standard id of the list view for an entity, for example Customer.list.
      Parameters:
      metaClass - entity metaclass
    • getLookupViewId

      public String getLookupViewId(MetaClass metaClass)
      Returns standard id of the lookup view for an entity, for example Customer.lookup.
      Parameters:
      metaClass - entity metaclass
    • getDetailViewId

      public String getDetailViewId(MetaClass metaClass)
      Returns standard id of the detail view for an entity, for example Customer.detail.
      Parameters:
      metaClass - entity metaclass
    • getDetailViewInfo

      public ViewInfo getDetailViewInfo(MetaClass metaClass)
      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

      public ViewInfo getDetailViewInfo(Class<?> entityClass)
      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

      public ViewInfo getDetailViewInfo(Object entity)
      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

      public ViewInfo getListViewInfo(MetaClass metaClass)
      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

      public ViewInfo getListViewInfo(Class<?> entityClass)
      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

      public ViewInfo getListViewInfo(Object entity)
      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

      public ViewInfo getLookupViewInfo(MetaClass metaClass)
      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

      public ViewInfo getLookupViewInfo(Class<?> entityClass)
      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

      public ViewInfo getLookupViewInfo(Object entity)
      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

      public String getAvailableListViewId(MetaClass metaClass)
      Returns list view id by entity metaclass determined by the following procedure:
      1. If a view annotated with @PrimaryListView exists, its id is used
      2. Otherwise, a view with <entity_name>.list id is used
      Parameters:
      metaClass - entity metaclass
      Returns:
      view's id
    • getAvailableLookupViewId

      public String getAvailableLookupViewId(MetaClass metaClass)
      Returns lookup view id by entity metaclass determined by the following procedure:
      1. If a view annotated with @PrimaryLookupView exists, its id is used
      2. Otherwise, if a view with <entity_name>.lookup id exists, its id is used
      3. Otherwise, if a view annotated with @PrimaryListView exists, its id is used
      4. Otherwise, a view with <entity_name>.list id is used
      Parameters:
      metaClass - entity metaclass
      Returns:
      view's id
    • getListViewIdInternal

      protected String getListViewIdInternal(MetaClass metaClass)
    • getLookupViewIdInternal

      protected String getLookupViewIdInternal(MetaClass metaClass)
    • loadViewClass

      public void loadViewClass(String className)
      Reloads a view class for hot-deploy.
      Parameters:
      className - view class name
    • unloadViewClass

      public boolean unloadViewClass(String className)
      Removes a view class previously registered via loadViewClass(String). Removes the explicit ViewControllersConfiguration entry 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:
      true if a matching configuration was found and removed
    • setPrimaryListView

      public void setPrimaryListView(Class<?> entityClass, ViewInfo viewInfo)
      Registers a primary list view for the given entity class.
      Parameters:
      entityClass - entity class
      viewInfo - view info to associate as the primary list view
    • setPrimaryDetailView

      public void setPrimaryDetailView(Class<?> entityClass, ViewInfo viewInfo)
      Registers a primary detail view for the given entity class.
      Parameters:
      entityClass - entity class
      viewInfo - view info to associate as the primary detail view
    • hasPrimaryListView

      public boolean hasPrimaryListView(Class<?> entityClass)
      Returns true if a primary list view is registered for the given entity class.
      Parameters:
      entityClass - entity class
    • hasPrimaryDetailView

      public boolean hasPrimaryDetailView(Class<?> entityClass)
      Returns true if a primary detail view is registered for the given entity class.
      Parameters:
      entityClass - entity class
    • removePrimaryListView

      public boolean removePrimaryListView(Class<?> entityClass)
      Removes the primary list view registration for the given entity class.
      Parameters:
      entityClass - entity class
      Returns:
      true if a primary list view was registered for the entity class
    • removePrimaryDetailView

      public boolean removePrimaryDetailView(Class<?> entityClass)
      Removes the primary detail view registration for the given entity class.
      Parameters:
      entityClass - entity class
      Returns:
      true if a primary detail view was registered for the entity class
    • registerViewRoutes

      public void registerViewRoutes()
      Iterates over all registered views and registers their routes.
    • registerRoute

      public void registerRoute(ViewInfo viewInfo)
      Registers route for the passed viewInfo instance.
      Parameters:
      viewInfo - a viewInfo instance to register route
    • registerRoute

      public void registerRoute(Class<? extends View<?>> viewClass)
      Registers route for the passed view class.
      Parameters:
      viewClass - a view class to register route
    • registerRoute

      protected void registerRoute(String routePath, com.vaadin.flow.router.RouteConfiguration routeConfiguration, Class<? extends com.vaadin.flow.router.RouterLayout> layout, Class<? extends View<?>> viewClass)
    • unregisterRoute

      protected void unregisterRoute(Class<? extends View<?>> viewClass)
      Unregisters the route and route aliases declared on the given view class.
      Parameters:
      viewClass - a view class whose routes should be removed
    • getParentChain

      protected List<Class<? extends com.vaadin.flow.router.RouterLayout>> getParentChain(Class<? extends com.vaadin.flow.router.RouterLayout> layout, List<Class<? extends com.vaadin.flow.router.RouterLayout>> defaultChain)
    • getDefaultParentChain

      protected List<Class<? extends com.vaadin.flow.router.RouterLayout>> 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