]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/scl/Simantics/Typicals.scl
Fixed Simantics/Diagram/setElements to resolve attachment relations
[simantics/platform.git] / bundles / org.simantics.modeling / scl / Simantics / Typicals.scl
1 import "Simantics/Ontologies"
2 import "Simantics/Model"
3
4 @private
5 toDiagrams composites = map (flip singleObject MOD.CompositeToDiagram) composites
6
7 @private
8 importJava "org.simantics.modeling.typicals.SyncTypicalTemplatesToInstances" where
9     syncTypicals :: Boolean -> [Resource] -> [Resource] -> <WriteGraph> ()
10
11 """
12     syncAllTypicals False currentModel
13
14 Synchronizes all typical master diagrams in the specified model with all
15 instances of the found typical master diagrams.
16
17 The first argument controls whether a log of the synchronization will be
18 stored in the database, in the model's Documents folder.
19 """
20 syncAllTypicals :: Boolean -> Resource -> <Proc> ()
21 syncAllTypicals log model = syncInstancesOfTypicalMasters log masterComposites
22     where
23         masterComposites = lift2Read searchByTypeShallow model MOD.MasterTypicalCompositeType
24
25 """
26     syncInstancesOfTypicalMasters False [aMasterTypicalComposite]
27
28 Synchronizes all instances of the specified typical master diagram(s).
29
30 The first argument controls whether a log of the synchronization will be
31 stored in the database, in the model's Documents folder.
32
33 The second argument expects diagram configuration composite resources.
34 """
35 syncInstancesOfTypicalMasters :: Boolean -> [Resource] -> <Proc> ()
36 syncInstancesOfTypicalMasters log typicalMasterComposites = syncWrite (\_ -> syncTypicals log masterDiagrams [])
37     where
38         masterDiagrams = lift1Read toDiagrams typicalMasterComposites
39
40 """
41     syncTypicalInstances False [aTypicalInstance]
42
43 Synchronizes the specified typical instance diagram(s) with their master
44 diagrams.
45
46 The first argument controls whether a log of the synchronization will be
47 stored in the database, in the model's Documents folder.
48
49 The second argument expects diagram configuration composite resources.
50 """
51 syncTypicalInstances :: Boolean -> [Resource] -> <Proc> ()
52 syncTypicalInstances log typicalInstanceComposites = let
53         instanceDiagrams = lift1Read toDiagrams typicalInstanceComposites
54     in
55         syncWrite (\_ -> syncTypicals log [] instanceDiagrams)