Author: mes
Date: 2010-11-15 14:24:40 -0800 (Mon, 15 Nov 2010)
New Revision: 22857
Added:
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/AbstractCyAction.java
Removed:
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/CytoscapeAction.java
Modified:
core3/manual-layout-impl/trunk/src/main/java/org/cytoscape/view/manual/internal/common/AbstractManualLayoutAction.java
core3/manual-layout-impl/trunk/src/main/java/org/cytoscape/view/manual/internal/common/AbstractManualPanel.java
core3/manual-layout-impl/trunk/src/main/java/org/cytoscape/view/manual/internal/common/GraphConverter2.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/BookmarkAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/CytoPanelAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/DeleteAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/ExitAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/PreferenceAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/PrintAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/RedoAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/UndoAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/layout/ui/SettingsAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/CytoPanelTaskFactoryTunableAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkCollectionTaskFactoryTunableAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkTaskFactoryTunableAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkViewCollectionTaskFactoryTunableAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkViewTaskFactoryTunableAction.java
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/TaskFactoryTunableAction.java
Log:
Changed the name of CytoscapeAction to AbstractCyAction
Modified:
core3/manual-layout-impl/trunk/src/main/java/org/cytoscape/view/manual/internal/common/AbstractManualLayoutAction.java
===================================================================
---
core3/manual-layout-impl/trunk/src/main/java/org/cytoscape/view/manual/internal/common/AbstractManualLayoutAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/manual-layout-impl/trunk/src/main/java/org/cytoscape/view/manual/internal/common/AbstractManualLayoutAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -37,29 +37,19 @@
package org.cytoscape.view.manual.internal.common;
-import java.awt.Dimension;
import java.awt.event.ActionEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.HashMap;
-import javax.swing.Action;
+
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
-import javax.swing.JPanel;
-import javax.swing.JSplitPane;
-import javax.swing.SwingConstants;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
import javax.swing.event.MenuEvent;
-
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.application.swing.CySwingApplication;
import org.cytoscape.application.swing.CytoPanel;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.application.swing.CytoPanelName;
import org.cytoscape.application.swing.CytoPanelState;
-import org.cytoscape.application.swing.CytoscapeAction;
import org.cytoscape.application.swing.events.CytoPanelComponentSelectedEvent;
import
org.cytoscape.application.swing.events.CytoPanelComponentSelectedListener;
import org.cytoscape.session.CyApplicationManager;
@@ -68,8 +58,9 @@
* Base class for displaying cytopanel menu items. This class primarily
* manages the Layout Menu logic and tab selection of the tools cytopanel.
*/
+...@suppresswarnings("serial")
public abstract class AbstractManualLayoutAction
- extends CytoscapeAction
+ extends AbstractCyAction
implements CytoPanelComponentSelectedListener {
static protected CytoPanel manualLayoutPanel;
Modified:
core3/manual-layout-impl/trunk/src/main/java/org/cytoscape/view/manual/internal/common/AbstractManualPanel.java
===================================================================
---
core3/manual-layout-impl/trunk/src/main/java/org/cytoscape/view/manual/internal/common/AbstractManualPanel.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/manual-layout-impl/trunk/src/main/java/org/cytoscape/view/manual/internal/common/AbstractManualPanel.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -42,6 +42,7 @@
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.application.swing.CytoPanelName;
+...@suppresswarnings("serial")
public abstract class AbstractManualPanel extends JPanel implements
CytoPanelComponent {
private final String title;
Modified:
core3/manual-layout-impl/trunk/src/main/java/org/cytoscape/view/manual/internal/common/GraphConverter2.java
===================================================================
---
core3/manual-layout-impl/trunk/src/main/java/org/cytoscape/view/manual/internal/common/GraphConverter2.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/manual-layout-impl/trunk/src/main/java/org/cytoscape/view/manual/internal/common/GraphConverter2.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -37,23 +37,19 @@
package org.cytoscape.view.manual.internal.common;
-import
org.cytoscape.view.manual.internal.layout.algorithm.MutablePolyEdgeGraphLayout;
+import java.util.List;
-import org.cytoscape.view.model.CyNetworkView;
-import org.cytoscape.view.model.View;
-import org.cytoscape.view.presentation.property.TwoDVisualLexicon;
+import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
-import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyTableEntry;
import org.cytoscape.model.CyTableUtil;
+import
org.cytoscape.view.manual.internal.layout.algorithm.MutablePolyEdgeGraphLayout;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.presentation.property.TwoDVisualLexicon;
-import java.awt.geom.Point2D;
-import java.util.Iterator;
-import java.util.List;
-
-
/**
*
*/
Copied:
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/AbstractCyAction.java
(from rev 22852,
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/CytoscapeAction.java)
===================================================================
---
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/AbstractCyAction.java
(rev 0)
+++
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/AbstractCyAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -0,0 +1,365 @@
+/*
+ File: AbstractCyAction.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 org.cytoscape.session.CyApplicationManager;
+import org.cytoscape.view.model.CyNetworkViewManager;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.view.model.CyNetworkView;
+
+import javax.swing.*;
+import javax.swing.event.MenuEvent;
+import javax.swing.event.PopupMenuEvent;
+import java.awt.event.ActionEvent;
+import java.awt.Toolkit;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * An abstract implementation of the CyAction interface. Instead of using this
+ * class directly you should (strongly) consider implementing a
+ * org.cytoscape.work.TaskFactory/org.cytoscape.work.Task pair. Doing
+ * so will allow your action to be used outside of a Swing specific
application
+ * (which the CyAction interface binds you to)!
+ */
+public abstract class AbstractCyAction extends AbstractAction implements
CyAction {
+ protected String preferredMenu = null;
+ protected String preferredButtonGroup = null;
+ protected float menuGravity = 1.0f;
+ protected float toolbarGravity = 1.0f;
+ protected boolean acceleratorSet = false;
+ protected KeyStroke acceleratorKeyStroke = null;
+ protected String name;
+ protected boolean useCheckBoxMenuItem = false;
+ protected boolean inToolBar = false;
+ protected boolean inMenuBar = true;
+ protected String enableFor = null;
+ protected CyApplicationManager applicationManager;
+
+ /**
+ * Creates a new AbstractCyAction object.
+ *
+ * @param name The name of the action.
+ * @param applicationManager The application manager providing context
for this action.
+ */
+ public AbstractCyAction(final String name, final CyApplicationManager
applicationManager) {
+ super(name);
+ this.name = name;
+ this.applicationManager = applicationManager;
+ }
+
+ /**
+ * Creates a new AbstractCyAction object.
+ *
+ * @param configProps A String-String Map of configuration metadata.
This
+ * will usually be the Map provided by the Spring service
configuration.
+ * Available configuration keys include:
+ * <ul>
+ * <li>title</li>
+ * <li>preferredMenu</li>
+ * <li>preferredButtonGroup</li>
+ * <li>iconName</li>
+ * <li>tooltip</li>
+ * <li>inToolBar</li>
+ * <li>inMenuBar</li>
+ * <li>enableFor</li>
+ * <li>accelerator</li>
+ * </ul>
+ * @param applicationManager The application manager providing context
for this action.
+ */
+ public AbstractCyAction(final Map configProps, final
CyApplicationManager applicationManager) {
+ this((String)(configProps.get("title")), applicationManager);
+
+ String prefMenu = (String)(configProps.get("preferredMenu"));
+ if ( prefMenu != null )
+ setPreferredMenu(prefMenu);
+
+ String prefButtonGroup =
(String)(configProps.get("preferredButtonGroup"));
+ if ( prefButtonGroup != null )
+ setPreferredButtonGroup(prefButtonGroup);
+
+ String iconName = (String)(configProps.get("iconName"));
+ if ( iconName != null )
+ putValue(SMALL_ICON,new
ImageIcon(getClass().getResource(iconName)));
+
+ String tooltip = (String)(configProps.get("tooltip"));
+ if ( tooltip != null )
+ putValue(SHORT_DESCRIPTION,tooltip);
+
+ String foundInToolBar = (String)(configProps.get("inToolBar"));
+ if ( foundInToolBar != null )
+ inToolBar = true;
+
+ String foundInMenuBar = (String)(configProps.get("inMenuBar"));
+ if ( foundInMenuBar != null )
+ inMenuBar = true;
+
+ enableFor = (String)(configProps.get("enableFor"));
+
+ String keyComboString = (String) configProps.get("accelerator");
+ if (keyComboString != null)
+ setAcceleratorKeyStroke(
AcceleratorParser.parse(keyComboString) );
+ }
+
+ /**
+ * Sets the name of the action.
+ * @param name The name of the action.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * {...@inheritdoc}
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * By default all CytoscapeActions wish to be included in the menu bar
+ * at the 'preferredMenuName' location is specified and the 'Tools' menu
+ * not.
+ * @return true if this CyAction should be included in menu bar.
+ */
+ public boolean isInMenuBar() {
+ return inMenuBar;
+ }
+
+ /**
+ * By default no CytoscapeActions will be included in the toolbar.
+ * @return true if this Action should be included in the toolbar.
+ */
+ public boolean isInToolBar() {
+ return inToolBar;
+ }
+
+ /**
+ * Sets the gravity used to order this action in the menu bar.
+ * @param gravity The gravity for ordering menu bar actions.
+ */
+ public void setMenuGravity(float gravity) {
+ menuGravity = gravity;
+ }
+
+ /**
+ * {...@inheritdoc}
+ */
+ public float getMenuGravity() {
+ return menuGravity;
+ }
+
+ /**
+ * Sets the gravity used to order this action in the toolbar.
+ * @param gravity The gravity for ordering toolbar actions.
+ */
+ public void setToolbarGravity(float gravity) {
+ toolbarGravity = gravity;
+ }
+
+ /**
+ * {...@inheritdoc}
+ */
+ public float getToolbarGravity() {
+ return toolbarGravity;
+ }
+
+ /**
+ * Sets the accelerator KeyStroke for this action.
+ * @param ks The KeyStroke to be used as an accelerator for this action.
+ * This parameter may be null, in which case no accelerator is defined.
+ */
+ public void setAcceleratorKeyStroke(KeyStroke ks) {
+ acceleratorKeyStroke = ks;
+ }
+
+ /**
+ * {...@inheritdoc}
+ */
+ public KeyStroke getAcceleratorKeyStroke() {
+ return acceleratorKeyStroke;
+ }
+
+ /**
+ * {...@inheritdoc}
+ */
+ public String getPreferredMenu() {
+ return preferredMenu;
+ }
+
+ /**
+ * Sets the preferredMenuString. See the {...@link #getPreferredMenu}
+ * description for formatting description.
+ * @param new_preferred The string describing the preferred menu name.
+ */
+ public void setPreferredMenu(String new_preferred) {
+ preferredMenu = new_preferred;
+ }
+
+ /**
+ * {...@inheritdoc}
+ */
+ public String getPreferredButtonGroup() {
+ return preferredButtonGroup;
+ }
+
+ /**
+ * Sets the preferred button group.
+ * @param new_preferred The preferred button group for this action.
+ */
+ public void setPreferredButtonGroup(String new_preferred) {
+ preferredButtonGroup = new_preferred;
+ }
+
+ /**
+ * {...@inheritdoc}
+ */
+ public boolean useCheckBoxMenuItem() {
+ return useCheckBoxMenuItem;
+ }
+
+ /**
+ * This method can be used at your discretion, but otherwise does
nothing.
+ * @param e The triggering event.
+ */
+ 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) {}
+
+ /**
+ * This method can be overridden by individual actions to set the state
of menu items
+ * based on whatever unique circumstances that menu option cares about.
By default it
+ * sets the state of the menu based on the "enableFor" property found
in the properties used
+ * to construct the action. The valid options for "enableFor" are
"network", "networkAndView",
+ * and "selectedNetworkObjs".
+ * @param e The triggering event.
+ */
+ public void menuSelected(MenuEvent e) { enableMenus(); }
+
+ /**
+ * This method can be overridden by individual actions to set the state
of menu items
+ * based on whatever unique circumstances that menu option cares about.
By default it
+ * sets the state of the menu based on the "enableFor" property found
in the properties used
+ * to construct the action. The valid options for "enableFor" are
"network", "networkAndView",
+ * and "selectedNetworkObjs".
+ * @param e The triggering event.
+ */
+ public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
enableMenus(); }
+
+ /**
+ * This method can be used at your discretion, but otherwise does
nothing.
+ * @param e The triggering event.
+ */
+ public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {}
+
+ /**
+ * This method can be used at your discretion, but otherwise does
nothing.
+ * @param e The triggering event.
+ */
+ public void popupMenuCanceled(PopupMenuEvent e) {}
+
+ //
+ // 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.
+ //
+
+ private void enableMenus() {
+ if ( enableFor == null || enableFor.equals("") )
+ setEnabled(true);
+ else if ( enableFor.equals("network") )
+ enableForNetwork();
+ else if ( enableFor.equals("networkAndView") )
+ enableForNetworkAndView();
+ else if ( enableFor.equals("selectedNetworkObjs") )
+ enableForSelectedNetworkObjs();
+ }
+
+ /**
+ * Enable the action if the current network exists and is not null.
+ */
+ protected void enableForNetwork() {
+ CyNetwork n = applicationManager.getCurrentNetwork();
+ if ( n == null )
+ setEnabled(false);
+ else
+ setEnabled(true);
+ }
+
+ /**
+ * Enable the action if the current network and view exist and are not
null.
+ */
+ protected void enableForNetworkAndView() {
+ CyNetworkView v = applicationManager.getCurrentNetworkView();
+ if ( v == null )
+ setEnabled(false);
+ else
+ setEnabled(true);
+ }
+
+ /**
+ * Enable the action if more than one network object is required to
execute
+ * the action.
+ */
+ protected void enableForSelectedNetworkObjs() {
+ 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;
+ }
+ }
+ for ( CyEdge edge : n.getEdgeList() ) {
+ if ( edge.getCyRow().get("selected",Boolean.class) ) {
+ setEnabled(true);
+ return;
+ }
+ }
+ setEnabled(false);
+ }
+}
Deleted:
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/CytoscapeAction.java
===================================================================
---
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/CytoscapeAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/CytoscapeAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -1,365 +0,0 @@
-/*
- File: CytoscapeAction.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 org.cytoscape.session.CyApplicationManager;
-import org.cytoscape.view.model.CyNetworkViewManager;
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.model.CyNode;
-import org.cytoscape.model.CyEdge;
-import org.cytoscape.view.model.CyNetworkView;
-
-import javax.swing.*;
-import javax.swing.event.MenuEvent;
-import javax.swing.event.PopupMenuEvent;
-import java.awt.event.ActionEvent;
-import java.awt.Toolkit;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * An abstract implementation of the CyAction interface. Instead of using this
- * class directly you should (strongly) consider implementing a
- * org.cytoscape.work.TaskFactory/org.cytoscape.work.Task pair. Doing
- * so will allow your action to be used outside of a Swing specific
application
- * (which the CyAction interface binds you to)!
- */
-public abstract class CytoscapeAction extends AbstractAction implements
CyAction {
- protected String preferredMenu = null;
- protected String preferredButtonGroup = null;
- protected float menuGravity = 1.0f;
- protected float toolbarGravity = 1.0f;
- protected boolean acceleratorSet = false;
- protected KeyStroke acceleratorKeyStroke = null;
- protected String name;
- protected boolean useCheckBoxMenuItem = false;
- protected boolean inToolBar = false;
- protected boolean inMenuBar = true;
- protected String enableFor = null;
- protected CyApplicationManager applicationManager;
-
- /**
- * Creates a new CytoscapeAction object.
- *
- * @param name The name of the action.
- * @param applicationManager The application manager providing context
for this action.
- */
- public CytoscapeAction(final String name, final CyApplicationManager
applicationManager) {
- super(name);
- this.name = name;
- this.applicationManager = applicationManager;
- }
-
- /**
- * Creates a new CytoscapeAction object.
- *
- * @param configProps A String-String Map of configuration metadata.
This
- * will usually be the Map provided by the Spring service
configuration.
- * Available configuration keys include:
- * <ul>
- * <li>title</li>
- * <li>preferredMenu</li>
- * <li>preferredButtonGroup</li>
- * <li>iconName</li>
- * <li>tooltip</li>
- * <li>inToolBar</li>
- * <li>inMenuBar</li>
- * <li>enableFor</li>
- * <li>accelerator</li>
- * </ul>
- * @param applicationManager The application manager providing context
for this action.
- */
- public CytoscapeAction(final Map configProps, final
CyApplicationManager applicationManager) {
- this((String)(configProps.get("title")), applicationManager);
-
- String prefMenu = (String)(configProps.get("preferredMenu"));
- if ( prefMenu != null )
- setPreferredMenu(prefMenu);
-
- String prefButtonGroup =
(String)(configProps.get("preferredButtonGroup"));
- if ( prefButtonGroup != null )
- setPreferredButtonGroup(prefButtonGroup);
-
- String iconName = (String)(configProps.get("iconName"));
- if ( iconName != null )
- putValue(SMALL_ICON,new
ImageIcon(getClass().getResource(iconName)));
-
- String tooltip = (String)(configProps.get("tooltip"));
- if ( tooltip != null )
- putValue(SHORT_DESCRIPTION,tooltip);
-
- String foundInToolBar = (String)(configProps.get("inToolBar"));
- if ( foundInToolBar != null )
- inToolBar = true;
-
- String foundInMenuBar = (String)(configProps.get("inMenuBar"));
- if ( foundInMenuBar != null )
- inMenuBar = true;
-
- enableFor = (String)(configProps.get("enableFor"));
-
- String keyComboString = (String) configProps.get("accelerator");
- if (keyComboString != null)
- setAcceleratorKeyStroke(
AcceleratorParser.parse(keyComboString) );
- }
-
- /**
- * Sets the name of the action.
- * @param name The name of the action.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * {...@inheritdoc}
- */
- public String getName() {
- return name;
- }
-
- /**
- * By default all CytoscapeActions wish to be included in the menu bar
- * at the 'preferredMenuName' location is specified and the 'Tools' menu
- * not.
- * @return true if this CyAction should be included in menu bar.
- */
- public boolean isInMenuBar() {
- return inMenuBar;
- }
-
- /**
- * By default no CytoscapeActions will be included in the toolbar.
- * @return true if this Action should be included in the toolbar.
- */
- public boolean isInToolBar() {
- return inToolBar;
- }
-
- /**
- * Sets the gravity used to order this action in the menu bar.
- * @param gravity The gravity for ordering menu bar actions.
- */
- public void setMenuGravity(float gravity) {
- menuGravity = gravity;
- }
-
- /**
- * {...@inheritdoc}
- */
- public float getMenuGravity() {
- return menuGravity;
- }
-
- /**
- * Sets the gravity used to order this action in the toolbar.
- * @param gravity The gravity for ordering toolbar actions.
- */
- public void setToolbarGravity(float gravity) {
- toolbarGravity = gravity;
- }
-
- /**
- * {...@inheritdoc}
- */
- public float getToolbarGravity() {
- return toolbarGravity;
- }
-
- /**
- * Sets the accelerator KeyStroke for this action.
- * @param ks The KeyStroke to be used as an accelerator for this action.
- * This parameter may be null, in which case no accelerator is defined.
- */
- public void setAcceleratorKeyStroke(KeyStroke ks) {
- acceleratorKeyStroke = ks;
- }
-
- /**
- * {...@inheritdoc}
- */
- public KeyStroke getAcceleratorKeyStroke() {
- return acceleratorKeyStroke;
- }
-
- /**
- * {...@inheritdoc}
- */
- public String getPreferredMenu() {
- return preferredMenu;
- }
-
- /**
- * Sets the preferredMenuString. See the {...@link #getPreferredMenu}
- * description for formatting description.
- * @param new_preferred The string describing the preferred menu name.
- */
- public void setPreferredMenu(String new_preferred) {
- preferredMenu = new_preferred;
- }
-
- /**
- * {...@inheritdoc}
- */
- public String getPreferredButtonGroup() {
- return preferredButtonGroup;
- }
-
- /**
- * Sets the preferred button group.
- * @param new_preferred The preferred button group for this action.
- */
- public void setPreferredButtonGroup(String new_preferred) {
- preferredButtonGroup = new_preferred;
- }
-
- /**
- * {...@inheritdoc}
- */
- public boolean useCheckBoxMenuItem() {
- return useCheckBoxMenuItem;
- }
-
- /**
- * This method can be used at your discretion, but otherwise does
nothing.
- * @param e The triggering event.
- */
- 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) {}
-
- /**
- * This method can be overridden by individual actions to set the state
of menu items
- * based on whatever unique circumstances that menu option cares about.
By default it
- * sets the state of the menu based on the "enableFor" property found
in the properties used
- * to construct the action. The valid options for "enableFor" are
"network", "networkAndView",
- * and "selectedNetworkObjs".
- * @param e The triggering event.
- */
- public void menuSelected(MenuEvent e) { enableMenus(); }
-
- /**
- * This method can be overridden by individual actions to set the state
of menu items
- * based on whatever unique circumstances that menu option cares about.
By default it
- * sets the state of the menu based on the "enableFor" property found
in the properties used
- * to construct the action. The valid options for "enableFor" are
"network", "networkAndView",
- * and "selectedNetworkObjs".
- * @param e The triggering event.
- */
- public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
enableMenus(); }
-
- /**
- * This method can be used at your discretion, but otherwise does
nothing.
- * @param e The triggering event.
- */
- public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {}
-
- /**
- * This method can be used at your discretion, but otherwise does
nothing.
- * @param e The triggering event.
- */
- public void popupMenuCanceled(PopupMenuEvent e) {}
-
- //
- // 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.
- //
-
- private void enableMenus() {
- if ( enableFor == null || enableFor.equals("") )
- setEnabled(true);
- else if ( enableFor.equals("network") )
- enableForNetwork();
- else if ( enableFor.equals("networkAndView") )
- enableForNetworkAndView();
- else if ( enableFor.equals("selectedNetworkObjs") )
- enableForSelectedNetworkObjs();
- }
-
- /**
- * Enable the action if the current network exists and is not null.
- */
- protected void enableForNetwork() {
- CyNetwork n = applicationManager.getCurrentNetwork();
- if ( n == null )
- setEnabled(false);
- else
- setEnabled(true);
- }
-
- /**
- * Enable the action if the current network and view exist and are not
null.
- */
- protected void enableForNetworkAndView() {
- CyNetworkView v = applicationManager.getCurrentNetworkView();
- if ( v == null )
- setEnabled(false);
- else
- setEnabled(true);
- }
-
- /**
- * Enable the action if more than one network object is required to
execute
- * the action.
- */
- protected void enableForSelectedNetworkObjs() {
- 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;
- }
- }
- for ( CyEdge edge : n.getEdgeList() ) {
- if ( edge.getCyRow().get("selected",Boolean.class) ) {
- setEnabled(true);
- return;
- }
- }
- setEnabled(false);
- }
-}
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/BookmarkAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/BookmarkAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/BookmarkAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -46,14 +46,14 @@
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.application.swing.CySwingApplication;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.internal.dialogs.BookmarkDialogImpl;
import org.cytoscape.internal.dialogs.BookmarkDialogFactoryImpl;
/**
*
*/
-public class BookmarkAction extends CytoscapeAction {
+public class BookmarkAction extends AbstractCyAction {
private final static long serialVersionUID = 120233986993206L;
private CySwingApplication desktop;
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/CytoPanelAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/CytoPanelAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/CytoPanelAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -36,11 +36,11 @@
import org.cytoscape.application.swing.CySwingApplication;
import org.cytoscape.application.swing.CytoPanelName;
import org.cytoscape.application.swing.CytoPanelState;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.session.CyApplicationManager;
-public class CytoPanelAction extends CytoscapeAction {
+public class CytoPanelAction extends AbstractCyAction {
private final static long serialVersionUID = 1202339869395571L;
protected static String SHOW = "Show";
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/DeleteAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/DeleteAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/DeleteAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -37,7 +37,7 @@
import javax.swing.event.MenuEvent;
import javax.swing.KeyStroke;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.model.CyTableUtil;
import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNetwork;
@@ -60,7 +60,7 @@
* @version 1.0
*
*/
-public class DeleteAction extends CytoscapeAction {
+public class DeleteAction extends AbstractCyAction {
private static final long serialVersionUID = -5769255815829787466L;
private CyRootNetworkFactory cyRootNetworkFactory;
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/ExitAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/ExitAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/ExitAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -40,7 +40,7 @@
// $Author: mes $
package org.cytoscape.internal.actions;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.application.swing.CytoscapeShutdown;
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.view.model.CyNetworkViewManager;
@@ -53,7 +53,7 @@
/**
*
*/
-public class ExitAction extends CytoscapeAction {
+public class ExitAction extends AbstractCyAction {
private final static long serialVersionUID = 1202339869460858L;
protected int returnVal;
private final CytoscapeShutdown shutdown;
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/PreferenceAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/PreferenceAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/PreferenceAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -44,7 +44,7 @@
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.application.swing.CySwingApplication;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.internal.dialogs.PreferencesDialogImpl;
import org.cytoscape.internal.dialogs.PreferencesDialogFactoryImpl;
@@ -55,7 +55,7 @@
/**
*
*/
-public class PreferenceAction extends CytoscapeAction {
+public class PreferenceAction extends AbstractCyAction {
private final static long serialVersionUID = 1202339870248574L;
/**
* Creates a new PreferenceAction object.
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/PrintAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/PrintAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/PrintAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -51,7 +51,7 @@
import javax.swing.event.MenuEvent;
import javax.swing.KeyStroke;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.view.model.CyNetworkViewManager;
import org.cytoscape.view.presentation.RenderingEngine;
@@ -60,7 +60,7 @@
/**
*
*/
-public class PrintAction extends CytoscapeAction {
+public class PrintAction extends AbstractCyAction {
private final static long serialVersionUID = 1202339870257629L;
/**
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/RedoAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/RedoAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/RedoAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -44,7 +44,7 @@
import javax.swing.undo.CannotUndoException;
import javax.swing.KeyStroke;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.work.undo.UndoSupport;
@@ -53,7 +53,7 @@
* An action that calls redo for the most recent edit in the
* undoable edit stack.
*/
-public class RedoAction extends CytoscapeAction {
+public class RedoAction extends AbstractCyAction {
private final static long serialVersionUID = 1202339875203626L;
private final UndoSupport undo;
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/UndoAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/UndoAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/actions/UndoAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -44,7 +44,7 @@
import javax.swing.event.MenuEvent;
import javax.swing.undo.CannotUndoException;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.work.undo.UndoSupport;
@@ -53,7 +53,7 @@
* An action that calls undo for the most recent edit in the
* undoable edit stack.
*/
-public class UndoAction extends CytoscapeAction {
+public class UndoAction extends AbstractCyAction {
private final static long serialVersionUID = 1202339875212525L;
private UndoSupport undo;
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/layout/ui/SettingsAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/layout/ui/SettingsAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/layout/ui/SettingsAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -31,7 +31,7 @@
import org.cytoscape.application.swing.CySwingApplication;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.view.layout.CyLayouts;
import org.cytoscape.work.swing.GUITaskManager;
@@ -40,7 +40,7 @@
import java.awt.event.ActionEvent;
-public class SettingsAction extends CytoscapeAction {
+public class SettingsAction extends AbstractCyAction {
private final static long serialVersionUID = 1202339874289357L;
private CyLayouts cyl;
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/CytoPanelTaskFactoryTunableAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/CytoPanelTaskFactoryTunableAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/CytoPanelTaskFactoryTunableAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -48,7 +48,7 @@
import org.cytoscape.application.swing.CytoPanel;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.application.swing.CytoPanelName;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.work.TaskFactory;
import org.cytoscape.work.TunableValidator;
@@ -63,7 +63,7 @@
* This class is used to provide actions for task factories that have been
annotated with tunables and therefore
* should end up wrapped in CytoPanel components.
*/
-public class CytoPanelTaskFactoryTunableAction extends CytoscapeAction {
+public class CytoPanelTaskFactoryTunableAction extends AbstractCyAction {
/**
* A listener that upon receiving the button-click event validates the
tunables and then
* creates and executes a task.
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkCollectionTaskFactoryTunableAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkCollectionTaskFactoryTunableAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkCollectionTaskFactoryTunableAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -35,7 +35,7 @@
import org.cytoscape.work.TaskFactory;
import org.cytoscape.work.TaskManager;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.task.NetworkCollectionTaskFactory;
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkTaskFactoryTunableAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkTaskFactoryTunableAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkTaskFactoryTunableAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -38,7 +38,7 @@
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskManager;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.task.NetworkTaskFactory;
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkViewCollectionTaskFactoryTunableAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkViewCollectionTaskFactoryTunableAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkViewCollectionTaskFactoryTunableAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -35,7 +35,7 @@
import org.cytoscape.work.TaskFactory;
import org.cytoscape.work.TaskManager;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.task.NetworkViewCollectionTaskFactory;
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkViewTaskFactoryTunableAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkViewTaskFactoryTunableAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/NetworkViewTaskFactoryTunableAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -37,7 +37,7 @@
import org.cytoscape.work.TaskFactory;
import org.cytoscape.work.TaskManager;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.task.NetworkViewTaskFactory;
Modified:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/TaskFactoryTunableAction.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/TaskFactoryTunableAction.java
2010-11-15 21:38:39 UTC (rev 22856)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/TaskFactoryTunableAction.java
2010-11-15 22:24:40 UTC (rev 22857)
@@ -37,14 +37,14 @@
import org.cytoscape.work.TaskFactory;
import org.cytoscape.work.TaskManager;
-import org.cytoscape.application.swing.CytoscapeAction;
+import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.session.CyApplicationManager;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
-public class TaskFactoryTunableAction<T extends TaskFactory> extends
CytoscapeAction {
+public class TaskFactoryTunableAction<T extends TaskFactory> extends
AbstractCyAction {
protected T factory;
protected TaskManager manager;
private final static Logger logger = LoggerFactory.getLogger(
TaskFactoryTunableAction.class );
--
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.