]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/SyncTypicalTemplatesToInstances.java
Sync git svn branch with SVN repository r33203.
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / typicals / SyncTypicalTemplatesToInstances.java
index 56d61c86845b3a4941e8da58b088f786aac9dcb6..55f5aef3dabf1869b305b5376d14633abbcf9850 100644 (file)
@@ -545,6 +545,7 @@ public class SyncTypicalTemplatesToInstances extends WriteRequest {
         \r
         // Perform changes\r
         boolean changed = false;\r
+        changed |= synchronizeDiagramChanges(graph, info, template, instance);\r
         changed |= removeElements(graph, info, instanceElementsRemovedFromTemplate);\r
         changed |= addMissingElements(graph, info, template, instance, templateElementsAddedToTemplate);\r
         changed |= synchronizeChangedElements(graph, info, template, instance, changedTemplateElements, templateElementsAddedToTemplate, changedElementsByDiagram == ALL);\r
@@ -553,6 +554,35 @@ public class SyncTypicalTemplatesToInstances extends WriteRequest {
             metadata.addTypical(instance);\r
     }\r
 \r
+    /**\r
+     * Synchronize any configurable aspects of the typical diagram instance itself.\r
+     * Every rule executed here comes from the ontology, nothing is fixed. \r
+     * \r
+     * @param graph\r
+     * @param typicalInfo\r
+     * @param template\r
+     * @param instance\r
+     * @return if any changes were made. \r
+     * @throws DatabaseException\r
+     */\r
+    private boolean synchronizeDiagramChanges(\r
+            WriteGraph graph,\r
+            TypicalInfo typicalInfo,\r
+            Resource template,\r
+            Resource instance)\r
+                    throws DatabaseException\r
+    {\r
+        boolean changed = false;\r
+        for (Resource rule : graph.getObjects(template, MOD.HasTypicalSynchronizationRule)) {\r
+            if (selectedRules != null && !selectedRules.contains(rule))\r
+                continue;\r
+            ITypicalSynchronizationRule r = graph.getPossibleAdapter(rule, ITypicalSynchronizationRule.class);\r
+            if (r != null)\r
+                changed |= r.synchronize(graph, template, instance, typicalInfo);\r
+        }\r
+        return changed;\r
+    }\r
+\r
     /**\r
      * Add elements from template that do not yet exist in the instance.\r
      * \r