X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Ftypicals%2FSyncTypicalTemplatesToInstances.java;h=55f5aef3dabf1869b305b5376d14633abbcf9850;hb=23755ed9225d2e231bcde85c5f6a36d1e1040c16;hp=435d6447324e0497b55a7d46b1442412094f37e5;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git 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 435d64473..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 @@ -437,7 +437,11 @@ public class SyncTypicalTemplatesToInstances extends WriteRequest { private boolean isSynchronizedConnector(ReadGraph graph, Resource templateConnection, Resource instanceConnector) throws DatabaseException { DiagramResource DIA = DiagramResource.getInstance(graph); Resource instanceConnection = graph.getPossibleObject(instanceConnector, DIA.IsConnectorOf); - return graph.hasStatement(instanceConnection, MOD.HasElementSource, templateConnection); + return graph.hasStatement(instanceConnection, MOD.HasElementSource, templateConnection) + // If the master connection has been removed, this is all that's left + // to identify a connection that at least was originally synchronized + // from the typical master to this instance. + || graph.hasStatement(instanceConnection, MOD.IsTemplatized); } /** @@ -541,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); @@ -549,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. *