From cb9643ae2fed519f02b4e95126836722d97105bc Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Fri, 21 Dec 2018 14:32:53 +0200 Subject: [PATCH] Spreadsheet changes Change-Id: Id02f01e1b19e227ea8d0ae6c0887a945874ac317 --- .../spreadsheet/util/SpreadsheetUtils.java | 10 +- .../scl/Spreadsheet/All.scl | 38 +++++ .../simantics/spreadsheet/graph/GraphUI.java | 3 +- .../graph/SpreadsheetGraphUtils.java | 52 +++++++ .../celleditor/GraphCellEditorAdapter.java | 3 +- .../spreadsheet/graph/function/All.java | 133 ++++++++++-------- .../spreadsheet/ui/ClientTableModel.java | 2 +- .../spreadsheet/ui/ExcelAdapter.java | 4 +- .../spreadsheet/ui/SpreadsheetModel.java | 4 +- .../spreadsheet/ui/SpreadsheetTable.java | 2 +- .../org/simantics/spreadsheet/CellEditor.java | 23 --- .../simantics/spreadsheet/ClientModel.java | 5 - .../simantics/spreadsheet/OperationMode.java | 6 + .../simantics/spreadsheet/Transaction.java | 24 ++++ .../spreadsheet/solver/SpreadsheetCell.java | 4 + 15 files changed, 209 insertions(+), 104 deletions(-) create mode 100644 bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/OperationMode.java create mode 100644 bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/Transaction.java diff --git a/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/util/SpreadsheetUtils.java b/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/util/SpreadsheetUtils.java index dcd88cf61..3559a8006 100644 --- a/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/util/SpreadsheetUtils.java +++ b/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/util/SpreadsheetUtils.java @@ -46,16 +46,14 @@ import org.simantics.document.server.io.SimpleFont; import org.simantics.layer0.Layer0; import org.simantics.scl.runtime.function.Function1; import org.simantics.scl.runtime.tuple.Tuple; -import org.simantics.spreadsheet.CellEditor; -import org.simantics.spreadsheet.CellEditor.Transaction; import org.simantics.spreadsheet.ClientModel; -import org.simantics.spreadsheet.ClientModel.OperationMode; +import org.simantics.spreadsheet.OperationMode; import org.simantics.spreadsheet.Range; import org.simantics.spreadsheet.Spreadsheets; +import org.simantics.spreadsheet.Transaction; import org.simantics.spreadsheet.common.TableCell; import org.simantics.spreadsheet.common.cell.StringCellParser; import org.simantics.spreadsheet.resource.SpreadsheetResource; -import org.simantics.spreadsheet.synchronization.LineContentBean; import org.simantics.utils.datastructures.Pair; public class SpreadsheetUtils { @@ -174,7 +172,7 @@ public class SpreadsheetUtils { return true; } - public static void schedule(CellEditor.Transaction transaction, Write write) { + public static void schedule(Transaction transaction, Write write) { if(transaction == null) { @@ -199,7 +197,7 @@ public class SpreadsheetUtils { return new TransactionImpl(mode); } - static class TransactionImpl implements CellEditor.Transaction { + static class TransactionImpl implements Transaction { private ArrayList writes = new ArrayList<>(); private final OperationMode mode; diff --git a/bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl b/bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl index a6660e57b..b493d65f5 100644 --- a/bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl +++ b/bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl @@ -5,12 +5,41 @@ 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 -> Transaction + @JavaName "edit" + editProperty_ :: CellEditor -> String -> String -> a -> Binding a -> Maybe Consumer -> () + @JavaName "edit" + editContent :: CellEditor -> String -> Variant -> Maybe Consumer -> () + +@inline +editProperty :: Serializable a => CellEditor -> String -> String -> a -> Maybe Consumer -> () +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 -> () + importJava "org.simantics.spreadsheet.common.TreeTableCell" where data TreeTableCell @@ -47,6 +76,12 @@ importJava "org.simantics.spreadsheet.graph.SpreadsheetGraphUtils" where invalidateAll :: Variable -> () extRefVariable :: Variable -> Variant extRefActiveVariable :: Variable -> Variant + cellEditor :: Resource -> CellEditor + syncExec :: CellEditor -> OperationMode -> ( a) -> a + cellColumn :: Variable -> Integer + +importJava "org.simantics.spreadsheet.Spreadsheets" where + cellName :: Integer -> Integer -> String importJava "org.simantics.spreadsheet.util.SpreadsheetUtils" where createSheet :: Resource -> String -> Resource @@ -65,6 +100,9 @@ importJava "org.simantics.spreadsheet.util.SpreadsheetUtils" where setSCLLine :: Resource -> Integer -> String -> () sheetRun :: Resource -> Variable -> Variable +sheetRunDefault :: Resource -> Variable +sheetRunDefault sheet = sheetRun sheet (resourceVariable sheet) + importJava "org.simantics.spreadsheet.graph.SpreadsheetSessionManager" where removeSpreadsheetSession :: Variable -> () diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/GraphUI.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/GraphUI.java index 0f0175bfc..5717aa807 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/GraphUI.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/GraphUI.java @@ -59,8 +59,9 @@ import org.simantics.simulator.toolkit.StandardRealm; import org.simantics.spreadsheet.Adaptable; import org.simantics.spreadsheet.CellEditor; import org.simantics.spreadsheet.ClientModel; -import org.simantics.spreadsheet.ClientModel.OperationMode; +import org.simantics.spreadsheet.OperationMode; import org.simantics.spreadsheet.SheetCommands; +import org.simantics.spreadsheet.Transaction; import org.simantics.spreadsheet.event.model.RemoveCellHandler; import org.simantics.spreadsheet.resource.SpreadsheetResource; import org.simantics.spreadsheet.solver.SheetNode; diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetGraphUtils.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetGraphUtils.java index 52b7cab5c..ee57745ae 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetGraphUtils.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetGraphUtils.java @@ -30,20 +30,29 @@ import org.simantics.db.common.utils.LiteralFileUtil; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.ServiceException; import org.simantics.db.layer0.util.Layer0Utils; +import org.simantics.db.layer0.variable.StandardGraphChildVariable; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; import org.simantics.db.procedure.Listener; import org.simantics.db.service.ClusteringSupport; import org.simantics.layer0.Layer0; +import org.simantics.scl.compiler.commands.CommandSession; +import org.simantics.scl.runtime.SCLContext; +import org.simantics.scl.runtime.function.Function; +import org.simantics.scl.runtime.tuple.Tuple0; import org.simantics.scl.runtime.tuple.Tuple2; import org.simantics.simulator.toolkit.StandardRealm; +import org.simantics.spreadsheet.CellEditor; import org.simantics.spreadsheet.ExternalRef; +import org.simantics.spreadsheet.OperationMode; import org.simantics.spreadsheet.Range; import org.simantics.spreadsheet.Spreadsheets; +import org.simantics.spreadsheet.Transaction; import org.simantics.spreadsheet.graph.synchronization.SpreadsheetSynchronizationEventHandler; import org.simantics.spreadsheet.resource.SpreadsheetResource; import org.simantics.spreadsheet.solver.SheetNode; import org.simantics.spreadsheet.solver.SpreadsheetBook; +import org.simantics.spreadsheet.solver.SpreadsheetCell; import org.simantics.spreadsheet.solver.SpreadsheetEngine; import org.simantics.spreadsheet.solver.SpreadsheetLine; import org.simantics.spreadsheet.solver.SpreadsheetStyle; @@ -566,4 +575,47 @@ public class SpreadsheetGraphUtils { } + 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()); + } + } diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/celleditor/GraphCellEditorAdapter.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/celleditor/GraphCellEditorAdapter.java index ae22581a2..9cabb6c32 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/celleditor/GraphCellEditorAdapter.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/celleditor/GraphCellEditorAdapter.java @@ -12,7 +12,8 @@ import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.request.Write; import org.simantics.spreadsheet.CellEditor; -import org.simantics.spreadsheet.ClientModel.OperationMode; +import org.simantics.spreadsheet.OperationMode; +import org.simantics.spreadsheet.Transaction; import org.simantics.spreadsheet.util.SpreadsheetUtils; public class GraphCellEditorAdapter implements CellEditor { diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/function/All.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/function/All.java index 865a60ebe..bc034086c 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/function/All.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/function/All.java @@ -55,6 +55,7 @@ import org.simantics.spreadsheet.CellEditor; import org.simantics.spreadsheet.ClientModel; import org.simantics.spreadsheet.Range; import org.simantics.spreadsheet.Spreadsheets; +import org.simantics.spreadsheet.Transaction; import org.simantics.spreadsheet.graph.SpreadsheetGraphUtils; import org.simantics.spreadsheet.graph.SpreadsheetNodeManager; import org.simantics.spreadsheet.graph.SpreadsheetSessionManager; @@ -560,88 +561,96 @@ public class All { } }; + + public static class DefaultSheetCellEditor extends GraphCellEditorAdapter { + + final public Variable sheet; + + public DefaultSheetCellEditor(Variable sheet, Variable cell) { + super(cell); + this.sheet = sheet; + } + @Override + public void edit(final Transaction transaction, final String location, final String property, final T value, final Binding binding, Consumer callback) { - @SCLValue(type = "ReadGraph -> Resource -> Variable -> CellEditor") - public static CellEditor defaultSheetCellEditor(ReadGraph graph, Resource resource, final Variable context_) throws DatabaseException { - - final Variable sheet = context_.getParent(graph); - - return new GraphCellEditorAdapter(null) { + SpreadsheetUtils.schedule(transaction, new WriteRequest() { - @Override - public void edit(final Transaction transaction, final String location, final String property, final T value, final Binding binding, Consumer callback) { + @Override + public void perform(WriteGraph graph) throws DatabaseException { + CellEditor editor = getPossibleCellEditor(graph, location, value == null ? null : new Variant(binding, value)); + if (editor == null) + return; + editor.edit(transaction, location, property, value, binding, callback); + } + }); - SpreadsheetUtils.schedule(transaction, new WriteRequest() { + } - @Override - public void perform(WriteGraph graph) throws DatabaseException { - CellEditor editor = getPossibleCellEditor(graph, location, value == null ? null : new Variant(binding, value)); - if (editor == null) - return; - editor.edit(transaction, location, property, value, binding, callback); - } - }); + @Override + public void edit(final Transaction transaction, final String location, final Variant value, Consumer callback) { + SpreadsheetUtils.schedule(transaction, new WriteRequest() { - } + @Override + public void perform(WriteGraph graph) throws DatabaseException { + CellEditor editor = getPossibleCellEditor(graph, location, value); + if (editor == null) + return; + editor.edit(transaction, location, value, callback); + } + }); - @Override - public void edit(final Transaction transaction, final String location, final Variant value, Consumer callback) { - SpreadsheetUtils.schedule(transaction, new WriteRequest() { - - @Override - public void perform(WriteGraph graph) throws DatabaseException { - CellEditor editor = getPossibleCellEditor(graph, location, value); - if (editor == null) - return; - editor.edit(transaction, location, value, callback); - } - }); + } - } + private CellEditor getPossibleCellEditor(WriteGraph graph, String location, Variant value) throws DatabaseException { + SpreadsheetResource SHEET = SpreadsheetResource.getInstance(graph); + Range range = Spreadsheets.decodePossibleCellAbsolute(location); + if(range == null) return null; //No editor found - private CellEditor getPossibleCellEditor(WriteGraph graph, String location, Variant value) throws DatabaseException { - SpreadsheetResource SHEET = SpreadsheetResource.getInstance(graph); - Range range = Spreadsheets.decodePossibleCellAbsolute(location); - if(range == null) return null; //No editor found - - List cells = SpreadsheetGraphUtils.possibleConfigurationCellVariables(graph, sheet, range); - if (cells.isEmpty()) { - if (value == null) { - return null; - } else { - cells = SpreadsheetGraphUtils.getOrCreateConfigurationCellVariables(graph, sheet, range); - } + List cells = SpreadsheetGraphUtils.possibleConfigurationCellVariables(graph, sheet, range); + if (cells.isEmpty()) { + if (value == null) { + return null; + } else { + cells = SpreadsheetGraphUtils.getOrCreateConfigurationCellVariables(graph, sheet, range); } - if (cells.size() != 1) - throw new DatabaseException("Can edit only one cell at a time!"); - - return cells.iterator().next().getPropertyValue(graph, SHEET.cellEditor); } + if (cells.size() != 1) + throw new DatabaseException("Can edit only one cell at a time!"); - @Override - public void copy(final Transaction transaction, final String location, final MutableVariant variant, Consumer callback) { + return cells.iterator().next().getPropertyValue(graph, SHEET.cellEditor); + } + + @Override + public void copy(final Transaction transaction, final String location, final MutableVariant variant, Consumer callback) { - SpreadsheetUtils.schedule(transaction, new WriteRequest() { + SpreadsheetUtils.schedule(transaction, new WriteRequest() { - @Override - public void perform(WriteGraph graph) throws DatabaseException { + @Override + public void perform(WriteGraph graph) throws DatabaseException { - SpreadsheetResource SHEET = SpreadsheetResource.getInstance(graph); - Variable variable = sheet.getPossibleChild(graph, location); - if(variable != null) { - CellEditor editor = variable.getPossiblePropertyValue(graph, SHEET.cellEditor); - if(editor != null) { - editor.copy(transaction, location, variant, null); - } + SpreadsheetResource SHEET = SpreadsheetResource.getInstance(graph); + Variable variable = sheet.getPossibleChild(graph, location); + if(variable != null) { + CellEditor editor = variable.getPossiblePropertyValue(graph, SHEET.cellEditor); + if(editor != null) { + editor.copy(transaction, location, variant, null); } } + } - }); + }); - } + } + + } - }; + + @SCLValue(type = "ReadGraph -> Resource -> Variable -> CellEditor") + public static CellEditor defaultSheetCellEditor(ReadGraph graph, Resource resource, final Variable context_) throws DatabaseException { + + final Variable sheet = context_.getParent(graph); + return new DefaultSheetCellEditor(sheet, null); } diff --git a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/ClientTableModel.java b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/ClientTableModel.java index 08a1b0ef6..b77350a0c 100644 --- a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/ClientTableModel.java +++ b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/ClientTableModel.java @@ -18,7 +18,7 @@ import javax.swing.table.DefaultTableModel; import org.simantics.spreadsheet.ClientModel; import org.simantics.spreadsheet.ClientModel.ClientModelListener; -import org.simantics.spreadsheet.ClientModel.OperationMode; +import org.simantics.spreadsheet.OperationMode; import org.simantics.spreadsheet.Spreadsheets; import org.simantics.spreadsheet.solver.SpreadsheetStyle; import org.simantics.spreadsheet.util.SpreadsheetUtils; diff --git a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/ExcelAdapter.java b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/ExcelAdapter.java index a51b32a0f..f39e92c7a 100644 --- a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/ExcelAdapter.java +++ b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/ExcelAdapter.java @@ -24,11 +24,11 @@ import org.simantics.databoard.binding.mutable.MutableVariant; import org.simantics.databoard.binding.mutable.Variant; import org.simantics.spreadsheet.Adaptable; import org.simantics.spreadsheet.CellEditor; -import org.simantics.spreadsheet.CellEditor.Transaction; import org.simantics.spreadsheet.ClientModel; -import org.simantics.spreadsheet.ClientModel.OperationMode; +import org.simantics.spreadsheet.OperationMode; import org.simantics.spreadsheet.Range; import org.simantics.spreadsheet.Spreadsheets; +import org.simantics.spreadsheet.Transaction; import org.simantics.spreadsheet.common.cell.StringCellParser; import org.simantics.spreadsheet.util.SpreadsheetUtils; import org.simantics.utils.threads.logger.ITask; diff --git a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SpreadsheetModel.java b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SpreadsheetModel.java index 7d6051947..137cde7a4 100644 --- a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SpreadsheetModel.java +++ b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SpreadsheetModel.java @@ -68,11 +68,11 @@ import org.simantics.scenegraph.INode; import org.simantics.scenegraph.swing.JScrollPaneSG; import org.simantics.spreadsheet.Adaptable; import org.simantics.spreadsheet.CellEditor; -import org.simantics.spreadsheet.CellEditor.Transaction; import org.simantics.spreadsheet.ClientModel; -import org.simantics.spreadsheet.ClientModel.OperationMode; +import org.simantics.spreadsheet.OperationMode; import org.simantics.spreadsheet.SheetCommands; import org.simantics.spreadsheet.Spreadsheets; +import org.simantics.spreadsheet.Transaction; import org.simantics.spreadsheet.common.cell.Parsers; import org.simantics.spreadsheet.common.cell.StringCellParser; import org.simantics.spreadsheet.event.model.RemoveCellHandler; diff --git a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SpreadsheetTable.java b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SpreadsheetTable.java index ee9a55b1d..96254ae63 100644 --- a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SpreadsheetTable.java +++ b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SpreadsheetTable.java @@ -30,7 +30,7 @@ import org.simantics.scenegraph.INode; import org.simantics.scenegraph.swing.JTableSG; import org.simantics.spreadsheet.CellEditor; import org.simantics.spreadsheet.ClientModel; -import org.simantics.spreadsheet.ClientModel.OperationMode; +import org.simantics.spreadsheet.OperationMode; public class SpreadsheetTable extends JTableSG { diff --git a/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/CellEditor.java b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/CellEditor.java index a90cf5146..4448a8798 100644 --- a/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/CellEditor.java +++ b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/CellEditor.java @@ -11,37 +11,14 @@ *******************************************************************************/ package org.simantics.spreadsheet; -import java.util.List; import java.util.function.Consumer; import org.simantics.databoard.binding.Binding; import org.simantics.databoard.binding.mutable.MutableVariant; import org.simantics.databoard.binding.mutable.Variant; -import org.simantics.spreadsheet.ClientModel.OperationMode; public interface CellEditor { - public interface Transaction { - - void setContext(Object context); - - Object getContext(); - - void add(O operation); - - /* - * Applies the operations collected with this transaction - * - */ - void commit(); - - boolean isOperationMode(); - - List needSynchronization(); - - void needSynchronization(Object synchronizable); - } - /* * Sets the given property of the given cell * diff --git a/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/ClientModel.java b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/ClientModel.java index 7304419d1..bd9b5d1a1 100644 --- a/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/ClientModel.java +++ b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/ClientModel.java @@ -19,11 +19,6 @@ import org.simantics.utils.datastructures.Pair; public interface ClientModel extends CellModifier { - public enum OperationMode { - OPERATION, - EDIT_MODE - } - public interface ClientModelListener { public void rows(int amount); diff --git a/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/OperationMode.java b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/OperationMode.java new file mode 100644 index 000000000..f894cc545 --- /dev/null +++ b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/OperationMode.java @@ -0,0 +1,6 @@ +package org.simantics.spreadsheet; + +public enum OperationMode { + OPERATION, + EDIT_MODE +} \ No newline at end of file diff --git a/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/Transaction.java b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/Transaction.java new file mode 100644 index 000000000..3702a22da --- /dev/null +++ b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/Transaction.java @@ -0,0 +1,24 @@ +package org.simantics.spreadsheet; + +import java.util.List; + +public interface Transaction { + + void setContext(Object context); + + Object getContext(); + + void add(O operation); + + /* + * Applies the operations collected with this transaction + * + */ + void commit(); + + boolean isOperationMode(); + + List needSynchronization(); + + void needSynchronization(Object synchronizable); +} \ No newline at end of file diff --git a/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/solver/SpreadsheetCell.java b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/solver/SpreadsheetCell.java index 6f6a37216..dd05bf370 100644 --- a/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/solver/SpreadsheetCell.java +++ b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/solver/SpreadsheetCell.java @@ -61,6 +61,10 @@ public class SpreadsheetCell implements SpreadsheetElement, SheetNode { public void setContent(Object newContent) { this.content = newContent; } + + public int getColumn() { + return column; + } @Override public String getName() { -- 2.43.2