]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateList.java
Use ArrayList (instead of HashSet) to store changes
[simantics/interop.git] / org.simantics.interop.update / src / org / simantics / interop / update / model / UpdateList.java
index beb0e431e9216eae79eabd864436cc7ba1c610da..2267ebec6f47e8ec101a39d1945e19d99aa1325a 100644 (file)
@@ -10,29 +10,29 @@ import org.simantics.db.Resource;
 import org.simantics.db.Statement;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.interop.test.GraphChanges;
-import org.simantics.interop.update.model.ModelUpdate.ChangeFilter;
+import org.simantics.interop.test.GraphChanges.Modification;
 import org.simantics.utils.datastructures.Pair;
 
 public class UpdateList {
-       private HashSet<PropertyChange> changes;
+       private List<PropertyChange> changes;
        
        public UpdateList() {
-               changes = new HashSet<>();
+               changes = new ArrayList<>();
        }
        
        public UpdateList(Collection<PropertyChange> changes) {
-               this.changes = new HashSet<>(changes);
+               this.changes = new ArrayList<>(changes);
        }
        
-       public UpdateList(GraphChanges graphChanges, Collection<Pair<Statement, Statement>> coll) {
-               this.changes = new HashSet<>();
-               for (Pair<Statement, Statement> p : coll) {
-                       changes.add(create(graphChanges, p));
+       public UpdateList(GraphChanges graphChanges, Collection<Modification> coll) {
+               this.changes = new ArrayList<>();
+               for (Modification p : coll) {
+                       addChange(create(graphChanges, p.getLeftSub(),p.getRightSub(),new Pair<Statement, Statement>(p.getLeftStm(), p.getRightStm())));
                }
        }
        
-       protected PropertyChange create(GraphChanges changes, Pair<Statement, Statement> change) {
-               return new PropertyChange(changes, change);
+       protected PropertyChange create(GraphChanges changes, Resource left, Resource right, Pair<Statement, Statement> change) {
+               return new PropertyChange(changes, left,right, change);
        }
        
        public Collection<PropertyChange> getChanges() {
@@ -40,7 +40,8 @@ public class UpdateList {
        }
 
        public void addChange(PropertyChange change) {
-               changes.add(change);
+           if (!changes.contains(change))
+               changes.add(change);
        }
        
        public void removeChange(PropertyChange change) {