diff --git a/org.fortiss.af3.platform.raspberry.ui/trunk/plugin.xml b/org.fortiss.af3.platform.raspberry.ui/trunk/plugin.xml index f06adbb2bb3f2f4de108790f8f7eee26f428c9d6..d89627e88644561c4ecf221bc81bd57ed6e3ffda 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 0000000000000000000000000000000000000000..926331f9efd823122b48ebc48f88d0513f495967 --- /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 0000000000000000000000000000000000000000..008d6854c8b495d8aa68c3829ea81e07628a31c4 --- /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 06c079bec4ed02fd75510022dfec3dfdb52c9979..54a50024f56f97322ea93c461aeb2b62289e2189 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 92d3da59a4daf5678bea21be5c742aaf0540b45e..78a316b38a56887262991b00be9e611939d0612a 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 a575b391614f7c9d518914ce602ddf9a729f4bdd..c2d0ed23d38b58ecfd564cfe458f9d56ccd3e8ed 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 57f73114b144ae7dd06883e3c894126bbd980486..7ac665a7efa79e9db8a3307cc562fa8284426e19 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 30771359911aca6b3a68720a25ec9c536682c967..5d1f3d8405969c1dfa65386a6440e15985ce2e89 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 0000000000000000000000000000000000000000..ef580fefd707e825574909373c0400e613f4fb9d --- /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 083f65b92d02b81aefed69a67bec1d94415a471d..0cd01d340a2eea70059ead201819640adc255645 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 0000000000000000000000000000000000000000..7c18a6de8fa0cfc18d7dfb8c43ff314bc99d5429 --- /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 8f2b4fb0f0828f322e5b63185e2a7821f21a4e92..8449c3babd152087f63e061fd8e8a5b0aa39962f 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; + } }