From cec724b0623ecad719c5c08c5e51e20783fc6323 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Fri, 31 Jan 2020 11:58:48 +0200 Subject: [PATCH] Fix DNElementRemover to remove the actual component first if possible gitlab #77 Change-Id: If3f627eff8a0bda7567a313446dff4f2cfd5b634 (cherry picked from commit ba7c2c670c6c2d2c358664474607461f1bbc2d6c) --- .../district/network/ui/DNElementRemover.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/DNElementRemover.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/DNElementRemover.java index 06b31031..a32d5359 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/DNElementRemover.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/DNElementRemover.java @@ -10,6 +10,7 @@ import org.simantics.district.network.DistrictNetworkUtil; import org.simantics.district.network.ontology.DistrictNetworkResource; import org.simantics.layer0.Layer0; import org.simantics.layer0.utils.binaryPredicates.OrderedSetElementsPredicate; +import org.simantics.modeling.ModelingResources; import org.simantics.modeling.adapters.ElementRemover; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,9 +72,15 @@ public class DNElementRemover extends ElementRemover { Boolean trackChangesEnabled = DistrictNetworkUtil.trackChangesEnabled(graph, graph.getPossibleObject(resource, Layer0.getInstance(graph).PartOf)); if (trackChangesEnabled) { DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - Resource mappedComponent = graph.getPossibleObject(resource, DN.MappedComponent); - if (mappedComponent != null) { - RemoverUtil.remove(graph, mappedComponent); + Resource element = graph.getPossibleObject(resource, DN.MappedComponent); + if (element != null) { + // get component + ModelingResources MOD = ModelingResources.getInstance(graph); + Resource component = graph.getPossibleObject(element, MOD.ElementToComponent); + if (component != null) + RemoverUtil.remove(graph, component); + else + RemoverUtil.remove(graph, element); } } } -- 2.47.1