Author: clopes
Date: 2011-10-19 12:58:24 -0700 (Wed, 19 Oct 2011)
New Revision: 27237

Modified:
   cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/GraphProxy.as
   
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/InteractionVO.as
   cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ExternalMediator.as
Log:
Fixed bug #2602: Added merged edge cannot be selected.

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/GraphProxy.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/GraphProxy.as    
2011-10-19 19:13:46 UTC (rev 27236)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/GraphProxy.as    
2011-10-19 19:58:24 UTC (rev 27237)
@@ -719,10 +719,16 @@
             _missingChildren = null;
         }
         
-        public function addEdge(data:Object):EdgeSprite {
+        /**
+         * @return The newly created edges. The first element of the array is 
the added edge.
+         *         There can be a second one, which is always a merged edge,
+         *         but only if it was created as a result of adding the new 
element.  
+         */
+        public function addEdge(data:Object):Array {
             if (data == null) throw new CWError("The 'data' argument is 
mandatory",
                                                 
ErrorCodes.INVALID_DATA_CONVERSION);
             trace("add edge: " + data.id);
+            var arr:Array = [];
             
             normalizeData(data, Groups.EDGES);
             
@@ -737,6 +743,7 @@
 
             // Create edge:
             var e:EdgeSprite = graphData.addEdgeFor(src, tgt, data.directed, 
data);
+            arr.push(e);
             
             // Add it to cache:
             createCache(e);
@@ -747,11 +754,12 @@
             
             if (inter == null) {
                 inter = createInteraction(e.source, e.target);
+                arr.push(inter.mergedEdge);
             } else {
                 inter.update(edgesSchema);
             }
             
-            return e;
+            return arr;
         }
         
         public function remove(items:Array):void {

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/InteractionVO.as
===================================================================
--- 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/InteractionVO.as
    2011-10-19 19:13:46 UTC (rev 27236)
+++ 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/InteractionVO.as
    2011-10-19 19:58:24 UTC (rev 27237)
@@ -34,6 +34,8 @@
     import flare.vis.data.EdgeSprite;
     import flare.vis.data.NodeSprite;
     
+    import org.cytoscapeweb.util.DataSchemaUtils;
+    
     public class InteractionVO {
         
         private var _key:String;
@@ -201,11 +203,14 @@
         // ========[ PRIVATE METHODS 
]==============================================================
         
         private function recreateDataFields(edgesSchema:DataSchema):void {
-            _mergedEdge.data = {};
-            _mergedEdge.data.source = node1.data.id;
-            _mergedEdge.data.target = node2.data.id;
-            _mergedEdge.data.directed = false;
+            var id:String = _mergedEdge.data.id;
             
+            _mergedEdge.data = { };
+            _mergedEdge.data[DataSchemaUtils.ID] = id;
+            _mergedEdge.data[DataSchemaUtils.SOURCE] = node1.data.id;
+            _mergedEdge.data[DataSchemaUtils.TARGET] = node2.data.id;
+            _mergedEdge.data[DataSchemaUtils.DIRECTED] = false;
+            
             var v:*;
             
             for each (var df:DataField in edgesSchema.fields) {

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ExternalMediator.as
===================================================================
--- 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ExternalMediator.as   
    2011-10-19 19:13:46 UTC (rev 27236)
+++ 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ExternalMediator.as   
    2011-10-19 19:58:24 UTC (rev 27237)
@@ -397,6 +397,7 @@
             var newAll:Array = [], newNodes:Array = [], newEdges:Array = [], 
ret:Array = [];
             var edgesToAdd:Array = [], childrenToAdd:Array = [];
             var gr:String, newElement:DataSprite, parent:CompoundNodeSprite, 
o:Object;
+            var createdEdges:Array;
             
             try {                
                 // Create element:
@@ -438,9 +439,13 @@
                 
                 // Now it is safe to add the edges:
                 for each (o in edgesToAdd) {
-                    newElement = graphProxy.addEdge(o.data);
-                    newEdges.push(newElement);
-                    newAll.push(newElement);
+                    createdEdges = graphProxy.addEdge(o.data);
+                    newEdges.push(createdEdges[0]);
+                    newAll.push(createdEdges[0]);
+                    
+                    if (createdEdges.length > 1) {
+                        newEdges.push(createdEdges[1]);
+                    }
                 }
                 
                 // process child nodes to add, and update corresponding parent 
compound nodes
@@ -536,12 +541,12 @@
             
             try {
                 // Create edge:
-                var e:EdgeSprite = graphProxy.addEdge(data);
+                var createdEdges:Array = graphProxy.addEdge(data);
                 // Set listeners, styles, etc:
-                graphMediator.initialize(Groups.EDGES, [e]);
+                graphMediator.initialize(Groups.EDGES, createdEdges);
                 
                 if (updateVisualMappers) 
sendNotification(ApplicationFacade.GRAPH_DATA_CHANGED);
-                o = ExternalObjectConverter.toExtElement(e, graphProxy.zoom);
+                o = ExternalObjectConverter.toExtElement(createdEdges[0], 
graphProxy.zoom);
                 
             } catch (err:Error) {
                 trace("[ERROR]: addEdge: " + err.getStackTrace());

-- 
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