Class RouteCreator

java.lang.Object
com.vaadin.copilot.RouteCreator

public class RouteCreator extends Object
Handles creation of views for new routes.
  • 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 view
      route - the path to create a view for
      qualifiedClassNamePath - qualified class name path that is used to create the file e.g. com.vaadin.org.MainView.java
      accessRequirement - the access requirement for the view
      layoutClass - the layout class to use, or null to not use a layout
      templateFileName - the file name to select the template of view
      templateData - data for the selected template, or null
      Throws:
      IOException - if the view file could not be created
      RouteDuplicatedException
    • 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 view
      route - the path to create a view for
      filePath - the folder to add view
      accessRequirement - the access requirement for the view
      templateFileName - the selected template for the view
      templateData - data for the selected template, or null
      addToMenu -
      Throws:
      RouteDuplicatedException
      IOException
    • 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

      public static Path getNewFilePath(String framework, String qualifiedClassNameOrViewFile, com.vaadin.flow.server.VaadinSession session)