From: Tuukka Lehtonen Date: Wed, 21 Aug 2019 12:32:52 +0000 (+0300) Subject: Small changes to synchronization base impl to allow extending it X-Git-Tag: v1.43.0~136^2~104 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=99fde2d98f5eda43f77c3fad4c07a2f4f234380c Small changes to synchronization base impl to allow extending it gitlab #356 Change-Id: I66327777c16645c582573df0f485d2c5452e088e --- diff --git a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/ModuleUpdateContext.java b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/ModuleUpdateContext.java index a4dea1ab2..246b69360 100644 --- a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/ModuleUpdateContext.java +++ b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/ModuleUpdateContext.java @@ -66,11 +66,20 @@ public class ModuleUpdateContext> { public int getModuleId() { return component.getModuleId(); } - + + public ModuleUpdaterBase getUpdater() { + return updater; + } + public SynchronizationEventHandlerBase getHandler() { return handler; } + @SuppressWarnings("unchecked") + public > E getConcreteHandler() { + return (E) handler; + } + public void setModuleId(int moduleId) { component.setModuleId(moduleId); } diff --git a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java index a6efeefb2..67b120b64 100644 --- a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java +++ b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java @@ -248,7 +248,7 @@ public abstract class SynchronizationEventHandlerBase if(oldChildMap != null) for(T component : oldChildMap.values()) { component.clearParent(); - mapping.addPendingRemoval(component); + addPendingRemoval(component); } } // Alternative implementation when uids are not available. @@ -275,7 +275,7 @@ public abstract class SynchronizationEventHandlerBase if(oldChildMap != null) for(T component : oldChildMap.values()) { component.clearParent(); - mapping.addPendingRemoval(component); + addPendingRemoval(component); } } @@ -334,6 +334,12 @@ public abstract class SynchronizationEventHandlerBase } } + protected void addPendingRemoval(T component) { + if (TRACE_EVENTS) + System.out.println("addPendingRemoval(" + component.componentId + " : " + component.solverComponentName + ")"); + mapping.addPendingRemoval(component); + } + private String getSubprocessName(String name, Collection properties) { for(SerializedVariable property : properties) diff --git a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/MappingBase.java b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/MappingBase.java index 3c96a3fef..423e5a125 100644 --- a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/MappingBase.java +++ b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/MappingBase.java @@ -1,12 +1,13 @@ package org.simantics.structural.synchronization.utils; -import java.io.PrintWriter; - import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectObjectProcedure; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; +import java.io.PrintWriter; +import java.util.function.Consumer; + /** * The entry point to the mapping structure between Simantics database and a * designated solver. It is used to synchronize changes from Simantics to the @@ -219,4 +220,11 @@ abstract public class MappingBase> { return !pendingRemoval.isEmpty(); } + public void forEachPendingRemoval(Consumer consumer) { + pendingRemoval.forEach(c -> { + consumer.accept(c); + return true; + }); + } + }