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

  • 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 JavaSource handleSetComponentProperty(JavaFileSourceProvider javaFileSourceProvider, String property, String value) throws IOException
      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:
      The changed source
      Throws:
      IOException - is thrown when file operation fails
    • handleDataStatementsAndClearDataProps

      public static void handleDataStatementsAndClearDataProps(com.github.javaparser.ast.CompilationUnit compilationUnit, JavaDataProviderHandler.FieldOrVariable 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 - The parent variable that has items
      javaComponent - component that has children and properties.
      insertionPoint - to insert new method calls