1 package org.simantics.spreadsheet.solver;
3 import org.simantics.databoard.binding.mutable.Variant;
4 import org.simantics.spreadsheet.ExternalRef;
5 import org.simantics.spreadsheet.ExternalRef.ExternalRefListener;
7 class ExternalRefData implements ExternalRefListener {
9 final private SpreadsheetBook book;
10 final private long referenceKey;
11 final private ExternalRef ref;
12 private boolean isDisposed = false;
13 private Variant value = SpreadsheetBook.DEFAULT_VALUE;
15 public ExternalRefData(SpreadsheetBook book, long referenceKey, ExternalRef ref) {
17 this.referenceKey = referenceKey;
19 ref.listen(book.context, this);
22 public Variant getContent() {
26 public ExternalRef getRef() {
31 public void newValue(Variant newVariant) {
32 SpreadsheetCell cell = book.cellByReferenceKey(referenceKey);
33 if(cell.getContent() instanceof SpreadsheetSCLConstant) {
34 SpreadsheetSCLConstant ssc = (SpreadsheetSCLConstant)cell.getContent();
35 Object content = ssc.getContent();
36 if(content.equals(ref)) {
38 book.fireChanges(book.invalidate(cell));
46 public boolean isDisposed() {
49 return book.isDisposed();