From 1b1673ddba381f9712c6dbb50ea679e3d96315ae Mon Sep 17 00:00:00 2001
From: Alexander Diewald <diewald@fortiss.org>
Date: Fri, 25 May 2018 17:07:14 +0200
Subject: [PATCH] JavaFX: Check null in the DynamicTreeViewer already.

* The UI provider operates on the items passed by the updateItem method
  in the DynamicTreeViewer.
* Avoid the required null-checks in the UI providers by moving this
  check to the Viewer. This reduces the boilerplate code.

Issue-Ref: 3209
Issue-Url: https://af3-developer.fortiss.org/issues/3209
Signed-off-by: Alexander Diewald <diewald@fortiss.org>
---
 .../common/ui/javafx/control/treetableview/.ratings        | 2 +-
 .../ui/javafx/control/treetableview/DynamicTreeViewer.java | 7 +++++--
 2 files changed, 6 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 dbd2e7da4..486249c05 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
@@ -3,6 +3,6 @@ DynamicTreeItem.java afc105cf5acf3d2506d89e0892555100c234ce5b YELLOW
 DynamicTreeTableUIProviderBase.java fd9fce19a65eb1006ceacb0d869bbe90a8c578b3 YELLOW
 DynamicTreeTableViewer.java 22bd5e5b13b959807596fff5b4024b3383737103 YELLOW
 DynamicTreeUIProviderBase.java 56fe4df4577b35f1e5e6e4c4be189b706c852d52 YELLOW
-DynamicTreeViewer.java 72945b28f34d9d268df4ce763fdabb7a8561fbc6 YELLOW
+DynamicTreeViewer.java d5b9f87862d9c42327c46bce02fb34d64673d413 YELLOW
 DynamicTreeViewerBase.java 47124c847de322a0ae26eb7a114f85ce4bd02d7e YELLOW
 IDoubleClickHandler.java 447f7769dead9a106b3ea3139ef0da51eb0b9a89 YELLOW
diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeViewer.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeViewer.java
index 72945b28f..d5b9f8786 100644
--- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeViewer.java
+++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeViewer.java
@@ -129,10 +129,13 @@ public final class DynamicTreeViewer<T> extends DynamicTreeViewerBase<T> {
 						menu = uiProvider.createContextMenu(item);
 						EventDispatcher original = this.getEventDispatcher();
 						this.setEventDispatcher(new DoubleClickEventDispatcher(original));
+						this.setText(uiProvider.getLabel(item));
+						this.setGraphic(uiProvider.getIconNode(item));
+					} else {
+						this.setText(null);
+						this.setGraphic(null);
 					}
 					this.setContextMenu(menu);
-					this.setText(uiProvider.getLabel(item));
-					this.setGraphic(uiProvider.getIconNode(item));
 				}
 			};
 			return cell;
-- 
GitLab