X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2FSpreadsheetBook.java;h=5a7dcd5ee0aae8f1f129158c284ac00cd666deba;hp=f87ce4d0675e851fee84a432d093241f38245607;hb=664f37a026967c90a9a8a4ef3c5336ee426f67aa;hpb=1251d640abb698a4018ef1ea212f8cdf78befaaf 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 f87ce4d06..5a7dcd5ee 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 @@ -6,9 +6,11 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import org.simantics.databoard.Bindings; import org.simantics.databoard.binding.Binding; @@ -40,7 +42,9 @@ public class SpreadsheetBook implements StandardNodeManagerSupport, S private static final long serialVersionUID = 7417208688311691396L; - public Serializable NotAvailableError = new Serializable() {}; + public Serializable NotAvailableError = new Serializable() { + private static final long serialVersionUID = 2535371785498129460L; + }; public Long2ObjectOpenHashMap referenceMap = new Long2ObjectOpenHashMap<>(); @@ -365,7 +369,26 @@ public class SpreadsheetBook implements StandardNodeManagerSupport, S v.visit(this); } - public List invalidate(SpreadsheetCell cell) { + //Recursively find all SpreadsheetCells, invalidate them and return them all as a set + public Set invalidate(SpreadsheetCell cell) { + Set result = new HashSet<>(); + result.add(cell); + cell.invalidate(); + long refKey = cell.makeReferenceKey(); + AbstractLongSet refs = referenceMap.remove(refKey); + if(refs == null) return result; + for(long ref : refs) { + long sheet = ref >> 40; + long row = (ref >> 20) & 0xFFFFF; + long col = (ref) & 0xFFFFF; + SpreadsheetCell referer = get(sheets.get((int)sheet), (int)row, (int)col); + result.addAll(invalidate(referer)); + } + return result; + } + + @Deprecated + public List invalidateShallow(SpreadsheetCell cell) { ArrayList result = new ArrayList<>(); result.add(cell); cell.invalidate();