From 3c2b37469df3e7c1d23a9e971c57165e159a11f0 Mon Sep 17 00:00:00 2001 From: Steve Monnier Date: Tue, 14 Jan 2025 16:50:28 -0500 Subject: [PATCH] #2913 Fix NPE and edge source/target inversion 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 --- .../aird/AssociationCDBMigrationContributor.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/plugins/org.polarsys.capella.core.data.migration/src/org/polarsys/capella/core/data/migration/aird/AssociationCDBMigrationContributor.java b/core/plugins/org.polarsys.capella.core.data.migration/src/org/polarsys/capella/core/data/migration/aird/AssociationCDBMigrationContributor.java index eea7d267ae..c233f1c101 100644 --- a/core/plugins/org.polarsys.capella.core.data.migration/src/org/polarsys/capella/core/data/migration/aird/AssociationCDBMigrationContributor.java +++ b/core/plugins/org.polarsys.capella.core.data.migration/src/org/polarsys/capella/core/data/migration/aird/AssociationCDBMigrationContributor.java @@ -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 @@ -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); @@ -286,9 +286,11 @@ private void migrateGMFEdge(Edge gmfEdge) { Optional 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)));