Skip to content

Commit

Permalink
Fixed exception when moving Subapp with Connection into Subapp
Browse files Browse the repository at this point in the history
  • Loading branch information
sebHollersbacher authored and azoitl committed Jun 3, 2024
1 parent d1dcdca commit 0744d20
Showing 1 changed file with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,14 @@ private Map<IFigure, Integer> calculateInput(final List<InterfaceEditPart> input
((ConnectionEditPart) conn2).getConnectionFigure().getEnd().y));
if (max.isPresent()) {
final ConnectionEditPart connEp = (ConnectionEditPart) max.get();
final Point end = connEp.getConnectionFigure().getEnd();
final var fig = ((GraphicalEditPart) max.get().getSource()).getFigure();
final int y = end.y - (sizes.get(fig).intValue() / 2);
if (connEp.getSource() instanceof final GraphicalEditPart graphicalEditPart) {
final Point end = connEp.getConnectionFigure().getEnd();

if (!isSkipConnection(connEp)) {
map.put(ie.getFigure(), Integer.valueOf(Math.max(y, inputDirectEnd)));
final int y = end.y - (sizes.get(graphicalEditPart.getFigure()).intValue() / 2);

if (!isSkipConnection(connEp)) {
map.put(ie.getFigure(), Integer.valueOf(Math.max(y, inputDirectEnd)));
}
}
} else {
map.put(ie.getFigure(), Integer.valueOf(Integer.MAX_VALUE));
Expand All @@ -449,12 +451,13 @@ private Map<IFigure, Integer> calculateOutput(final List<InterfaceEditPart> outp
((ConnectionEditPart) conn2).getConnectionFigure().getStart().y));
if (max.isPresent()) {
final ConnectionEditPart connEp = (ConnectionEditPart) max.get();
final Point start = connEp.getConnectionFigure().getStart();
final var fig = ((GraphicalEditPart) max.get().getTarget()).getFigure();
final int y = start.y - (sizes.get(fig).intValue() / 2);
if (connEp.getTarget() instanceof final GraphicalEditPart graphicalEditPart) {
final Point start = connEp.getConnectionFigure().getStart();
final int y = start.y - (sizes.get(graphicalEditPart.getFigure()).intValue() / 2);

if (!isSkipConnection(connEp)) {
map.put(ie.getFigure(), Integer.valueOf(Math.max(y, outputDirectEnd)));
if (!isSkipConnection(connEp)) {
map.put(ie.getFigure(), Integer.valueOf(Math.max(y, outputDirectEnd)));
}
}
} else {
map.put(ie.getFigure(), Integer.valueOf(Integer.MAX_VALUE));
Expand All @@ -464,10 +467,14 @@ private Map<IFigure, Integer> calculateOutput(final List<InterfaceEditPart> outp
}

private static boolean isSkipConnection(final ConnectionEditPart ep) {
final var sourceModel = (IInterfaceElement) ep.getSource().getModel();
final var targetModel = (IInterfaceElement) ep.getTarget().getModel();
return sourceModel.eContainer().eContainer() instanceof final SubApp sourceSub
&& targetModel.eContainer().eContainer() instanceof final SubApp targetSub && sourceSub == targetSub;
if (ep.getSource() != null && ep.getTarget() != null) {
final var sourceModel = (IInterfaceElement) ep.getSource().getModel();
final var targetModel = (IInterfaceElement) ep.getTarget().getModel();
return sourceModel.eContainer().eContainer() instanceof final SubApp sourceSub
&& targetModel.eContainer().eContainer() instanceof final SubApp targetSub
&& sourceSub == targetSub;
}
return false;
}

private void resolveCollisions(final Map<IFigure, Integer> positions) {
Expand Down

0 comments on commit 0744d20

Please sign in to comment.