Author: clopes
Date: 2011-09-15 13:56:24 -0700 (Thu, 15 Sep 2011)
New Revision: 26822

Modified:
   cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ExternalMediator.as
Log:
Roll back and delete any new items if there is an exception while adding 
nodes/edges through addElements().

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ExternalMediator.as
===================================================================
--- 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ExternalMediator.as   
    2011-09-15 20:10:06 UTC (rev 26821)
+++ 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ExternalMediator.as   
    2011-09-15 20:56:24 UTC (rev 26822)
@@ -381,6 +381,7 @@
                                newElement.y = p.y;
                                
                                newNodes.push(newElement);
+                               newAll.push(newElement);
                            } else {
                                // Just store the edge,
                                // so it can be added after all new nodes have 
been created first:
@@ -392,15 +393,13 @@
                 for each (o in edgesToAdd) {
                        newElement = graphProxy.addEdge(o.data);
                        newEdges.push(newElement);
+                       newAll.push(newElement);
                 }
                 
                 // Set listeners, styles, etc:
                 graphMediator.initialize(Groups.NODES, newNodes);
                 graphMediator.initialize(Groups.EDGES, newEdges);
                 
-                // Add the edges to the array of all new elements:
-                newAll = newNodes.concat(newEdges);
-                
                 // Do it before converting the Nodes/Edges to plain objects,
                 // in order to get the rendered visual properties:
                 if (updateVisualMappers) 
sendNotification(ApplicationFacade.GRAPH_DATA_CHANGED);
@@ -412,10 +411,12 @@
                 }
             } catch (err:Error) {
                 trace("[ERROR]: addElements: " + err.getStackTrace());
+                
+                // Rollback--delete any new item:
+                removeElements(Groups.NONE, newAll, updateVisualMappers);
+                ret = [];
+                
                 error(err);
-            } finally {
-               // Rollback--delete any new item:
-               // TODO: 
             }
                
                return ret;

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to