Author: ruschein
Date: 2010-11-18 14:47:46 -0800 (Thu, 18 Nov 2010)
New Revision: 22908
Modified:
core3/core-task-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/AbstractCyAction.java
Log:
Renamed selectedNetworkObjs to selectedNodesOrEdges and added enableFor=
settings named selectedNodes and selectedEdges.
Modified:
core3/core-task-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
---
core3/core-task-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2010-11-18 22:18:56 UTC (rev 22907)
+++
core3/core-task-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2010-11-18 22:47:46 UTC (rev 22908)
@@ -293,7 +293,7 @@
<osgi:service-properties>
<entry key="title" value="From selected nodes, selected
edges" />
<entry key="preferredMenu" value="File.New.Network" />
- <entry key="enableFor" value="selectedNetworkObjs" />
+ <entry key="enableFor" value="selectedNodesOrEdges" />
<entry key="accelerator" value="cmd shift n"/>
</osgi:service-properties>
</osgi:service>
@@ -304,7 +304,7 @@
<osgi:service-properties>
<entry key="title" value="From selected nodes, all
edges" />
<entry key="preferredMenu" value="File.New.Network" />
- <entry key="enableFor" value="selectedNetworkObjs" />
+ <entry key="enableFor" value="selectedNodesOrEdges" />
<entry key="accelerator" value="cmd n"/>
</osgi:service-properties>
</osgi:service>
@@ -315,7 +315,7 @@
<osgi:service-properties>
<entry key="title" value="Clone Current Network" />
<entry key="preferredMenu" value="File.New.Network" />
- <entry key="enableFor" value="selectedNetworkObjs" />
+ <entry key="enableFor" value="selectedNodesOrEdges" />
</osgi:service-properties>
</osgi:service>
Modified:
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/AbstractCyAction.java
===================================================================
---
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/AbstractCyAction.java
2010-11-18 22:18:56 UTC (rev 22907)
+++
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/AbstractCyAction.java
2010-11-18 22:47:46 UTC (rev 22908)
@@ -254,13 +254,13 @@
* This method can be used at your discretion, but otherwise does
nothing.
* @param e The triggering event.
*/
- public void menuCanceled(MenuEvent e) {}
+ public void menuCanceled(MenuEvent e) { }
/**
* This method can be used at your discretion, but otherwise does
nothing.
* @param e The triggering event.
*/
- public void menuDeselected(MenuEvent e) {}
+ public void menuDeselected(MenuEvent e) { }
/**
* This method can be overridden by individual actions to set the state
of menu items
@@ -270,7 +270,7 @@
* and "selectedNetworkObjs".
* @param e The triggering event.
*/
- public void menuSelected(MenuEvent e) { enableMenus(); }
+ public void menuSelected(MenuEvent e) { enableMenus(); }
/**
* This method can be overridden by individual actions to set the state
of menu items
@@ -304,14 +304,18 @@
//
private void enableMenus() {
- if ( enableFor == null || enableFor.equals("") )
+ if (enableFor == null || enableFor.equals(""))
setEnabled(true);
- else if ( enableFor.equals("network") )
+ else if (enableFor.equals("network"))
enableForNetwork();
- else if ( enableFor.equals("networkAndView") )
+ else if (enableFor.equals("networkAndView"))
enableForNetworkAndView();
- else if ( enableFor.equals("selectedNetworkObjs") )
- enableForSelectedNetworkObjs();
+ else if (enableFor.equals("selectedNodesOrEdges"))
+ enableForSelectedNodesOrEdges();
+ else if (enableFor.equals("selectedNodes"))
+ enableForSelectedNodes();
+ else if (enableFor.equals("selectedEdges"))
+ enableForSelectedEdges();
}
/**
@@ -337,29 +341,67 @@
}
/**
- * Enable the action if more than one network object is required to
execute
- * the action.
+ * Enable the action if at least one selected node or edge is required
to perform the action.
*/
- protected void enableForSelectedNetworkObjs() {
+ protected void enableForSelectedNodesOrEdges() {
CyNetwork n = applicationManager.getCurrentNetwork();
- if ( n == null ) {
+ if (n == null) {
setEnabled(false);
return;
}
- for ( CyNode node : n.getNodeList() ) {
- if ( node.getCyRow().get("selected",Boolean.class) ) {
+ for (CyNode node : n.getNodeList()) {
+ if (node.getCyRow().get("selected", Boolean.class)) {
setEnabled(true);
return;
}
}
- for ( CyEdge edge : n.getEdgeList() ) {
- if ( edge.getCyRow().get("selected",Boolean.class) ) {
+ for (CyEdge edge : n.getEdgeList()) {
+ if (edge.getCyRow().get("selected", Boolean.class)) {
setEnabled(true);
return;
}
}
setEnabled(false);
}
+
+ /**
+ * Enable the action if at least one selected node is required to
perform the action.
+ */
+ protected void enableForSelectedNodes() {
+ CyNetwork n = applicationManager.getCurrentNetwork();
+
+ if (n == null) {
+ setEnabled(false);
+ return;
+ }
+
+ for (CyNode node : n.getNodeList()) {
+ if (node.getCyRow().get("selected", Boolean.class)) {
+ setEnabled(true);
+ return;
+ }
+ }
+ setEnabled(false);
+ }
+ /**
+ * Enable the action if at least one selected edge is required to
perform the action.
+ */
+ protected void enableForSelectedEdges() {
+ CyNetwork n = applicationManager.getCurrentNetwork();
+
+ if (n == null) {
+ setEnabled(false);
+ return;
+ }
+
+ for (CyEdge edge : n.getEdgeList()) {
+ if (edge.getCyRow().get("selected", Boolean.class)) {
+ setEnabled(true);
+ return;
+ }
+ }
+ setEnabled(false);
+ }
}
--
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.