Commit e5608adf authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Merge branch '3962' into 'master'

[3962] State automata: Allow the creation of transitions to parent states

See merge request af3/af3!304
parents 6ad2d8ad 44d91819
ModeAutomatonControllerFactory.java 3e60fb8432aef914d0c63e8dfeb18b6ac57ddb6f GREEN
ModeAutomatonControllerFactory.java aa768159a389d90522b275e4481fb2db78669a25 GREEN
ModeAutomatonFXEditor.java 0e772da01045f7dc39c1005735c47e51d8b92a5b GREEN
ModeAutomatonFXEditorBinding.java d3503a20fc9fccc6a8805674bdabaa2135fd28c2 GREEN
ModeAutomatonModelFactory.java 90826e0ff88b73784e41cc71f473c11daa6bc36d GREEN
......
......@@ -15,22 +15,22 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mode.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.mode.model.Mode;
import org.fortiss.af3.mode.model.ModeAutomaton;
import org.fortiss.af3.mode.model.SwitchSegment;
import org.fortiss.af3.mode.model.SwitchSegmentConnector;
import org.fortiss.tooling.base.ui.editor.fx.controller.CurvedLinkLayoutedContentAnchorangeController;
import org.fortiss.tooling.base.ui.editor.fx.controller.CurvedLinkLayoutedDiagramAnchorangeController;
import org.fortiss.tooling.base.ui.editor.fx.controller.EObjectDiagramController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedCurveLinkBendPointController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedDiagramAnchorageController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedEllipticResizableContentController;
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;
/**
* Implementation of the {@link IControllerFactory} for the {@link ModeAutomaton} editor.
......@@ -41,33 +41,32 @@ public class ModeAutomatonControllerFactory implements IControllerFactory {
/** {@inheritDoc} */
@Override
public IController createContentController(IContentMVCBundle model) {
return new LayoutedEllipticResizableContentController<Mode>(model, Mode.class);
return new LayoutedEllipticResizableContentController<>(model, Mode.class);
}
/** {@inheritDoc} */
@Override
public IController createDiagramAnchorageController(IDiagramAnchorageMVCBundle modelBundle) {
return new LayoutedDiagramAnchorageController<SwitchSegmentConnector>(modelBundle,
return new CurvedLinkLayoutedDiagramAnchorangeController<>(modelBundle,
SwitchSegmentConnector.class);
}
/** {@inheritDoc} */
@Override
public IController createContentAnchorageController(IContentAnchorageMVCBundle modelBundle) {
return new CurvedLinkLayoutedContentAnchorangeController<SwitchSegmentConnector>(
modelBundle, SwitchSegmentConnector.class);
return new CurvedLinkLayoutedContentAnchorangeController<>(modelBundle,
SwitchSegmentConnector.class);
}
/** {@inheritDoc} */
@Override
public IController createLinkController(ILinkMVCBundle modelBundle) {
return new LayoutedCurveLinkBendPointController<SwitchSegment>(modelBundle,
SwitchSegment.class);
return new LayoutedCurveLinkBendPointController<>(modelBundle, SwitchSegment.class);
}
/** {@inheritDoc} */
@Override
public IController createDiagramController(IDiagramMVCBundle diagramBundle) {
return new EObjectDiagramController<Mode>(diagramBundle, Mode.class);
return new EObjectDiagramController<>(diagramBundle, Mode.class);
}
}
......@@ -3,7 +3,7 @@ DataStateFXEditorBase.java 0bec3533962ebcd7326f6597d598a5ff7c8ba8e6 GREEN
DataStateFXEditorBinding.java 46ab36b197a6fca102a5e2d75aa24b1fbba26b89 GREEN
DataStateFXEditorContentProvider.java 324cd24e2219ba2cf360b0f82e3628ca1b5dabba GREEN
DataStateFXEditorUIProvider.java 4993d4a6685b7738dd28a7a55177ab43fe81fc53 GREEN
StateAutomatonControllerFactory.java 03d624ad560508280c01898da29eac0450bbb237 GREEN
StateAutomatonControllerFactory.java 67f7f7bbc318018080a4569d84e0f1830ce33bda GREEN
StateAutomatonFXEditor.java eea88e496c873ec92f6b2a0735cbd3d542a3063f GREEN
StateAutomatonFXEditorBase.java 901e1ce52a2a53fb73c160b0af7fd7fbfc1e3044 GREEN
StateAutomatonFXEditorBinding.java 5fae7a8e04236c07d176a2b1ed22f7043e3a09fe GREEN
......
......@@ -15,22 +15,22 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.state.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.state.model.State;
import org.fortiss.af3.state.model.StateAutomaton;
import org.fortiss.af3.state.model.TransitionSegment;
import org.fortiss.af3.state.model.TransitionSegmentConnector;
import org.fortiss.tooling.base.ui.editor.fx.controller.CurvedLinkLayoutedContentAnchorangeController;
import org.fortiss.tooling.base.ui.editor.fx.controller.CurvedLinkLayoutedDiagramAnchorangeController;
import org.fortiss.tooling.base.ui.editor.fx.controller.EObjectDiagramController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedCurveLinkBendPointController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedDiagramAnchorageController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedEllipticResizableContentController;
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 a {@link StateAutomaton}.
......@@ -41,21 +41,21 @@ public class StateAutomatonControllerFactory implements IControllerFactory {
/** {@inheritDoc} */
@Override
public IController createContentController(IContentMVCBundle model) {
return new LayoutedEllipticResizableContentController<State>(model, State.class);
return new LayoutedEllipticResizableContentController<>(model, State.class);
}
/** {@inheritDoc} */
@Override
public IController createDiagramAnchorageController(IDiagramAnchorageMVCBundle modelBundle) {
return new LayoutedDiagramAnchorageController<TransitionSegmentConnector>(modelBundle,
return new CurvedLinkLayoutedDiagramAnchorangeController<>(modelBundle,
TransitionSegmentConnector.class);
}
/** {@inheritDoc} */
@Override
public IController createContentAnchorageController(IContentAnchorageMVCBundle modelBundle) {
return new CurvedLinkLayoutedContentAnchorangeController<TransitionSegmentConnector>(
modelBundle, TransitionSegmentConnector.class);
return new CurvedLinkLayoutedContentAnchorangeController<>(modelBundle,
TransitionSegmentConnector.class);
}
/** {@inheritDoc} */
......
BehaviorComponentCompositor.java a1dbd75cfce361b709249b0d851f080cf63d243c GREEN
ConnectorConnectionCompositor.java aa5842f6de9a764cbd5e1b90fc56427560e062a0 GREEN
ConnectorConnectionCompositor.java cfa132219000b2f3048c56452e22eeac832314b3 GREEN
ConnectorStateConnectionCompositor.java a0fb18af7ded52cbcb18be83cf1d9960028ceac2 GREEN
StateAutomatonCompositor.java 42625f27b7e2d5de0df39c56618173ff057ea7a5 GREEN
StateCompositor.java 299d369552fb940a1297d64606c3c0c1698e57a8 GREEN
......
......@@ -22,6 +22,7 @@ import org.fortiss.af3.state.model.State;
import org.fortiss.tooling.base.compose.ConnectorConnectionCompositorBase;
import org.fortiss.tooling.base.model.base.ConnectionSegmentBase;
import org.fortiss.tooling.base.model.base.ConnectorBase;
import org.fortiss.tooling.base.model.base.EntryConnectorBase;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.kernel.extension.data.IConnectionCompositionContext;
......@@ -37,17 +38,55 @@ public class ConnectorConnectionCompositor
@Override
public boolean canConnect(ConnectorBase source, ConnectorBase target, State parent,
IConnectionCompositionContext context) {
// Do not allow connections from and to already occupied ports. Since a link can be drawn
// from an entry not to an exit node as well, both end points have to be checked for both
// incoming and outgoing links.
boolean freeSource = source.getOutgoing().isEmpty() && source.getIncoming().isEmpty();
boolean freeTarget = target.getIncoming().isEmpty() && target.getOutgoing().isEmpty();
// Do not allow connections from and to already occupied ports.
// Since a link can be drawn from an entry not to an exit node as well, both end
// points have to be checked for both incoming and outgoing links.
boolean freeSource = false;
boolean freeTarget = false;
// If both connectors are on the same level, they can be connected only once:
if(source.eContainer() == target.eContainer()) {
freeSource = isSameLevelPortFree(source);
freeTarget = isSameLevelPortFree(target);
// In case on of the connections is attached to the parent, it is possible that a port
// has an incoming and an outcoming connection (one on each level):
} else if(source.eContainer() == target.eContainer().eContainer()) {
// Case where the source is the cross-level port:
freeSource = isCrossLevelPortFree(source);
freeTarget = isSameLevelPortFree(target);
} else if(source.eContainer() != target.eContainer().eContainer()) {
// Case where the target is the cross-level port:
freeSource = isSameLevelPortFree(source);
freeTarget = isCrossLevelPortFree(target);
}
if(freeSource && freeTarget) {
return super.canConnect(source, target, parent, context);
}
return false;
}
/**
* Checks whether a port is available for a connection on the same level. In this case the port
* cannot have any other connections.
*/
private boolean isSameLevelPortFree(ConnectorBase connector) {
return connector.getOutgoing().isEmpty() && connector.getIncoming().isEmpty();
}
/**
* Checks whether a port is available for a connection to or from another level. In this case
* the port may already have another connection on the other level. However, the port cannot
* have an existing connection on the level of the connection to be established.
*/
private boolean isCrossLevelPortFree(ConnectorBase connector) {
boolean isFree;
if(connector instanceof EntryConnectorBase) {
isFree = connector.getOutgoing().isEmpty();
} else {
isFree = connector.getIncoming().isEmpty();
}
return isFree;
}
/** {@inheritDoc} */
@Override
protected ConnectionSegmentBase createConnection() {
......
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