[ui] add possibility to disable row hovering in tables for one row

Table api allows disabling hover for whole tables, and sometimes it's needed to disable hover for some rows (e.g. separators)

GitOrigin-RevId: 05378dce11134fb7590583f106366a783dc74547
This commit is contained in:
Alisa.Afonina
2024-07-08 17:21:31 +00:00
committed by intellij-monorepo-bot
parent 0ee47cd0db
commit a4e89fb0c3
2 changed files with 5 additions and 1 deletions
@@ -738,7 +738,7 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
}
}
else {
Color hovered = isHoverPaintingDisabled(this) ? null : getHoveredRowBackground();
Color hovered = isHoverPaintingDisabled(this) || isHoverPaintingDisabled(component) ? null : getHoveredRowBackground();
if (hovered != null) {
if (row == TableHoverListener.getHoveredRow(this)) {
setRendererBackground(component, hovered);
@@ -162,6 +162,10 @@ public final class RenderingUtil {
return Boolean.FALSE.equals(component.getClientProperty(PAINT_HOVERED_BACKGROUND));
}
@ApiStatus.Internal
public static void setHoverPaintingDisabled(@NotNull JComponent component, boolean disabled) {
component.putClientProperty(PAINT_HOVERED_BACKGROUND, !disabled);
}
public static @Nullable Color getHoverBackground(@NotNull JList<?> list) {
if (isHoverPaintingDisabled(list)) return null;
return CurrentTheme.List.Hover.background(isFocused(list));