]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateNode.java
Added support for filtering changes
[simantics/interop.git] / org.simantics.interop.update / src / org / simantics / interop / update / model / UpdateNode.java
index fec8e09d6c1f032a4251a0d97ed3017749bd8cbb..3a7953174bd3ffb6b080af45cbe8f039ed5ced72 100644 (file)
@@ -8,20 +8,15 @@ 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 class UpdateNode {
 
-       public enum Status {EXIST,DELETED,NEW,CONTAINS};
-       
-
-       private Status status;
+       private UpdateStatus status;
        private UpdateOp op;
        private Resource r;
        private String label;
+       private boolean visible = true;
        
        
        private Collection<UpdateNode> children = new ArrayList<UpdateNode>();
@@ -31,19 +26,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);
        }
        
@@ -56,11 +55,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;
        }
        
@@ -103,5 +102,15 @@ 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;
+       }
 
 }