Commit 80344629 authored by Liana Soima's avatar Liana Soima
Browse files

Merge branch 'master' of https://git.fortiss.org/af3/af3.git into 3976

parents a405d7dd 4484186c
ComponentControllerFactory.java 57c48af3d6c2d51a9040a8b754a8b19b73525777 GREEN ComponentControllerFactory.java a5feb78f57aee4a8206866ef2dc6ca13bb145305 GREEN
ComponentModelFactory.java 9141373b9498b8e947ef1ca8921128bdf66ec308 GREEN ComponentModelFactory.java 9141373b9498b8e947ef1ca8921128bdf66ec308 GREEN
ComponentStructureFXEditor.java c9016fd1b30ee8ed98cace186615c03ccb894abc GREEN ComponentStructureFXEditor.java c9016fd1b30ee8ed98cace186615c03ccb894abc GREEN
ComponentStructureFXEditorBinding.java 19ca73be6a4ea974994d26db537329878748b20d GREEN ComponentStructureFXEditorBinding.java 19ca73be6a4ea974994d26db537329878748b20d GREEN
......
...@@ -15,21 +15,21 @@ ...@@ -15,21 +15,21 @@
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.af3.component.ui.editor.fx; package org.fortiss.af3.component.ui.editor.fx;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IControllerFactory;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IDiagramAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IDiagramMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle;
import org.fortiss.af3.component.model.Channel; import org.fortiss.af3.component.model.Channel;
import org.fortiss.af3.component.model.Component; import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.Port; import org.fortiss.af3.component.model.Port;
import org.fortiss.af3.component.ui.editor.fx.controller.PortContentAnchorageController;
import org.fortiss.tooling.base.ui.editor.fx.controller.EObjectDiagramController; import org.fortiss.tooling.base.ui.editor.fx.controller.EObjectDiagramController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedContentAnchorageController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedDiagramAnchorageController; import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedDiagramAnchorageController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedLineLinkBendPointController; import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedLineLinkBendPointController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedRectangularResizableContentController; import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedRectangularResizableContentController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IControllerFactory;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IDiagramAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IDiagramMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle;
/** /**
* The implementation of the {@link IControllerFactory} for the component editor. * The implementation of the {@link IControllerFactory} for the component editor.
...@@ -53,7 +53,7 @@ public final class ComponentControllerFactory implements IControllerFactory { ...@@ -53,7 +53,7 @@ public final class ComponentControllerFactory implements IControllerFactory {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public IController createContentAnchorageController(IContentAnchorageMVCBundle modelBundle) { public IController createContentAnchorageController(IContentAnchorageMVCBundle modelBundle) {
return new LayoutedContentAnchorageController<>(modelBundle, Port.class); return new PortContentAnchorageController(modelBundle);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
......
PortContentAnchorageController.java 39be36e3ff4a4d1d629e9a630b8a7fb96648f426 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2020 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.component.ui.editor.fx.controller;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static javafx.scene.input.KeyCode.DOWN;
import static javafx.scene.input.KeyCode.LEFT;
import static javafx.scene.input.KeyCode.RIGHT;
import static javafx.scene.input.KeyCode.UP;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE;
import static org.fortiss.tooling.base.layout.LayoutKeyConstants.CONNECTOR_OFFSET_ORIENTATION;
import static org.fortiss.tooling.base.model.layout.EOrientation.EAST;
import static org.fortiss.tooling.base.model.layout.EOrientation.NORTH;
import static org.fortiss.tooling.base.model.layout.EOrientation.SOUTH;
import static org.fortiss.tooling.base.model.layout.EOrientation.WEST;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectorOffsetOrientation;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.getNodeBounds;
import static org.fortiss.tooling.base.utils.OffsetOrientationUtils.setOffsetOrientation;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.Port;
import org.fortiss.tooling.base.model.layout.EOrientation;
import org.fortiss.tooling.base.model.layout.OffsetOrientation;
import org.fortiss.tooling.base.model.layout.Rectangle;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedContentAnchorageController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.change.Change;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import javafx.scene.input.KeyCode;
/**
* {@link LayoutedContentAnchorageController} for implementing the keyboard move behavior.
*
* @author hoelzl
*/
public class PortContentAnchorageController extends LayoutedContentAnchorageController<Port> {
/** Constructor. */
public PortContentAnchorageController(IContentAnchorageMVCBundle mvcb) {
super(mvcb, Port.class);
}
/** {@inheritDoc} */
@Override
protected Change keyMove(KeyCode code) {
final Component parent = ((Port)getLayoutedME()).getComponent();
final Rectangle bounds = getNodeBounds(parent);
final OffsetOrientation oo = getConnectorOffsetOrientation(getLayoutedME());
final EOrientation orient = oo.getOrientation();
final int offset = oo.getOffset();
final int step = DEFAULT_CONNECTOR_SIZE / 2;
final int maxX = bounds.getWidth() - 2 * step;
final int maxY = bounds.getHeight() - 2 * step;
int newOffset = -1;
EOrientation newOrient = null;
if(orient == NORTH) {
if(code == LEFT && offset > step) {
newOrient = NORTH;
newOffset = max(offset - step, step);
} else if(code == RIGHT && offset < maxX) {
newOrient = NORTH;
newOffset = min(offset + step, maxX);
} else if(code == DOWN) {
newOrient = (offset < maxX - offset) ? WEST : EAST;
newOffset = step;
}
} else if(orient == SOUTH) {
if(code == LEFT && offset > step) {
newOrient = SOUTH;
newOffset = max(offset - step, step);
} else if(code == RIGHT && offset < maxX) {
newOrient = SOUTH;
newOffset = min(offset + step, maxX);
} else if(code == UP) {
newOrient = (offset < maxX - offset) ? WEST : EAST;
newOffset = maxY;
}
} else if(orient == WEST) {
if(code == UP && offset > step) {
newOrient = WEST;
newOffset = max(offset - step, step);
} else if(code == DOWN && offset < maxY) {
newOrient = WEST;
newOffset = min(offset + step, maxY);
} else if(code == RIGHT) {
newOrient = (offset < maxY - offset) ? NORTH : SOUTH;
newOffset = step;
}
} else if(orient == EAST) {
if(code == UP && offset > step) {
newOrient = EAST;
newOffset = max(offset - step, step);
} else if(code == DOWN && offset < maxY) {
newOrient = EAST;
newOffset = min(offset + step, maxY);
} else if(code == LEFT) {
newOrient = (offset < maxY - offset) ? NORTH : SOUTH;
newOffset = maxX;
}
}
if(newOrient != null) {
final int newOffsetFinal = newOffset;
final EOrientation newOrientFinal = newOrient;
return () -> {
setOffsetOrientation(getLayoutedME(), CONNECTOR_OFFSET_ORIENTATION, newOffsetFinal,
newOrientFinal);
};
}
return null;
}
}
HierarchicPlatformArchitectureCompositor.java fecefdbd64c391f179730ac5aea7e7265ec81fca GREEN HierarchicPlatformArchitectureCompositor.java fecefdbd64c391f179730ac5aea7e7265ec81fca GREEN
HierarchicalCompositionRules.java 70651bf28c1a455eead6556e7578c81317aa9d5c GREEN HierarchicalCompositionRules.java 2eee9812a32b4be0d4f50babfec86bd96af6ecfe GREEN
...@@ -84,6 +84,7 @@ public class HierarchicalCompositionRules extends PlatformHierarchicalCompositio ...@@ -84,6 +84,7 @@ public class HierarchicalCompositionRules extends PlatformHierarchicalCompositio
rval.add(IMemoryDomain.class); rval.add(IMemoryDomain.class);
rval.add(INocDomain.class); rval.add(INocDomain.class);
rval.add(IElectronicsDomain.class); rval.add(IElectronicsDomain.class);
rval.add(IPeripheralsDomain.class);
} else if(hasEqualLevel(domain, IMemoryDomain.class)) { } else if(hasEqualLevel(domain, IMemoryDomain.class)) {
rval.add(IProcessorDomain.class); rval.add(IProcessorDomain.class);
rval.add(ITileDomain.class); rval.add(ITileDomain.class);
...@@ -112,11 +113,14 @@ public class HierarchicalCompositionRules extends PlatformHierarchicalCompositio ...@@ -112,11 +113,14 @@ public class HierarchicalCompositionRules extends PlatformHierarchicalCompositio
public boolean isCompatibleDomains(Class<? extends IArchitectureDomain> domain1, public boolean isCompatibleDomains(Class<? extends IArchitectureDomain> domain1,
Class<? extends IArchitectureDomain> domain2) { Class<? extends IArchitectureDomain> domain2) {
boolean processorAndPeripherals = isCompatibleDomainsCommutative(domain1, domain2, // Memory
IProcessorDomain.class, IPeripheralsDomain.class);
boolean processorAndMemory = isCompatibleDomainsCommutative(domain1, domain2, boolean processorAndMemory = isCompatibleDomainsCommutative(domain1, domain2,
IProcessorDomain.class, IMemoryDomain.class); IProcessorDomain.class, IMemoryDomain.class);
// Peripherals
boolean tileAndPeripherals = isCompatibleDomainsCommutative(domain1, domain2,
ITileDomain.class, IPeripheralsDomain.class);
// Electrical supply of platform elements down to tiles. // Electrical supply of platform elements down to tiles.
boolean tileAndElectrialSupply = isCompatibleDomainsCommutative(domain1, domain2, boolean tileAndElectrialSupply = isCompatibleDomainsCommutative(domain1, domain2,
ITileDomain.class, IElectronicsDomain.class); ITileDomain.class, IElectronicsDomain.class);
...@@ -126,10 +130,13 @@ public class HierarchicalCompositionRules extends PlatformHierarchicalCompositio ...@@ -126,10 +130,13 @@ public class HierarchicalCompositionRules extends PlatformHierarchicalCompositio
IClusterDomain.class, IElectronicsDomain.class); IClusterDomain.class, IElectronicsDomain.class);
boolean memoryAndElectrialSupply = isCompatibleDomainsCommutative(domain1, domain2, boolean memoryAndElectrialSupply = isCompatibleDomainsCommutative(domain1, domain2,
IMemoryDomain.class, IElectronicsDomain.class); IMemoryDomain.class, IElectronicsDomain.class);
boolean electricalSupply = tileAndElectrialSupply || nodeAndElectrialSupply || boolean peripheralsAndElectrialSupply = isCompatibleDomainsCommutative(domain1, domain2,
clusterAndElectrialSupply || memoryAndElectrialSupply; IPeripheralsDomain.class, IElectronicsDomain.class);
boolean electricalSupply =
tileAndElectrialSupply || nodeAndElectrialSupply || clusterAndElectrialSupply ||
memoryAndElectrialSupply || peripheralsAndElectrialSupply;
return processorAndPeripherals || processorAndMemory || electricalSupply || return tileAndPeripherals || processorAndMemory || electricalSupply ||
super.isCompatibleDomains(domain1, domain2); super.isCompatibleDomains(domain1, domain2);
} }
} }
...@@ -38,19 +38,19 @@ public class ConnectionCompositorServiceTest extends CompositorServiceTestModel ...@@ -38,19 +38,19 @@ public class ConnectionCompositorServiceTest extends CompositorServiceTestModel
public void testCorrectConnections() { public void testCorrectConnections() {
// two subcomponents of the same component can be connected // two subcomponents of the same component can be connected
assertTrue(compositor.canConnect(atomicCompA1, atomicCompA2, null, null)); // TODO: Can be re-enabled once #3966 has been implemented.
assertTrue(compositor.canConnect(atomicCompB1, atomicCompB2, null, null)); // assertTrue(compositor.canConnect(atomicCompA1, atomicCompA2, null, null));
// assertTrue(compositor.canConnect(atomicCompB1, atomicCompB2, null, null));
// two states of the same automaton can be connected // two states of the same automaton can be connected
assertTrue(compositor.canConnect(stateA1, stateA2, null, null)); assertTrue(compositor.canConnect(stateA1, stateA2, null, null));
assertTrue(compositor.canConnect(stateB1, stateB2, null, null)); assertTrue(compositor.canConnect(stateB1, stateB2, null, null));
// a component and its subcomponent can be connected // a component and its subcomponent can be connected
assertTrue(compositor.canConnect(topCompA, atomicCompA1, null, null)); // assertTrue(compositor.canConnect(topCompA, atomicCompA1, null, null));
// two subcomponents of different components can be connected // two subcomponents of different components can be connected
assertTrue(compositor.canConnect(atomicCompA1, atomicCompB2, null, null)); // assertTrue(compositor.canConnect(atomicCompA1, atomicCompB2, null, null));
} }
/** Testing connections that are not allowed. */ /** Testing connections that are not allowed. */
......
Markdown is supported
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