X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2FSpreadsheetGraphUtils.java;fp=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2FSpreadsheetGraphUtils.java;h=35a05d7aa59c7d45980f0a781a8fdd726ea621e3;hb=e5871be84f8ba53a1c80be728bcfb67231c29279;hp=51f292929c440ff6bde32142ec34222633ad565e;hpb=fb89ec6bace6b3eef93a4c437171bb173fc861b6;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetGraphUtils.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetGraphUtils.java index 51f292929..35a05d7aa 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetGraphUtils.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetGraphUtils.java @@ -26,6 +26,7 @@ import org.simantics.db.WriteGraph; import org.simantics.db.common.request.BinaryRead; import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.common.request.UnaryRead; +import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.LiteralFileUtil; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.ServiceException; @@ -528,6 +529,20 @@ public class SpreadsheetGraphUtils { }); } + @Override + public void modify(Object context, Variant newValue) { + + Simantics.getSession().asyncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + Variable variable = Variables.getVariable(graph, uri); + variable.setValue(graph, newValue); + } + }); + + } + } public static Variant extRefActiveVariable(ReadGraph graph, Variable var) throws DatabaseException { @@ -574,6 +589,23 @@ public class SpreadsheetGraphUtils { }); } + @Override + public void modify(Object context, Variant newValue) { + + Simantics.getSession().asyncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + Variable contextVariable = Variables.getVariable(graph, (String)context); + Variable configVariable = Variables.getVariable(graph,uri); + Variable activeVariable = Variables.switchPossibleContext(graph, configVariable, contextVariable.getRepresents(graph)); + if(activeVariable == null) return; + activeVariable.setValue(graph, newValue.getValue(), newValue.getBinding()); + } + }); + + } + } public static CellEditor cellEditor(ReadGraph graph, Resource sheet) throws DatabaseException {