Commit b1fe3232 authored by Daniel Ratiu's avatar Daniel Ratiu
Browse files

removing some duplication

refs 733
parent d5d47a3c
......@@ -54,10 +54,7 @@ public final class GenericToBusConnectionCompositor implements
@Override
public boolean connect(GenericTransceiver source, GenericTransceiver target,
IPlatformArchitectureElement parent, IConnectionCompositionContext context) {
TransmissionConnection conn = createTransmissionConnection();
parent.getPlatformArchitecture().getConnectionsList().add(conn);
conn.setSource(source);
conn.setTarget(target);
createTransmissionConnection(parent, source, target);
return true;
}
......
......@@ -34,7 +34,7 @@ import org.fortiss.tooling.kernel.extension.data.IConnectionCompositionContext;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: B3E935FE9BD40F5D6E483B984E6FC6AF
* @ConQAT.Rating YELLOW Hash: 84A17B53554DC850E2D9C0263B1E8D01
*/
public final class GenericToExecutionUnitConnectionCompositor implements
IConnectionCompositor<IPlatformArchitectureElement, GenericTransceiver, GenericTransceiver> {
......@@ -54,11 +54,8 @@ public final class GenericToExecutionUnitConnectionCompositor implements
@Override
public boolean connect(GenericTransceiver source, GenericTransceiver target,
IPlatformArchitectureElement parent, IConnectionCompositionContext context) {
TransmissionConnection conn = createTransmissionConnection();
parent.getPlatformArchitecture().getConnectionsList().add(conn);
// Swap connection target in model is always the bus.
conn.setSource(target);
conn.setTarget(source);
createTransmissionConnection(parent, target, source);
return true;
}
......
......@@ -29,7 +29,6 @@ import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.setStickyConnect
import org.fortiss.af3.component.ui.examples.SimpleTrafficLightsComponentArchitectureExample;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.platform.model.TransmissionConnection;
import org.fortiss.af3.platform.model.generic.GenericExecutionUnit;
import org.fortiss.af3.platform.model.generic.GenericReceiver;
import org.fortiss.af3.platform.model.generic.GenericTransceiver;
......@@ -47,9 +46,10 @@ import org.fortiss.tooling.kernel.utils.UniqueIDUtils;
* @author wandinger
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 6C7F86B919C70F61C8A3960E52B396A8
* @ConQAT.Rating YELLOW Hash: 7E7934991C4C8B4899F8A6ABC0890754
*/
public class SimpleTrafficLightsPlatformArchitectureExample extends SimpleTrafficLightsComponentArchitectureExample {
public class SimpleTrafficLightsPlatformArchitectureExample extends
SimpleTrafficLightsComponentArchitectureExample {
/** The example singleton. */
@SuppressWarnings("hiding")
......@@ -142,15 +142,8 @@ public class SimpleTrafficLightsPlatformArchitectureExample extends SimpleTraffi
plarch.getContainedElementsList().add(net);
// The network connections.
TransmissionConnection con0 = createTransmissionConnection();
con0.setSource(fromECU0ToNET);
con0.setTarget(fromNETToECU0);
plarch.getConnectionsList().add(con0);
TransmissionConnection con1 = createTransmissionConnection();
con1.setSource(fromECU1ToNET);
con1.setTarget(fromNETToECU1);
plarch.getConnectionsList().add(con1);
createTransmissionConnection(plarch, fromECU0ToNET, fromNETToECU0);
createTransmissionConnection(plarch, fromECU1ToNET, fromNETToECU1);
// Add the platform architecture to the project.
project.getRootElementsList().add(plarch);
......
......@@ -18,7 +18,9 @@ $Id$
package org.fortiss.af3.platform.utils;
import org.fortiss.af3.platform.model.AF3PlatformFactory;
import org.fortiss.af3.platform.model.IPlatformArchitectureElement;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.platform.model.Transceiver;
import org.fortiss.af3.platform.model.TransmissionConnection;
import org.fortiss.af3.platform.model.generic.AF3GenericFactory;
import org.fortiss.af3.platform.model.generic.GenericExecutionUnit;
......@@ -34,7 +36,7 @@ import org.fortiss.tooling.base.utils.LayoutModelElementFactory;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 016EED7BD22D81E5452C58BCF579F255
* @ConQAT.Rating YELLOW Hash: E2BD10143332A49BDC22160BB1E07F4D
*/
public class PlatformModelElementFactory {
......@@ -44,10 +46,8 @@ public class PlatformModelElementFactory {
}
/** Creates a {@link PlatformArchitecture}. */
public static PlatformArchitecture createPlatformArchitecture(String name,
String comment) {
PlatformArchitecture arch = AF3PlatformFactory.eINSTANCE
.createPlatformArchitecture();
public static PlatformArchitecture createPlatformArchitecture(String name, String comment) {
PlatformArchitecture arch = AF3PlatformFactory.eINSTANCE.createPlatformArchitecture();
arch.setName(name);
arch.setComment(comment);
return arch;
......@@ -55,28 +55,46 @@ public class PlatformModelElementFactory {
/** Creates a {@link TransmissionConnection} element. */
public static TransmissionConnection createTransmissionConnection() {
TransmissionConnection tc = AF3PlatformFactory.eINSTANCE
.createTransmissionConnection();
TransmissionConnection tc = AF3PlatformFactory.eINSTANCE.createTransmissionConnection();
tc.setName("");
tc.setComment("");
LayoutModelElementFactory.createConnectionLayout(tc);
return tc;
}
/**
* Creates a {@link TransmissionConnection} element, sets source and target and adds it to the
* platform.
*/
public static TransmissionConnection createTransmissionConnection(
IPlatformArchitectureElement parent, Transceiver source, Transceiver target) {
return createTransmissionConnection(parent.getPlatformArchitecture(), source, target);
}
/**
* Creates a {@link TransmissionConnection} element, sets source and target and adds it to the
* platform.
*/
public static TransmissionConnection createTransmissionConnection(PlatformArchitecture plarch,
Transceiver source, Transceiver target) {
TransmissionConnection conn = createTransmissionConnection();
plarch.getConnectionsList().add(conn);
conn.setSource(source);
conn.setTarget(target);
return conn;
}
/** Creates a {@link GenericExecutionUnit}. */
public static GenericExecutionUnit createGenericExecutionUnit(String name) {
GenericExecutionUnit eu = AF3GenericFactory.eINSTANCE
.createGenericExecutionUnit();
GenericExecutionUnit eu = AF3GenericFactory.eINSTANCE.createGenericExecutionUnit();
eu.setName(name);
LayoutModelElementFactory.createNodeElementLayout(eu);
return eu;
}
/** Creates a {@link GenericTransmissionUnit}. */
public static GenericTransmissionUnit createGenericTransmissionUnit(
String name) {
GenericTransmissionUnit tu = AF3GenericFactory.eINSTANCE
.createGenericTransmissionUnit();
public static GenericTransmissionUnit createGenericTransmissionUnit(String name) {
GenericTransmissionUnit tu = AF3GenericFactory.eINSTANCE.createGenericTransmissionUnit();
tu.setName(name);
LayoutModelElementFactory.createNodeElementLayout(tu);
return tu;
......@@ -84,8 +102,7 @@ public class PlatformModelElementFactory {
/** Creates a {@link GenericTransmitter}. */
public static GenericTransmitter createGenericTransmitter(String name) {
GenericTransmitter trans = AF3GenericFactory.eINSTANCE
.createGenericTransmitter();
GenericTransmitter trans = AF3GenericFactory.eINSTANCE.createGenericTransmitter();
trans.setName(name);
LayoutModelElementFactory.createConnectorLayout(trans);
return trans;
......@@ -93,8 +110,7 @@ public class PlatformModelElementFactory {
/** Creates a {@link GenericTransceiver}. */
public static GenericTransceiver createGenericTransceiver(String name) {
GenericTransceiver trans = AF3GenericFactory.eINSTANCE
.createGenericTransceiver();
GenericTransceiver trans = AF3GenericFactory.eINSTANCE.createGenericTransceiver();
trans.setName(name);
LayoutModelElementFactory.createConnectorLayout(trans);
return trans;
......@@ -102,8 +118,7 @@ public class PlatformModelElementFactory {
/** Creates a {@link GenericReceiver}. */
public static GenericReceiver createGenericReceiver(String name) {
GenericReceiver rec = AF3GenericFactory.eINSTANCE
.createGenericReceiver();
GenericReceiver rec = AF3GenericFactory.eINSTANCE.createGenericReceiver();
rec.setName(name);
LayoutModelElementFactory.createConnectorLayout(rec);
return rec;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment