Class AiChatAction<A extends AiChatAction<A,E,C>,E extends AiChatMessage,C extends AiChat<E>>

Type Parameters:
A - the concrete action type (self-type, for fluent setters)
E - the chat's message type
C - the AiChat type this action targets
All Implemented Interfaces:
ExecutableAction, TargetAction<C>, Action, HasShortcutCombination

public abstract class AiChatAction<A extends AiChatAction<A,E,C>,E extends AiChatMessage,C extends AiChat<E>> extends SecuredBaseAction<A> implements TargetAction<C>, ExecutableAction
An abstract base class for actions that can be associated with an AiChat.

The action reaches its chat through getTarget(); the target is wired by the chat's actions support when the action is added, and cleared when it is removed. Business logic goes in ExecutableAction.execute(); a custom ActionPerformedEvent listener overrides it.

  • Field Details

    • target

      protected @Nullable C extends AiChat<E> target
  • Constructor Details

    • AiChatAction

      public AiChatAction(String id)
      Creates the action with the given id.
      Parameters:
      id - the action id
  • Method Details

    • initAction

      protected void initAction()
      Hook for subclasses to set defaults (icon, text, variant). Empty by default.
    • getTarget

      public @Nullable C getTarget()
      Specified by:
      getTarget in interface TargetAction<A extends AiChatAction<A,E,C>>
    • setTarget

      public void setTarget(@Nullable C target)
      Specified by:
      setTarget in interface TargetAction<A extends AiChatAction<A,E,C>>
    • setTargetInternal

      protected void setTargetInternal(@Nullable C target)
    • actionPerform

      public void actionPerform(com.vaadin.flow.component.Component component)
      Description copied from interface: Action
      Executes action logic.
      Specified by:
      actionPerform in interface Action
      Overrides:
      actionPerform in class ObservableBaseAction<A extends AiChatAction<A,E,C>>
      Parameters:
      component - Component that triggered this action
    • withTarget

      public A withTarget(@Nullable C target)
      Sets the chat this action operates on and returns this action, for fluent configuration.
      Parameters:
      target - the chat to target, or null to clear
      Returns:
      this action
    • checkTarget

      protected void checkTarget()