From 2746added2a50dec1f665d49515da01a91b487cf Mon Sep 17 00:00:00 2001
From: Jan Kozusznik <jan@kozusznik.cz>
Date: Mon, 12 Feb 2018 10:09:04 +0100
Subject: [PATCH] solved Petr Bainar discusion

discusion is hear:
https://code.it4i.cz/fiji/haas-java-client/merge_requests/10#note_4876
---
 .../it4i/fiji/haas/ui/CloseableControl.java   | 22 ++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/CloseableControl.java b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/CloseableControl.java
index c607db6d..b7ecbbf4 100644
--- a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/CloseableControl.java
+++ b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/CloseableControl.java
@@ -38,14 +38,18 @@ public interface CloseableControl extends Closeable {
 			}
 		});
 		fxmlLoader.setRoot(parent);
-		// fxmlLoader.setController(parent);
-
-		try {
-			fxmlLoader.load();
-		} catch (IOException exception) {
-			throw new RuntimeException(exception);
-		}
-
+		Object explicitController = null;
+		do {
+			fxmlLoader.setController(explicitController);
+			try {
+				fxmlLoader.load();
+			} catch (IOException exception) {
+				throw new RuntimeException(exception);
+			}
+			if(fxmlLoader.getController() == null) {
+				explicitController = parent;
+			}
+		} while(fxmlLoader.getController() == null);
 	}
 
 	static public <V> void executeAsync(Executor executor, Callable<V> action, Consumer<V> postAction) {
@@ -73,8 +77,6 @@ public interface CloseableControl extends Closeable {
 			Function<U, V> mapper) {
 		((TableColumn<T, V>) tableView.getColumns().get(index))
 				.setCellValueFactory(f -> new ObservableValueAdapter<U, V>(f.getValue(), mapper));
-		// ((TableColumn<T, String>)
-		// tableView.getColumns().get(index)).setCellFactory(f->f.set);
 
 	}
 
-- 
GitLab