Class JavaDataProviderHandler

java.lang.Object
com.vaadin.copilot.javarewriter.JavaDataProviderHandler

public class JavaDataProviderHandler extends Object
Handler for data provider changes. Any updates on component which are generated from DataProvider is handled in this class.
  • Constructor Details

    • JavaDataProviderHandler

      public JavaDataProviderHandler(ProjectManager projectManager, ComponentTypeAndSourceLocation typeAndSourceLocation) throws IOException
      Reads source file which is found from typeAndSourceLocation
      Parameters:
      projectManager - Project manager for handling file operations
      typeAndSourceLocation - of the component
      Throws:
      IOException - when file read operation fails
  • Method Details

    • isDataProviderItemChange

      public static boolean isDataProviderItemChange(ComponentTypeAndSourceLocation componentTypeAndSourceLocation)
      Check for attach and create location is generated from DataProvider
      Parameters:
      componentTypeAndSourceLocation - component type and source location
      Returns:
      true if data provider operation, false otherwise
    • handleSetComponentProperty

      public JavaDataProviderHandler.JavaDataProviderHandlerResult handleSetComponentProperty(String property, String value)
      Replaces the value of items from data provider
      Parameters:
      property - only label is support for now which is sent from client
      value - to replace
      Returns:
      Final result or exception if any occurs
    • handleDataStatementsAndClearDataProps

      public static void handleDataStatementsAndClearDataProps(com.github.javaparser.ast.CompilationUnit compilationUnit, com.github.javaparser.ast.body.VariableDeclarator parent, JavaComponent javaComponent, InsertionPoint insertionPoint, String dataEntityRecordName)
      Creates the data statements when adding a new template e.g.setItems, setItemLabelGenerator etc... and clears children or props if they are definition of data instead of real components.
      Parameters:
      compilationUnit - the compilation unit to look for the record definitions.
      parent - Component variable that has items
      javaComponent - component that has children and properties.
      insertionPoint - to insert new method calls