From c42cfa3905eb9b7b12d2e3efe7860c726500fdd2 Mon Sep 17 00:00:00 2001
From: Alexander Diewald <diewald@fortiss.org>
Date: Thu, 28 Jun 2018 16:03:57 +0200
Subject: [PATCH] JavaFX: YELLOW

* Add an abstract method for "initialize()".
* Fixed comments.

Issue-Ref: 3463
Issue-Url: https://af3-developer.fortiss.org/issues/3463
Signed-off-by: Alexander Diewald <diewald@fortiss.org>
---
 .../fortiss/tooling/common/ui/javafx/.ratings |  2 +-
 .../common/ui/javafx/AF3FXViewPart.java       | 28 ++++++++++++-------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/.ratings
index 2e06d6b86..72f1df8ab 100644
--- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/.ratings
+++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/.ratings
@@ -1 +1 @@
-AF3FXViewPart.java 10100de78c542858792cb51a7c3cfe7e55ec95d7 YELLOW
+AF3FXViewPart.java 96871186e27ace44069441dbf7ac8ebcd7753390 YELLOW
diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/AF3FXViewPart.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/AF3FXViewPart.java
index b47d37d00..96871186e 100644
--- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/AF3FXViewPart.java
+++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/AF3FXViewPart.java
@@ -30,6 +30,7 @@ import org.apache.commons.lang3.SystemUtils;
 import org.eclipse.fx.ui.workbench3.FXViewPart;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
 
 /**
  * Base class to create eclipse (SWT-based) views using JavaFX GUI elements. This class requires
@@ -61,11 +62,7 @@ public abstract class AF3FXViewPart extends FXViewPart { // NO_UCD
 	private Pane root;
 
 	/**
-	 * TODO(JE): Is this comment correct? No FXML def is passed here. Additionally, it would be
-	 * beneficial to mention here that a default definition is used when using this Constructor.
-	 * 
-	 * 
-	 * Constructor. Allows to pass the view's FXML definition file along with style.
+	 * Constructor that is intended for {@link ViewPart}s which host a single view/node/control.
 	 * 
 	 * @param viewerClass
 	 *            Class implementing the {@link AF3FXViewPart} to load resources from its containing
@@ -79,6 +76,8 @@ public abstract class AF3FXViewPart extends FXViewPart { // NO_UCD
 	 */
 	public AF3FXViewPart(Class<? extends AF3FXViewPart> viewerClass, String cssLocation)
 			throws Exception {
+		// Initializing the base constructor with "null" for the FXML file indicates a
+		// single-view/node/control usecase.
 		this(viewerClass, null, cssLocation);
 	}
 
@@ -165,6 +164,17 @@ public abstract class AF3FXViewPart extends FXViewPart { // NO_UCD
 		// Not needed.
 	}
 
+	/**
+	 * Init method that is called after the JavaFX toolkit has been launched. The initialize method
+	 * is needed for single-node/view/control {@link ViewPart}s and for controls in a FXML-based
+	 * view that require an initial configuration. If no initial configuration is required place a
+	 * stub.
+	 * <p>
+	 * For FXML, the initialize method is called via the JavaFX framework. Otherwise, it is called
+	 * via reflection from this class.
+	 */
+	protected abstract void initialize();
+
 	/**
 	 * Adds a single {@link Node} to this view. It embeds the given {@link Node} to the
 	 * {@link AnchorPane} of this view and stretches it to the borders of the view.
@@ -196,11 +206,9 @@ public abstract class AF3FXViewPart extends FXViewPart { // NO_UCD
 	}
 
 	/**
-	 * TODO(JE): Please check correctness of first sentence. I guess there is a 'not' missing.
-	 * 
-	 * Sets the native look of the target platform to break the UI. Most of the UI code is based on
-	 * SWT which uses a platform native look. Currently, Windows 8&10, Windows 7, and MacOS X native
-	 * looks are supported.
+	 * Sets the native look of the target platform to not break the UI experience. Most of the UI
+	 * code is based on SWT which uses a platform native look. Currently, Windows 8&10, Windows 7,
+	 * and MacOS X native looks are supported.
 	 */
 	private void setNativeLook(Pane pane) {
 		if(SystemUtils.IS_OS_WINDOWS_10 || SystemUtils.IS_OS_WINDOWS_8) {
-- 
GitLab