X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=org.simantics.interop.update%2Fsrc%2Forg%2Fsimantics%2Finterop%2Fupdate%2Fmodel%2FUpdateNode.java;h=159abd8d9f14a0079255d088996ad826072e4e50;hb=e2f57d7e61d6c52b6341f793f6988c123daa1647;hp=e1312bfac3fb1d38d0caa869599290fc9a8a0319;hpb=9076887bb7f54a038ef1a32c2f1121f7ebb5ed7d;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 e1312bf..159abd8 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 @@ -8,12 +8,9 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.exception.NoSingleResultException; -import org.simantics.db.exception.ServiceException; -import org.simantics.db.exception.ValidationException; import org.simantics.layer0.Layer0; -public abstract class UpdateNode { +public class UpdateNode { public enum Status {EXIST,DELETED,NEW,CONTAINS}; @@ -21,6 +18,7 @@ public abstract class UpdateNode { private Status status; private UpdateOp op; private Resource r; + private String label; private Collection children = new ArrayList(); @@ -30,18 +28,20 @@ public abstract class UpdateNode { * @param status * @param changes */ - public UpdateNode(Status status, UpdateOp op) { + public UpdateNode(ReadGraph g, Status status, UpdateOp op) throws DatabaseException{ this.status = status; this.op = op; this.r = op.getResource(); + this.label = getLabel(g, r); } - public UpdateNode(Status status, Resource r) { + public UpdateNode(ReadGraph g, Status status, Resource r) throws DatabaseException { this.status = status; this.op = null; this.r = r; + this.label = getLabel(g, r); } public Resource getResource() { @@ -67,15 +67,28 @@ public abstract class UpdateNode { public void addChild(UpdateNode node) { children.add(node); + if (op != null && node.op != null) { + if (!op.getSubOps().contains(node.op)) { + op.addSubOp(node.op); + node.op.addParentOp(op); + } + } } - public abstract ImageDescriptor getImage(ReadGraph graph) throws DatabaseException; + public ImageDescriptor getImage(ReadGraph graph) throws DatabaseException { + return null; + } - public String getLabel(ReadGraph graph) throws DatabaseException { - return getLabel(graph,r); + public String getLabel() { + return label; + } + + @Override + public String toString() { + return label; } - protected String getLabel(ReadGraph graph, Resource r) throws ValidationException, ServiceException, NoSingleResultException { + protected String getLabel(ReadGraph graph, Resource r) throws DatabaseException { String label = NameUtils.getSafeLabel(graph, r); if (label.length() == 0) label = NameUtils.getSafeName(graph, r);