]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.template2d.ui/scl/Simantics/DrawingTemplate.scl
Merge branch 'feature/funcwrite'
[simantics/platform.git] / bundles / org.simantics.modeling.template2d.ui / scl / Simantics / DrawingTemplate.scl
1 import "Simantics/Variables"
2 include "Simantics/Model"
3 import "Simantics/Misc"
4 import "Simantics/Library"
5 import "Simantics/Diagram"
6 import "Simantics/Flag"
7 //import "Simantics/DB"
8 //import "Simantics/Entity"
9
10 // --- Entity types -------------------------------------------------
11
12 type DrawingTemplate = Resource
13 type DrawingTemplateLibrary = Resource
14 type FlagTable = Resource
15 type VisualComposite = Resource
16 type FlagTypeVisual = Resource
17 type VisualFilter = Resource
18 type Monitor = Resource
19 type SVGImage = Resource
20
21 importJava "org.simantics.modeling.template2d.ui.actions.NewDrawingTemplate" where
22     @JavaName createDrawingTemplate
23     """
24     Creates new Drawing Template under the given Drawing Template library instance. Returns the created Drawing Template.
25     """
26     createDrawingTemplate :: DrawingTemplateLibrary -> <WriteGraph> DrawingTemplate
27     
28     @JavaName getDrawingTemplateLibrary
29     """
30     Returns the Drawing Template library folder of the given Model instance.
31     """
32     drawingTemplateLibraryOf :: Model -> <ReadGraph> DrawingTemplateLibrary 
33     
34 importJava "org.simantics.modeling.template2d.ui.actions.NewFlagTable" where
35     @JavaName createFlagTable
36     """
37     Creates new Flag Table under the given Drawing Template instance. Returns the created Flag Table.
38     """
39     createFlagTable :: DrawingTemplate -> <WriteGraph> FlagTable
40     
41 importJava "org.simantics.modeling.template2d.ui.actions.NewScenegraph" where
42     @JavaName createVisualComposite
43     """
44     Creates new Visual Composite under the given Drawing Template instance. Returns the created Visual Composite.
45     """
46     createVisualComposite :: DrawingTemplate -> <WriteGraph> VisualComposite
47     
48 importJava "org.simantics.modeling.template2d.ui.actions.NewFlagTypeVisual" where
49     @JavaName createNewFlagTypeVisual
50     """
51     Creates new FlagTypeVisual under the given Flag Table instance. Returns the created FlagTypeVisual
52     """
53     createFlagTypeVisual :: FlagTable -> <WriteGraph> FlagTypeVisual
54
55 importJava "org.simantics.modeling.template2d.ui.actions.NewFlagTypeVisualFilter" where
56     @JavaName createNewFilter
57     """
58     Creates new Filter under the given Flag Table instance. Returns the created Filter.
59     """
60     createFilter :: FlagTable -> <WriteGraph> VisualFilter
61
62 importJava "org.simantics.modeling.template2d.ui.actions.NewMonitor" where
63     @JavaName createNewMonitor
64     """
65     Creates new Monitor under the given Flag Table instance. Returns the created Monitor.
66     """
67     createMonitor :: FlagTable -> <WriteGraph> Monitor
68     
69     @JavaName createNewMonitor
70     """
71     Creates new Monitor under the given Visual Composite instance. Returns the created Monitor.
72     """
73     createMonitorInComposite :: VisualComposite -> <WriteGraph> Monitor
74     
75 importJava "org.simantics.modeling.template2d.ui.actions.NewSVGImage" where
76     @JavaName createNewSVGImage
77     """
78     Creates new SVG image under the given Flag Table instance. Returns the created SVG Image.
79     """
80     createImageInTable :: FlagTable -> <WriteGraph> SVGImage
81     
82     @JavaName createNewSVGImage
83     """
84     Creates new SVG image under the given Visual Composite instance. Returns the created SVG Image.
85     """
86     createImageInComposite :: VisualComposite -> <WriteGraph> SVGImage
87
88 importJava "org.simantics.modeling.template2d.ui.wizard.DrawingTemplateExporter" where
89     @JavaName doExport
90     """
91     Exports the given Drawing Template to the given File location
92     """
93     exportDrawingTemplate :: File -> DrawingTemplate -> <Proc> ()
94
95 importJava "org.simantics.modeling.template2d.ui.actions.AssignDrawingTemplate" where
96     @Javaname assignTemplateToDiagram
97     """
98     Assigns the given Drawing Template to the given Diagram instance
99     """
100     assignTemplateToDiagrams :: [Diagram] -> DrawingTemplate -> <WriteGraph> ()
101
102 assignTemplateToDiagram :: Diagram -> DrawingTemplate -> <WriteGraph> ()
103 assignTemplateToDiagram diagram template = assignTemplateToDiagrams [diagram] template
104
105 importJava "org.simantics.modeling.ui.SCLLibrary" where
106     @JavaName createLibrary
107     """
108     Creates a new Library under the given Drawing Template parameter. Returns the created Library.
109     """
110     createLibraryInTemplate :: DrawingTemplate -> <Proc> Library
111
112 importJava "org.simantics.modeling.ModelingUtils" where
113     importDrawingTemplate :: Model -> File -> <Proc> Resource
114
115 setMonitorPropertyValue :: Monitor -> String -> String -> <WriteGraph> ()
116 setMonitorPropertyValue monitor property newValue = do
117     monitorUri = uriOf monitor
118     completeUri = monitorUri + "#" + property + "#HasDisplayValue"
119     propertyVariable = variable completeUri
120     setValue propertyVariable newValue
121     
122 setFlagTablePropertyValue :: FlagTable -> String -> String -> <WriteGraph> ()
123 setFlagTablePropertyValue flagTable property newValue = do
124     flagTableUri = uriOf flagTable
125     completeUri = flagTableUri + "#" + property + "#HasDisplayValue"
126     propertyVariable = variable completeUri
127     setValue propertyVariable newValue
128
129 importJava "org.simantics.modeling.ui.SCLDiagramTemplate" where
130     templateComposite :: Variable -> <ReadGraph> Variable
131     templateDiagram :: Variable -> <ReadGraph> Variable
132     templateModel :: Variable -> <ReadGraph> Variable
133
134 importJava "org.simantics.diagram.flag.IOTableUtil" where
135     bindFlagToTable :: Diagram -> Flag -> Double -> Double -> <WriteGraph> Boolean