Package com.vaadin.copilot
Class RouteCreator
java.lang.Object
com.vaadin.copilot.RouteCreator
Handles creation of views for new routes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateFlowView(String title, String route, Path qualifiedClassNamePath, AccessRequirement accessRequirement, Class<?> layoutClass, String templateFileName, String templateData, Boolean addToMenu, String menuIcon) Creates a Flow view for the given route using the given access requirement.voidcreateHillaView(String title, String route, Path filePath, AccessRequirement accessRequirement, String templateFileName, String templateData, boolean addToMenu) Creates a Hilla view for the given route using the given access requirement.static StringgetNewClassPackageNameRelative(String framework, com.vaadin.flow.server.VaadinSession session) Returns the folder where new views are created, relative to the source folder of the framework, in the form the new view dialog suggests it.static PathgetNewFilePath(String framework, String qualifiedClassNameOrViewFile, com.vaadin.flow.server.VaadinSession session)
-
Constructor Details
-
RouteCreator
public RouteCreator(com.vaadin.flow.server.VaadinSession vaadinSession)
-
-
Method Details
-
createFlowView
public void createFlowView(String title, String route, Path qualifiedClassNamePath, AccessRequirement accessRequirement, Class<?> layoutClass, String templateFileName, String templateData, Boolean addToMenu, String menuIcon) throws IOException, RouteDuplicatedException Creates a Flow view for the given route using the given access requirement.- Parameters:
title- the title of the viewroute- the path to create a view forqualifiedClassNamePath- qualified class name path that is used to create the file e.g. com.vaadin.org.MainView.javaaccessRequirement- the access requirement for the viewlayoutClass- the layout class to use, ornullto not use a layouttemplateFileName- the file name to select the template of viewtemplateData- data for the selected template, ornull- Throws:
IOException- if the view file could not be createdRouteDuplicatedException
-
createHillaView
public void createHillaView(String title, String route, Path filePath, AccessRequirement accessRequirement, String templateFileName, String templateData, boolean addToMenu) throws RouteDuplicatedException, IOException Creates a Hilla view for the given route using the given access requirement.- Parameters:
title- the title of the viewroute- the path to create a view forfilePath- the folder to add viewaccessRequirement- the access requirement for the viewtemplateFileName- the selected template for the viewtemplateData- data for the selected template, ornulladdToMenu-- Throws:
RouteDuplicatedExceptionIOException
-
getNewClassPackageNameRelative
public static String getNewClassPackageNameRelative(String framework, com.vaadin.flow.server.VaadinSession session) Returns the folder where new views are created, relative to the source folder of the framework, in the form the new view dialog suggests it. The result is the same on every operating system.- Parameters:
framework-"flow"or"hilla"session- the Vaadin session- Returns:
- for Flow, the package name joined with
.(e.g.com.example.views); for Hilla, the folder relative to the frontend folder joined with/(e.g.views/admin) - Throws:
IllegalArgumentException- if the framework is unknown
-
getNewFilePath
-