X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop.update%2Fsrc%2Forg%2Fsimantics%2Finterop%2Fupdate%2Fmodel%2FUpdateNode.java;h=b786586c9a3daef1c2b562707e1b07779d107a54;hb=f46f7fca458ebc63f7a280b9088904710f6149f1;hp=159abd8d9f14a0079255d088996ad826072e4e50;hpb=e2f57d7e61d6c52b6341f793f6988c123daa1647;p=simantics%2Finterop.git diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateNode.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateNode.java index 159abd8..b786586 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateNode.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateNode.java @@ -12,13 +12,12 @@ import org.simantics.layer0.Layer0; public class UpdateNode { - public enum Status {EXIST,DELETED,NEW,CONTAINS}; - - - private Status status; + private UpdateNode parent; + private UpdateStatus status; private UpdateOp op; private Resource r; private String label; + private boolean visible = true; private Collection children = new ArrayList(); @@ -28,19 +27,23 @@ public class UpdateNode { * @param status * @param changes */ - public UpdateNode(ReadGraph g, Status status, UpdateOp op) throws DatabaseException{ + public UpdateNode(ReadGraph g, UpdateStatus status, UpdateOp op) throws DatabaseException{ this.status = status; this.op = op; this.r = op.getResource(); - this.label = getLabel(g, r); + init(g); } - public UpdateNode(ReadGraph g, Status status, Resource r) throws DatabaseException { + public UpdateNode(ReadGraph g, UpdateStatus status, Resource r) throws DatabaseException { this.status = status; this.op = null; this.r = r; + init(g); + } + + protected void init(ReadGraph g) throws DatabaseException { this.label = getLabel(g, r); } @@ -53,11 +56,11 @@ public class UpdateNode { return g.getPossibleObject(r, l0.PartOf); } - public void setStatus(Status status) { + public void setStatus(UpdateStatus status) { this.status = status; } - public Status getStatus() { + public UpdateStatus getStatus() { return status; } @@ -67,6 +70,7 @@ public class UpdateNode { public void addChild(UpdateNode node) { children.add(node); + node.parent = this; if (op != null && node.op != null) { if (!op.getSubOps().contains(node.op)) { op.addSubOp(node.op); @@ -100,5 +104,30 @@ public class UpdateNode { public UpdateOp getOp() { return op; } + + public boolean isVisible() { + return visible; + } + + public void setVisible(boolean visible) { + this.visible = visible; + if (op != null) + op.visible = visible; + if (visible) { + if (parent != null && !parent.visible) + parent.setVisible(true); + } else { + for (UpdateNode n : children) + n.setVisible(false); + } + } + + public void setAllVisible(boolean visible) { + this.visible = visible; + if (op != null) + op.visible = visible; + for (UpdateNode n : children) + n.setAllVisible(visible); + } }