Author: scooter
Date: 2012-08-01 11:54:23 -0700 (Wed, 01 Aug 2012)
New Revision: 30065

Modified:
   
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutMenuPopulator.java
Log:
Make sure the layout menu shows up, even when we don't have a network or 
network view


Modified: 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutMenuPopulator.java
===================================================================
--- 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutMenuPopulator.java
     2012-08-01 18:19:28 UTC (rev 30064)
+++ 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutMenuPopulator.java
     2012-08-01 18:54:23 UTC (rev 30065)
@@ -107,13 +107,12 @@
      */
     public void menuSelected(MenuEvent e) {
         CyNetworkView view = appMgr.getCurrentNetworkView();
-        if ( view == null )
-            return;
+        CyNetwork network = appMgr.getCurrentNetwork();
 
-        CyNetwork network = view.getModel();
-
         // Figure out if we have anything selected
-        boolean someSelected = 
network.getDefaultNodeTable().countMatchingRows(CyNetwork.SELECTED, true) > 0;
+        boolean someSelected = false;
+        if (network != null)
+            someSelected = 
network.getDefaultNodeTable().countMatchingRows(CyNetwork.SELECTED, true) > 0;
         boolean enableMenuItem = checkEnabled();
 
         // Get all of the algorithms
@@ -121,15 +120,15 @@
             Map props = algorithmMap.get(layout);
             double gravity = 1000.0;
             if (props.get(MENU_GRAVITY) != null)
-               gravity = Double.parseDouble((String)props.get(MENU_GRAVITY));
+                gravity = Double.parseDouble((String)props.get(MENU_GRAVITY));
 
-                                               boolean separatorAfter = false;
+            boolean separatorAfter = false;
             if (props.get(INSERT_SEPARATOR_AFTER) != null)
-               separatorAfter = 
Boolean.parseBoolean((String)props.get(INSERT_SEPARATOR_AFTER));
+                separatorAfter = 
Boolean.parseBoolean((String)props.get(INSERT_SEPARATOR_AFTER));
 
-                                               boolean separatorBefore = false;
+            boolean separatorBefore = false;
             if (props.get(INSERT_SEPARATOR_BEFORE) != null)
-               separatorBefore = 
Boolean.parseBoolean((String)props.get(INSERT_SEPARATOR_BEFORE));
+                separatorBefore = 
Boolean.parseBoolean((String)props.get(INSERT_SEPARATOR_BEFORE));
 
             // Remove the old menu
             if (menuMap.containsKey(layout)) {
@@ -137,10 +136,12 @@
                 menuMap.remove(layout);
             }
         
-            boolean usesNodeAttrs = 
-                
hasValidAttributes(layout.getSupportedNodeAttributeTypes(),network.getDefaultNodeTable());
-            boolean usesEdgeAttrs = 
-                
hasValidAttributes(layout.getSupportedEdgeAttributeTypes(),network.getDefaultEdgeTable());
+            boolean usesNodeAttrs = false;
+            if (network != null)
+                usesNodeAttrs = 
hasValidAttributes(layout.getSupportedNodeAttributeTypes(),network.getDefaultNodeTable());
+            boolean usesEdgeAttrs = false;
+            if (network != null)
+                usesEdgeAttrs = 
hasValidAttributes(layout.getSupportedEdgeAttributeTypes(),network.getDefaultEdgeTable());
             boolean usesSelected = (layout.getSupportsSelectedOnly() && 
someSelected);
 
             if (usesNodeAttrs || usesEdgeAttrs || usesSelected) {

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