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

public abstract class CopilotCommand extends Object
Base class for all classes that handle Copilot commands from the browser.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static 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 String
     
    static final String
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if given command can be handled asynchronously.
    Shorthand for getting the ProjectFileManager instance.
    protected com.vaadin.flow.server.VaadinServletContext
    Gets the vaadin context.
    protected com.vaadin.flow.server.VaadinSession
    Gets the vaadin session.
    void
    handleConnect(com.vaadin.base.devserver.DevToolsInterface devToolsInterface)
    Called when a new browser (tab) connects to the server.
    abstract boolean
    handleMessage(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 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • KEY_REQ_ID

      public static final String KEY_REQ_ID
      See Also:
    • KEY_CANCEL_REQ_ID

      public static final String KEY_CANCEL_REQ_ID
      See Also:
    • currentSession

      public static final ThreadLocal<com.vaadin.flow.server.VaadinSession> 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, tools.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 handle
      data - the data for the command
      devToolsInterface - 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

      public boolean canBeParallelCommand(String command)
      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

      public ProjectFileManager 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