com.vaadin.flow.internal.menu.

Class MenuRegistry

java.lang.Object
com.vaadin.flow.internal.menu.MenuRegistry
public class MenuRegistry extends Object

Registry for getting the menu items available for the current state of the application. Only returns views that are accessible at the moment and leaves out routes that require path parameters.

For internal use only. May be renamed or removed in a future release.

  • Field Details

  • Constructor Details

    • MenuRegistry

      public MenuRegistry()
  • Method Details

    • collectMenuItems

      public static Map<String,AvailableViewInfo> collectMenuItems()

      Collect views with menu annotation for automatic menu population. All client views are collected and any accessible server views.

      Returns:

      routes with view information

    • collectMenuItemsList

      public static List<AvailableViewInfo> collectMenuItemsList()

      Collect ordered list of views with menu annotation for automatic menu population. All client views are collected and any accessible server views.

      Returns:

      ordered routes with view information

    • collectMenuItemsList

      public static List<AvailableViewInfo> collectMenuItemsList(Locale locale)

      Collect ordered list of views with menu annotation for automatic menu population. All client views are collected and any accessible server views.

      Parameters:

      locale - locale to use for ordering. null for default locale.

      Returns:

      ordered routes with view information

    • getMenuItems

      public static Map<String,AvailableViewInfo> getMenuItems(boolean filterClientViews)

      Collect views with menu annotation for automatic menu population. All client views are collected and any accessible server views.

      Parameters:

      filterClientViews - true to filter routes by authentication status

      Returns:

      routes with view information

    • collectAndAddServerMenuItems

      public static void collectAndAddServerMenuItems(RouteConfiguration routeConfiguration, Map<String,AvailableViewInfo> menuRoutes)

      Collect all active and accessible server menu items.

      Parameters:

      routeConfiguration - routeConfiguration to use

      menuRoutes - map to add route data into

    • collectAndAddServerMenuItems

      public static void collectAndAddServerMenuItems(RouteConfiguration routeConfiguration, List<BeforeEnterListener> accessControls, Map<String,AvailableViewInfo> menuRoutes)

      Collect all active and accessible server menu items.

      Parameters:

      routeConfiguration - routeConfiguration to use

      accessControls - extra access controls if needed

      menuRoutes - map to add route data into

    • getTitle

      public static String getTitle(Class<? extends Component> target)

      Get page title for route or simple name if no PageTitle is set.

      Parameters:

      target - route class to get title for

      Returns:

      title to use for route

    • collectClientMenuItems

      public static Map<String,AvailableViewInfo> collectClientMenuItems(boolean filterClientViews, AbstractConfiguration configuration)

      Collect all available client routes.

      Parameters:

      filterClientViews - true to filter routes by authentication status

      configuration - application configuration

      Returns:

      map of registered routes

    • getClientRoutes

      public static List<String> getClientRoutes(boolean filterClientViews, AbstractConfiguration configuration)

      Get registered client routes. Possible to have all routes or only accessible routes.

      Parameters:

      filterClientViews - true to filter routes by authentication status

      configuration - application configuration

      Returns:

      list of available client routes

    • collectClientMenuItems

      public static Map<String,AvailableViewInfo> collectClientMenuItems(boolean filterClientViews, AbstractConfiguration configuration, VaadinRequest vaadinRequest)

      Collect all available client routes.

      Parameters:

      filterClientViews - true to filter routes by authentication status

      configuration - application configuration

      vaadinRequest - current request

      Returns:

      map of registered routes

    • hasHillaMainLayout

      public static boolean hasHillaMainLayout(AbstractConfiguration configuration)

      Determines whether the application contains a Hilla automatic main layout.

      This method detects only a top-level main layout, when the following conditions are met:

      • only one single root element is present in file-routes.json
      • this element has no or blank route parameter
      • this element has non-null children array, which may or may not be empty

      This method doesn't check nor does it detect the nested layouts, i.e. that are not root entries.

      Parameters:

      configuration - the AbstractConfiguration containing the application configuration

      Returns:

      true if a Hilla automatic main layout is present in the configuration, false otherwise

    • getViewsJsonAsResource

      public static URL getViewsJsonAsResource(AbstractConfiguration configuration)

      Load views json as a resource.

      Parameters:

      configuration - current application configuration

      Returns:

      URL to json resource

    • getClassLoader

      public static ClassLoader getClassLoader()

      Get the current thread ContextClassLoader.

      Note! public for testing.

      Returns:

      ClassLoader

    • hasClientRoute

      public static boolean hasClientRoute(String route)

      See if there is a client route available for given route path.

      Parameters:

      route - route path to check

      Returns:

      true if a client route is found.

    • clearFileRoutesCache

      public static void clearFileRoutesCache()

      For internal use only.

      Clears file routes cache when running in production. Only used in tests and should not be needed in projects.

    • hasClientRoute

      public static boolean hasClientRoute(String route, boolean excludeLayouts)

      See if there is a client route available for given route path, optionally excluding layouts (routes with children) from the check.

      Parameters:

      route - route path to check

      excludeLayouts - true to exclude layouts from the check, false to include them

      Returns:

      true if a client route is found.

    • getClientRoutes

      public static Map<String,AvailableViewInfo> getClientRoutes(boolean excludeLayouts)

      Get available client routes, optionally excluding any layout targets.

      Parameters:

      excludeLayouts - true to exclude layouts from the check, false to include them

      Returns:

      Map of client routes available