]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Support for custom property values. 13/3713/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 16 Dec 2019 11:18:14 +0000 (13:18 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 16 Dec 2019 11:18:14 +0000 (13:18 +0200)
gitlab #18

Change-Id: I2c5a7803ef7ac5f7156676fd8c3252cf38c35108

org.simantics.interop.update/src/org/simantics/interop/update/model/PropertyChange.java

index 947f516849ea7c6beea0f4ad5b982eb85d15985b..54d2f76f55fe083f1af1f54a904cf0cc79709dd6 100644 (file)
@@ -16,6 +16,8 @@ public class PropertyChange {
        protected boolean selected = false;
        protected boolean visible = true;
        protected boolean enabled = true;
+       protected Object customValue = null;
+       
        
        public PropertyChange(GraphChanges changes, Resource left, Statement first, Resource right, Statement second) {
                if (first == null && second == null)
@@ -89,18 +91,20 @@ public class PropertyChange {
                        return;
                } 
                Resource s = leftSubject;
-               //Resource s = changes.getComparable().getLeft(rightSubject);
-               //Resource s = pair.first.getSubject();
+               Object value = null;
+               if (customValue != null)
+                       value = customValue;
+               else if (graph.hasValue(pair.second.getObject())) {
+                       value = graph.getValue(pair.second.getObject());
+               }
                Resource pred = pair.second.getPredicate();
-               if (graph.hasValue(pair.second.getObject())) {
-                       Object value = graph.getValue(pair.second.getObject());
+               if (value != null) {
                        graph.deny(s, pred);
                        graph.claimLiteral(s, pred, value);
                } else {
                        graph.deny(s,pred);
                }
                applied = true;
-               
        }
        
        /**
@@ -175,4 +179,12 @@ public class PropertyChange {
                return s;
        }
        
+       public Object getCustomValue() {
+               return customValue;
+       }
+       
+       public void setCustomValue(Object customValue) {
+               this.customValue = customValue;
+       }
+       
 }