From 1e40ef29b56fc8aed14cf8df9faeebe3347f8beb Mon Sep 17 00:00:00 2001
From: Johannes Eder <eder@fortiss.org>
Date: Mon, 15 Jun 2020 11:49:11 +0200
Subject: [PATCH] YELLOW

Issue-Ref: 4029
Issue-Url: https://af3-developer.fortiss.org/issues/4029

Signed-off-by: Johannes Eder <eder@fortiss.org>
---
 .../ui/javafx/control/treetableview/.ratings  |  2 +-
 .../DynamicTreeTableUIProviderBase.java       | 24 ++++++++-----------
 2 files changed, 11 insertions(+), 15 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 d113be5ff..5a61ef22f 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
@@ -1,6 +1,6 @@
 DynamicTreeContentProviderBase.java 6760a6dc5721175b1dada8f30fd9da05f7bcc4b3 GREEN
 DynamicTreeItem.java 75dc5534b119ffdb3c10a65810c2a0f330b7955e GREEN
-DynamicTreeTableUIProviderBase.java b9e68bede4ad0763e4ea3d3c1e7edeb0d63ed261 RED
+DynamicTreeTableUIProviderBase.java 4adb4066bdd8eac75f7b8a4ba7aa5d42b43d8e32 YELLOW
 DynamicTreeTableViewer.java 5e58a31a63f8e56d8c8e69e2c4d095809bc46bf1 GREEN
 DynamicTreeUIProviderBase.java e9b68607683de279d0cb8712a28dc131c5c33ece GREEN
 DynamicTreeViewer.java 725f41f4fb4b6bfa813f010fb9083ab02eea164a 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 b9e68bede..4adb4066b 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
@@ -156,22 +156,12 @@ public abstract class DynamicTreeTableUIProviderBase<T> {
 
 	/** Applies a checkbox editing support to the given checkbox column. */
 	/* package */ final void applyToCheckboxColumn(int i, TreeTableColumn<T, Boolean> column) {
-		// TODO (SB): Maybe the following would be safer?
-		// column.setOnEditCommit(null);
-		// column.setEditable(isEditable(i));
-		// if(!isEditable(i)) {
-		// return;
-		// }
+		column.setOnEditCommit(null);
+		column.setEditable(isEditable(i));
 		if(!isEditable(i)) {
-			column.setEditable(false);
-			column.setOnEditCommit(null);
 			return;
 		}
-		column.setEditable(true);
-		// end of previous TODO
 
-		// TODO Could we save some memory here and use the same CallBack for all columns (i.e., make
-		// this a static field of DynamicTreeTableUIProviderBase)?
 		// setOnEditCommit() does not work for CheckBoxTreeTableCell. This is why a custom
 		// CellValueFactory has to be set here
 		column.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<T, Boolean>, //
@@ -183,8 +173,14 @@ public abstract class DynamicTreeTableUIProviderBase<T> {
 					call(TreeTableColumn.CellDataFeatures<T, Boolean> param) {
 				TreeItem<T> treeItem = param.getValue();
 				T value = treeItem.getValue();
-				String label = getLabel(value, i);
-				// TODO (SB) Error handling for values != "true" or "false"
+				String label = getLabel(value, i).trim().toLowerCase();
+				// String to boolean transformations throw no error/exception that is why this has
+				// to be captured manually here.
+				if(!(label.equals("true") || label.equals("false"))) {
+					throw new RuntimeException(
+							"Wrong type in chebckobx table cell. Expected boolean \"true\" or \"false\" but received \"" +
+									label + "\".");
+				}
 				boolean b = Boolean.valueOf(label);
 				SimpleBooleanProperty booleanProp = new SimpleBooleanProperty(b);
 
-- 
GitLab