From: Tuukka Lehtonen Date: Mon, 29 Aug 2016 10:15:21 +0000 (+0300) Subject: SpreadsheetCells with Circular References support iterations. X-Git-Tag: v1.25.0~146 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=3c9ab161a5c118fe740ab42c8a33ad672081d0d7;p=simantics%2Fplatform.git SpreadsheetCells with Circular References support iterations. Default number of iterations is 100 times. Previously, AstIdentifier visits in CellValueVisitor would throw IllegalStateException. Now, a FormulaError is returned instead. refs #6659 --- diff --git a/bundles/org.simantics.scl.runtime/build.properties b/bundles/org.simantics.scl.runtime/build.properties index cd7bc4044..cbbb8252d 100755 --- a/bundles/org.simantics.scl.runtime/build.properties +++ b/bundles/org.simantics.scl.runtime/build.properties @@ -3,4 +3,4 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ scl/,\ - schema/ + schema/ \ No newline at end of file diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/CellValueVisitor.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/CellValueVisitor.java index b0abb61b1..385af9938 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/CellValueVisitor.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/CellValueVisitor.java @@ -434,7 +434,8 @@ public class CellValueVisitor implements AstValueVisitor { @Override public Object visit(AstIdentifier id) { - throw new IllegalStateException(); + return FormulaError2.NAME.getString(); + //throw new IllegalStateException(); } @Override 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 80e9656e3..9a3e87326 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 @@ -495,7 +495,13 @@ public class GraphUI implements Adaptable, ListenerSupport, AsyncListenerSupport public void edit(Transaction transaction, String location, String property, T value, Binding binding, Consumer callback) { if (ClientModel.ITERATION_ENABLED.equals(location)) { - + Simantics.getSession().asyncRequest(new ReadRequest() { + @Override + public void run(ReadGraph graph) throws DatabaseException { + getBook(graph).setIterationEnabled((boolean)value); + } + }); + return; } if (ClientModel.MODE.equals(location)) { diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetBook.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetBook.java index caf3cd984..e292fd918 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetBook.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetBook.java @@ -57,6 +57,8 @@ public class SpreadsheetBook implements SpreadsheetElement children = new HashMap<>(); + private boolean iterationEnabled; + public int getNewId(SpreadsheetElement element) { int result = idCounter++; children.put(result, element); @@ -401,4 +403,12 @@ public class SpreadsheetBook implements SpreadsheetElement> functions = new HashMap<>(); public int iterationLimit = 100; - public boolean iterationEnabled = false; - public SpreadsheetEvaluationEnvironment(SpreadsheetBook book) { this.book = book; 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 9b4ef34e3..d534c9488 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 @@ -753,6 +753,10 @@ public class SpreadsheetModel { @Override public void actionPerformed(ActionEvent e) { System.out.println("state is " + iterationEnabled.isSelected()); + CellEditor editor = serverInterface.getAdapter(CellEditor.class); + if(editor != null) { + editor.edit(null, ClientModel.ITERATION_ENABLED, ClientModel.ITERATION_ENABLED, iterationEnabled.isSelected(), null, null); + } } });