Author: mes
Date: 2010-11-05 17:58:18 -0700 (Fri, 05 Nov 2010)
New Revision: 22746

Removed:
   
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyMenuBar.java
   
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyMenus.java
   
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyToolBar.java
Modified:
   
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyAction.java
   
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CySwingApplication.java
   
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CytoscapeAction.java
Log:
cleaned up menu and toolbar world

Modified: 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyAction.java
===================================================================
--- 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyAction.java
    2010-11-06 00:48:08 UTC (rev 22745)
+++ 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyAction.java
    2010-11-06 00:58:18 UTC (rev 22746)
@@ -45,39 +45,75 @@
 import java.util.List;
 
 /**
- * This is a temporary interface that captures everything
- * in CytoscapeAction so that CytoscapeActions can be registered
- * as Services. 
+ * An interface that describes how an action should be placed within 
+ * the menus and/or toolbars of the Swing application.
  */
 public interface CyAction extends Action, MenuListener, PopupMenuListener {
 
-        void setName(String name);
-        String getName();
+       /**
+        * Returns the name of the action.
+        * @return the name of the action.
+        */
+       String getName();
 
-        boolean isInMenuBar();
+       /**
+        * Returns whether the action should be in the menu bar.
+        * @return whether the action should be in the menu bar.
+        */
+       boolean isInMenuBar();
 
-        boolean isInToolBar();
+       /**
+        * Returns whether the action should be in the tool bar.
+        * @return whether the action should be in the tool bar.
+        */
+       boolean isInToolBar();
 
-        void setPreferredIndex(int index);
-        Integer getPrefferedIndex();
+       /**
+        * Returns the gravity used to place the menu item for this action.
+        * @return The gravity used to place the menu item for this action.
+        */
+       float getMenuGravity();
 
-        void setAcceleratorCombo(int key_code, int key_mods);
-        boolean isAccelerated();
+       /**
+        * Returns the gravity used to place this action in the toolbar.
+        * @return The gravity used to place this action in the toolbar.
+        */
+       float getToolbarGravity();
 
-        int getKeyCode();
+       /**
+        * Returns whether or not this action is accelerated.
+        * @return Whether or not this action is accelerated.
+        */
+       boolean isAccelerated();
 
-        int getKeyModifiers();
+       /**
+        * Returns the key code used to identify this action.
+        * @return the key code used to identify this action.
+        */
+       int getKeyCode();
 
-        String getPreferredMenu();
-        void setPreferredMenu(String new_preferred);
+       /**
+        * Returns the key modifiers used to identify this action.
+        * @return the key modifiers used to identify this action.
+        */
+       int getKeyModifiers();
 
-        /**
-         * Buttons will be grouped according to name.  Buttons are added 
-         * sequentially to groups as the service is registered. Groups are
-         * ordered lexicographically within the toolbar.
-         */
-        String getPreferredButtonGroup();
-        void setPreferredButtonGroup(String new_preferred);
+       /** 
+        * Returns the string identifying the preferred menu.
+        * @return the string identifying the preferred menu.
+        */
+       String getPreferredMenu();
 
-        boolean useCheckBoxMenuItem();
+       /**
+        * Buttons will be grouped according to name and according to gravity
+        * within the group.  
+        * @return The name identifying the button group.
+        */
+       String getPreferredButtonGroup();
+
+       /** 
+        * Returns whether or not a checkbox menu item should be used.
+        * @return whether or not a checkbox menu item should be used.
+        */
+       boolean useCheckBoxMenuItem();
 }

Deleted: 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyMenuBar.java
===================================================================
--- 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyMenuBar.java
   2010-11-06 00:48:08 UTC (rev 22745)
+++ 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyMenuBar.java
   2010-11-06 00:58:18 UTC (rev 22746)
@@ -1,63 +0,0 @@
-/*
-  File: CyMenuBar.java
-
-  Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
-
-  The Cytoscape Consortium is:
-  - Institute for Systems Biology
-  - University of California San Diego
-  - Memorial Sloan-Kettering Cancer Center
-  - Institut Pasteur
-  - Agilent Technologies
-
-  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.view;
-
-
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-
-
-// TODO clean up this interface - too many redundant interfaces
-// Maybe this should just exist as hidden implementation?
-/**
- * An interface that captures much of JMenuBar.
- */
-public interface CyMenuBar { 
-
-       public void setDefaultMenuSpecifier(String menu_name);
-       public String getDefaultMenuSpecifier();
-       public boolean addAction(CyAction action);
-       public boolean addAction(CyAction action, int index);
-       public boolean removeAction(CyAction action);
-       public JMenu getMenu(String menu_string);
-       public JMenu getMenu(String menu_string, int parentPosition);
-       public boolean equals(Object other_object);
-       public String getIdentifier();
-       public void setIdentifier(String new_identifier);
-       public String toString();
-       public JMenuBar getJMenuBar();
-}

Deleted: 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyMenus.java
===================================================================
--- 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyMenus.java 
    2010-11-06 00:48:08 UTC (rev 22745)
+++ 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyMenus.java 
    2010-11-06 00:58:18 UTC (rev 22746)
@@ -1,64 +0,0 @@
-/*
- File: CyMenus.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.view;
-
-
-import javax.swing.JMenu;
-import java.util.Map;
-import org.cytoscape.work.TaskFactory;
-
-
-// TODO clean up the menus offered - these should match what's implemented
-/**
- * A simplified API that provides access to Cytoscape's menu and toolbar 
system.
- */
-public interface CyMenus { 
-
-       public CyMenuBar getMenuBar();
-       public CyToolBar getToolBar();
-
-       public JMenu getFileMenu();
-       public JMenu getLoadSubMenu();
-       public JMenu getSaveSubMenu();
-       public JMenu getEditMenu();
-       public JMenu getViewMenu();
-       public JMenu getSelectMenu();
-       public JMenu getLayoutMenu();
-       public JMenu getVizMenu();
-       public JMenu getHelpMenu();
-       public JMenu getOperationsMenu();
-       public JMenu getNewNetworkMenu();
-
-       public void addAction(CyAction action, Map props);
-       public void removeAction(CyAction action, Map props);
-
-       public void addAction(CyAction action);
-       public void addAction(CyAction action, int index);
-}

Modified: 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CySwingApplication.java
===================================================================
--- 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CySwingApplication.java
  2010-11-06 00:48:08 UTC (rev 22745)
+++ 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CySwingApplication.java
  2010-11-06 00:58:18 UTC (rev 22746)
@@ -38,54 +38,59 @@
 
 
 import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JToolBar;
 
 
+/**
+ * This interface provides basic access to the Swing objects that
+ * constitute this application.
+ */
 public interface CySwingApplication {
-       /**
-        *
-        */
-       String NETWORK_VIEWS_SELECTED = "NETWORK_VIEWS_SELECTED";
 
-       /**
-        *
+       /** 
+        * Returns the JMenu for the specified name and null if no 
+        * menu exists for the name.
+        * @return The JMenu for the specified name and null if no 
+        * menu exists for the name.
         */
-       String NETWORK_VIEW_FOCUSED = "NETWORK_VIEW_FOCUSED";
+       public JMenu getJMenu(String menuName);
 
        /**
-        *
+        * Returns the JMenuBar object for the application. 
+        * @return The JMenuBar object for the application. 
         */
-       String NETWORK_VIEW_FOCUS = "NETWORK_VIEW_FOCUS";
+       public JMenuBar getJMenuBar();
 
        /**
-        *
+        * Returns the JToolBar object for the application. 
+        * @return The JToolBar object for the application. 
         */
-       String NETWORK_VIEW_CREATED = "NETWORK_VIEW_CREATED";
+       public JToolBar getJToolBar();
 
        /**
-        *
+        * Add a CyAction to application.
+        * @param action The CyAction to be added to the application.
         */
-       String NETWORK_VIEW_DESTROYED = "NETWORK_VIEW_DESTROYED";
+       void addAction(CyAction action);
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * Remove the specified CyAction from the application.
+        * @param action The CyAction to be removed from the application.
         */
-       CyMenus getCyMenus();
+       void removeAction(CyAction action);
 
        /**
-        *  DOCUMENT ME!
-        *
+        * Returns the appropriate CytoPanel for the specified compass 
direction.
         * @param compassDirection  one of the enum values of CytoPanelName
-        *
         * @return the CytoPanel corresponding to "compassDirection"
         */
        CytoPanel getCytoPanel(CytoPanelName compassDirection);
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * Returns the JFrame that contains the application. 
+        * @return the JFrame that contains the application. 
         */
        JFrame getJFrame();
 }

Deleted: 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyToolBar.java
===================================================================
--- 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyToolBar.java
   2010-11-06 00:48:08 UTC (rev 22745)
+++ 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CyToolBar.java
   2010-11-06 00:58:18 UTC (rev 22746)
@@ -1,48 +0,0 @@
-/*
-  File: CyToolBar.java
-
-  Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
-
-  The Cytoscape Consortium is:
-  - Institute for Systems Biology
-  - University of California San Diego
-  - Memorial Sloan-Kettering Cancer Center
-  - Institut Pasteur
-  - Agilent Technologies
-
-  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.view;
-
-import javax.swing.JToolBar;
-
-/**
- *
- */
-public interface CyToolBar { 
-       public boolean addAction(CyAction action);
-       public boolean removeAction(CyAction action);
-       public JToolBar getJToolBar();
-}

Modified: 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CytoscapeAction.java
===================================================================
--- 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CytoscapeAction.java
     2010-11-06 00:48:08 UTC (rev 22745)
+++ 
core3/swing-application-api/trunk/src/main/java/org/cytoscape/view/CytoscapeAction.java
     2010-11-06 00:58:18 UTC (rev 22746)
@@ -57,30 +57,28 @@
 public abstract class CytoscapeAction extends AbstractAction implements 
CyAction {
        protected String preferredMenu = null;
        protected String preferredButtonGroup = null;
-       protected Integer menuIndex = Integer.valueOf(-1);
+       protected float menuGravity = 1.0f; 
+       protected float toolbarGravity = 1.0f; 
        protected boolean acceleratorSet = false;
        protected int keyModifiers;
        protected int keyCode;
        protected String consoleName;
        protected boolean useCheckBoxMenuItem = false;
-       protected CyApplicationManager applicationManager;
-       protected CyNetworkViewManager networkViewManager;
        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 netmgr The NetworkManger providing context for this action.
+        * @param applicationManager The application manager providing context 
for this action.
         */
-       public CytoscapeAction(String name, final CyApplicationManager 
applicationManager,
-                              final CyNetworkViewManager networkViewManager)
-       {
+       public CytoscapeAction(final String name, final CyApplicationManager 
applicationManager) {
                super(name);
                this.consoleName = name;
                this.applicationManager = applicationManager;
-               this.networkViewManager = networkViewManager;
 
                consoleName = consoleName.replaceAll(":. \'", "");
        }
@@ -90,12 +88,10 @@
         *
         * @param configProps A String-String Map of configuration metadata. 
This
         * will usually be the Map provided by the Spring service configuration.
-        * @param netmgr The NetworkManger providing context for this action.
+        * @param applicationManager The application manager providing context 
for this action.
         */
-       public CytoscapeAction(Map configProps, final CyApplicationManager 
applicationManager,
-                               final CyNetworkViewManager networkViewManager)
-       {
-               this((String)(configProps.get("title")), applicationManager, 
networkViewManager);
+       public CytoscapeAction(final Map configProps, final 
CyApplicationManager applicationManager) {
+               this((String)(configProps.get("title")), applicationManager);
 
                String prefMenu = (String)(configProps.get("preferredMenu"));
                if ( prefMenu != null )
@@ -135,43 +131,20 @@
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param name DOCUMENT ME!
+        * @inheritdoc 
         */
        public void setName(String name) {
                this.consoleName = name;
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * @inheritdoc 
         */
        public String getName() {
                return consoleName;
        }
 
-       // implements AbstractAction
        /**
-        *  DOCUMENT ME!
-        *
-        * @param e DOCUMENT ME!
-        */
-       public abstract void actionPerformed(ActionEvent e);
-
-       /**
-        * The default clone() implementation delegates to the create() method 
of
-        * DataTypeUtilities.getDataTypeFactory( this.getClass() ). Override if 
your
-        * CytoscapeAction maintains state that must be transmitted to the 
clone.
-        */
-
-       // implements Cloneable
-       public Object clone() {
-               return this;
-       } // clone()
-
-       /**
         * By default all CytoscapeActions wish to be included in 
CommunityMenuBars,
         * but you may override if you wish.
         *
@@ -180,7 +153,7 @@
         * @beaninfo (ri)
         */
        public boolean isInMenuBar() {
-               return true;
+               return inMenuBar;
        }
 
        /**
@@ -196,29 +169,36 @@
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param index DOCUMENT ME!
+        * @inheritdoc 
         */
-       public void setPreferredIndex(int index) {
-               menuIndex = Integer.valueOf(index);
+       public void setMenuGravity(float gravity) {
+               menuGravity = gravity;
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * @inheritdoc 
         */
-       public Integer getPrefferedIndex() {
-               return menuIndex;
+       public float getMenuGravity() {
+               return menuGravity;
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param key_code DOCUMENT ME!
-        * @param key_mods DOCUMENT ME!
+        * @inheritdoc 
         */
+       public void setToolbarGravity(float gravity) {
+               toolbarGravity = gravity;
+       }
+
+       /**
+        * @inheritdoc 
+        */
+       public float getToolbarGravity() {
+               return toolbarGravity;
+       }
+
+       /**
+        * @inheritdoc 
+        */
        public void setAcceleratorCombo(int key_code, int key_mods) {
                acceleratorSet = true;
                keyCode = key_code;
@@ -226,27 +206,21 @@
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * @inheritdoc 
         */
        public boolean isAccelerated() {
                return acceleratorSet;
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * @inheritdoc 
         */
        public int getKeyCode() {
                return keyCode;
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * @inheritdoc 
         */
        public int getKeyModifiers() {
                return keyModifiers;
@@ -267,7 +241,7 @@
        }
 
        /**
-        * @beaninfo (rwb)
+        * @inheritdoc 
         */
        public void setPreferredMenu(String new_preferred) {
                preferredMenu = new_preferred;
@@ -288,7 +262,7 @@
        }
 
        /**
-        * @beaninfo (rwb)
+        * @inheritdoc 
         */
        public void setPreferredButtonGroup(String new_preferred) {
                preferredButtonGroup = new_preferred;
@@ -384,19 +358,17 @@
         * Enable the action if the current network and view exist and are not 
null.
         */
        protected void enableForNetworkAndView() {
-               CyNetwork n = applicationManager.getCurrentNetwork();
-               if ( n == null ) {
-                       setEnabled(false);
-                       return;
-               }
-               
-               CyNetworkView v = 
networkViewManager.getNetworkView(n.getSUID());
+               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();
 

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