X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop.update%2Fsrc%2Forg%2Fsimantics%2Finterop%2Fupdate%2Fmodel%2FPropertyChange.java;h=491bf5753c8932f8e031fcbe30a523ac70a33fa5;hb=c276677539e2b4111a072a2e6f6c4e8aa3e65b30;hp=9867a396601c5557f1f1ee9c363bf98f18983eb3;hpb=b0205b09bbd81755eb69452eae0142d5a93f95a4;p=simantics%2Finterop.git diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/PropertyChange.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/PropertyChange.java index 9867a39..491bf57 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/PropertyChange.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/PropertyChange.java @@ -9,29 +9,59 @@ import org.simantics.utils.datastructures.Pair; public class PropertyChange { protected GraphChanges changes; + protected Resource leftSubject; + protected Resource rightSubject; protected Pair pair; protected boolean applied = false; protected boolean selected = false; + protected boolean visible = true; - public PropertyChange(GraphChanges changes, Statement first, Statement second) { + public PropertyChange(GraphChanges changes, Resource left, Statement first, Resource right, Statement second) { + if (first == null && second == null) + throw new IllegalArgumentException("At least one of the stamenents must be non null."); + if (left == null || right == null) + throw new IllegalArgumentException("Subject resources cannot be null."); this.pair = new Pair(first, second); this.changes = changes; + this.leftSubject = left; + this.rightSubject = right; } - public PropertyChange(GraphChanges changes, Pair change) { + public PropertyChange(GraphChanges changes, Resource left, Resource right, Pair change) { + if (change == null || (change.first == null && change.second == null)) + throw new IllegalArgumentException("At least one of the stamenents must be non null."); + if (left == null || right == null) + throw new IllegalArgumentException("Subject resources cannot be null."); this.pair = change; this.changes = changes; + this.leftSubject = left; + this.rightSubject = right; + } + + + public Resource getFirstSubject() { + return leftSubject; } public Statement getFirst() { return pair.first; } + public Resource getSecondSubject() { + return rightSubject; + } + public Statement getSecond() { return pair.second; } + public Resource getPredicate() { + if (pair.first != null) + return pair.first.getPredicate(); + return pair.second.getPredicate(); + } + public GraphChanges getChanges() { return changes; } @@ -55,10 +85,11 @@ public class PropertyChange { if (applied) return; if (pair.second == null) { - graph.deny(pair.first); + graph.deny(leftSubject, pair.first.getPredicate(),pair.first.getObject()); return; } - Resource s = changes.getComparable().getLeft(pair.second.getSubject()); + Resource s = leftSubject; + //Resource s = changes.getComparable().getLeft(rightSubject); //Resource s = pair.first.getSubject(); Resource pred = pair.second.getPredicate(); if (graph.hasValue(pair.second.getObject())) { @@ -87,5 +118,22 @@ public class PropertyChange { return applied; } + public boolean isVisible() { + return visible; + } + + public void setVisible(boolean visible) { + this.visible = visible; + } + + @Override + public String toString() { + String s = "PropertyChange"; + if (pair.first != null) + s += " (" + (leftSubject) + " , " + pair.first.getPredicate() + " , " + pair.first.getObject() + ")"; + if (pair.second != null) + s += " (" + (rightSubject) + " , " + pair.second.getPredicate() + " , " + pair.second.getObject() + ")"; + return s; + } }