]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl
ddfd3bef027adc184773dc43efe6cac5316c94ad
[simantics/platform.git] / bundles / org.simantics.spreadsheet.graph / scl / Spreadsheet / All.scl
1 include "Simantics/DB"
2 include "Simantics/Ontologies"
3 include "Simantics/SCL"
4 include "Document/All"
5 include "File"
6
7 importJava "org.simantics.spreadsheet.common.TableCell" where
8     data TableCell
9
10 importJava "org.simantics.spreadsheet.common.TreeTableCell" where
11     data TreeTableCell
12
13 importJava "org.simantics.spreadsheet.common.SpreadsheetCell" where
14     data SpreadsheetCell
15
16 importJava "org.simantics.spreadsheet.graph.SCL" where
17     toVariant :: a -> Variant
18     modelsSourceContribution :: Resource -> <ReadGraph> [Variable]
19     modelsSourceContributionLabeler :: Variable -> <ReadGraph> String
20
21 importJava "org.simantics.spreadsheet.graph.SpreadsheetGraphUtils" where
22     @JavaName "fullSynchronization"
23     fullSynchronizeSheet :: Variable -> <ReadGraph> Boolean
24     evaluateAll :: Variable -> <ReadGraph> ()
25     saveInitialCondition :: Variable -> Resource -> String -> <WriteGraph> Resource
26     findCell :: Variable -> String -> <ReadGraph> Maybe Variable
27     invalidateAll :: Variable -> <ReadGraph> ()
28
29 importJava "org.simantics.spreadsheet.util.SpreadsheetUtils" where
30     createSheet :: Resource -> String -> <WriteGraph> Resource
31     queryCells :: a -> [TableCell]
32     modifyCells1 :: [TableCell] -> (TableCell -> TableCell) -> [TableCell]
33     modifyCells :: [TableCell] -> [(TableCell -> TableCell)] -> [TableCell]
34     organizeCells :: Integer -> [String] -> [TableCell] -> [TableCell]
35     applyFont :: IFont -> (TableCell -> Boolean) -> TableCell -> TableCell
36     applyAlign :: Integer -> (TableCell -> Boolean) -> TableCell -> TableCell
37     applyForeground :: IColor -> (TableCell -> Boolean) -> TableCell -> TableCell
38     applyBackground :: IColor -> (TableCell -> Boolean) -> TableCell -> TableCell
39     simpleFont :: String -> String -> Integer -> IFont
40     rgbColor :: Integer -> Integer -> Integer -> IColor
41     selectRow :: Integer -> TableCell -> Boolean
42     selectColumn :: Integer -> TableCell -> Boolean
43     setSCLLine :: Resource -> Integer -> String -> <WriteGraph> ()
44     sheetRun :: Resource -> Variable -> <ReadGraph> Variable
45     
46 importJava "org.simantics.spreadsheet.graph.ExcelImport" where
47     importBook :: Resource -> File -> <Proc> ()
48
49 createSpreadsheetBookAction :: Resource -> <Proc> ()
50 createSpreadsheetBookAction res = do
51   syncWrite (\() -> createSpreadsheetBookDefault res)
52   ()
53   
54 createSpreadsheetSheetAction :: Resource -> <Proc> ()
55 createSpreadsheetSheetAction res = do
56   syncWrite (\() -> createSpreadsheetDefault res)
57   ()
58
59 createSpreadsheetDefault :: Resource -> <WriteGraph> Resource
60 createSpreadsheetDefault library = createSheet library $ findFreshEscapedName "Sheet" library 
61
62 createSpreadsheetBookDefault :: Resource -> <WriteGraph> Resource
63 createSpreadsheetBookDefault library = createSpreadsheetBook library $ findFreshEscapedName "Book" library 
64
65 createRange :: Resource -> Resource -> String -> String -> <WriteGraph> Resource
66 createRange library type_ name expression = do
67     range = newResource ()
68     claim range L0.InstanceOf type_
69     claimRelatedValue range L0.HasName name
70     createSCLValue range SHEET.ExpressionRange.cells SHEET.SCLValue expression
71     claim range L0.PartOf library
72     range
73
74 createSpreadsheetBook :: Resource -> String -> <WriteGraph> Resource
75 createSpreadsheetBook library name = do
76     markUndoPoint ()
77     book = newResource ()
78     claim book L0.InstanceOf SHEET.Book
79     claimRelatedValue book L0.HasName name
80     claim book L0.PartOf library
81     createSheet book "Sheet"
82     addCommentMetadata ("Created Spreadsheet Book " + name)
83     book
84