import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.Session;
this.updateOps = updateOps;
this.updateOps.populate(g);
populate(g);
+ this.rootNode.sort();
}
public UpdateTree(Session session, GraphChanges changes, UpdateOperations updateOps) throws DatabaseException {
+ this(session, changes, updateOps, new NullProgressMonitor());
+ }
+
+ public UpdateTree(Session session, GraphChanges changes, UpdateOperations updateOps, IProgressMonitor monitor) throws DatabaseException {
this.changes = changes;
this.nodes = new HashMap<Resource, UpdateNode>();
this.rootNode = session.syncRequest(new NodeRequest(UpdateStatus.EXIST, changes.getResource1()));
nodes.put(changes.getResource1(), rootNode);
nodes.put(changes.getResource2(), rootNode);
this.updateOps = updateOps;
- this.updateOps.populate(session);
- populate(session);
+ this.updateOps.populate(session, monitor);
+ populate(session, monitor);
+ if (monitor.isCanceled()) {
+ this.changes = null;
+ this.nodes.clear();
+ this.updateOps = null;
+ this.rootNode = null;
+ } else {
+ this.rootNode.sort();
+ }
}
private class NodeRequest extends ResourceRead<UpdateNode> {
}
}
- protected void populate(Session session) throws DatabaseException{
+ protected void populate(Session session, IProgressMonitor monitor) throws DatabaseException{
int i = 0;
while (i < updateOps.getOperations().size()) {
+ if (monitor.isCanceled())
+ return;
i = session.syncRequest(new PopulateRead(i));
}
}