]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateNode.java
Create UpdateNode labels in the constructor.
[simantics/interop.git] / org.simantics.interop.update / src / org / simantics / interop / update / model / UpdateNode.java
index de9d685abd84fafdeccf9ab69914555f23bc608d..fec8e09d6c1f032a4251a0d97ed3017749bd8cbb 100644 (file)
@@ -21,6 +21,7 @@ public class UpdateNode {
        private Status status;
        private UpdateOp op;
        private Resource r;
+       private String label;
        
        
        private Collection<UpdateNode> children = new ArrayList<UpdateNode>();
@@ -30,18 +31,20 @@ public 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() {
@@ -79,11 +82,16 @@ public class UpdateNode {
                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);