From 64a1a3e449b7e515dddbab0cc23aa50618eb432e Mon Sep 17 00:00:00 2001 From: Martin Fleck Date: Tue, 7 Dec 2021 10:50:22 +0100 Subject: [PATCH] #460: Notify source/target feature change on source/target id change Fixes https://github.com/eclipse-glsp/glsp/issues/460 --- .../eclipse/glsp/graph/impl/GEdgeImpl.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/plugins/org.eclipse.glsp.graph/src-gen/org/eclipse/glsp/graph/impl/GEdgeImpl.java b/plugins/org.eclipse.glsp.graph/src-gen/org/eclipse/glsp/graph/impl/GEdgeImpl.java index f3830b5c..16c5cc23 100644 --- a/plugins/org.eclipse.glsp.graph/src-gen/org/eclipse/glsp/graph/impl/GEdgeImpl.java +++ b/plugins/org.eclipse.glsp.graph/src-gen/org/eclipse/glsp/graph/impl/GEdgeImpl.java @@ -430,7 +430,7 @@ public EList getRoutingPoints() { * * * - * @generated + * @generated NOT */ @Override public void setSourceId(final String newSourceId) { @@ -438,6 +438,9 @@ public void setSourceId(final String newSourceId) { sourceId = newSourceId; if (eNotificationRequired()) { eNotify(new ENotificationImpl(this, Notification.SET, GraphPackage.GEDGE__SOURCE_ID, oldSourceId, sourceId)); + GModelElement oldSource = findElement(oldSourceId).orElse(null); + GModelElement newSource = findElement(newSourceId).orElse(null); + eNotify(new ENotificationImpl(this, Notification.SET, GraphPackage.GEDGE__SOURCE, oldSource, newSource)); } } @@ -454,7 +457,7 @@ public void setSourceId(final String newSourceId) { * * * - * @generated + * @generated NOT */ @Override public void setTargetId(final String newTargetId) { @@ -462,6 +465,9 @@ public void setTargetId(final String newTargetId) { targetId = newTargetId; if (eNotificationRequired()) { eNotify(new ENotificationImpl(this, Notification.SET, GraphPackage.GEDGE__TARGET_ID, oldTargetId, targetId)); + GModelElement oldTarget = findElement(oldTargetId).orElse(null); + GModelElement newTarget = findElement(newTargetId).orElse(null); + eNotify(new ENotificationImpl(this, Notification.SET, GraphPackage.GEDGE__TARGET, oldTarget, newTarget)); } } @@ -495,14 +501,10 @@ public GModelElement basicGetSource() { */ @Override public void setSource(final GModelElement newSource) { - if (newSource == null) { - this.sourceId = null; - return; - } - this.sourceId = newSource.getId(); + setSourceId(newSource == null ? null : newSource.getId()); } - private Optional findElement(final String elementId) { + protected Optional findElement(final String elementId) { return GModelIndex.get(this).get(elementId); } @@ -536,11 +538,7 @@ public GModelElement basicGetTarget() { */ @Override public void setTarget(final GModelElement newTarget) { - if (newTarget == null) { - this.targetId = null; - return; - } - this.targetId = newTarget.getId(); + setTargetId(newTarget == null ? null : newTarget.getId()); } /**