]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.interop.update/src/org/simantics/interop/update/model/PropertyChange.java
Add post processing step to bind property and structural changes
[simantics/interop.git] / org.simantics.interop.update / src / org / simantics / interop / update / model / PropertyChange.java
index 81a342a7ef079429d9d3c7afdcb76fb1171644d1..07a3dc38e35cd98334a4238bc095d6e0154ded72 100644 (file)
@@ -15,7 +15,7 @@ public class PropertyChange {
        protected boolean applied = false;
        protected boolean selected = false;
        protected boolean visible = true;
-       
+       protected boolean enabled = true;
        
        public PropertyChange(GraphChanges changes, Resource left, Statement first, Resource right, Statement second) {
                if (first == null && second == null)
@@ -103,22 +103,40 @@ public class PropertyChange {
                
        }
        
+       /**
+        * Sets selected state. 
+        * @param select
+        * @return true if selection state was changed
+        */
        public boolean select(boolean select) {
+           if (!enabled)
+               return false;
                if (applied)
                        return false;
                this.selected = select;
                return true;
        }
        
-       
+       /**
+        * Is change selected.
+        * @return
+        */
        public boolean selected() {
                return selected;
        }
        
+       /**
+        * Has change been applied
+        * @return
+        */
        public boolean applied() {
                return applied;
        }
        
+       /**
+        * Is change visible
+        * @return
+        */
        public boolean isVisible() {
                return visible;
        }
@@ -127,13 +145,33 @@ public class PropertyChange {
                this.visible = visible;
        }
        
+       /**
+        * IS change enabled. Disabled changes do not allow changing selected state.
+        * @return
+        */
+       public boolean isEnabled() {
+        return enabled;
+    }
+       
+       public void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+       
        @Override
        public String toString() {
                String s = "PropertyChange";
                if (pair.first != null)
-                       s += " (" + (leftSubject) + " , " + pair.first.getPredicate() + " , " + pair.first.getObject() + ")";
+                       s += " L(" + (leftSubject) + " , " + pair.first.getPredicate() + " , " + pair.first.getObject() + ")";
                if (pair.second != null)
-                       s += " (" + (rightSubject) + " , " + pair.second.getPredicate() + " , " + pair.second.getObject() + ")";
+                       s += " R(" + (rightSubject) + " , " + pair.second.getPredicate() + " , " + pair.second.getObject() + ")";
+               if (selected)
+                   s += " selected";
+               if (enabled)
+                   s += " enabled";
+               if (visible)
+            s += " visible";
+               if (applied)
+                   s += " applied";
                return s;
        }