Skip to content

Commit

Permalink
eclipse-capella#2913 Fix NPE and edge source/target inversion
Browse files Browse the repository at this point in the history
Fix an NPE that failed the migration if an edge add an empty bendpoint
list (edge not displayed on the diagram).
Fix the process that invert source and target of edges that failed for
edges with the same source and target.

Change-Id: I7df8d6d319613f5da6151948efca460a2ab2989b
Signed-off-by: Steve Monnier <[email protected]>
  • Loading branch information
SteveMonnier committed Jan 16, 2025
1 parent 77a9975 commit 3c2b374
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 THALES GLOBAL SERVICES.
* Copyright (c) 2025 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -139,10 +139,10 @@ private void migrateDEdge(DEdge dEdge) {
dEdge.setTargetNode(sourceNode);
dEdge.setBeginLabel(endLabel);
dEdge.setEndLabel(beginLabel);
sourceNodeIncommingEdges.add(dEdge);
targetNodeOutgoingEdges.add(dEdge);
sourceNodeOutgoingEdges.remove(dEdge);
targetNodeIncommingEdges.remove(dEdge);
sourceNodeIncommingEdges.add(dEdge);
targetNodeOutgoingEdges.add(dEdge);

dEdge.getOwnedStyle().setSourceArrow(targetArrow);
dEdge.getOwnedStyle().setTargetArrow(sourceArrow);
Expand Down Expand Up @@ -286,9 +286,11 @@ private void migrateGMFEdge(Edge gmfEdge) {
Optional<Node> endLabel = edgeChildren.stream().filter(this::isEndLabel).map(Node.class::cast).findAny();

// changes
beginLabel.ifPresent(label -> migrateLabelPosition(label, bendpointsList, revBendpointsList));
middleLabel.ifPresent(label -> migrateLabelPosition(label, bendpointsList, revBendpointsList));
endLabel.ifPresent(label -> migrateLabelPosition(label, bendpointsList, revBendpointsList));
if (!bendpointsList.isEmpty()) {
beginLabel.ifPresent(label -> migrateLabelPosition(label, bendpointsList, revBendpointsList));
middleLabel.ifPresent(label -> migrateLabelPosition(label, bendpointsList, revBendpointsList));
endLabel.ifPresent(label -> migrateLabelPosition(label, bendpointsList, revBendpointsList));
}

beginLabel.ifPresent(label -> label.setType(SiriusVisualIDRegistry.getType(DEdgeEndNameEditPart.VISUAL_ID)));
endLabel.ifPresent(label -> label.setType(SiriusVisualIDRegistry.getType(DEdgeBeginNameEditPart.VISUAL_ID)));
Expand Down

0 comments on commit 3c2b374

Please sign in to comment.