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)
    • 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()
    • init

      protected void init()
    • loadViewConfigurations

      protected void loadViewConfigurations()
    • 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
    • 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
    • getParentChain

      protected List<Class<? extends com.vaadin.flow.router.RouterLayout>> getParentChain(com.vaadin.flow.router.Route route, 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()
    • setRouteConfiguration

      public void setRouteConfiguration(com.vaadin.flow.router.RouteConfiguration routeConfiguration)