Author: pwang
Date: 2012-09-18 10:56:27 -0700 (Tue, 18 Sep 2012)
New Revision: 30376

Modified:
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadnetwork/GenerateNetworkViewsTask.java
Log:
If root network does not have a name, make it the same as its base subnetwork

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadnetwork/GenerateNetworkViewsTask.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadnetwork/GenerateNetworkViewsTask.java
 2012-09-18 15:45:47 UTC (rev 30375)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadnetwork/GenerateNetworkViewsTask.java
 2012-09-18 17:56:27 UTC (rev 30376)
@@ -35,6 +35,8 @@
 import org.cytoscape.io.read.CyNetworkReader;
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyNetworkManager;
+import org.cytoscape.model.subnetwork.CySubNetwork;
+import org.cytoscape.model.subnetwork.CyRootNetwork;
 import org.cytoscape.session.CyNetworkNaming;
 import org.cytoscape.view.model.CyNetworkView;
 import org.cytoscape.view.model.CyNetworkViewManager;
@@ -98,6 +100,20 @@
 
                        informUserOfGraphStats(network, numGraphObjects, 
taskMonitor);
                }
+
+               // If this is a subnetwork, and there is only one subnetwork in 
the root, check the name of the root network
+               // If there is no name yet for the root network, set it the 
same as its base subnetwork
+               if (networks.length == 1){
+                       if (networks[0] instanceof CySubNetwork){
+                               CySubNetwork subnet = (CySubNetwork) 
networks[0];
+                               final CyRootNetwork rootNet = 
subnet.getRootNetwork();
+                               String rootNetName = 
rootNet.getRow(rootNet).get(CyNetwork.NAME, String.class);
+                               if (rootNetName == null || 
rootNetName.trim().length() == 0){
+                                       // The root network does not have a 
name yet, set it the same as the base subnetwork
+                                       
rootNet.getRow(rootNet).set(CyNetwork.NAME, 
networks[0].getRow(networks[0]).get(CyNetwork.NAME, String.class));
+                               }
+                       }
+               }
        }
 
        /**

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