From fe6c8fb9ecdca69f389ded4019b83dd5bdf70fb7 Mon Sep 17 00:00:00 2001
From: Johannes Eder <eder@fortiss.org>
Date: Wed, 19 Apr 2017 13:09:30 +0000
Subject: [PATCH] ConConnector still not working

---
 .../trunk/plugin.xml                          | 21 ++++
 .../ui/editpart/EditPartFactory.java          | 65 ++++++++++++
 .../ui/handler/CanConnectorHandler.java       | 48 +++++++++
 .../ui/prototype/ProtoypeProvider.java        | 12 +++
 .../trunk/model/raspberry.ecore               |  1 +
 .../trunk/model/raspberry.genmodel            |  3 +-
 .../trunk/plugin.xml                          | 29 ++++++
 .../raspberry/compose/CanBusCompositor.java   | 11 ++-
 .../compose/CanToRaspberryCompositor.java     | 99 +++++++++++++++++++
 .../compose/RaspberryPiCompositor.java        | 11 ++-
 .../compose/RaspberryToCanCompositor.java     | 99 +++++++++++++++++++
 .../util/RaspberryModelElementFactory.java    | 15 ++-
 12 files changed, 407 insertions(+), 7 deletions(-)
 create mode 100644 org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/editpart/EditPartFactory.java
 create mode 100644 org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/handler/CanConnectorHandler.java
 create mode 100644 org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/CanToRaspberryCompositor.java
 create mode 100644 org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/RaspberryToCanCompositor.java

diff --git a/org.fortiss.af3.platform.raspberry.ui/trunk/plugin.xml b/org.fortiss.af3.platform.raspberry.ui/trunk/plugin.xml
index f06adbb2..d89627e8 100644
--- a/org.fortiss.af3.platform.raspberry.ui/trunk/plugin.xml
+++ b/org.fortiss.af3.platform.raspberry.ui/trunk/plugin.xml
@@ -28,5 +28,26 @@
             modelElementClass="org.fortiss.af3.platform.raspberry.model.CanBus">
       </modelElementClass>
    </modelElementHandler>
+   <modelElementHandler
+         handler="org.fortiss.af3.platform.raspberry.ui.handler.CanConnectorHandler">
+      <modelElementClass
+            modelElementClass="org.fortiss.af3.platform.raspberry.model.CanConnector">
+      </modelElementClass>
+   </modelElementHandler>
+</extension>
+<extension
+      point="org.fortiss.tooling.kernel.ui.editPartFactory">
+   <editPartFactory
+         factory="org.fortiss.af3.platform.raspberry.ui.editpart.EditPartFactory">
+      <modelElementClass
+            modelElementClass="org.fortiss.af3.platform.raspberry.model.RaspberryPi">
+      </modelElementClass>
+      <modelElementClass
+            modelElementClass="org.fortiss.af3.platform.raspberry.model.CanBus">
+      </modelElementClass>
+      <modelElementClass
+            modelElementClass="org.fortiss.af3.platform.raspberry.model.CanConnector">
+      </modelElementClass>
+   </editPartFactory>
 </extension>
 </plugin>
diff --git a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/editpart/EditPartFactory.java b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/editpart/EditPartFactory.java
new file mode 100644
index 00000000..926331f9
--- /dev/null
+++ b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/editpart/EditPartFactory.java
@@ -0,0 +1,65 @@
+/*--------------------------------------------------------------------------+
+$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+|                                                                          |
+| Copyright 2017 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.af3.platform.raspberry.ui.editpart;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.swt.graphics.Color;
+import org.fortiss.af3.platform.model.PlatformConnectorUnit;
+import org.fortiss.af3.platform.raspberry.model.CanBus;
+import org.fortiss.af3.platform.raspberry.model.CanConnector;
+import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
+import org.fortiss.af3.platform.ui.DefaultStyle;
+import org.fortiss.af3.platform.ui.editpart.generic.ExecutionUnitEditPart;
+import org.fortiss.af3.platform.ui.editpart.generic.StickyPlatformConnectorUnitEditPart;
+import org.fortiss.af3.platform.ui.editpart.generic.TransmissionUnitDefaultEditPart;
+import org.fortiss.tooling.kernel.ui.extension.IEditPartFactory;
+
+/**
+ * 
+ * @author eder
+ * @author $Author: hoelzl $
+ * @version $Rev: 18709 $
+ * @ConQAT.Rating RED Hash:
+ */
+public class EditPartFactory implements IEditPartFactory {
+
+	/** {@inheritDoc} */
+	@Override
+	public EditPart createEditPart(EditPart context, Object model) {
+		if(model instanceof RaspberryPi) {
+			return new ExecutionUnitEditPart((RaspberryPi)model) {
+				/** {@inheritDoc} */
+				@Override
+				protected Color getBackgroundColor() {
+					return DefaultStyle.EU_BACKGROUND;
+				}
+
+				/** {@inheritDoc} */
+				@Override
+				protected Color getForegroundColor() {
+					return DefaultStyle.EU_FOREGROUND;
+				}
+			};
+		} else if(model instanceof CanBus) {
+			return new TransmissionUnitDefaultEditPart((CanBus)model);
+		} else if(model instanceof CanConnector) {
+			return new StickyPlatformConnectorUnitEditPart((PlatformConnectorUnit)model);
+		}
+		return null;
+	}
+}
diff --git a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/handler/CanConnectorHandler.java b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/handler/CanConnectorHandler.java
new file mode 100644
index 00000000..008d6854
--- /dev/null
+++ b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/handler/CanConnectorHandler.java
@@ -0,0 +1,48 @@
+/*--------------------------------------------------------------------------+
+$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+|                                                                          |
+| Copyright 2017 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.af3.platform.raspberry.ui.handler;
+
+import static org.fortiss.af3.platform.ui.AF3PlatformUIActivator.getImageDescriptor;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.fortiss.af3.platform.raspberry.model.CanConnector;
+import org.fortiss.tooling.kernel.ui.extension.base.ModelElementHandlerBase;
+
+/**
+ * 
+ * @author eder
+ * @author $Author: hoelzl $
+ * @version $Rev: 18709 $
+ * @ConQAT.Rating RED Hash:
+ */
+public class CanConnectorHandler extends ModelElementHandlerBase<CanConnector> {
+
+	/** {@inheritDoc} */
+	@Override
+	public ImageDescriptor getIconImageDescriptor() {
+		return getImageDescriptor("icons/unknown.png");
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public String getName(CanConnector element) {
+		String name = element.getName();
+		return name != null ? name : "CanConnector";
+	}
+
+}
diff --git a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/prototype/ProtoypeProvider.java b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/prototype/ProtoypeProvider.java
index 06c079be..54a50024 100644
--- a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/prototype/ProtoypeProvider.java
+++ b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/prototype/ProtoypeProvider.java
@@ -17,9 +17,14 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
 +--------------------------------------------------------------------------*/
 package org.fortiss.af3.platform.raspberry.ui.prototype;
 
+import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.setConnectorPosition;
+import static org.fortiss.tooling.base.utils.LayoutDataUtils.setNodePosition;
+
 import org.fortiss.af3.platform.raspberry.model.CanBus;
+import org.fortiss.af3.platform.raspberry.model.CanConnector;
 import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
 import org.fortiss.af3.platform.raspberry.util.RaspberryModelElementFactory;
+import org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils;
 import org.fortiss.tooling.kernel.extension.base.PrototypeProviderBase;
 
 /**
@@ -38,9 +43,16 @@ public class ProtoypeProvider extends PrototypeProviderBase {
 	@Override
 	protected void registerPrototypes() {
 		RaspberryPi pi = RaspberryModelElementFactory.createRaspberryPi();
+		LayoutDataUIUtils.setConnectorPosition(pi, 0, 0);
 		registerPrimaryPrototype("RaspberryPi", pi, CATEGORY_NAME);
 
 		CanBus bus = RaspberryModelElementFactory.createCanBus();
+		LayoutDataUIUtils.setConnectorPosition(bus, 0, 0);
 		registerPrototype("CanBus", bus, CATEGORY_NAME);
+
+		CanConnector con = RaspberryModelElementFactory.createCanConnector();
+		setNodePosition(con, 0, 0);
+		setConnectorPosition(con, 0, 0);
+		registerPrototype("CanConnector", con, CATEGORY_NAME);
 	}
 }
diff --git a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore
index 92d3da59..78a316b3 100644
--- a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore
+++ b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore
@@ -4,4 +4,5 @@
     nsPrefix="org-fortiss-af3-platform-raspberry">
   <eClassifiers xsi:type="ecore:EClass" name="RaspberryPi" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ExecutionUnit"/>
   <eClassifiers xsi:type="ecore:EClass" name="CanBus" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//TransmissionUnit"/>
+  <eClassifiers xsi:type="ecore:EClass" name="CanConnector" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transceiver"/>
 </ecore:EPackage>
diff --git a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.genmodel b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.genmodel
index a575b391..c2d0ed23 100644
--- a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.genmodel
+++ b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.genmodel
@@ -3,11 +3,12 @@
     modelDirectory="/org.fortiss.af3.platform.raspberry/generated-src"
     modelPluginID="org.fortiss.af3.platform.raspberry" modelName="Raspberry" importerID="org.eclipse.emf.importer.ecore"
     containmentProxies="true" arrayAccessors="true" complianceLevel="7.0" copyrightFields="false"
-    usedGenPackages="../../org.fortiss.tooling.base/model/base.genmodel#//model ../../org.fortiss.af3.platform/model/platform.genmodel#//model ../../org.fortiss.tooling.kernel/model/kernel.genmodel#//model">
+    usedGenPackages="platform:/resource/org.fortiss.tooling.base/model/base.genmodel#//model platform:/resource/org.fortiss.af3.platform/model/platform.genmodel#//model platform:/resource/org.fortiss.tooling.kernel/model/kernel.genmodel#//model">
   <foreignModel>raspberry.ecore</foreignModel>
   <genPackages prefix="Model" basePackage="org.fortiss.af3.platform.raspberry" disposableProviderFactory="true"
       ecorePackage="raspberry.ecore#/">
     <genClasses ecoreClass="raspberry.ecore#//RaspberryPi"/>
     <genClasses ecoreClass="raspberry.ecore#//CanBus"/>
+    <genClasses ecoreClass="raspberry.ecore#//CanConnector"/>
   </genPackages>
 </genmodel:GenModel>
diff --git a/org.fortiss.af3.platform.raspberry/trunk/plugin.xml b/org.fortiss.af3.platform.raspberry/trunk/plugin.xml
index 57f73114..7ac665a7 100644
--- a/org.fortiss.af3.platform.raspberry/trunk/plugin.xml
+++ b/org.fortiss.af3.platform.raspberry/trunk/plugin.xml
@@ -32,6 +32,35 @@
          </modelElementClass>
       </modelElementCompositor>
    </extension>
+   <extension
+         point="org.fortiss.tooling.kernel.modelConnectionCompositor">
+      <modelConnectionCompositor
+            modelConnectionCompositor="org.fortiss.af3.platform.raspberry.compose.RaspberryToCanCompositor">
+         <source>
+            <modelElementClass
+                  modelElementClass="org.fortiss.af3.platform.raspberry.model.CanConnector">
+            </modelElementClass>
+         </source>
+         <target>
+            <modelElementClass
+                  modelElementClass="org.fortiss.af3.platform.raspberry.model.CanConnector">
+            </modelElementClass>
+         </target>
+      </modelConnectionCompositor>
+      <modelConnectionCompositor
+            modelConnectionCompositor="org.fortiss.af3.platform.raspberry.compose.CanToRaspberryCompositor">
+         <source>
+            <modelElementClass
+                  modelElementClass="org.fortiss.af3.platform.raspberry.model.CanConnector">
+            </modelElementClass>
+         </source>
+         <target>
+            <modelElementClass
+                  modelElementClass="org.fortiss.af3.platform.raspberry.model.CanConnector">
+            </modelElementClass>
+         </target>
+      </modelConnectionCompositor>
+   </extension>
 
    
    
diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/CanBusCompositor.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/CanBusCompositor.java
index 30771359..5d1f3d84 100644
--- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/CanBusCompositor.java
+++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/CanBusCompositor.java
@@ -17,9 +17,13 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
 +--------------------------------------------------------------------------*/
 package org.fortiss.af3.platform.raspberry.compose;
 
+import static org.conqat.lib.commons.reflect.ReflectionUtils.isInstanceOfAny;
+
 import org.eclipse.emf.ecore.EObject;
 import org.fortiss.af3.platform.compose.PlatformArchitectureElementCompositorBase;
 import org.fortiss.af3.platform.model.IPlatformArchitectureElement;
+import org.fortiss.af3.platform.raspberry.model.CanBus;
+import org.fortiss.af3.platform.raspberry.model.CanConnector;
 
 /**
  * 
@@ -35,8 +39,11 @@ public class CanBusCompositor extends
 	@Override
 	protected boolean isCorrectElementClass(IPlatformArchitectureElement container,
 			EObject contained) {
-		// TODO Auto-generated method stub
-		return false;
+		if(container != null) {
+			return isInstanceOfAny(container, CanBus.class) &&
+					isInstanceOfAny(contained, CanConnector.class);
+		}
+		return isInstanceOfAny(contained, CanConnector.class);
 	}
 
 }
diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/CanToRaspberryCompositor.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/CanToRaspberryCompositor.java
new file mode 100644
index 00000000..ef580fef
--- /dev/null
+++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/CanToRaspberryCompositor.java
@@ -0,0 +1,99 @@
+/*--------------------------------------------------------------------------+
+$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+|                                                                          |
+| Copyright 2017 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.af3.platform.raspberry.compose;
+
+import static org.fortiss.af3.platform.utils.PlatformModelElementFactory.createTransmissionConnection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.fortiss.af3.platform.model.TransmissionConnection;
+import org.fortiss.af3.platform.raspberry.model.CanBus;
+import org.fortiss.af3.platform.raspberry.model.CanConnector;
+import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
+import org.fortiss.tooling.base.model.element.IHierarchicElement;
+import org.fortiss.tooling.kernel.extension.IConnectionCompositor;
+import org.fortiss.tooling.kernel.extension.data.IConnectionCompositionContext;
+
+/**
+ * Connection compositor for {@link RaspberryPi} to {@link CanBus} connections.
+ * 
+ * @author eder
+ * @author $Author: hoelzl $
+ * @version $Rev: 18709 $
+ * @ConQAT.Rating RED Hash:
+ */
+public class CanToRaspberryCompositor implements
+		IConnectionCompositor<IHierarchicElement, CanConnector, CanConnector> {
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean canConnect(CanConnector source, CanConnector target, IHierarchicElement parent,
+			IConnectionCompositionContext context) {
+		if(source.getOwner() instanceof CanBus && target.getOwner() instanceof RaspberryPi) {
+			return source.getOutgoing().isEmpty();
+		}
+		return false;
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean connect(CanConnector source, CanConnector target, IHierarchicElement parent,
+			IConnectionCompositionContext context) {
+		createTransmissionConnection(parent, source, target);
+		return true;
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean canReconnect(EObject connection, CanConnector source, CanConnector target,
+			IConnectionCompositionContext context) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean reconnect(EObject connection, CanConnector source, CanConnector target,
+			IConnectionCompositionContext context) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean canDisconnect(EObject connection) {
+		if(connection instanceof TransmissionConnection) {
+			TransmissionConnection c = (TransmissionConnection)connection;
+			return c.getSource() instanceof CanConnector && c.getTarget() instanceof CanConnector;
+		}
+		return false;
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean disconnect(EObject connection) {
+		if(connection instanceof TransmissionConnection) {
+			TransmissionConnection tcon = ((TransmissionConnection)connection);
+			tcon.setOwner(null);
+			tcon.setSource(null);
+			tcon.setTarget(null);
+			return true;
+		}
+		return false;
+	}
+
+}
diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/RaspberryPiCompositor.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/RaspberryPiCompositor.java
index 083f65b9..0cd01d34 100644
--- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/RaspberryPiCompositor.java
+++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/RaspberryPiCompositor.java
@@ -17,9 +17,13 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
 +--------------------------------------------------------------------------*/
 package org.fortiss.af3.platform.raspberry.compose;
 
+import static org.conqat.lib.commons.reflect.ReflectionUtils.isInstanceOfAny;
+
 import org.eclipse.emf.ecore.EObject;
 import org.fortiss.af3.platform.compose.PlatformArchitectureElementCompositorBase;
 import org.fortiss.af3.platform.model.IPlatformArchitectureElement;
+import org.fortiss.af3.platform.raspberry.model.CanConnector;
+import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
 
 /**
  * 
@@ -35,8 +39,11 @@ public class RaspberryPiCompositor extends
 	@Override
 	protected boolean isCorrectElementClass(IPlatformArchitectureElement container,
 			EObject contained) {
-		// TODO Auto-generated method stub
-		return false;
+		if(container != null) {
+			return isInstanceOfAny(container, RaspberryPi.class) &&
+					isInstanceOfAny(contained, CanConnector.class);
+		}
+		return isInstanceOfAny(contained, CanConnector.class);
 	}
 
 }
diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/RaspberryToCanCompositor.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/RaspberryToCanCompositor.java
new file mode 100644
index 00000000..7c18a6de
--- /dev/null
+++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/RaspberryToCanCompositor.java
@@ -0,0 +1,99 @@
+/*--------------------------------------------------------------------------+
+$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+|                                                                          |
+| Copyright 2017 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.af3.platform.raspberry.compose;
+
+import static org.fortiss.af3.platform.utils.PlatformModelElementFactory.createTransmissionConnection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.fortiss.af3.platform.model.TransmissionConnection;
+import org.fortiss.af3.platform.raspberry.model.CanBus;
+import org.fortiss.af3.platform.raspberry.model.CanConnector;
+import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
+import org.fortiss.tooling.base.model.element.IHierarchicElement;
+import org.fortiss.tooling.kernel.extension.IConnectionCompositor;
+import org.fortiss.tooling.kernel.extension.data.IConnectionCompositionContext;
+
+/**
+ * Connection compositor for {@link RaspberryPi} to {@link CanBus} connections.
+ * 
+ * @author eder
+ * @author $Author: hoelzl $
+ * @version $Rev: 18709 $
+ * @ConQAT.Rating RED Hash:
+ */
+public class RaspberryToCanCompositor implements
+		IConnectionCompositor<IHierarchicElement, CanConnector, CanConnector> {
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean canConnect(CanConnector source, CanConnector target, IHierarchicElement parent,
+			IConnectionCompositionContext context) {
+		if(source.getOwner() instanceof RaspberryPi && target.getOwner() instanceof CanBus) {
+			return source.getOutgoing().isEmpty();
+		}
+		return false;
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean connect(CanConnector source, CanConnector target, IHierarchicElement parent,
+			IConnectionCompositionContext context) {
+		createTransmissionConnection(parent, source, target);
+		return true;
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean canReconnect(EObject connection, CanConnector source, CanConnector target,
+			IConnectionCompositionContext context) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean reconnect(EObject connection, CanConnector source, CanConnector target,
+			IConnectionCompositionContext context) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean canDisconnect(EObject connection) {
+		if(connection instanceof TransmissionConnection) {
+			TransmissionConnection c = (TransmissionConnection)connection;
+			return c.getSource() instanceof CanConnector && c.getTarget() instanceof CanConnector;
+		}
+		return false;
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean disconnect(EObject connection) {
+		if(connection instanceof TransmissionConnection) {
+			TransmissionConnection tcon = ((TransmissionConnection)connection);
+			tcon.setOwner(null);
+			tcon.setSource(null);
+			tcon.setTarget(null);
+			return true;
+		}
+		return false;
+	}
+
+}
diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/util/RaspberryModelElementFactory.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/util/RaspberryModelElementFactory.java
index 8f2b4fb0..8449c3ba 100644
--- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/util/RaspberryModelElementFactory.java
+++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/util/RaspberryModelElementFactory.java
@@ -17,7 +17,10 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
 +--------------------------------------------------------------------------*/
 package org.fortiss.af3.platform.raspberry.util;
 
+import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createConnectorLayout;
+
 import org.fortiss.af3.platform.raspberry.model.CanBus;
+import org.fortiss.af3.platform.raspberry.model.CanConnector;
 import org.fortiss.af3.platform.raspberry.model.ModelFactory;
 import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
 
@@ -31,17 +34,25 @@ import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
  */
 public class RaspberryModelElementFactory {
 
-	/** Creates a RaspberryPi. */
+	/** Creates a {@link RaspberryPi}. */
 	public static RaspberryPi createRaspberryPi() {
 		final RaspberryPi pi = ModelFactory.eINSTANCE.createRaspberryPi();
 		pi.setName("RaspberryPI");
 		return pi;
 	}
 
-	/** Creates a CanBus. */
+	/** Creates a {@link CanBus}. */
 	public static CanBus createCanBus() {
 		final CanBus bus = ModelFactory.eINSTANCE.createCanBus();
 		bus.setName("CanBus");
 		return bus;
 	}
+
+	/** Creates a {@link CanConnector}. */
+	public static CanConnector createCanConnector() {
+		CanConnector canConnector = ModelFactory.eINSTANCE.createCanConnector();
+		canConnector.setName("CanConnector");
+		createConnectorLayout(canConnector);
+		return canConnector;
+	}
 }
-- 
GitLab