Class AiConversationCard

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<com.vaadin.flow.component.card.Card>
io.jmix.aitoolsflowui.view.chathub.component.AiConversationCard
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, Serializable

public class AiConversationCard extends com.vaadin.flow.component.Composite<com.vaadin.flow.component.card.Card>
Outlined card for a single conversation in the chat hub's recent list and history side panel. Clicking the card body opens the conversation. The trash delete button is rendered only when a delete handler is supplied (history panel); without one the card shows no delete button.

Configure the card through the setters, then call build() to (re)assemble its content from the current property values.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
     
    protected static final String
     
    protected @Nullable String
     
    protected static final String
     
    protected static final String
     
    protected @Nullable String
     
    protected @Nullable Runnable
     
    protected com.vaadin.flow.component.Component
     
    protected static final String
     
    protected Runnable
     
    protected static final String
     
    protected String
     
    protected static final String
     
    protected static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    (Re)assembles the card content from the currently configured properties.
    protected com.vaadin.flow.component.orderedlayout.VerticalLayout
    createBody(com.vaadin.flow.component.Component icon, String title, Runnable openHandler, @Nullable String createdDate)
    Stacks the title row and (optionally) the date as the clickable body of the card.
    protected com.vaadin.flow.component.card.Card
     
    protected com.vaadin.flow.component.html.Span
    createDate(String createdDate)
     
    protected com.vaadin.flow.component.button.Button
    createDeleteButton(Runnable deleteHandler, @Nullable String deleteAriaLabel)
    Trash button.
    protected com.vaadin.flow.component.orderedlayout.HorizontalLayout
    createRow(com.vaadin.flow.component.orderedlayout.VerticalLayout body)
    Outer row that lets the clickable body grow and parks an optional delete button alongside it.
    protected com.vaadin.flow.component.html.Span
     
    protected com.vaadin.flow.component.orderedlayout.HorizontalLayout
    createTitleRow(com.vaadin.flow.component.Component icon, String title)
    Icon + title in one row, so the icon visually reads as a marker of the title rather than of the whole card.
    protected com.vaadin.flow.component.card.Card
     
    void
    setCreatedDate(@Nullable String createdDate)
    Sets the formatted creation date; when null the date line is omitted.
    void
    setDeleteAriaLabel(@Nullable String deleteAriaLabel)
    Sets the aria-label of the delete button.
    void
    setDeleteHandler(@Nullable Runnable deleteHandler)
    Sets the handler invoked by the delete button; when null no delete button is rendered.
    void
    setIcon(com.vaadin.flow.component.Component icon)
    Sets the title-row icon (required).
    void
    setOpenHandler(Runnable openHandler)
    Sets the handler invoked when the card body is clicked (required).
    void
    Sets the conversation title (required).

    Methods inherited from class com.vaadin.flow.component.Composite

    getChildren, getContent, getElement

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, bindVisible, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
  • Field Details

  • Constructor Details

    • AiConversationCard

      public AiConversationCard()
  • Method Details

    • initContent

      protected com.vaadin.flow.component.card.Card initContent()
      Overrides:
      initContent in class com.vaadin.flow.component.Composite<com.vaadin.flow.component.card.Card>
    • setIcon

      public void setIcon(com.vaadin.flow.component.Component icon)
      Sets the title-row icon (required). Call build() afterwards to apply the change.
      Parameters:
      icon - title-row icon
    • setTitle

      public void setTitle(String title)
      Sets the conversation title (required). Call build() afterwards to apply the change.
      Parameters:
      title - conversation title
    • setCreatedDate

      @NullMarked public void setCreatedDate(@Nullable String createdDate)
      Sets the formatted creation date; when null the date line is omitted. Call build() afterwards to apply the change.
      Parameters:
      createdDate - formatted creation date, or null to omit the date line
    • setOpenHandler

      public void setOpenHandler(Runnable openHandler)
      Sets the handler invoked when the card body is clicked (required). Call build() afterwards to apply the change.
      Parameters:
      openHandler - handler invoked when the card body is clicked
    • setDeleteHandler

      @NullMarked public void setDeleteHandler(@Nullable Runnable deleteHandler)
      Sets the handler invoked by the delete button; when null no delete button is rendered. Call build() afterwards to apply the change.
      Parameters:
      deleteHandler - handler invoked by the delete button, or null to render no delete button
    • setDeleteAriaLabel

      @NullMarked public void setDeleteAriaLabel(@Nullable String deleteAriaLabel)
      Sets the aria-label of the delete button. Call build() afterwards to apply the change.
      Parameters:
      deleteAriaLabel - aria-label for the delete button, or null for none
    • build

      public void build()
      (Re)assembles the card content from the currently configured properties. Call after the setters; setIcon(Component), setTitle(String) and setOpenHandler(Runnable) are required and must be set beforehand.
    • createBody

      protected com.vaadin.flow.component.orderedlayout.VerticalLayout createBody(com.vaadin.flow.component.Component icon, String title, Runnable openHandler, @Nullable String createdDate)
      Stacks the title row and (optionally) the date as the clickable body of the card. The whole body is the open-conversation hit area.
      Parameters:
      icon - title-row icon
      title - conversation title
      openHandler - handler invoked when the body is clicked
      createdDate - formatted creation date, or null to omit the date line
      Returns:
      the assembled card body
    • createTitleRow

      protected com.vaadin.flow.component.orderedlayout.HorizontalLayout createTitleRow(com.vaadin.flow.component.Component icon, String title)
      Icon + title in one row, so the icon visually reads as a marker of the title rather than of the whole card.
      Parameters:
      icon - title-row icon
      title - conversation title
      Returns:
      the assembled title row
    • createTitle

      protected com.vaadin.flow.component.html.Span createTitle(String title)
    • createDate

      protected com.vaadin.flow.component.html.Span createDate(String createdDate)
    • createRow

      protected com.vaadin.flow.component.orderedlayout.HorizontalLayout createRow(com.vaadin.flow.component.orderedlayout.VerticalLayout body)
      Outer row that lets the clickable body grow and parks an optional delete button alongside it.
      Parameters:
      body - the clickable card body
      Returns:
      the assembled outer row
    • createDeleteButton

      @NullMarked protected com.vaadin.flow.component.button.Button createDeleteButton(Runnable deleteHandler, @Nullable String deleteAriaLabel)
      Trash button. Cross-theme: StyleUtility.Button.LINK_BUTTON gives the flat "tertiary-inline" look; icon and error are generic vaadin-button theme attributes (Lumo/Aura both honour them) — no LUMO_* variant prefixes.
      Parameters:
      deleteHandler - handler invoked when the button is clicked
      deleteAriaLabel - aria-label for the button, or null for none
      Returns:
      the assembled delete button
    • createContent

      protected com.vaadin.flow.component.card.Card createContent()