X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Ftypicals%2FSyncTypicalTemplatesToInstances.java;h=55f5aef3dabf1869b305b5376d14633abbcf9850;hp=56d61c86845b3a4941e8da58b088f786aac9dcb6;hb=fd452722e97db9cf876f4f03a9e44fe750625a92;hpb=a4c65e93ad56fe4f0e43c9b173a218b31e9a33b2 diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/SyncTypicalTemplatesToInstances.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/SyncTypicalTemplatesToInstances.java index 56d61c868..55f5aef3d 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/SyncTypicalTemplatesToInstances.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/SyncTypicalTemplatesToInstances.java @@ -545,6 +545,7 @@ public class SyncTypicalTemplatesToInstances extends WriteRequest { // Perform changes boolean changed = false; + changed |= synchronizeDiagramChanges(graph, info, template, instance); changed |= removeElements(graph, info, instanceElementsRemovedFromTemplate); changed |= addMissingElements(graph, info, template, instance, templateElementsAddedToTemplate); changed |= synchronizeChangedElements(graph, info, template, instance, changedTemplateElements, templateElementsAddedToTemplate, changedElementsByDiagram == ALL); @@ -553,6 +554,35 @@ public class SyncTypicalTemplatesToInstances extends WriteRequest { metadata.addTypical(instance); } + /** + * Synchronize any configurable aspects of the typical diagram instance itself. + * Every rule executed here comes from the ontology, nothing is fixed. + * + * @param graph + * @param typicalInfo + * @param template + * @param instance + * @return if any changes were made. + * @throws DatabaseException + */ + private boolean synchronizeDiagramChanges( + WriteGraph graph, + TypicalInfo typicalInfo, + Resource template, + Resource instance) + throws DatabaseException + { + boolean changed = false; + for (Resource rule : graph.getObjects(template, MOD.HasTypicalSynchronizationRule)) { + if (selectedRules != null && !selectedRules.contains(rule)) + continue; + ITypicalSynchronizationRule r = graph.getPossibleAdapter(rule, ITypicalSynchronizationRule.class); + if (r != null) + changed |= r.synchronize(graph, template, instance, typicalInfo); + } + return changed; + } + /** * Add elements from template that do not yet exist in the instance. *