Author: scooter
Date: 2010-08-17 15:11:13 -0700 (Tue, 17 Aug 2010)
New Revision: 21415

Modified:
   
csplugins/trunk/ucsf/scooter/namedSelection/src/namedSelection/NamedSelection.java
   
csplugins/trunk/ucsf/scooter/namedSelection/src/namedSelection/ui/GroupCreationDialog.java
   
csplugins/trunk/ucsf/scooter/namedSelection/src/namedSelection/ui/NamedSelectionCommandListener.java
Log:
Changes for 2.8 group mechanism


Modified: 
csplugins/trunk/ucsf/scooter/namedSelection/src/namedSelection/NamedSelection.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/namedSelection/src/namedSelection/NamedSelection.java
  2010-08-17 22:03:31 UTC (rev 21414)
+++ 
csplugins/trunk/ucsf/scooter/namedSelection/src/namedSelection/NamedSelection.java
  2010-08-17 22:11:13 UTC (rev 21415)
@@ -44,8 +44,8 @@
 import javax.swing.SwingConstants;
 
 // giny imports
+import ding.view.DGraphView;
 import giny.view.NodeView;
-
 import ding.view.NodeContextMenuListener;
 
 // Cytoscape imports
@@ -101,6 +101,11 @@
                        // Listen for network and session load events
                        
Cytoscape.getPropertyChangeSupport().addPropertyChangeListener(Cytoscape.NETWORK_LOADED,
 this);
                        
Cytoscape.getPropertyChangeSupport().addPropertyChangeListener(Cytoscape.SESSION_LOADED,
 this);
+                       Cytoscape.getDesktop().getSwingPropertyChangeSupport()
+                               .addPropertyChangeListener( 
CytoscapeDesktop.NETWORK_VIEW_CREATED, this );
+
+                       // Add ourselves to the current network context menu
+                       
((DGraphView)Cytoscape.getCurrentNetworkView()).addNodeContextMenuListener(this);
                } catch (ClassCastException e) {
                        myLogger.error(e.getMessage());
                }
@@ -143,18 +148,24 @@
                        Object[] ret_val = (Object []) e.getNewValue();
                        CyNetwork network = (CyNetwork)ret_val[0];
                        CyNetworkView netView = 
Cytoscape.getNetworkView(network.getIdentifier());
-                       if (!netView.equals(Cytoscape.getNullNetworkView()))
+                       if (!netView.equals(Cytoscape.getNullNetworkView())) {
                                
netView.addGraphViewChangeListener(groupPanel.getTree());
-
+                               netView.addNodeContextMenuListener(this);
+                       }
                } else if (e.getPropertyName() == Cytoscape.SESSION_LOADED &&
                           e.getNewValue() != null) {
                        List<String> netList = (List<String>) e.getNewValue();
                        for (String network: netList) {
                                CyNetwork net = Cytoscape.getNetwork(network);
                                CyNetworkView netView = 
Cytoscape.getNetworkView(net.getIdentifier());
-                               if 
(!netView.equals(Cytoscape.getNullNetworkView()))
+                               if 
(!netView.equals(Cytoscape.getNullNetworkView())) {
                                        
netView.addGraphViewChangeListener(groupPanel.getTree());
+                                       
netView.addNodeContextMenuListener(this);
+                               }
                        }
+               } else if (e.getPropertyName() == 
CytoscapeDesktop.NETWORK_VIEW_CREATED) {
+                       // Add menu to the context dialog
+                       
((CyNetworkView)e.getNewValue()).addNodeContextMenuListener(this);
                }
 
                // Update the tree

Modified: 
csplugins/trunk/ucsf/scooter/namedSelection/src/namedSelection/ui/GroupCreationDialog.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/namedSelection/src/namedSelection/ui/GroupCreationDialog.java
  2010-08-17 22:03:31 UTC (rev 21414)
+++ 
csplugins/trunk/ucsf/scooter/namedSelection/src/namedSelection/ui/GroupCreationDialog.java
  2010-08-17 22:11:13 UTC (rev 21415)
@@ -32,6 +32,7 @@
  */
 package namedSelection.ui;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import java.awt.event.ActionListener;
@@ -50,6 +51,7 @@
 import javax.swing.JSeparator;
 import javax.swing.JTextField;
 
+import cytoscape.CyEdge;
 import cytoscape.Cytoscape;
 import cytoscape.CyNetwork;
 import cytoscape.CyNode;
@@ -161,7 +163,7 @@
                        else
                                network = Cytoscape.getCurrentNetwork();
                        // Create the group
-                       group = CyGroupManager.createGroup(groupName, 
currentNodes, null, network);
+                       group = CyGroupManager.createGroup(groupName, 
currentNodes, new ArrayList<CyEdge>(), new ArrayList<CyEdge>(), null, network);
                        // Already there?
                        if (group == null) {
                                // Warn the user and return

Modified: 
csplugins/trunk/ucsf/scooter/namedSelection/src/namedSelection/ui/NamedSelectionCommandListener.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/namedSelection/src/namedSelection/ui/NamedSelectionCommandListener.java
        2010-08-17 22:03:31 UTC (rev 21414)
+++ 
csplugins/trunk/ucsf/scooter/namedSelection/src/namedSelection/ui/NamedSelectionCommandListener.java
        2010-08-17 22:11:13 UTC (rev 21415)
@@ -43,6 +43,7 @@
 import giny.view.NodeView;
 
 // Cytoscape imports
+import cytoscape.CyEdge;
 import cytoscape.CyNode;
 import cytoscape.CyNetwork;
 import cytoscape.Cytoscape;
@@ -105,7 +106,11 @@
                String groupName = JOptionPane.showInputDialog("Please enter a 
name for this selection");
                if (groupName == null) return;
 
-               CyGroup group = CyGroupManager.createGroup(groupName, 
currentNodes, NamedSelection.viewerName, network);
+               // By using the empty lists, we inhibit all of the overhead 
associated with figuring
+               // out internal and external edges (which we don't care about)
+               CyGroup group = CyGroupManager.createGroup(groupName, 
currentNodes, new ArrayList<CyEdge>(), 
+                                                          new 
ArrayList<CyEdge>(), 
+                                                          
NamedSelection.viewerName, network);
                group.setState(NamedSelection.SELECTED);
        }
 

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