Author: rozagh
Date: 2012-05-04 13:08:39 -0700 (Fri, 04 May 2012)
New Revision: 29114

Modified:
   
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/view/NetworkPanel.java
Log:
fixes #932 selecting root networks selects all of the subnetworks and sets the 
current network as the first network in the subtree. The functionality needs to 
be tested more precisely. 

Modified: 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/view/NetworkPanel.java
===================================================================
--- 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/view/NetworkPanel.java
 2012-05-04 19:43:13 UTC (rev 29113)
+++ 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/view/NetworkPanel.java
 2012-05-04 20:08:39 UTC (rev 29114)
@@ -496,6 +496,7 @@
                        if (parentTreeNode == null)
                                parentTreeNode = new NetworkTreeNode("", null);
 
+                       
                        // Actual tree node for this network
                        String netName = 
network.getRow(network).get(CyNetwork.NAME, String.class);
                        
@@ -581,7 +582,6 @@
        public void valueChanged(TreeSelectionEvent e) {
                if (ignoreTreeSelectionEvents)
                        return;
-               
                JTree mtree = treeTable.getTree();
 
                // sets the "current" network based on last node in the tree 
selected
@@ -590,18 +590,33 @@
                        // logger.debug("NetworkPanel: null node - returning");
                        return;
                }
-
+               
                final CyNetwork net = node.getNetwork();
-               
                // This is a "network set" node.
-               if (net == null)
+               if (net == null){ //When selecting root node all of the 
subnetworks are selected.
+                       CyRootNetwork root = ((CySubNetwork) ((NetworkTreeNode) 
node.getFirstChild()).getNetwork()).getRootNetwork();
+
+                       List<CySubNetwork> subNetworkList = 
root.getSubNetworkList();
+                       List<CyNetwork> networkList = new 
LinkedList<CyNetwork>();
+                       for ( CySubNetwork sn: subNetworkList)
+                               networkList.add(sn);
+                       if (networkList.size() > 0) {
+                               appManager.setCurrentNetwork( ( 
(NetworkTreeNode)node.getFirstChild() ).getNetwork() );
+                               appManager.setSelectedNetworks(networkList);
+                               final List<CyNetworkView> selectedViews = new 
ArrayList<CyNetworkView>();
+                               for(final CyNetwork network: networkList) {
+                                       final Collection<CyNetworkView> views = 
networkViewManager.getNetworkViews(network);
+                                       if(views.size() !=0)
+                                               selectedViews.addAll(views);
+                               }
+                               
appManager.setSelectedNetworkViews(selectedViews);
+                       }
                        return;
-               
+               }
                // No need to set the same network again. It should prevent 
infinite loops.
                // Also check if the network still exists (it could have been 
removed by another thread).
-               if (netmgr.networkExists(net.getSUID()) && 
!net.equals(appManager.getCurrentNetwork())) {
+               if (netmgr.networkExists(net.getSUID()) && 
!net.equals(appManager.getCurrentNetwork())) 
                        appManager.setCurrentNetwork(net);
-               }
 
                // creates a list of all selected networks
                List<CyNetwork> networkList = new LinkedList<CyNetwork>();
@@ -634,6 +649,7 @@
         * view, and destroying network (this is platform specific apparently)
         */
        private class PopupListener extends MouseAdapter {
+               
                /**
                 * Don't know why you need both of these, but this is how they 
did it in
                 * the example
@@ -657,7 +673,7 @@
                 * display the popup
                 */
                private void maybeShowPopup(MouseEvent e) {
-                       // check for the popup type
+
                        if (e.isPopupTrigger()) {
                                // get the row where the mouse-click originated
                                int row = treeTable.rowAtPoint(e.getPoint());
@@ -665,7 +681,7 @@
                                if (row != -1) {
                                        JTree tree = treeTable.getTree();
                                        TreePath treePath = 
tree.getPathForRow(row);
-                                       
+                               
                                        Long networkID = -1L;
                                        try {
                                                networkID = ((NetworkTreeNode) 
treePath.getLastPathComponent()).getNetwork().getSUID();                        
                 
@@ -674,6 +690,7 @@
                                                return;
                                        }
                                        
+                                       tree.setSelectionPath(treePath);
                                        CyNetwork cyNetwork = 
netmgr.getNetwork(networkID);
 
                                        if (cyNetwork != null) {
@@ -684,6 +701,7 @@
                                                // then popup menu
                                                popup.show(e.getComponent(), 
e.getX(), e.getY());
                                        }
+                                       
                                }
                        }
                }

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