From: Marko Luukkainen Date: Thu, 21 Nov 2019 12:30:32 +0000 (+0200) Subject: Added enabled flag for UpdateOp X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=3359124df6020037e7065723397fb00839e5a14b;p=simantics%2Finterop.git Added enabled flag for UpdateOp gitlab #16 Change-Id: I4f8e0146c15a30a0ad00650600f5275c0df05717 (cherry picked from commit 99c2a46dea84c410448a87c7f287e66a17ccde56) --- diff --git a/org.simantics.interop.update/scl/Interop/Update.scl b/org.simantics.interop.update/scl/Interop/Update.scl index 5769840..2c91248 100644 --- a/org.simantics.interop.update/scl/Interop/Update.scl +++ b/org.simantics.interop.update/scl/Interop/Update.scl @@ -122,7 +122,7 @@ importJava "org.simantics.interop.update.model.PropertyChange" where @JavaName isVisible pcVisible :: PropertyChange -> Boolean - @JavaName isEnabled + @JavaName enabled pcEnabled :: PropertyChange -> Boolean @JavaName setEnabled @@ -184,6 +184,9 @@ importJava "org.simantics.interop.update.model.UpdateOp" where @JavaName isChange opIsChange :: UpdateOp -> Boolean + @JavaName enabled + opEnabled :: UpdateOp -> Boolean + @JavaName getResource getOpResource :: UpdateOp -> Maybe Resource 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 07a3dc3..947f516 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 @@ -146,10 +146,10 @@ public class PropertyChange { } /** - * IS change enabled. Disabled changes do not allow changing selected state. + * Is change enabled. Disabled changes do not allow changing selected state. * @return */ - public boolean isEnabled() { + public boolean enabled() { return enabled; } diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateOp.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateOp.java index 00d1139..6fba567 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateOp.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateOp.java @@ -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 parentOps = new ArrayList(); private Collection subOps = new ArrayList(); @@ -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)