X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop.update%2Fsrc%2Forg%2Fsimantics%2Finterop%2Fupdate%2Fmodel%2FUpdateOp.java;h=6fba56723f2c5cf2cca45117643664eb30448991;hb=99c2a46dea84c410448a87c7f287e66a17ccde56;hp=46bfcd298624c5384d679e4aeaae11520f3f3ed5;hpb=69036b628df63d369733ab8bee9f402835ea1a13;p=simantics%2Finterop.git 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 46bfcd2..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 @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Collection; import org.simantics.db.Resource; +import org.simantics.db.Statement; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.interop.test.GraphChanges; @@ -21,6 +22,8 @@ public abstract class UpdateOp { private boolean selected = false; 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(); @@ -63,6 +66,10 @@ public abstract class UpdateOp { public abstract boolean isAdd(); public abstract boolean isDelete(); + public boolean isChange() { + return isAdd() || isDelete(); + } + /** * Is parent operation applied before this. * @return @@ -91,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; @@ -100,6 +111,10 @@ public abstract class UpdateOp { private boolean _select(boolean select) { if (select == selected) return true; + if (applied) + return false; + if (!isChange()) + return false; if (select) { if (selectParentOps()) { for (UpdateOp op : parentOps) @@ -136,6 +151,24 @@ public abstract class UpdateOp { public boolean applied() { return applied; } + + public boolean isVisible() { + 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) return; @@ -158,6 +191,12 @@ public abstract class UpdateOp { */ public abstract Resource getResource(); + /** + * Returns resource that this operation is changing. + * @return + */ + public abstract Statement getStatement(); + /** * Returns resource that this operation created during apply operation. If operation did not add anything, this returns null. * @return