com.vaadin.flow.internal.menu.
Class MenuRegistry
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
For internal use only.
static void
collectAndAddServerMenuItems
(RouteConfiguration routeConfiguration, List<BeforeEnterListener> accessControls, Map<String, AvailableViewInfo> menuRoutes) Collect all active and accessible server menu items.
static void
collectAndAddServerMenuItems
(RouteConfiguration routeConfiguration, Map<String, AvailableViewInfo> menuRoutes) Collect all active and accessible server menu items.
static Map<String,
AvailableViewInfo> collectClientMenuItems
(boolean filterClientViews, AbstractConfiguration configuration) Collect all available client routes.
static Map<String,
AvailableViewInfo> collectClientMenuItems
(boolean filterClientViews, AbstractConfiguration configuration, VaadinRequest vaadinRequest) Collect all available client routes.
static Map<String,
AvailableViewInfo> Collect views with menu annotation for automatic menu population.
static List<AvailableViewInfo>
Collect ordered list of views with menu annotation for automatic menu population.
static List<AvailableViewInfo>
collectMenuItemsList
(Locale locale) Collect ordered list of views with menu annotation for automatic menu population.
static ClassLoader
Get the current thread ContextClassLoader.
static Map<String,
AvailableViewInfo> getClientRoutes
(boolean excludeLayouts) Get available client routes, optionally excluding any layout targets.
getClientRoutes
(boolean filterClientViews, AbstractConfiguration configuration) Get registered client routes.
static Map<String,
AvailableViewInfo> getMenuItems
(boolean filterClientViews) Collect views with menu annotation for automatic menu population.
static String
Get page title for route or simple name if no PageTitle is set.
static URL
getViewsJsonAsResource
(AbstractConfiguration configuration) Load views json as a resource.
static boolean
hasClientRoute
(String route) See if there is a client route available for given route path.
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.
static boolean
hasHillaMainLayout
(AbstractConfiguration configuration) Determines whether the application contains a Hilla automatic main layout.
-
Field Details
-
FILE_ROUTES_JSON_NAME
See Also:
-
FILE_ROUTES_JSON_PROD_PATH
See Also:
-
-
Constructor Details
-
MenuRegistry
public MenuRegistry()
-
-
Method Details
-
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
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
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
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 statusReturns:
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 usemenuRoutes
- 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 useaccessControls
- extra access controls if neededmenuRoutes
- map to add route data into -
getTitle
Get page title for route or simple name if no PageTitle is set.
Parameters:
target
- route class to get title forReturns:
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 statusconfiguration
- application configurationReturns:
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 statusconfiguration
- application configurationReturns:
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 statusconfiguration
- application configurationvaadinRequest
- current requestReturns:
map of registered routes
-
hasHillaMainLayout
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
- theAbstractConfiguration
containing the application configurationReturns:
true
if a Hilla automatic main layout is present in the configuration,false
otherwise - only one single root element is present in
-
getViewsJsonAsResource
Load views json as a resource.
Parameters:
configuration
- current application configurationReturns:
URL to json resource
-
getClassLoader
Get the current thread ContextClassLoader.
Note! public for testing.
Returns:
ClassLoader
-
hasClientRoute
See if there is a client route available for given route path.
Parameters:
route
- route path to checkReturns:
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
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 checkexcludeLayouts
- true to exclude layouts from the check, false to include themReturns:
true if a client route is found.
-
getClientRoutes
Get available client routes, optionally excluding any layout targets.
Parameters:
excludeLayouts
- true to exclude layouts from the check, false to include themReturns:
Map of client routes available
-