Default number of iterations is 100 times.
Previously, AstIdentifier visits in CellValueVisitor would throw
IllegalStateException. Now, a FormulaError is returned instead.
refs #6659
bin.includes = META-INF/,\\r
.,\\r
scl/,\\r
- schema/\r
+ schema/
\ No newline at end of file
\r
@Override\r
public Object visit(AstIdentifier id) {\r
- throw new IllegalStateException();\r
+ return FormulaError2.NAME.getString();\r
+ //throw new IllegalStateException();\r
}\r
\r
@Override\r
public <T> void edit(Transaction<Write> transaction, String location, String property, T value, Binding binding, Consumer<?> callback) {\r
\r
if (ClientModel.ITERATION_ENABLED.equals(location)) {\r
- \r
+ Simantics.getSession().asyncRequest(new ReadRequest() {\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ getBook(graph).setIterationEnabled((boolean)value);\r
+ }\r
+ });\r
+ return;\r
}\r
\r
if (ClientModel.MODE.equals(location)) {\r
\r
public Map<Integer, SpreadsheetElement> children = new HashMap<>();\r
\r
+ private boolean iterationEnabled;\r
+\r
public int getNewId(SpreadsheetElement element) {\r
int result = idCounter++;\r
children.put(result, element);\r
\r
}\r
\r
+ public void setIterationEnabled(boolean value) {\r
+ this.iterationEnabled = value;\r
+ }\r
+ \r
+ public boolean isIterationEnabled() {\r
+ return iterationEnabled;\r
+ }\r
+\r
}\r
AstValue value = ((SpreadsheetFormula)content).value;\r
if(this.inProgress == true) this.iterations++;\r
\r
- if(env.iterationEnabled == false){\r
+ if(!env.getBook().isIterationEnabled()){\r
if(this.inProgress == false){\r
this.inProgress = true;\r
f.result = value.accept(visitor);\r
}\r
else f.result = FormulaError2.CIRCULAR_REF.getString();\r
}\r
- else if(iterations<env.iterationLimit){\r
+ else if(this.iterations<env.iterationLimit){\r
this.inProgress = true;\r
f.result = value.accept(visitor);\r
}\r
- else f.result = 0.0;\r
+ else {\r
+ if(f.result==null)\r
+ f.result = 0.0;\r
+ }\r
\r
env.getBook().registerReferences(makeReferenceKey(), visitor.getReferences());\r
}\r
this.inProgress = false;\r
+ this.iterations = 0;\r
return (T)f.result;\r
} else if (content instanceof SpreadsheetSCLConstant) {\r
SpreadsheetSCLConstant sclConstant = (SpreadsheetSCLConstant) content;\r
final private SpreadsheetBook book;\r
private Map<String, CellFormulaFunction<?>> functions = new HashMap<>();\r
public int iterationLimit = 100;\r
- public boolean iterationEnabled = false;\r
- \r
\r
public SpreadsheetEvaluationEnvironment(SpreadsheetBook book) {\r
this.book = book;\r
@Override\r
public void actionPerformed(ActionEvent e) {\r
System.out.println("state is " + iterationEnabled.isSelected());\r
+ CellEditor editor = serverInterface.getAdapter(CellEditor.class);\r
+ if(editor != null) {\r
+ editor.edit(null, ClientModel.ITERATION_ENABLED, ClientModel.ITERATION_ENABLED, iterationEnabled.isSelected(), null, null);\r
+ }\r
}\r
});\r
\r