]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateOp.java
Added enabled flag for UpdateOp
[simantics/interop.git] / org.simantics.interop.update / src / org / simantics / interop / update / model / UpdateOp.java
index 00d113938bb83c7c3d909b91083a18c0d00f86d3..6fba56723f2c5cf2cca45117643664eb30448991 100644 (file)
@@ -23,6 +23,7 @@ public abstract class UpdateOp {
        private boolean manualSelection = false;
        protected boolean applied = false;
        protected boolean visible = true;
+       protected boolean enabled = true;
        
        private Collection<UpdateOp> parentOps = new ArrayList<UpdateOp>();
        private Collection<UpdateOp> subOps = new ArrayList<UpdateOp>();
@@ -97,6 +98,10 @@ public abstract class UpdateOp {
        }
        
        public boolean select(boolean select) {
+           if (!enabled)
+               return false;
+           if (!isChange())
+               return false;
                boolean b = _select(select);
                if (b)
                        manualSelection = true;
@@ -108,6 +113,8 @@ public abstract class UpdateOp {
                        return true;
                if (applied)
                        return false;
+               if (!isChange())
+                   return false;
                if (select) {
                        if (selectParentOps()) {
                                for (UpdateOp op : parentOps)
@@ -149,6 +156,18 @@ public abstract class UpdateOp {
                return visible;
        }
        
+       /**
+     * Is change enabled. Disabled changes do not allow changing selected state.
+     * @return
+     */
+    public boolean enabled() {
+        return enabled;
+    }
+    
+    public void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+       
        
        public void apply(WriteGraph g) throws DatabaseException {
                if (applied)