From c6375dcdd1f1ee950e78b833e58131cee4ddca96 Mon Sep 17 00:00:00 2001
From: Andreas Bayha <bayha@fortis.org>
Date: Fri, 9 Feb 2018 12:22:32 +0000
Subject: [PATCH] Rollback of ElementCompositorBase (used in variability) refs
 2998

---
 .../extension/base/ElementCompositorBase.java | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ElementCompositorBase.java

diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ElementCompositorBase.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ElementCompositorBase.java
new file mode 100644
index 000000000..e478e7657
--- /dev/null
+++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ElementCompositorBase.java
@@ -0,0 +1,65 @@
+/*-------------------------------------------------------------------------+
+| Copyright 2014 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.kernel.extension.base;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.fortiss.tooling.kernel.extension.IElementCompositor;
+import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
+import org.fortiss.tooling.kernel.extension.data.Prototype;
+
+/**
+ * Base implementation for supporting composition of {@link IElementCompositor}.
+ * 
+ * This class is used for example in the variability plugin.
+ * 
+ * @author moudy
+ */
+public abstract class ElementCompositorBase<C extends EObject> implements IElementCompositor<C> {
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean canCompose(C container, EObject contained, IElementCompositionContext context) {
+		return isCorrectClass(contained);
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean canComposePrototype(Prototype prototype) {
+		return isCorrectClass(prototype.getPrototype());
+	}
+
+	/** Returns true if the contained object is an instance of an acceptable class. */
+	protected abstract boolean isCorrectClass(EObject contained);
+
+	/** {@inheritDoc} */
+	@Override
+	abstract public boolean compose(C container, EObject contained,
+			IElementCompositionContext context);
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean canDecompose(EObject contained) {
+		return isCorrectClass(contained);
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean decompose(EObject contained) {
+		EcoreUtil.delete(contained, true);
+		return true;
+	}
+}
-- 
GitLab