Package com.vaadin.copilot.javarewriter
Class JavaDataProviderHandler
java.lang.Object
com.vaadin.copilot.javarewriter.JavaDataProviderHandler
Handler for data provider changes. Any updates on component which are generated from DataProvider is handled in this
class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordReturns the file that is changed along with the new result -
Constructor Summary
ConstructorsConstructorDescriptionJavaDataProviderHandler(ProjectManager projectManager, ComponentTypeAndSourceLocation typeAndSourceLocation) Reads source file which is found from typeAndSourceLocation -
Method Summary
Modifier and TypeMethodDescriptionstatic voidhandleDataStatementsAndClearDataProps(com.github.javaparser.ast.CompilationUnit compilationUnit, com.github.javaparser.ast.body.VariableDeclarator parentVarDec, JavaComponent javaComponent, InsertionPoint insertionPoint, String dataEntityRecordName) Creates the data statements when adding a new template e.g.setItems,setItemLabelGeneratoretc...handleSetComponentProperty(String property, String value) Replaces the value of items from data providerstatic booleanisDataProviderItemChange(ComponentTypeAndSourceLocation componentTypeAndSourceLocation) Check for attach and create location is generated from DataProvider
-
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 operationstypeAndSourceLocation- 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 clientvalue- 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 parentVarDec, JavaComponent javaComponent, InsertionPoint insertionPoint, String dataEntityRecordName) Creates the data statements when adding a new template e.g.setItems,setItemLabelGeneratoretc... 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.parentVarDec- Component variable that has itemsjavaComponent- component that has children and properties.insertionPoint- to insert new method calls
-