*/
THashSet<T> potentiallyUpdatedComponents = new THashSet<>();
+ /**
+ * Is this potentially an undo/redo-related synchronization?
+ *
+ * Default is true for backwards compatibility.
+ */
+ protected boolean isUndo = true;
+
public SynchronizationEventHandlerBase(Solver solver, ReferenceResolverBase<T> resolver, SolverNameUtil nameUtil,
ComponentFactory<T> componentFactory, ModuleUpdaterFactoryBase<T> moduleUpdaterFactory, MappingBase<T> mapping) {
this.solver = solver;
this.resolver = resolver;
}
+ /**
+ * Mark the undo/redo status of this handler.
+ *
+ * Set 'isUndo' to false when processing a normal synchronization and true when
+ * processing an undo/redo.
+ *
+ * When 'isUndo' is false, loading of component solver state from the state undo context
+ * is skipped for added components.
+ */
+ public void setAsUndo(boolean isUndo) {
+ this.isUndo = isUndo;
+ }
+
@Override
public void beginSynchronization() {
if(TRACE_EVENTS) {
else {
component.attached = false;
context.setModuleName(nameUtil.getFreshName(parentSolverComponentName, name));
- context.addPostUpdateAction(new Runnable() {
- @Override
- public void run() {
- context.stateLoadedFromUndo = mapping.undoContext.loadState(solver,
- context.component.componentId,
- context.component.uid);
- }
- });
+ if (isUndo) {
+ context.addPostUpdateAction(new Runnable() {
+ @Override
+ public void run() {
+ context.stateLoadedFromUndo = mapping.undoContext.loadState(solver,
+ context.component.componentId,
+ context.component.uid);
+ }
+ });
+ }
updater.create(context, properties, connections);
solverComponentNameToComponent.put(context.getModuleName(), component);
}