--- /dev/null
+import "Simantics/DB"\r
+import "Simantics/Variables"\r
+import "Simantics/Model"\r
+import "Simantics/Entity"\r
+import "Simantics/Subscription"\r
+\r
+import "http://www.simantics.org/Charts-1.2" as CHART\r
+\r
+type Chart = Resource\r
+type ChartGroup = Resource\r
+type ChartItem = Resource\r
+\r
+importJava "org.simantics.charts.ui.SCLChart" where\r
+ @JavaName createNewChart\r
+ """\r
+ Creates a new Chart to the default Charts folder under the given Model parameter. Returns the created Chart.\r
+ """\r
+ createChart :: Model -> <Proc> Chart\r
+\r
+ @JavaName createNewChart\r
+ """\r
+ Creates a new Chart under the given ChartGroup parameter. Returns the created Chart.\r
+ """\r
+ createChartInGroup :: ChartGroup -> <Proc> Chart\r
+\r
+ @JavaName createNewChartGroup\r
+ """\r
+ Creates a new ChartGroup under the given Model parameter. Returns the created ChartGroup.\r
+ """\r
+ createChartGroup :: Model -> <Proc> ChartGroup\r
+\r
+ @JavaName addChartItems\r
+ """\r
+ Creates new chartItem with the given Variable to the given Chart and returns the created ChartItem. New Subscription item is created at the same time.\r
+ """\r
+ addChartItems :: Chart -> Variable -> <WriteGraph> ChartItem \r
+\r
+ @JavaName linkSubToChart\r
+ """\r
+ Links the given Subscription to the given chart and returns the created ChartItem.\r
+ """\r
+ linkSubToChart :: Subscription -> Chart -> <WriteGraph> ChartItem\r
+\r
+"""\r
+Browses the given Model for its Charts and then returns them in a list.\r
+"""\r
+chartsOf :: Model -> <ReadGraph> [Chart]\r
+chartsOf model = recurse (toResource model)\r
+ where\r
+ recurse r = do\r
+ cs = resourceChildrenOf r \r
+ charts = map fromResource $ filter isChart cs\r
+ chartGrp = filter isChartGroup cs\r
+ charts + concatMap recurse chartGrp\r
+ isChart r = isInstanceOf r CHART.TimeSeriesChart\r
+ isChartGroup r = isInstanceOf r CHART.ChartGroup\r