Skip to content
Snippets Groups Projects
Commit fe6c8fb9 authored by Johannes Eder's avatar Johannes Eder
Browse files

ConConnector still not working

parent 8e5c1271
No related branches found
No related tags found
No related merge requests found
Showing
with 407 additions and 7 deletions
......@@ -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>
/*--------------------------------------------------------------------------+
$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;
}
}
/*--------------------------------------------------------------------------+
$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";
}
}
......@@ -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);
}
}
......@@ -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>
......@@ -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>
......@@ -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>
......
......@@ -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);
}
}
/*--------------------------------------------------------------------------+
$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;
}
}
......@@ -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);
}
}
/*--------------------------------------------------------------------------+
$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;
}
}
......@@ -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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment