Package com.vaadin.copilot
Class OptimisticDraftHandler
java.lang.Object
com.vaadin.copilot.CopilotCommand
com.vaadin.copilot.OptimisticDraftHandler
Commits browser-owned optimistic operations as one atomic source rewrite.
Operations are first applied to in-memory source models. Sources are saved only after every operation succeeds, allowing optimistic editors to provide an all-or-nothing submit action. New optimistic editors can add operation handlers here without becoming part of a source-editor command handler.
-
Field Summary
FieldsFields inherited from class com.vaadin.copilot.CopilotCommand
currentSession, KEY_CANCEL_REQ_ID, KEY_REQ_ID -
Constructor Summary
ConstructorsConstructorDescriptionOptimisticDraftHandler(JavaRewriteHandler javaRewriteHandler) Creates the optimistic draft command handler. -
Method Summary
Modifier and TypeMethodDescriptionstatic ComponentInfofindPreviewComponent(String draftId, String optimisticComponentId, Path projectRoot) Resolves an optimistic component exclusively from its persisted preview source.booleanhandleMessage(String command, tools.jackson.databind.JsonNode data, com.vaadin.base.devserver.DevToolsInterface devToolsInterface) Called whenever there is a message from the browser.Methods inherited from class com.vaadin.copilot.CopilotCommand
canBeParallelCommand, getProjectFileManager, getVaadinContext, getVaadinSession, handleConnect
-
Field Details
-
COMMAND
- See Also:
-
PREVIEW_OPERATION_COMMAND
- See Also:
-
PREVIEW_DIFF_COMMAND
- See Also:
-
-
Constructor Details
-
OptimisticDraftHandler
Creates the optimistic draft command handler.- Parameters:
javaRewriteHandler- the Java source rewrite operations used by the component editor
-
-
Method Details
-
handleMessage
public boolean handleMessage(String command, tools.jackson.databind.JsonNode data, com.vaadin.base.devserver.DevToolsInterface devToolsInterface) Description copied from class:CopilotCommandCalled whenever there is a message from the browser. Implementations should check if the command is for them, handle it and return true if the command was handled.- Specified by:
handleMessagein classCopilotCommand- Parameters:
command- the command to handledata- the data for the commanddevToolsInterface- the devtools interface for the connection- Returns:
- true if the command was handled, false otherwise
-
findPreviewComponent
public static ComponentInfo findPreviewComponent(String draftId, String optimisticComponentId, Path projectRoot) throws IOException Resolves an optimistic component exclusively from its persisted preview source. No browser DOM or operation-local metadata is retained server side between requests.- Throws:
IOException
-