+ public static CellEditor cellEditor(ReadGraph graph, Resource sheet) throws DatabaseException {
+ SpreadsheetResource SHEET = SpreadsheetResource.getInstance(graph);
+ Variable sheetVariable = Variables.getVariable(graph, sheet);
+ return sheetVariable.getPropertyValue(graph, SHEET.cellEditor);
+ }
+
+ public static final String SPREADSHEET_TRANSACTION = "spreadsheetTransaction";
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static Object syncExec(CellEditor editor, OperationMode mode, Function fun) throws InterruptedException {
+
+ Transaction tr = editor.startTransaction(mode);
+
+ SCLContext context = SCLContext.getCurrent();
+ Transaction oldTransaction = (Transaction)context.put(SPREADSHEET_TRANSACTION, tr);
+
+ Object result = null;
+
+ try {
+
+ result = fun.apply(Tuple0.INSTANCE);
+
+ } finally {
+
+ tr.commit();
+
+ context.put(SPREADSHEET_TRANSACTION, oldTransaction);
+
+ }
+
+ return result;
+
+ }
+
+ public static int cellColumn(ReadGraph graph, Variable cell) {
+ if(cell instanceof StandardGraphChildVariable) {
+ StandardGraphChildVariable sgcv = (StandardGraphChildVariable)cell;
+ SpreadsheetCell sc = (SpreadsheetCell)sgcv.node.node;
+ return sc.getColumn();
+ }
+ throw new IllegalStateException("Expected StandardGraphChildVariable, got " + cell.getClass().getName());
+ }
+