2 include "Simantics/Ontologies"
3 include "Simantics/SCL"
9 effect SpreadsheetTransaction
10 "spreadsheetTransaction"
11 "org.simantics.spreadsheet.Transaction"
13 importJava "org.simantics.spreadsheet.graph.ExternalRef" where
16 importJava "org.simantics.spreadsheet.common.TableCell" where
19 importJava "java.util.function.Consumer" where
22 importJava "org.simantics.spreadsheet.CellEditor" where
24 startTransaction :: CellEditor -> OperationMode -> <Proc> Transaction
26 editProperty_ :: CellEditor -> String -> String -> a -> Binding a -> Maybe Consumer -> <SpreadsheetTransaction> ()
28 editContent :: CellEditor -> String -> Variant -> Maybe Consumer -> <SpreadsheetTransaction> ()
31 editProperty :: Serializable a => CellEditor -> String -> String -> a -> Maybe Consumer -> <SpreadsheetTransaction> ()
32 editProperty editor location property value consumer = editProperty_ editor location property value binding consumer
34 importJava "org.simantics.spreadsheet.OperationMode" where
36 OPERATION :: OperationMode
37 EDIT_MODE :: OperationMode
39 importJava "org.simantics.spreadsheet.Transaction" where
41 commit :: Transaction -> <Proc> ()
43 importJava "org.simantics.spreadsheet.common.TreeTableCell" where
47 getTreeTableCellData :: TreeTableCell -> <Proc> a
49 createTreeTableCell :: String -> a -> Maybe b -> Integer -> Integer -> Integer -> Boolean -> <Proc> TreeTableCell
51 createTreeTableCell2 :: String -> a -> Maybe b -> a -> Integer -> Integer -> Boolean -> <Proc> TreeTableCell
54 treeTableCellText :: TreeTableCell -> <Proc> String
56 treeTableCellFont :: TreeTableCell -> <Proc> Maybe IFont
58 treeTableCellRow :: TreeTableCell -> <Proc> Integer
60 treeTableCellColumn :: TreeTableCell -> <Proc> Integer
62 importJava "org.simantics.spreadsheet.common.SpreadsheetCell" where
65 importJava "org.simantics.spreadsheet.graph.SCL" where
66 toVariant :: a -> Variant
67 modelsSourceContribution :: Resource -> <ReadGraph> [Variable]
68 modelsSourceContributionLabeler :: Variable -> <ReadGraph> String
70 importJava "org.simantics.spreadsheet.graph.SpreadsheetGraphUtils" where
71 @JavaName "fullSynchronization"
72 fullSynchronizeSheet :: Variable -> <ReadGraph> Boolean
73 evaluateAll :: Variable -> <ReadGraph> ()
74 saveInitialCondition :: Variable -> Resource -> String -> <WriteGraph> Resource
75 findCell :: Variable -> String -> <ReadGraph> Maybe Variable
76 invalidateAll :: Variable -> <ReadGraph> ()
77 extRefVariable :: Variable -> <ReadGraph> Variant
78 extRefActiveVariable :: Variable -> <ReadGraph> Variant
79 cellEditor :: Resource -> <ReadGraph> CellEditor
80 syncExec :: CellEditor -> OperationMode -> (<SpreadsheetTransaction, Proc> a) -> <Proc> a
81 cellColumn :: Variable -> <ReadGraph> Integer
83 importJava "org.simantics.spreadsheet.Spreadsheets" where
84 cellName :: Integer -> Integer -> String
86 importJava "org.simantics.spreadsheet.util.SpreadsheetUtils" where
87 createSheet :: Resource -> String -> <WriteGraph> Resource
88 queryCells :: a -> [TableCell]
89 modifyCells1 :: [TableCell] -> (TableCell -> TableCell) -> [TableCell]
90 modifyCells :: [TableCell] -> [(TableCell -> TableCell)] -> [TableCell]
91 organizeCells :: Integer -> [String] -> [TableCell] -> [TableCell]
92 applyFont :: IFont -> (TableCell -> Boolean) -> TableCell -> TableCell
93 applyAlign :: Integer -> (TableCell -> Boolean) -> TableCell -> TableCell
94 applyForeground :: IColor -> (TableCell -> Boolean) -> TableCell -> TableCell
95 applyBackground :: IColor -> (TableCell -> Boolean) -> TableCell -> TableCell
96 simpleFont :: String -> String -> Integer -> IFont
97 rgbColor :: Integer -> Integer -> Integer -> IColor
98 selectRow :: Integer -> TableCell -> Boolean
99 selectColumn :: Integer -> TableCell -> Boolean
100 setSCLLine :: Resource -> Integer -> String -> <WriteGraph> ()
101 sheetRun :: Resource -> Variable -> <ReadGraph> Variable
103 sheetRunDefault :: Resource -> <ReadGraph> Variable
104 sheetRunDefault sheet = sheetRun sheet (resourceVariable sheet)
106 importJava "org.simantics.spreadsheet.graph.SpreadsheetSessionManager" where
107 removeSpreadsheetSession :: Variable -> <Proc, WriteGraph> ()
109 importJava "org.simantics.spreadsheet.graph.ExcelImport" where
110 importBook :: Resource -> File -> <Proc> ()
112 importSpreadsheetBookAction :: Resource -> <Proc> ()
113 importSpreadsheetBookAction res = match fileDialog "foo" [("Excel file", "*.xls"), ("Excel File", "*.xlsx")] with
115 Just file -> importBook res file
117 createSpreadsheetBookAction :: Resource -> <Proc> ()
118 createSpreadsheetBookAction res = do
119 syncWrite (\() -> createSpreadsheetBookDefault res)
122 createSpreadsheetSheetAction :: Resource -> <Proc> ()
123 createSpreadsheetSheetAction res = do
124 syncWrite (\() -> createSpreadsheetDefault res)
127 createSpreadsheetDefault :: Resource -> <WriteGraph> Resource
128 createSpreadsheetDefault library = createSheet library $ findFreshEscapedName "Sheet" library
130 createSpreadsheetBookDefault :: Resource -> <WriteGraph> Resource
131 createSpreadsheetBookDefault library = createSpreadsheetBook library $ findFreshEscapedName "Book" library
133 createRange :: Resource -> Resource -> String -> String -> <WriteGraph> Resource
134 createRange library type_ name expression = do
135 range = newResource ()
136 claim range L0.InstanceOf type_
137 claimRelatedValue range L0.HasName name
138 createSCLValue range SHEET.ExpressionRange.cells SHEET.SCLValue expression
139 claim range L0.PartOf library
142 createSpreadsheetBook :: Resource -> String -> <WriteGraph> Resource
143 createSpreadsheetBook library name = do
145 book = newResource ()
146 claim book L0.InstanceOf SHEET.Book
147 claimRelatedValue book L0.HasName name
148 claim book L0.PartOf library
149 createSheet book "Sheet"
150 addCommentMetadata ("Created Spreadsheet Book " + name)