]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.interop.update/src/org/simantics/interop/update/model/PropertyChange.java
Handle asserted property statements
[simantics/interop.git] / org.simantics.interop.update / src / org / simantics / interop / update / model / PropertyChange.java
index 69256b0381ed7549ed4f4484734b6ddbbf306fc6..75d8456140d77f82709f61381fea218e4e086af2 100644 (file)
@@ -9,30 +9,49 @@ import org.simantics.utils.datastructures.Pair;
 
 public class PropertyChange {
        protected GraphChanges changes;
+       protected Resource leftSubject;
+       protected Resource rightSubject;
        protected Pair<Statement, Statement> 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<Statement, Statement>(first, second);
                this.changes = changes;
+               this.leftSubject = left;
+               this.rightSubject = right;
        }
        
-       public PropertyChange(GraphChanges changes, Pair<Statement, Statement> change) {
+       public PropertyChange(GraphChanges changes, Resource left, Resource right, Pair<Statement, Statement> 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;
        }
@@ -60,10 +79,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())) {
@@ -104,9 +124,9 @@ public class PropertyChange {
        public String toString() {
                String s = "PropertyChange";
                if (pair.first != null)
-                       s += " (" + (pair.first.getSubject()) + " , " + pair.first.getPredicate() + " , " + pair.first.getObject() + ")";
+                       s += " (" + (leftSubject) + " , " + pair.first.getPredicate() + " , " + pair.first.getObject() + ")";
                if (pair.second != null)
-                       s += " (" + (pair.second.getSubject()) + " , " + pair.second.getPredicate() + " , " + pair.second.getObject() + ")";
+                       s += " (" + (rightSubject) + " , " + pair.second.getPredicate() + " , " + pair.second.getObject() + ")";
                return s;
        }