From a76d0ed3388a3ed7ed24a4125b348c789744fd8b Mon Sep 17 00:00:00 2001 From: lolodomo Date: Sun, 19 May 2024 15:05:03 +0200 Subject: [PATCH] [BasicUI] Switch between several Button elements at a place in the grid (#2580) Several Button elements are accepted at the same place in the grid only when they all have visibility conditions. In this case, the user must define proper conditions so that only one button is visible at any time. Signed-off-by: Laurent Garnier --- .../internal/render/ButtongridRenderer.java | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/ButtongridRenderer.java b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/ButtongridRenderer.java index 5cb5175c30..fee96f3480 100644 --- a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/ButtongridRenderer.java +++ b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/ButtongridRenderer.java @@ -12,7 +12,9 @@ */ package org.openhab.ui.basic.internal.render; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.eclipse.emf.common.util.ECollections; @@ -69,7 +71,7 @@ public EList renderWidget(Widget w, StringBuilder sb, String sitemap) th Buttongrid grid = (Buttongrid) w; Map> rowsButtons = new HashMap<>(); - Map> rowsButtonWidgets = new HashMap<>(); + Map>> rowsButtonWidgets = new HashMap<>(); int maxColumn = 0; int mawRow = 0; @@ -123,16 +125,26 @@ public EList renderWidget(Widget w, StringBuilder sb, String sitemap) th "Several buttons at row {} and column {} in \"buttons\" parameter and as \"Button\" element; only the first is considered", row, column); } else { - Map columnsButtonWidgets = rowsButtonWidgets.get(row); + Map> columnsButtonWidgets = rowsButtonWidgets.get(row); if (columnsButtonWidgets == null) { columnsButtonWidgets = new HashMap<>(); rowsButtonWidgets.put(row, columnsButtonWidgets); } - if (columnsButtonWidgets.get(column) != null) { - logger.warn("Several \"Button\" elements at row {} and column {}; only the first is considered", - row, column); + List