X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.objmap2%2Fsrc%2Forg%2Fsimantics%2Fobjmap%2Fgraph%2Fimpl%2FRangeUpdateRequest.java;h=d62435cd1de24a11748be77b99928a28649f86e4;hb=HEAD;hp=b84b9c94ff8b866eb8ecea86471914d6dc7d1bda;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/RangeUpdateRequest.java b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/RangeUpdateRequest.java index b84b9c94f..d62435cd1 100644 --- a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/RangeUpdateRequest.java +++ b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/RangeUpdateRequest.java @@ -21,7 +21,7 @@ import org.simantics.objmap.forward.IForwardMapping; import org.simantics.objmap.graph.impl.Link; -public class RangeUpdateRequest implements Read, SyncListener { +public class RangeUpdateRequest implements Read, SyncListener { Link link; /* @@ -30,27 +30,24 @@ public class RangeUpdateRequest implements Read, SyncList */ IForwardMapping map; // map==null is used to flag that request is performed once Mapping mapping; // mapping==null is used as a flag the request disposed + int counter; public RangeUpdateRequest(Link link, IForwardMapping map, Mapping mapping) { this.link = link; this.map = map; this.mapping = mapping; + this.counter = 0; } @Override - public Boolean perform(ReadGraph g) throws DatabaseException { - if(map != null) { - link.type.updateRange(g, map, link.domainElement, link.rangeElement); - map = null; - return Boolean.TRUE; - } - else if(mapping != null) { - mapping.domainModified(link); - mapping = null; - return Boolean.FALSE; - } - else - return null; + public Integer perform(ReadGraph g) throws DatabaseException { + boolean changed = false; + if (map != null) + changed = link.type.checkChanges(g, map, link.domainElement, link.rangeElement); + else if (mapping != null) + changed = link.type.checkChanges(g, mapping, link.domainElement, link.rangeElement); + + return changed ? counter + 1 : counter; } @Override @@ -63,15 +60,24 @@ public class RangeUpdateRequest implements Read, SyncList } @Override - public void execute(ReadGraph graph, Boolean result) - throws DatabaseException { + public void execute(ReadGraph graph, Integer result) + throws DatabaseException { + boolean changed = result != counter; + counter = result; + + if (map != null) { + if (changed) + link.type.updateRange(graph, map, link.domainElement, link.rangeElement); + map = null; + } + else if (mapping != null && changed) { + mapping.domainModified(link); + mapping = null; + } } @Override public boolean isDisposed() { return mapping == null || link.removed || mapping.isDisposed(); } - - - }