From 6602e8bbb9982bacbd6087bb9104eba8e8bea0f9 Mon Sep 17 00:00:00 2001
From: Alexander Diewald <diewald@fortiss.org>
Date: Wed, 11 Dec 2019 16:36:56 +0100
Subject: [PATCH] JFX visuals: Separate layouted and named rectangulars

Issue-Ref: 3883
Issue-Url: https://af3-developer.fortiss.org/issues/3883
Signed-off-by: Alexander Diewald <diewald@fortiss.org>
---
 .../tooling/base/ui/editor/fx/visual/.ratings |  3 +-
 .../LayoutedRectangularContentVisualBase.java | 25 +++++-------
 ...NamedLayoutedRectengularContentVisual.java | 40 +++++++++++++++++++
 3 files changed, 51 insertions(+), 17 deletions(-)
 create mode 100644 org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedRectengularContentVisual.java

diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/.ratings b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/.ratings
index 7e5017be0..1041b466a 100644
--- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/.ratings
+++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/.ratings
@@ -2,7 +2,8 @@ CoordinateCorrections.java c5cc475b45de38c56fc2e888a2d3093cd2efb52a YELLOW
 LayoutedCircularContentAnchorageVisualBase.java 4c3ee2d3c00f3b04c0824330fa5c5aeaeb91da2f YELLOW
 LayoutedCircularDiagramAnchorageVisualBase.java dff18208ffd98682dca49c061361550d310bdf76 YELLOW
 LayoutedLineLinkVisual.java 634c6ceeab057afc5da0924f227375785836b179 YELLOW
-LayoutedRectangularContentVisualBase.java 8618a2fb836c0289df2a3a3a7b06d4648c255de3 YELLOW
+LayoutedRectangularContentVisualBase.java c2a3937b99284713e0bbcd3ce458874567b25ac5 YELLOW
 NamedLayoutedConnectorContentVisual.java 087280aba1c523f5055bccad5cd4acde37abd7b9 YELLOW
 NamedLayoutedConnectorDiagramVisual.java 9fcf3825f7cfcdd5dafb58f9c53ad99fa9c0f381 YELLOW
 NamedLayoutedLinkVisual.java 92ce828c82e3a231b8f6e153d39bc77f396118fa YELLOW
+NamedLayoutedRectengularContentVisual.java 8d5428bdf53d50c604a2af5d6161a1a7a627250b YELLOW
diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedRectangularContentVisualBase.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedRectangularContentVisualBase.java
index 8618a2fb8..c2a3937b9 100644
--- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedRectangularContentVisualBase.java
+++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedRectangularContentVisualBase.java
@@ -28,7 +28,6 @@ import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.rectangular
 import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.rectangular.RectangularContentVisualBase;
 import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
 import org.fortiss.tooling.base.model.layout.Rectangle;
-import org.fortiss.tooling.kernel.model.INamedElement;
 
 import javafx.geometry.Dimension2D;
 import javafx.geometry.Rectangle2D;
@@ -40,7 +39,7 @@ import javafx.geometry.Side;
  * 
  * @author munaro
  */
-public abstract class LayoutedRectangularContentVisualBase<T extends ILayoutedModelElement & INamedElement>
+public abstract class LayoutedRectangularContentVisualBase<T extends ILayoutedModelElement>
 		extends RectangularContentVisualBase {
 
 	/** Constructor. */
@@ -58,6 +57,14 @@ public abstract class LayoutedRectangularContentVisualBase<T extends ILayoutedMo
 		}
 	}
 
+	/** Returns the model element with the specified type. */
+	// TODO(#3877): Move type checks to a common base class.
+	@SuppressWarnings("unchecked")
+	protected T getModelElement() {
+		// Safe wild cast due to type check in constructor
+		return (T)getModel();
+	}
+
 	/** {@inheritDoc} */
 	@Override
 	public Rectangle2D getModelBounds() {
@@ -107,18 +114,4 @@ public abstract class LayoutedRectangularContentVisualBase<T extends ILayoutedMo
 	protected boolean requireSelectionForResizeGesture() {
 		return false;
 	}
-
-	/** Return the {@link ILayoutedModelElement}. */
-	// TODO(#3877): Move type checks to a common base class.
-	@SuppressWarnings("unchecked")
-	protected T getModelElement() {
-		// Safe wild cast due to type check in constructor
-		return (T)getModel();
-	}
-
-	/** {@inheritDoc} */
-	@Override
-	protected String getName() {
-		return getModelElement().getName();
-	}
 }
diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedRectengularContentVisual.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedRectengularContentVisual.java
new file mode 100644
index 000000000..8d5428bdf
--- /dev/null
+++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedRectengularContentVisual.java
@@ -0,0 +1,40 @@
+/*-------------------------------------------------------------------------+
+| Copyright 2019 fortiss GmbH                                              |
+|                                                                          |
+| Licensed under the Apache License, Version 2.0 (the "License");          |
+| you may not use this file except in compliance with the License.         |
+| You may obtain a copy of the License at                                  |
+|                                                                          |
+|    http://www.apache.org/licenses/LICENSE-2.0                            |
+|                                                                          |
+| Unless required by applicable law or agreed to in writing, software      |
+| distributed under the License is distributed on an "AS IS" BASIS,        |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and      |
+| limitations under the License.                                           |
++--------------------------------------------------------------------------*/
+package org.fortiss.tooling.base.ui.editor.fx.visual;
+
+import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
+import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
+import org.fortiss.tooling.kernel.model.INamedElement;
+
+/**
+ * {@link LayoutedRectangularContentVisualBase} that defines its name.
+ * 
+ * @author diewald
+ */
+public class NamedLayoutedRectengularContentVisual<T extends INamedElement & ILayoutedModelElement>
+		extends LayoutedRectangularContentVisualBase<T> {
+
+	/** Constructor. */
+	public NamedLayoutedRectengularContentVisual(IContentMVCBundle mvcb, Class<T> modelType) {
+		super(mvcb, modelType);
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	protected String getName() {
+		return getModelElement().getName();
+	}
+}
-- 
GitLab