package org.simantics.spreadsheet.graph;
import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
+import org.simantics.databoard.binding.Binding;
import org.simantics.layer0.Layer0;
import org.simantics.simulator.toolkit.StandardNodeManager;
import org.simantics.simulator.variable.exceptions.NodeManagerException;
return null;
}
}
-
+
+ //Custom setValue logic for SpreadsheetNodeManager - calls the setValueAndFireSelectedListeners
+ @Override
+ public void setValue(SheetNode node, Object value, Binding binding) throws NodeManagerException {
+ Set<SheetNode> dirtyNodeContents = findDirtyNodeContents(node);
+ super.setValueAndFireSelectedListeners(node, value, binding, dirtyNodeContents);
+ }
+
+ //Find the cells that are used by this cell and their SpreadsheetContents, so that they can be marked as dirty later
+ public Set<SheetNode> findDirtyNodeContents(SheetNode node){
+ Set<SheetNode> dirty = new HashSet<>();
+
+ SpreadsheetCell sscell = null;
+ if(node instanceof SpreadsheetCell) {
+ sscell = (SpreadsheetCell)node;
+ } else if (node instanceof SpreadsheetCellContent) {
+ sscell = ((SpreadsheetCellContent)node).cell;
+ }
+
+ if(sscell != null) {
+ Set<SpreadsheetCell> result = ((SpreadsheetRealm)super.getRealm()).getEngine().invalidate(sscell);
+ dirty.addAll(result);
+ }
+
+ Set<SheetNode> dirtyNodeContents = new HashSet<>();
+ for(SheetNode cell : dirty) {
+ Map<String, SheetNode> properties = cell.getProperties();
+ dirtyNodeContents.add((SpreadsheetCellContent)properties.get("content"));
+ }
+
+ return dirtyNodeContents;
+ }
}