From 19833d0668636b7f65a02797e0a5ba4ea51cfc76 Mon Sep 17 00:00:00 2001 From: Sebastian Bergemann <bergemann@fortiss.org> Date: Thu, 20 Jan 2022 15:11:13 +0100 Subject: [PATCH] Added date update with change notifier for all reuse elements Issue-Ref: 4149 Issue-Url: af3#4149 Signed-off-by: Sebastian Bergemann <bergemann@fortiss.org> --- .../fortiss/tooling/ext/reuse/utils/.ratings | 2 +- .../ReuseLibraryModelElementFactory.java | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/.ratings b/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/.ratings index 3c0000d22..814ab789e 100644 --- a/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/.ratings +++ b/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/.ratings @@ -1,2 +1,2 @@ -ReuseLibraryModelElementFactory.java b6109682e2b465c98d6ff4453f409ab9801e70fa YELLOW +ReuseLibraryModelElementFactory.java d72834d2f7d337dc4bf716f5cfd957c826083517 YELLOW ReuseLibraryUtils.java 623e28edc4ce7d5e7cb46d66ba5dcae6c86bb1bc YELLOW diff --git a/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/ReuseLibraryModelElementFactory.java b/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/ReuseLibraryModelElementFactory.java index b6109682e..d72834d2f 100644 --- a/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/ReuseLibraryModelElementFactory.java +++ b/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/ReuseLibraryModelElementFactory.java @@ -22,7 +22,10 @@ import static org.fortiss.tooling.ext.reuse.utils.ReuseLibraryUtils.getReuseElem import java.util.Date; import java.util.Random; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.ENamedElement; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EContentAdapter; import org.fortiss.tooling.ext.reuse.model.AF3ReuseFactory; import org.fortiss.tooling.ext.reuse.model.ReuseElementSpec; import org.fortiss.tooling.ext.reuse.model.ReuseLibrary; @@ -84,6 +87,24 @@ public class ReuseLibraryModelElementFactory { spec.setSourceLibUUID(sourceLibrary.getLibraryUUID()); spec.setSourceLibName(sourceLibrary.getName()); spec.setLastUpdate(now); + + // if the new reuse element is changed, the update date needs to be updated + element.eAdapters().add(new EContentAdapter() { + @Override + public void notifyChanged(Notification notification) { + // only update if the change was not already a previous date update + Object feature = notification.getFeature(); + if (feature instanceof ENamedElement) { + String featureName = ((ENamedElement) feature).getName(); + if (!featureName.equals("lastUpdate")) { + spec.setLastUpdate(new Date()); + } + } + + super.notifyChanged(notification); + } + }); + return spec; } -- GitLab