]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/scl/Simantics/Typicals.scl
Sync git svn branch with SVN repository r33216.
[simantics/platform.git] / bundles / org.simantics.modeling / scl / Simantics / Typicals.scl
diff --git a/bundles/org.simantics.modeling/scl/Simantics/Typicals.scl b/bundles/org.simantics.modeling/scl/Simantics/Typicals.scl
new file mode 100644 (file)
index 0000000..a16ea6c
--- /dev/null
@@ -0,0 +1,55 @@
+import "Simantics/Ontologies"\r
+import "Simantics/Model"\r
+\r
+@private\r
+toDiagrams composites = map (flip singleObject MOD.CompositeToDiagram) composites\r
+\r
+@private\r
+importJava "org.simantics.modeling.typicals.SyncTypicalTemplatesToInstances" where\r
+    syncTypicals :: Boolean -> [Resource] -> [Resource] -> <WriteGraph> ()\r
+\r
+"""\r
+    syncAllTypicals False currentModel\r
+\r
+Synchronizes all typical master diagrams in the specified model with all\r
+instances of the found typical master diagrams.\r
+\r
+The first argument controls whether a log of the synchronization will be\r
+stored in the database, in the model's Documents folder.\r
+"""\r
+syncAllTypicals :: Boolean -> Resource -> <Proc> ()\r
+syncAllTypicals log model = syncInstancesOfTypicalMasters log masterComposites\r
+    where\r
+        masterComposites = lift2Read searchByTypeShallow model MOD.MasterTypicalCompositeType\r
+\r
+"""\r
+    syncInstancesOfTypicalMasters False [aMasterTypicalComposite]\r
+\r
+Synchronizes all instances of the specified typical master diagram(s).\r
+\r
+The first argument controls whether a log of the synchronization will be\r
+stored in the database, in the model's Documents folder.\r
+\r
+The second argument expects diagram configuration composite resources.\r
+"""\r
+syncInstancesOfTypicalMasters :: Boolean -> [Resource] -> <Proc> ()\r
+syncInstancesOfTypicalMasters log typicalMasterComposites = syncWrite (\_ -> syncTypicals log masterDiagrams [])\r
+    where\r
+        masterDiagrams = lift1Read toDiagrams typicalMasterComposites\r
+\r
+"""\r
+    syncTypicalInstances False [aTypicalInstance]\r
+\r
+Synchronizes the specified typical instance diagram(s) with their master\r
+diagrams.\r
+\r
+The first argument controls whether a log of the synchronization will be\r
+stored in the database, in the model's Documents folder.\r
+\r
+The second argument expects diagram configuration composite resources.\r
+"""\r
+syncTypicalInstances :: Boolean -> [Resource] -> <Proc> ()\r
+syncTypicalInstances log typicalInstanceComposites = let\r
+        instanceDiagrams = lift1Read toDiagrams typicalInstanceComposites\r
+    in\r
+        syncWrite (\_ -> syncTypicals log [] instanceDiagrams)\r