X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2FSpreadsheetNodeManager.java;h=caa6dc23f4602d10589187018c99f66a9f1f9a24;hb=bb4e04be3cb29a5d08e412cd4eaa90ad0158b954;hp=a6ebeb0980ad0eb811d75b9c31e28d7f318a33ab;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetNodeManager.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetNodeManager.java index a6ebeb098..caa6dc23f 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetNodeManager.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetNodeManager.java @@ -1,23 +1,26 @@ package org.simantics.spreadsheet.graph; import java.util.Collections; +import java.util.HashSet; +import java.util.Map; import java.util.Set; -import org.simantics.db.layer0.StandardNodeManager; +import org.simantics.databoard.binding.Binding; import org.simantics.layer0.Layer0; +import org.simantics.simulator.toolkit.StandardNodeManager; import org.simantics.simulator.variable.exceptions.NodeManagerException; import org.simantics.spreadsheet.resource.SpreadsheetResource; import org.simantics.structural.stubs.StructuralResource2; @SuppressWarnings("rawtypes") public class SpreadsheetNodeManager extends StandardNodeManager { - + public SpreadsheetNodeManager(SpreadsheetRealm realm) { super(realm, realm.getEngine()); } static final Set COMPONENT_CLASS = Collections.singleton(StructuralResource2.URIs.Component); - + @Override public Set getClassifications(SheetNode node) throws NodeManagerException { checkThreadAccess(); @@ -26,22 +29,53 @@ public class SpreadsheetNodeManager extends StandardNodeManager 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 findDirtyNodeContents(SheetNode node){ + Set 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 result = ((SpreadsheetRealm)super.getRealm()).getEngine().invalidate(sscell); + dirty.addAll(result); + } + + Set dirtyNodeContents = new HashSet<>(); + for(SheetNode cell : dirty) { + Map properties = cell.getProperties(); + dirtyNodeContents.add((SpreadsheetCellContent)properties.get("content")); + } + + return dirtyNodeContents; + } }