From 31b575ef56c661cc6e2951b25571c80edd72cbc5 Mon Sep 17 00:00:00 2001
From: Andreas Bayha <bayha@fortiss.org>
Date: Tue, 20 Oct 2020 18:06:23 +0200
Subject: [PATCH] Kernel: Fixed column number issue in
 DynamicTreeTableUIProviderBase

DynamicTreeTableUIProviderBase did not take into account hidden
(invisible) columns for numbering. With this, column numbers changed,
whenever a column became invisible.

Now the column number is correct - also invisible columns are counted.

Issue-Ref: 4014
Issue-Url: https://af3-developer.fortiss.org/issues/4014
Signed-off-by: Andreas Bayha <bayha@fortiss.org>
---
 .../common/ui/javafx/control/treetableview/.ratings    |  2 +-
 .../treetableview/DynamicTreeTableUIProviderBase.java  | 10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings
index 5a5921339..f5d10778d 100644
--- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings
+++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings
@@ -5,7 +5,7 @@ DynamicTextFieldTreeTableCell.java de24117e6f785b328f1ff62383626a0b4b54e8ff GREE
 DynamicTreeContentProviderBase.java 91896b1fb5104d126544c44c1ff8c30f2a13a8d6 GREEN
 DynamicTreeItem.java 7486071d20e896d6ca9a9101bf105caccf3656d0 GREEN
 DynamicTreeItemBase.java d883066ecc181120302ca32f328538de7a45b093 GREEN
-DynamicTreeTableUIProviderBase.java b326c4b666e54285ebbb67570da05d002d52fb3c GREEN
+DynamicTreeTableUIProviderBase.java a4cd60795d114984f7fd255f273fc39937889f22 YELLOW
 DynamicTreeTableViewer.java ead6f6671e9cb6b14632940bf440cba7e81fcd98 GREEN
 DynamicTreeUIProviderBase.java 82d3c051213f0147f4c67ad247a08696cee73110 GREEN
 DynamicTreeViewer.java e58d2cf7239e45f1b790ce9770a8a8649b1b5fb9 GREEN
diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableUIProviderBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableUIProviderBase.java
index b326c4b66..a4cd60795 100644
--- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableUIProviderBase.java
+++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableUIProviderBase.java
@@ -85,7 +85,8 @@ public abstract class DynamicTreeTableUIProviderBase<T> {
 	}
 
 	/**
-* Determines the background color for a given element in the specified column.
+	 * Determines the background color for a given element in the specified column.
+	 * 
 	 * @param element
 	 *            The element to specify the background color for.
 	 * @param column
@@ -196,7 +197,12 @@ public abstract class DynamicTreeTableUIProviderBase<T> {
 		});
 		column.setOnEditCommit(event -> {
 			T element = event.getRowValue().getValue();
-			int colIndex = event.getTreeTablePosition().getColumn();
+
+			// The column number needs to be retrieved from the viewer, as the the
+			// event.getTablePosition() does not take into account invisible columns for numbering.
+			TreeTableColumn<T, String> tableColumn = event.getTableColumn();
+			int colIndex = tableColumn.getTreeTableView().getColumns().indexOf(tableColumn);
+
 			String value = event.getNewValue();
 			updateValue(element, colIndex, value);
 			column.getTreeTableView().refresh();
-- 
GitLab