]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl
Adopt spreadsheet changes made in Balas development
[simantics/platform.git] / bundles / org.simantics.spreadsheet.graph / scl / Spreadsheet / All.scl
index 8898ce10a9a306d58b0ea796e6d96653987fd132..aa58a7f73c2f5654dffac51ce7e81accd1eee6be 100644 (file)
@@ -1,12 +1,45 @@
 include "Simantics/DB"
 include "Simantics/Ontologies"
 include "Simantics/SCL"
+include "Simantics/UI"
 include "Document/All"
 include "File"
 
+
+effect SpreadsheetTransaction 
+    "spreadsheetTransaction" 
+    "org.simantics.spreadsheet.Transaction"
+
+importJava "org.simantics.spreadsheet.graph.ExternalRef" where
+    data ExternalRef
+
 importJava "org.simantics.spreadsheet.common.TableCell" where
     data TableCell
 
+importJava "java.util.function.Consumer" where
+    data Consumer
+
+importJava "org.simantics.spreadsheet.CellEditor" where
+    data CellEditor
+    startTransaction :: CellEditor -> OperationMode -> <Proc> Transaction
+    @JavaName "edit"
+    editProperty_ :: CellEditor -> String -> String -> a -> Binding a -> Maybe Consumer -> <SpreadsheetTransaction> () 
+    @JavaName "edit"
+    editContent :: CellEditor -> String -> Variant -> Maybe Consumer -> <SpreadsheetTransaction> () 
+
+@inline
+editProperty :: Serializable a => CellEditor -> String -> String -> a -> Maybe Consumer -> <SpreadsheetTransaction> ()
+editProperty editor location property value consumer = editProperty_ editor location property value binding consumer
+
+importJava "org.simantics.spreadsheet.OperationMode" where
+    data OperationMode
+    OPERATION :: OperationMode
+    EDIT_MODE :: OperationMode
+
+importJava "org.simantics.spreadsheet.Transaction" where
+    data Transaction
+    commit :: Transaction -> <Proc> ()
+
 importJava "org.simantics.spreadsheet.common.TreeTableCell" where
     data TreeTableCell
 
@@ -41,6 +74,14 @@ importJava "org.simantics.spreadsheet.graph.SpreadsheetGraphUtils" where
     saveInitialCondition :: Variable -> Resource -> String -> <WriteGraph> Resource
     findCell :: Variable -> String -> <ReadGraph> Maybe Variable
     invalidateAll :: Variable -> <ReadGraph> ()
+    extRefVariable :: Variable -> <ReadGraph> Variant
+    extRefActiveVariable :: Variable -> <ReadGraph> Variant
+    cellEditor :: Resource -> <ReadGraph> CellEditor
+    syncExec :: CellEditor -> OperationMode -> (<SpreadsheetTransaction, Proc> a) -> <Proc> a
+    cellColumn :: Variable -> <ReadGraph> Integer
+
+importJava "org.simantics.spreadsheet.Spreadsheets" where
+     cellName :: Integer -> Integer -> String
 
 importJava "org.simantics.spreadsheet.util.SpreadsheetUtils" where
     createSheet :: Resource -> String -> <WriteGraph> Resource
@@ -58,6 +99,11 @@ importJava "org.simantics.spreadsheet.util.SpreadsheetUtils" where
     selectColumn :: Integer -> TableCell -> Boolean
     setSCLLine :: Resource -> Integer -> String -> <WriteGraph> ()
     sheetRun :: Resource -> Variable -> <ReadGraph> Variable
+    @JavaName "sheetRun"
+    bookRun :: Resource -> Variable -> <ReadGraph> Variable
+
+sheetRunDefault :: Resource -> <ReadGraph> Variable
+sheetRunDefault sheet = sheetRun sheet (resourceVariable sheet)
 
 importJava "org.simantics.spreadsheet.graph.SpreadsheetSessionManager" where
     removeSpreadsheetSession :: Variable -> <Proc, WriteGraph> ()
@@ -65,6 +111,11 @@ importJava "org.simantics.spreadsheet.graph.SpreadsheetSessionManager" where
 importJava "org.simantics.spreadsheet.graph.ExcelImport" where
     importBook :: Resource -> File -> <Proc> ()
 
+importSpreadsheetBookAction :: Resource -> <Proc> ()
+importSpreadsheetBookAction res = match fileDialog "foo" [("Excel file", "*.xls"), ("Excel File", "*.xlsx")] with
+  Nothing -> ()
+  Just file -> importBook res file
+
 createSpreadsheetBookAction :: Resource -> <Proc> ()
 createSpreadsheetBookAction res = do
   syncWrite (\() -> createSpreadsheetBookDefault res)