Package com.vaadin.copilot
Class CopilotCommand
java.lang.Object
com.vaadin.copilot.CopilotCommand
- Direct Known Subclasses:
AccessibilityCheckerMessageHandler,AICommandHandler,AICreateFieldsHandler,AnalyticsInterceptor,ApplicationInitializer,ApplicationUserSwitchHandler,ComponentInfoHandler,CreateLumoThemeVariablesHandler,DevSetupHandler,DocsHandler,ErrorHandler,FeedbackHandler,GenerateTestsHandler,HotswapDownloadHandler,I18nHandler,IdeHandler,IdePluginCommandHandler,JavaParserHandler,JavaRewriteHandler,LitTemplateHandler,MachineConfigurationHandler,OpenComponentInIDE,PreviewHandler,ProjectFileHandler,ProjectInfoHandler,ProjectStateConfigurationHandler,RouteHandler,TestBenchRecordHandler,ThemeEditorMessageHandler,UiServiceHandler,UserInfoHandler,VaadinVersionUpdateHandler
Base class for all classes that handle Copilot commands from the browser.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ThreadLocal<com.vaadin.flow.server.VaadinSession> Used to pass the session to all commands without having to add it to all constructors but so it is still available in constructors.static final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanBeParallelCommand(String command) Checks if given command can be handled asynchronously.Shorthand for getting the ProjectFileManager instance.protected com.vaadin.flow.server.VaadinServletContextGets the vaadin context.protected com.vaadin.flow.server.VaadinSessionGets the vaadin session.voidhandleConnect(com.vaadin.base.devserver.DevToolsInterface devToolsInterface) Called when a new browser (tab) connects to the server.abstract booleanhandleMessage(String command, com.fasterxml.jackson.databind.JsonNode data, com.vaadin.base.devserver.DevToolsInterface devToolsInterface) Called whenever there is a message from the browser.
-
Field Details
-
KEY_REQ_ID
- See Also:
-
KEY_CANCEL_REQ_ID
- See Also:
-
currentSession
Used to pass the session to all commands without having to add it to all constructors but so it is still available in constructors.
-
-
Constructor Details
-
CopilotCommand
protected CopilotCommand()
-
-
Method Details
-
handleMessage
public abstract boolean handleMessage(String command, com.fasterxml.jackson.databind.JsonNode data, com.vaadin.base.devserver.DevToolsInterface devToolsInterface) Called 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.- 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
-
handleConnect
public void handleConnect(com.vaadin.base.devserver.DevToolsInterface devToolsInterface) Called when a new browser (tab) connects to the server. Override to add logic that should run on every connect.- Parameters:
devToolsInterface- the devtools interface for the new connection
-
canBeParallelCommand
Checks if given command can be handled asynchronously. If the handler can't be asynchronous at all, it can return false always. But if you want to handle one or more commands asynchronously, you should specify the exact command to prevent handling commands that are not part of the handler as asynchronous.- Parameters:
command- the command to check- Returns:
- true if the command can be handled by this command handler
-
getProjectFileManager
Shorthand for getting the ProjectFileManager instance.- Returns:
- the ProjectFileManager instance
-
getVaadinSession
protected com.vaadin.flow.server.VaadinSession getVaadinSession()Gets the vaadin session. -
getVaadinContext
protected com.vaadin.flow.server.VaadinServletContext getVaadinContext()Gets the vaadin context.- Returns:
- the vaadin context
-