Class AiProviderRenderer

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, ListCellRenderer<Object>, SwingConstants, TableCellRenderer

public class AiProviderRenderer extends DefaultListCellRenderer implements TableCellRenderer
A unified, reusable Swing cell renderer for AbstractAiProvider instances.

This renderer implements both ListCellRenderer (for dropdowns like JComboBox and JList) and TableCellRenderer (for JTable and JXTable). It renders the provider's official logo icon alongside its display name or UUID, and formats null values cleanly as "All AI Providers".

Author:
anahata
See Also:
  • Field Details

    • tableRenderer

      private final DefaultTableCellRenderer tableRenderer
      Delegate renderer used for table cell background, selection, and border styling.
  • Constructor Details

    • AiProviderRenderer

      public AiProviderRenderer()
  • Method Details

    • getListCellRendererComponent

      public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus)

      Configures the list/combobox cell renderer component with the provider's logo icon and display name.

      Specified by:
      getListCellRendererComponent in interface ListCellRenderer<Object>
      Overrides:
      getListCellRendererComponent in class DefaultListCellRenderer
      Parameters:
      list - The JList being rendered.
      value - The value to assign to the cell (typically an AbstractAiProvider or null).
      index - The cell index.
      isSelected - True if the cell is selected.
      cellHasFocus - True if the cell has focus.
      Returns:
      The configured list cell component.
    • getTableCellRendererComponent

      public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
      Specified by:
      getTableCellRendererComponent in interface TableCellRenderer
    • configure

      private static void configure(Component comp, Object value, boolean isSelected)
      Configures a target label component with provider iconography, label text, and visual graying out if the provider is disabled or missing required API keys.
      Parameters:
      comp - The target component to configure.
      value - The provider entity or placeholder object.
      isSelected - Whether the cell is currently selected.