Author: mes
Date: 2012-04-24 14:20:30 -0700 (Tue, 24 Apr 2012)
New Revision: 28974

Added:
   
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/ActionEnableSupport.java
   
core3/api/trunk/swing-application-api/src/test/java/org/cytoscape/application/swing/ActionEnableSupportTest.java
Removed:
   
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/StringEnableSupport.java
   
core3/api/trunk/swing-application-api/src/test/java/org/cytoscape/application/swing/StringEnableSupportTest.java
Modified:
   
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/AbstractCyAction.java
   
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/AlwaysEnabledEnableSupport.java
   
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/TaskFactoryEnableSupport.java
   
core3/api/trunk/swing-application-api/src/test/java/org/cytoscape/application/swing/CyActionTest.java
   
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/NetworkViewMenuListener.java
Log:
fixes #884 Renamed StringEnableSuport to ActionEnableSupport and made 
TaskFactoryEnableSupport and AlwaysEnabledEnableSupport package scoped.

Modified: 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/AbstractCyAction.java
===================================================================
--- 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/AbstractCyAction.java
   2012-04-24 21:11:06 UTC (rev 28973)
+++ 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/AbstractCyAction.java
   2012-04-24 21:20:30 UTC (rev 28974)
@@ -133,7 +133,7 @@
        public AbstractCyAction(final String name, final CyApplicationManager 
applicationManager, final String enableFor,
                        final CyNetworkViewManager networkViewManager) {
                super(name);
-               this.enabler = new StringEnableSupport(this, enableFor, 
applicationManager, networkViewManager);
+               this.enabler = new ActionEnableSupport(this, enableFor, 
applicationManager, networkViewManager);
        }
 
        /**
@@ -151,7 +151,7 @@
         *            <li>tooltip - (The toolbar or menu tooltip.)</li>
         *            <li>inToolBar - (Whether the action should be in the 
toolbar.)</li>
         *            <li>inMenuBar - (Whether the action should be in a 
menu.)</li>
-        *            <li>enableFor - (System state that the action should be 
enabled for. See {@link StringEnableSupport} for more detail.)</li>
+        *            <li>enableFor - (System state that the action should be 
enabled for. See {@link ActionEnableSupport} for more detail.)</li>
         *            <li>accelerator - (Accelerator key bindings.)</li>
         *            <li>menuGravity - (Float value between 0.0 [top] and 
100.0 [bottom] placing the action in the menu.)</li>
         *            <li>toolBarGravity - (Float value between 0.0 [top] and 
100.0 [bottom] placing the action in the toolbar.)</li>
@@ -213,7 +213,7 @@
         *            <li>inToolBar - (Whether the action should be in the 
toolbar.)</li>
         *            <li>inMenuBar - (Whether the action should be in a 
menu.)</li>
         *            <li>enableFor - (<i>Will only use this value if the 
TaskFactory is not a TaskFactoryPredicate!</i> 
-        *                             See {@link StringEnableSupport} for more 
detail.)</li>
+        *                             See {@link ActionEnableSupport} for more 
detail.)</li>
         *            <li>accelerator - (Accelerator key bindings.)</li>
         *            <li>menuGravity - (Float value between 0.0 [top] and 
100.0 [bottom] placing the action in the menu.)</li>
         *            <li>toolBarGravity - (Float value between 0.0 [top] and 
100.0 [bottom] placing the action in the toolbar.)</li>
@@ -234,7 +234,7 @@
                if (enableFor == null)
                        this.enabler = new TaskFactoryEnableSupport(this, 
factory);
                else
-                       this.enabler = new StringEnableSupport(this, enableFor, 
applicationManager, networkViewManager);
+                       this.enabler = new ActionEnableSupport(this, enableFor, 
applicationManager, networkViewManager);
 
                configFromProps(configProps);
        }

Copied: 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/ActionEnableSupport.java
 (from rev 28961, 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/StringEnableSupport.java)
===================================================================
--- 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/ActionEnableSupport.java
                                (rev 0)
+++ 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/ActionEnableSupport.java
        2012-04-24 21:20:30 UTC (rev 28974)
@@ -0,0 +1,282 @@
+/*
+ File: ActionEnableSupport.java
+
+ Copyright (c) 2006, 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package org.cytoscape.application.swing;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.swing.Action;
+import javax.swing.JMenuItem;
+
+import org.cytoscape.application.CyApplicationManager;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.CyNetworkViewManager;
+import org.cytoscape.work.swing.DynamicSubmenuListener;
+
+/**
+ * A class that allows the enabled state of an Action of JMenuItem to managed 
in 
+ * a consistent way. 
+ * <br/>
+ * Recognized values for the "enableFor" description string are:
+ * <ul>
+ * <li>network</li>
+ * <li>networkWithoutView</li>
+ * <li>networkAndView</li>
+ * <li>selectedNodesOrEdges</li>
+ * <li>selectedNodes</li>
+ * <li>selectedEdges</li>
+ * <li>table</li>
+ * </ul>
+ * 
+ * @CyAPI.Final.Class
+ */
+public final class ActionEnableSupport extends AbstractEnableSupport {
+
+       private final CyApplicationManager applicationManager;
+       private final CyNetworkViewManager networkViewManager;
+       private final String enableFor;
+
+       /**
+        * Enable when at least one network exists.
+        */
+       public static final String ENABLE_FOR_NETWORK = "network";
+
+       /**
+        * Enable when at least one network with NO view exists.
+        */
+       public static final String ENABLE_FOR_NETWORK_WITHOUT_VIEW = 
"networkWithoutView";
+
+       /**
+        * Enable when at least one network WITH view exists.
+        */
+       public static final String ENABLE_FOR_NETWORK_AND_VIEW = 
"networkAndView";
+
+       /**
+        * Enable when either nodes or edges have been selected in a network. 
+        */
+       public static final String ENABLE_FOR_SELECTED_NODES_OR_EDGES = 
"selectedNodesOrEdges";
+
+       /**
+        * Enable when nodes have been selected in a network. 
+        */
+       public static final String ENABLE_FOR_SELECTED_NODES = "selectedNodes";
+
+       /**
+        * Enable when edges have been selected in a network. 
+        */
+       public static final String ENABLE_FOR_SELECTED_EDGES = "selectedEdges";
+
+       /**
+        * Enable when at least one network exists.
+        */
+       public static final String ENABLE_FOR_TABLE = "table";
+
+       /**
+        * Constructor.
+        * @param submenuListener The submenu listener whose enabled state will 
be updated.
+        * @param enableFor The description of how the submenu should be 
enabled.
+        * See class documentation above for allowable values for this string.
+        * @param applicationManager The application manager.
+        */
+       public ActionEnableSupport(DynamicSubmenuListener submenuListener, 
String enableFor,
+                       final CyApplicationManager applicationManager, final 
CyNetworkViewManager networkViewManager) {
+               super(submenuListener);
+
+               this.networkViewManager = networkViewManager;
+               this.enableFor = enableFor;
+               this.applicationManager = applicationManager;
+       }
+
+       /**
+        * Constructor.
+        * @param action The action whose enabled state will be updated.
+        * @param enableFor The description of how the action should be enabled.
+        * See class documentation above for allowable values for this string.
+        * @param applicationManager The application manager.
+        */
+       public ActionEnableSupport(Action action, String enableFor, 
CyApplicationManager applicationManager, final CyNetworkViewManager 
networkViewManager) {
+               super(action);
+               this.enableFor = enableFor;
+               this.applicationManager = applicationManager;
+               this.networkViewManager = networkViewManager;
+       }
+
+       /**
+        * Constructor.
+        * @param menuItem The menuItem whose enabled state will be updated.
+        * @param enableFor The description of how the menuItem should be 
enabled.
+        * See class documentation above for allowable values for this string.
+        * @param applicationManager The application manager.
+        */
+       public ActionEnableSupport(JMenuItem menuItem, String enableFor, 
CyApplicationManager applicationManager, final CyNetworkViewManager 
networkViewManager) {
+               super(menuItem);
+               this.enableFor = enableFor;
+               this.applicationManager = applicationManager;
+               this.networkViewManager = networkViewManager;
+       }
+
+       /**
+        * Updates the enable state for the specified 
action/menuListener/menuItem
+        * for the specified enableFor description and the state of the system.
+        */
+       public void updateEnableState() {
+               if (enableFor == null)
+                       setEnabled(true);
+               else if (enableFor.equals(ENABLE_FOR_NETWORK))
+                       enableForNetwork();
+               else if (enableFor.equals(ENABLE_FOR_NETWORK_WITHOUT_VIEW))
+                       enableForNetworkWithoutView();
+               else if (enableFor.equals(ENABLE_FOR_NETWORK_AND_VIEW))
+                       enableForNetworkAndView();
+               else if (enableFor.equals(ENABLE_FOR_SELECTED_NODES_OR_EDGES))
+                       enableForSelectedNodesOrEdges();
+               else if (enableFor.equals(ENABLE_FOR_SELECTED_NODES))
+                       enableForSelectedNodes();
+               else if (enableFor.equals(ENABLE_FOR_SELECTED_EDGES))
+                       enableForSelectedEdges();
+               else if (enableFor.equals(ENABLE_FOR_TABLE))
+                       enableForTable();
+               else
+                       setEnabled(true);
+       }
+
+       //
+       // The following methods are utility methods that that enable or disable
+       // the action based on the state of Cytoscape. These methods are meant 
to
+       // reduce duplicate code since many actions demand the same state to be
+       // functional (e.g. a network and network view must exist). These 
methods
+       // are generally called from within implementations of {@link
+       // #menuSelected},
+       // but can be called from anywhere.
+       //
+
+       /**
+        * Enable the action if the current network exists and is not null.
+        */
+       private void enableForNetwork() {
+               CyNetwork n = applicationManager.getCurrentNetwork();
+
+               if (n == null)
+                       setEnabled(false);
+               else
+                       setEnabled(true);
+       }
+
+       /**
+        * Enable the action if the selected network exists, is not null,
+        * and no view is available for the network.
+        */
+       private void enableForNetworkWithoutView() {
+               
+               final CyNetwork network = 
applicationManager.getCurrentNetwork();
+
+               if (network == null)
+                       setEnabled(false);
+               else {
+                       // Network exists.
+                       final Collection<CyNetworkView> views = 
networkViewManager.getNetworkViews(network);
+                       if(views.size() == 0)
+                               setEnabled(true);
+                       else
+                               setEnabled(false);
+               }
+       }
+
+       /**
+        * Enable the action if the current network and view exist and are not 
null.
+        */
+       private void enableForNetworkAndView() {
+               CyNetworkView v = applicationManager.getCurrentNetworkView();
+
+               if (v == null)
+                       setEnabled(false);
+               else
+                       setEnabled(true);
+       }
+
+       /**
+        * Enable the action if at least one selected node or edge is required 
to
+        * perform the action.
+        */
+       private void enableForSelectedNodesOrEdges() {
+               final CyNetwork curNetwork = 
applicationManager.getCurrentNetwork();
+
+               // Disable if there is no current network.
+               if (curNetwork == null) {
+                       setEnabled(false);
+
+                       return;
+               }
+
+               setEnabled( 
((curNetwork.getDefaultNodeTable().countMatchingRows(CyNetwork.SELECTED, true) 
> 0) ||
+                            
(curNetwork.getDefaultEdgeTable().countMatchingRows(CyNetwork.SELECTED, true) > 
0)) ); 
+       }
+
+       /**
+        * Enable the action if at least one selected node is required to 
perform
+        * the action.
+        */
+       private void enableForSelectedNodes() {
+               CyNetwork n = applicationManager.getCurrentNetwork();
+
+               if (n == null) {
+                       setEnabled(false);
+
+                       return;
+               }
+
+               setEnabled( 
(n.getDefaultNodeTable().countMatchingRows(CyNetwork.SELECTED, true) > 0) );
+       }
+
+       /**
+        * Enable the action if at least one selected edge is required to 
perform
+        * the action.
+        */
+       private void enableForSelectedEdges() {
+               CyNetwork n = applicationManager.getCurrentNetwork();
+
+               if (n == null) {
+                       setEnabled(false);
+
+                       return;
+               }
+
+               setEnabled( 
(n.getDefaultEdgeTable().countMatchingRows(CyNetwork.SELECTED, true) > 0) );
+       }
+
+       /**
+        * Enables the action/menuListener/menuItem if a table is available and 
not null.
+        */
+       private void enableForTable() {
+               setEnabled(applicationManager.getCurrentTable() != null);
+       }
+
+}

Modified: 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/AlwaysEnabledEnableSupport.java
===================================================================
--- 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/AlwaysEnabledEnableSupport.java
 2012-04-24 21:11:06 UTC (rev 28973)
+++ 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/AlwaysEnabledEnableSupport.java
 2012-04-24 21:20:30 UTC (rev 28974)
@@ -39,7 +39,7 @@
  * 
  * @CyAPI.Final.Class
  */
-public final class AlwaysEnabledEnableSupport extends AbstractEnableSupport {
+final class AlwaysEnabledEnableSupport extends AbstractEnableSupport {
 
 
        /**

Deleted: 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/StringEnableSupport.java
===================================================================
--- 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/StringEnableSupport.java
        2012-04-24 21:11:06 UTC (rev 28973)
+++ 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/StringEnableSupport.java
        2012-04-24 21:20:30 UTC (rev 28974)
@@ -1,282 +0,0 @@
-/*
- File: StringEnableSupport.java
-
- Copyright (c) 2006, 2010, The Cytoscape Consortium (www.cytoscape.org)
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications.  In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage.  See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-package org.cytoscape.application.swing;
-
-import java.util.Collection;
-import java.util.List;
-
-import javax.swing.Action;
-import javax.swing.JMenuItem;
-
-import org.cytoscape.application.CyApplicationManager;
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.view.model.CyNetworkView;
-import org.cytoscape.view.model.CyNetworkViewManager;
-import org.cytoscape.work.swing.DynamicSubmenuListener;
-
-/**
- * A class that allows the enabled state of an Action of JMenuItem to managed 
in 
- * a consistent way. 
- * <br/>
- * Recognized values for the "enableFor" description string are:
- * <ul>
- * <li>network</li>
- * <li>networkWithoutView</li>
- * <li>networkAndView</li>
- * <li>selectedNodesOrEdges</li>
- * <li>selectedNodes</li>
- * <li>selectedEdges</li>
- * <li>table</li>
- * </ul>
- * 
- * @CyAPI.Final.Class
- */
-public final class StringEnableSupport extends AbstractEnableSupport {
-
-       private final CyApplicationManager applicationManager;
-       private final CyNetworkViewManager networkViewManager;
-       private final String enableFor;
-
-       /**
-        * Enable when at least one network exists.
-        */
-       public static final String ENABLE_FOR_NETWORK = "network";
-
-       /**
-        * Enable when at least one network with NO view exists.
-        */
-       public static final String ENABLE_FOR_NETWORK_WITHOUT_VIEW = 
"networkWithoutView";
-
-       /**
-        * Enable when at least one network WITH view exists.
-        */
-       public static final String ENABLE_FOR_NETWORK_AND_VIEW = 
"networkAndView";
-
-       /**
-        * Enable when either nodes or edges have been selected in a network. 
-        */
-       public static final String ENABLE_FOR_SELECTED_NODES_OR_EDGES = 
"selectedNodesOrEdges";
-
-       /**
-        * Enable when nodes have been selected in a network. 
-        */
-       public static final String ENABLE_FOR_SELECTED_NODES = "selectedNodes";
-
-       /**
-        * Enable when edges have been selected in a network. 
-        */
-       public static final String ENABLE_FOR_SELECTED_EDGES = "selectedEdges";
-
-       /**
-        * Enable when at least one network exists.
-        */
-       public static final String ENABLE_FOR_TABLE = "table";
-
-       /**
-        * Constructor.
-        * @param submenuListener The submenu listener whose enabled state will 
be updated.
-        * @param enableFor The description of how the submenu should be 
enabled.
-        * See class documentation above for allowable values for this string.
-        * @param applicationManager The application manager.
-        */
-       public StringEnableSupport(DynamicSubmenuListener submenuListener, 
String enableFor,
-                       final CyApplicationManager applicationManager, final 
CyNetworkViewManager networkViewManager) {
-               super(submenuListener);
-
-               this.networkViewManager = networkViewManager;
-               this.enableFor = enableFor;
-               this.applicationManager = applicationManager;
-       }
-
-       /**
-        * Constructor.
-        * @param action The action whose enabled state will be updated.
-        * @param enableFor The description of how the action should be enabled.
-        * See class documentation above for allowable values for this string.
-        * @param applicationManager The application manager.
-        */
-       public StringEnableSupport(Action action, String enableFor, 
CyApplicationManager applicationManager, final CyNetworkViewManager 
networkViewManager) {
-               super(action);
-               this.enableFor = enableFor;
-               this.applicationManager = applicationManager;
-               this.networkViewManager = networkViewManager;
-       }
-
-       /**
-        * Constructor.
-        * @param menuItem The menuItem whose enabled state will be updated.
-        * @param enableFor The description of how the menuItem should be 
enabled.
-        * See class documentation above for allowable values for this string.
-        * @param applicationManager The application manager.
-        */
-       public StringEnableSupport(JMenuItem menuItem, String enableFor, 
CyApplicationManager applicationManager, final CyNetworkViewManager 
networkViewManager) {
-               super(menuItem);
-               this.enableFor = enableFor;
-               this.applicationManager = applicationManager;
-               this.networkViewManager = networkViewManager;
-       }
-
-       /**
-        * Updates the enable state for the specified 
action/menuListener/menuItem
-        * for the specified enableFor description and the state of the system.
-        */
-       public void updateEnableState() {
-               if (enableFor == null)
-                       setEnabled(true);
-               else if (enableFor.equals(ENABLE_FOR_NETWORK))
-                       enableForNetwork();
-               else if (enableFor.equals(ENABLE_FOR_NETWORK_WITHOUT_VIEW))
-                       enableForNetworkWithoutView();
-               else if (enableFor.equals(ENABLE_FOR_NETWORK_AND_VIEW))
-                       enableForNetworkAndView();
-               else if (enableFor.equals(ENABLE_FOR_SELECTED_NODES_OR_EDGES))
-                       enableForSelectedNodesOrEdges();
-               else if (enableFor.equals(ENABLE_FOR_SELECTED_NODES))
-                       enableForSelectedNodes();
-               else if (enableFor.equals(ENABLE_FOR_SELECTED_EDGES))
-                       enableForSelectedEdges();
-               else if (enableFor.equals(ENABLE_FOR_TABLE))
-                       enableForTable();
-               else
-                       setEnabled(true);
-       }
-
-       //
-       // The following methods are utility methods that that enable or disable
-       // the action based on the state of Cytoscape. These methods are meant 
to
-       // reduce duplicate code since many actions demand the same state to be
-       // functional (e.g. a network and network view must exist). These 
methods
-       // are generally called from within implementations of {@link
-       // #menuSelected},
-       // but can be called from anywhere.
-       //
-
-       /**
-        * Enable the action if the current network exists and is not null.
-        */
-       private void enableForNetwork() {
-               CyNetwork n = applicationManager.getCurrentNetwork();
-
-               if (n == null)
-                       setEnabled(false);
-               else
-                       setEnabled(true);
-       }
-
-       /**
-        * Enable the action if the selected network exists, is not null,
-        * and no view is available for the network.
-        */
-       private void enableForNetworkWithoutView() {
-               
-               final CyNetwork network = 
applicationManager.getCurrentNetwork();
-
-               if (network == null)
-                       setEnabled(false);
-               else {
-                       // Network exists.
-                       final Collection<CyNetworkView> views = 
networkViewManager.getNetworkViews(network);
-                       if(views.size() == 0)
-                               setEnabled(true);
-                       else
-                               setEnabled(false);
-               }
-       }
-
-       /**
-        * Enable the action if the current network and view exist and are not 
null.
-        */
-       private void enableForNetworkAndView() {
-               CyNetworkView v = applicationManager.getCurrentNetworkView();
-
-               if (v == null)
-                       setEnabled(false);
-               else
-                       setEnabled(true);
-       }
-
-       /**
-        * Enable the action if at least one selected node or edge is required 
to
-        * perform the action.
-        */
-       private void enableForSelectedNodesOrEdges() {
-               final CyNetwork curNetwork = 
applicationManager.getCurrentNetwork();
-
-               // Disable if there is no current network.
-               if (curNetwork == null) {
-                       setEnabled(false);
-
-                       return;
-               }
-
-               setEnabled( 
((curNetwork.getDefaultNodeTable().countMatchingRows(CyNetwork.SELECTED, true) 
> 0) ||
-                            
(curNetwork.getDefaultEdgeTable().countMatchingRows(CyNetwork.SELECTED, true) > 
0)) ); 
-       }
-
-       /**
-        * Enable the action if at least one selected node is required to 
perform
-        * the action.
-        */
-       private void enableForSelectedNodes() {
-               CyNetwork n = applicationManager.getCurrentNetwork();
-
-               if (n == null) {
-                       setEnabled(false);
-
-                       return;
-               }
-
-               setEnabled( 
(n.getDefaultNodeTable().countMatchingRows(CyNetwork.SELECTED, true) > 0) );
-       }
-
-       /**
-        * Enable the action if at least one selected edge is required to 
perform
-        * the action.
-        */
-       private void enableForSelectedEdges() {
-               CyNetwork n = applicationManager.getCurrentNetwork();
-
-               if (n == null) {
-                       setEnabled(false);
-
-                       return;
-               }
-
-               setEnabled( 
(n.getDefaultEdgeTable().countMatchingRows(CyNetwork.SELECTED, true) > 0) );
-       }
-
-       /**
-        * Enables the action/menuListener/menuItem if a table is available and 
not null.
-        */
-       private void enableForTable() {
-               setEnabled(applicationManager.getCurrentTable() != null);
-       }
-
-}

Modified: 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/TaskFactoryEnableSupport.java
===================================================================
--- 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/TaskFactoryEnableSupport.java
   2012-04-24 21:11:06 UTC (rev 28973)
+++ 
core3/api/trunk/swing-application-api/src/main/java/org/cytoscape/application/swing/TaskFactoryEnableSupport.java
   2012-04-24 21:20:30 UTC (rev 28974)
@@ -42,7 +42,7 @@
  * 
  * @CyAPI.Final.Class
  */
-public final class TaskFactoryEnableSupport extends AbstractEnableSupport {
+final class TaskFactoryEnableSupport extends AbstractEnableSupport {
 
        private final TaskFactory tfp;
 

Copied: 
core3/api/trunk/swing-application-api/src/test/java/org/cytoscape/application/swing/ActionEnableSupportTest.java
 (from rev 28961, 
core3/api/trunk/swing-application-api/src/test/java/org/cytoscape/application/swing/StringEnableSupportTest.java)
===================================================================
--- 
core3/api/trunk/swing-application-api/src/test/java/org/cytoscape/application/swing/ActionEnableSupportTest.java
                            (rev 0)
+++ 
core3/api/trunk/swing-application-api/src/test/java/org/cytoscape/application/swing/ActionEnableSupportTest.java
    2012-04-24 21:20:30 UTC (rev 28974)
@@ -0,0 +1,78 @@
+package org.cytoscape.application.swing;
+
+import static org.junit.Assert.*;
+
+import javax.swing.JMenuItem;
+
+import org.cytoscape.application.CyApplicationManager;
+import org.cytoscape.view.model.CyNetworkViewManager;
+import org.cytoscape.work.swing.DynamicSubmenuListener;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+public class ActionEnableSupportTest {
+       
+       private ActionEnableSupport support;
+       
+       @Mock private DynamicSubmenuListener action;
+       private String enableFor = ActionEnableSupport.ENABLE_FOR_NETWORK;
+       @Mock private CyApplicationManager applicationManager;
+       @Mock private CyNetworkViewManager networkViewManager;
+       @Mock private DynamicSubmenuListener submenuListener;
+
+       private JMenuItem menuItem = new JMenuItem();
+
+       @Before
+       public void setUp() throws Exception {
+               MockitoAnnotations.initMocks(this);
+               support = new ActionEnableSupport(action, enableFor, 
applicationManager, networkViewManager);
+       }
+
+       @Test
+       public void testUpdateEnableState() {
+               support = new 
ActionEnableSupport(action,ActionEnableSupport.ENABLE_FOR_NETWORK, 
applicationManager, networkViewManager);
+               support.updateEnableState();
+               assertFalse(support.isCurrentlyEnabled());
+               
+               support = new 
ActionEnableSupport(action,ActionEnableSupport.ENABLE_FOR_NETWORK_AND_VIEW, 
applicationManager, networkViewManager);
+               support.updateEnableState();
+               assertFalse(support.isCurrentlyEnabled());
+               
+               support = new 
ActionEnableSupport(action,ActionEnableSupport.ENABLE_FOR_NETWORK_WITHOUT_VIEW, 
applicationManager, networkViewManager);
+               support.updateEnableState();
+               assertFalse(support.isCurrentlyEnabled());
+               
+               support = new 
ActionEnableSupport(action,ActionEnableSupport.ENABLE_FOR_SELECTED_EDGES, 
applicationManager, networkViewManager);
+               support.updateEnableState();
+               assertFalse(support.isCurrentlyEnabled());
+               
+               support = new 
ActionEnableSupport(action,ActionEnableSupport.ENABLE_FOR_SELECTED_NODES, 
applicationManager, networkViewManager);
+               support.updateEnableState();
+               assertFalse(support.isCurrentlyEnabled());
+               
+               support = new 
ActionEnableSupport(action,ActionEnableSupport.ENABLE_FOR_SELECTED_NODES_OR_EDGES,
 applicationManager, networkViewManager);
+               support.updateEnableState();
+               assertFalse(support.isCurrentlyEnabled());
+               
+               support = new 
ActionEnableSupport(action,ActionEnableSupport.ENABLE_FOR_TABLE, 
applicationManager, networkViewManager);
+               support.updateEnableState();
+               assertFalse(support.isCurrentlyEnabled());
+               
+               support = new ActionEnableSupport(action,null, 
applicationManager, networkViewManager);
+               support.updateEnableState();
+               assertTrue(support.isCurrentlyEnabled());
+       }
+
+       @Test
+       public void testStringEnableSupportConstructor() {
+               support = new ActionEnableSupport(action, enableFor, 
applicationManager, networkViewManager);
+               assertNotNull(support);
+               support = new ActionEnableSupport(submenuListener, enableFor, 
applicationManager, networkViewManager);
+               assertNotNull(support);
+               support = new ActionEnableSupport(menuItem, enableFor, 
applicationManager, networkViewManager);
+               assertNotNull(support);
+       }
+}

Modified: 
core3/api/trunk/swing-application-api/src/test/java/org/cytoscape/application/swing/CyActionTest.java
===================================================================
--- 
core3/api/trunk/swing-application-api/src/test/java/org/cytoscape/application/swing/CyActionTest.java
       2012-04-24 21:11:06 UTC (rev 28973)
+++ 
core3/api/trunk/swing-application-api/src/test/java/org/cytoscape/application/swing/CyActionTest.java
       2012-04-24 21:20:30 UTC (rev 28974)
@@ -26,7 +26,7 @@
                configProps.put(ServiceProperties.ACCELERATOR, "cmd s");
                configProps.put(ServiceProperties.COMMAND, "test");
                configProps.put(ServiceProperties.COMMAND_NAMESPACE, "dummy");
-               configProps.put(ServiceProperties.ENABLE_FOR, 
StringEnableSupport.ENABLE_FOR_NETWORK);
+               configProps.put(ServiceProperties.ENABLE_FOR, 
ActionEnableSupport.ENABLE_FOR_NETWORK);
                configProps.put(ServiceProperties.ID, "dummyAction");
                configProps.put(ServiceProperties.IN_MENU_BAR, "true");
                configProps.put(ServiceProperties.IN_TOOL_BAR, "false");

Deleted: 
core3/api/trunk/swing-application-api/src/test/java/org/cytoscape/application/swing/StringEnableSupportTest.java
===================================================================
--- 
core3/api/trunk/swing-application-api/src/test/java/org/cytoscape/application/swing/StringEnableSupportTest.java
    2012-04-24 21:11:06 UTC (rev 28973)
+++ 
core3/api/trunk/swing-application-api/src/test/java/org/cytoscape/application/swing/StringEnableSupportTest.java
    2012-04-24 21:20:30 UTC (rev 28974)
@@ -1,78 +0,0 @@
-package org.cytoscape.application.swing;
-
-import static org.junit.Assert.*;
-
-import javax.swing.JMenuItem;
-
-import org.cytoscape.application.CyApplicationManager;
-import org.cytoscape.view.model.CyNetworkViewManager;
-import org.cytoscape.work.swing.DynamicSubmenuListener;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-public class StringEnableSupportTest {
-       
-       private StringEnableSupport support;
-       
-       @Mock private DynamicSubmenuListener action;
-       private String enableFor = StringEnableSupport.ENABLE_FOR_NETWORK;
-       @Mock private CyApplicationManager applicationManager;
-       @Mock private CyNetworkViewManager networkViewManager;
-       @Mock private DynamicSubmenuListener submenuListener;
-
-       private JMenuItem menuItem = new JMenuItem();
-
-       @Before
-       public void setUp() throws Exception {
-               MockitoAnnotations.initMocks(this);
-               support = new StringEnableSupport(action, enableFor, 
applicationManager, networkViewManager);
-       }
-
-       @Test
-       public void testUpdateEnableState() {
-               support = new 
StringEnableSupport(action,StringEnableSupport.ENABLE_FOR_NETWORK, 
applicationManager, networkViewManager);
-               support.updateEnableState();
-               assertFalse(support.isCurrentlyEnabled());
-               
-               support = new 
StringEnableSupport(action,StringEnableSupport.ENABLE_FOR_NETWORK_AND_VIEW, 
applicationManager, networkViewManager);
-               support.updateEnableState();
-               assertFalse(support.isCurrentlyEnabled());
-               
-               support = new 
StringEnableSupport(action,StringEnableSupport.ENABLE_FOR_NETWORK_WITHOUT_VIEW, 
applicationManager, networkViewManager);
-               support.updateEnableState();
-               assertFalse(support.isCurrentlyEnabled());
-               
-               support = new 
StringEnableSupport(action,StringEnableSupport.ENABLE_FOR_SELECTED_EDGES, 
applicationManager, networkViewManager);
-               support.updateEnableState();
-               assertFalse(support.isCurrentlyEnabled());
-               
-               support = new 
StringEnableSupport(action,StringEnableSupport.ENABLE_FOR_SELECTED_NODES, 
applicationManager, networkViewManager);
-               support.updateEnableState();
-               assertFalse(support.isCurrentlyEnabled());
-               
-               support = new 
StringEnableSupport(action,StringEnableSupport.ENABLE_FOR_SELECTED_NODES_OR_EDGES,
 applicationManager, networkViewManager);
-               support.updateEnableState();
-               assertFalse(support.isCurrentlyEnabled());
-               
-               support = new 
StringEnableSupport(action,StringEnableSupport.ENABLE_FOR_TABLE, 
applicationManager, networkViewManager);
-               support.updateEnableState();
-               assertFalse(support.isCurrentlyEnabled());
-               
-               support = new StringEnableSupport(action,null, 
applicationManager, networkViewManager);
-               support.updateEnableState();
-               assertTrue(support.isCurrentlyEnabled());
-       }
-
-       @Test
-       public void testStringEnableSupportConstructor() {
-               support = new StringEnableSupport(action, enableFor, 
applicationManager, networkViewManager);
-               assertNotNull(support);
-               support = new StringEnableSupport(submenuListener, enableFor, 
applicationManager, networkViewManager);
-               assertNotNull(support);
-               support = new StringEnableSupport(menuItem, enableFor, 
applicationManager, networkViewManager);
-               assertNotNull(support);
-       }
-}

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-04-24 21:11:06 UTC (rev 28973)
+++ 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutMenuPopulator.java
     2012-04-24 21:20:30 UTC (rev 28974)
@@ -48,7 +48,7 @@
 
 import org.cytoscape.application.CyApplicationManager;
 import org.cytoscape.application.swing.CySwingApplication;
-import org.cytoscape.application.swing.StringEnableSupport;
+import org.cytoscape.application.swing.ActionEnableSupport;
 import org.cytoscape.event.CyEventHelper;
 import org.cytoscape.internal.task.DynamicTaskFactoryProvisioner;
 import org.cytoscape.model.CyNetwork;
@@ -172,9 +172,9 @@
        }
 
        private class LayoutMenuEnabler implements MenuListener {
-               private final StringEnableSupport parentMenuSupport; 
+               private final ActionEnableSupport parentMenuSupport; 
                LayoutMenuEnabler(JMenu parentMenu, String enableFor, 
CyApplicationManager appMgr, final CyNetworkViewManager networkViewManager) {
-                       parentMenuSupport = new 
StringEnableSupport(parentMenu,enableFor,appMgr, networkViewManager);
+                       parentMenuSupport = new 
ActionEnableSupport(parentMenu,enableFor,appMgr, networkViewManager);
                }
                public void menuSelected(MenuEvent m) {
                        parentMenuSupport.updateEnableState();

Modified: 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/NetworkViewMenuListener.java
===================================================================
--- 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/NetworkViewMenuListener.java
 2012-04-24 21:11:06 UTC (rev 28973)
+++ 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/NetworkViewMenuListener.java
 2012-04-24 21:20:30 UTC (rev 28974)
@@ -40,7 +40,7 @@
 import javax.swing.event.MenuListener;
 
 import org.cytoscape.application.CyApplicationManager;
-import org.cytoscape.application.swing.StringEnableSupport;
+import org.cytoscape.application.swing.ActionEnableSupport;
 import org.cytoscape.view.model.CyNetworkViewManager;
 import org.cytoscape.work.swing.DynamicSubmenuListener;
 
@@ -48,11 +48,11 @@
 public class NetworkViewMenuListener implements MenuListener {
 
        private final MenuListener actualMenuListener;
-       private final StringEnableSupport menuEnableSupport; 
+       private final ActionEnableSupport menuEnableSupport; 
 
        public NetworkViewMenuListener(DynamicSubmenuListener 
actualMenuListener, CyApplicationManager appMgr, final CyNetworkViewManager 
networkViewManager, String enableFor) {
                this.actualMenuListener = actualMenuListener;
-               this.menuEnableSupport = new 
StringEnableSupport(actualMenuListener, enableFor, appMgr, networkViewManager);
+               this.menuEnableSupport = new 
ActionEnableSupport(actualMenuListener, enableFor, appMgr, networkViewManager);
        }
 
        public void menuSelected(MenuEvent m) {

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