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. The card body is a real link to the conversation, so it supports opening in a new browser tab, copying the address and keyboard activation; a plain click is handled in-app by the open handler instead of following the link. 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 @Nullable String
     
    protected static final String
     
    protected static final String
     
    protected static final String
     
    protected static final String
     
    protected @Nullable String
     
    protected @Nullable Runnable
     
    protected String
     
    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
    protected void
    bindOpenHandler(com.vaadin.flow.component.html.Anchor body, Runnable openHandler)
    Routes a plain click on the link to the open handler instead of letting the browser load the address.
    void
    (Re)assembles the card content from the currently configured properties.
    protected com.vaadin.flow.component.html.Anchor
    createBody(com.vaadin.flow.component.Component icon, String title, String href, Runnable openHandler, @Nullable String activityDate)
    Stacks the title row and (optionally) the date as the link body of the card.
    protected com.vaadin.flow.component.card.Card
     
    protected com.vaadin.flow.component.html.Span
    createDate(String activityDate)
     
    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.html.Anchor body)
    Outer row that lets the link body grow and parks an optional delete button alongside it — outside the link, so deleting is not a click on the conversation.
    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
    setActivityDate(@Nullable String activityDate)
    Sets the formatted last-activity date shown under the title; 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
    Sets the address the card body links to (required) — the conversation's own route.
    void
    setIcon(com.vaadin.flow.component.Component icon)
    Sets the title-row icon (required).
    void
    setOpenHandler(Runnable openHandler)
    Sets the handler invoked on a plain click on the card body (required), so that the click stays an in-app navigation instead of a page load.
    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, whenAttached

    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
    • setActivityDate

      @NullMarked public void setActivityDate(@Nullable String activityDate)
      Sets the formatted last-activity date shown under the title; when null the date line is omitted. Call build() afterwards to apply the change.
      Parameters:
      activityDate - formatted last-activity date, or null to omit the date line
    • setHref

      public void setHref(String href)
      Sets the address the card body links to (required) — the conversation's own route. It is what the browser uses for "open in new tab" and "copy link address"; a plain click goes to setOpenHandler(Runnable) instead. Call build() afterwards to apply the change.
      Parameters:
      href - address of the conversation
    • setOpenHandler

      public void setOpenHandler(Runnable openHandler)
      Sets the handler invoked on a plain click on the card body (required), so that the click stays an in-app navigation instead of a page load. Modified and non-primary clicks are left to the browser. Call build() afterwards to apply the change.
      Parameters:
      openHandler - handler invoked on a plain click on the card body
    • 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), setHref(String) and setOpenHandler(Runnable) are required and must be set beforehand.
    • createBody

      protected com.vaadin.flow.component.html.Anchor createBody(com.vaadin.flow.component.Component icon, String title, String href, Runnable openHandler, @Nullable String activityDate)
      Stacks the title row and (optionally) the date as the link body of the card. The whole body is the open-conversation hit area.
      Parameters:
      icon - title-row icon
      title - conversation title
      href - address of the conversation
      openHandler - handler invoked on a plain click on the body
      activityDate - formatted last-activity date, or null to omit the date line
      Returns:
      the assembled card body
    • bindOpenHandler

      protected void bindOpenHandler(com.vaadin.flow.component.html.Anchor body, Runnable openHandler)
      Routes a plain click on the link to the open handler instead of letting the browser load the address. Everything else — a modified click, a middle click (which fires auxclick, not click), the context menu — is left to the browser, which is what makes "open in new tab" and "copy link address" work.

      Suppressing the default action is part of the filter expression on purpose: Flow evaluates every event-data expression before it checks the filter, so preventDefault passed as event data would also cancel the modified clicks that must reach the browser. The filter is evaluated once per event, so folding preventDefault into the guard cancels exactly the clicks that are handled here.

      Parameters:
      body - the link body of the card
      openHandler - handler invoked on a plain click
    • 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 activityDate)
    • createRow

      protected com.vaadin.flow.component.orderedlayout.HorizontalLayout createRow(com.vaadin.flow.component.html.Anchor body)
      Outer row that lets the link body grow and parks an optional delete button alongside it — outside the link, so deleting is not a click on the conversation.
      Parameters:
      body - the link body of the card
      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()