Author: mes
Date: 2010-11-10 14:33:04 -0800 (Wed, 10 Nov 2010)
New Revision: 22808

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/view/BiModalJSplitPane.java
   
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoPanelContainer.java
   
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoPanelImp.java
   
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoscapeDesktop.java
   
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoscapeMenuPopulator.java
   
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/ToolCytoPanelListener.java
   
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
Log:
updated to reflect API changes

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-10 22:32:39 UTC (rev 22807)
+++ 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/task/CytoPanelTaskFactoryTunableAction.java
 2010-11-10 22:33:04 UTC (rev 22808)
@@ -39,16 +39,21 @@
 import java.awt.event.ActionListener;
 
 import java.util.Map;
+import java.util.Properties;
 
 import javax.swing.JButton;
 import javax.swing.JFrame;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
+import javax.swing.Icon;
+import java.awt.Component;
 
 import org.cytoscape.session.CyApplicationManager;
 import org.cytoscape.work.TaskFactory;
 import org.cytoscape.work.TunableValidator;
 import org.cytoscape.work.swing.GUITaskManager;
+import org.cytoscape.service.util.CyServiceRegistrar;
+import org.cytoscape.view.CytoPanelComponent;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -98,31 +103,38 @@
        final private TaskFactory factory;
        final private GUITaskManager manager;
        final private Map serviceProps;
-       private CytoPanel cytoPanel;
+       final private CytoPanelName cytoPanelName;
+       final private CyServiceRegistrar registrar;
        final private static Logger logger = 
LoggerFactory.getLogger(CytoPanelTaskFactoryTunableAction.class);
 
        public CytoPanelTaskFactoryTunableAction(final TaskFactory factory, 
                                                 final GUITaskManager manager,
-                                                final CySwingApplication app,
                                                 final Map serviceProps, 
-                                                final CyApplicationManager 
appMgr )
+                                                final CyApplicationManager 
appMgr,
+                                                                               
         final CyServiceRegistrar registrar)
        {
                super(serviceProps, appMgr);
 
                this.factory = factory;
                this.manager = manager;
                this.serviceProps = serviceProps;
+               this.registrar = registrar;
+               this.cytoPanelName = getCytoPanelName(); 
+       }
 
-               if (serviceProps.containsKey("preferredCytoPanel")) {
-                       try {
-                               cytoPanel = 
app.getCytoPanel(CytoPanelName.valueOf(serviceProps.get("preferredCytoPanel").toString()));
-                       } catch (final Exception e) {
-                               logger.warn("in 
CytoPanelTaskFactoryTunableAction constructor: value of 
serviceProps(\"preferredCytoPanel\") is \""
-                                           + 
serviceProps.get("preferredCytoPanel").toString() + "\"");
-                               cytoPanel = app.getCytoPanel(DEFAULT_CYTOPANEL);
-                       }
-               } else
-                       this.cytoPanel = app.getCytoPanel(DEFAULT_CYTOPANEL);
+       private CytoPanelName getCytoPanelName() {
+               CytoPanelName n;
+               try {
+                       Object name = serviceProps.get("preferredCytoPanel");
+                       if ( name != null )
+                               n = CytoPanelName.valueOf(name.toString());
+                       else 
+                               n = CytoPanelName.WEST;
+               } catch (Exception e) {
+                       logger.warn("couldn't find 'preferredCytoPanel' 
property",e);
+                       n = CytoPanelName.WEST;
+               }
+               return n;
        }
 
        /**
@@ -133,7 +145,9 @@
                if (innerPanel == null)
                        return;
 
-               cytoPanel.add(getCytoPanelComponentTitle(), 
createCytoPanelComponent(innerPanel));
+               CytoPanelComponentImp imp = new 
CytoPanelComponentImp(innerPanel,
+                                                                     
getCytoPanelComponentTitle());
+               registrar.registerService(imp,CytoPanelComponent.class,new 
Properties());
        }
 
        /**
@@ -159,32 +173,41 @@
 
                        return "*No Title*";
                } catch (final ClassCastException e) {
-                       logger.warn("This should *never* happen!\n" + 
e.toString());
+                       logger.warn("This should *never* happen!",e);
                        return "*Missing Title*";
                }
        }
 
-       /**
-        *  Adds Close/Execute buttons below "innerPanel" in a new enclosing 
panel.
-        *
-        *  @return the new enclosing panel
-        */
-       private JPanel createCytoPanelComponent(final JPanel innerPanel) {
-               final JPanel outerPanel = new JPanel();
-               outerPanel.add(innerPanel);
+       private class CytoPanelComponentImp implements CytoPanelComponent {
+               private final Component innerPanel;
+               private final Component comp;
+               private final String title;
+               CytoPanelComponentImp(Component innerPanel, String title) {
+                       this.innerPanel = innerPanel;
+                       this.title = title;
+                       this.comp = createComponent();
+               }
+               public String getTitle() { return title; }
+               public CytoPanelName getCytoPanelName() { return cytoPanelName; 
}
+               public Icon getIcon() { return null; }
+               public Component getComponent() { return comp; }
+               private Component createComponent() { 
+                       final JPanel outerPanel = new JPanel();
+                       outerPanel.add(innerPanel);
 
-               final JButton executeButton = new JButton("Execute");
-               executeButton.addActionListener(new 
ExecuteButtonListener(factory, manager));
-               outerPanel.add(executeButton);
-
-               final JButton closeButton = new JButton("Close");
-               closeButton.addActionListener(new ActionListener() {
-                               public void actionPerformed(final ActionEvent 
event) {
-                                       cytoPanel.remove(outerPanel);
-                               }
-                       });
-               outerPanel.add(closeButton);
+                       final JButton executeButton = new JButton("Execute");
+                       executeButton.addActionListener(new 
ExecuteButtonListener(factory, manager));
+                       outerPanel.add(executeButton);
+       
+                       final JButton closeButton = new JButton("Close");
+                       closeButton.addActionListener(new ActionListener() {
+                                       public void actionPerformed(final 
ActionEvent event) {
+                                               
registrar.unregisterService(this,CytoPanelComponent.class);     
+                                       }
+                               });
+                       outerPanel.add(closeButton);
                
-               return outerPanel;
+                       return outerPanel;
+               }
        }
 }

Modified: 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/BiModalJSplitPane.java
===================================================================
--- 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/BiModalJSplitPane.java
 2010-11-10 22:32:39 UTC (rev 22807)
+++ 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/BiModalJSplitPane.java
 2010-11-10 22:33:04 UTC (rev 22808)
@@ -40,6 +40,7 @@
 import javax.swing.JFrame;
 import javax.swing.JSplitPane;
 
+import org.cytoscape.internal.view.CytoPanelContainer;
 import org.cytoscape.view.CytoPanel;
 import org.cytoscape.view.CytoPanelName;
 import org.cytoscape.view.CytoPanelState;

Modified: 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoPanelContainer.java
===================================================================
--- 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoPanelContainer.java
        2010-11-10 22:32:39 UTC (rev 22807)
+++ 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoPanelContainer.java
        2010-11-10 22:33:04 UTC (rev 22808)
@@ -30,8 +30,9 @@
 package org.cytoscape.internal.view;
 
 
-import java.awt.Point;
-import java.awt.Rectangle;
+import org.cytoscape.view.CytoPanel;
+import org.cytoscape.view.CytoPanelName;
+import java.awt.*;
 
 import org.cytoscape.view.CytoPanel;
 import org.cytoscape.view.CytoPanelName;

Modified: 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoPanelImp.java
===================================================================
--- 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoPanelImp.java
      2010-11-10 22:32:39 UTC (rev 22807)
+++ 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoPanelImp.java
      2010-11-10 22:33:04 UTC (rev 22808)
@@ -62,9 +62,12 @@
 import javax.swing.event.ChangeListener;
 
 import org.cytoscape.view.CytoPanel;
-import org.cytoscape.view.CytoPanelListener;
 import org.cytoscape.view.CytoPanelName;
 import org.cytoscape.view.CytoPanelState;
+import org.cytoscape.view.events.CytoPanelStateChangedEvent;
+import org.cytoscape.view.events.CytoPanelComponentSelectedEvent;
+import org.cytoscape.view.CytoPanelComponent;
+import org.cytoscape.event.CyEventHelper;
 
 
 /**
@@ -95,11 +98,6 @@
        private CytoPanelName compassDirection;
 
        /**
-        * An array of CytoPanelListeners
-        */
-       private ArrayList<CytoPanelListener> cytoPanelListenerList;
-
-       /**
         * Notification state change.
         */
        private final int NOTIFICATION_STATE_CHANGE = 0;
@@ -191,6 +189,8 @@
         */
        private static final String FILE_SEPARATOR = "/";
 
+       private final CyEventHelper cyEventHelper;
+
        /**
         * Constructor.
         *
@@ -198,7 +198,8 @@
         * @param tabPlacement      Tab placement of this CytoPanel.
         * @param cytoPanelState    The starting CytoPanel state.
         */
-       public CytoPanelImp(final CytoPanelName compassDirection, final int 
tabPlacement, final CytoPanelState cytoPanelState) {
+       public CytoPanelImp(final CytoPanelName compassDirection, final int 
tabPlacement, final CytoPanelState cytoPanelState, final CyEventHelper eh) {
+               this.cyEventHelper = eh;
                // setup our tabbed pane
                tabbedPane = new JTabbedPane(tabPlacement);
                tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
@@ -206,9 +207,6 @@
 
                this.compassDirection = compassDirection;
 
-               // init listener list
-               cytoPanelListenerList = new ArrayList<CytoPanelListener>();
-
                // init the icons
                initIcons();
 
@@ -234,79 +232,21 @@
         *
         * @return A title string
         */
-       public String getTitle() {
+       private String getTitle() {
                return compassDirection.getTitle();
        }
 
-       /**
-        * Adds a component to the CytoPanel.
-        *
-        * @param component Component reference.
-        * @return component Component reference.
-        */
-       public Component add(Component component) {
-               // add tab to JTabbedPane (component)
-               Component c = tabbedPane.add(component);
-
-               // send out a notification
-               notifyListeners(NOTIFICATION_COMPONENT_ADDED);
-
-               // outta here
-               return c;
+       public CytoPanelName getCytoPanelName() {
+               return compassDirection;
        }
 
-       /**
-        * Adds a component to the CytoPanel at specified index.
-        *
-        * @param component Component reference.
-        * @param index     Component index.
-        * @return component Component reference.
-        */
-       public Component add(Component component, int index) {
-               // add tab to JTabbedPane (component, index)
-               Component c = tabbedPane.add(component, index);
 
-               // send out a notification
+       public void add(CytoPanelComponent comp) {
+               tabbedPane.addTab(comp.getTitle(), comp.getIcon(), 
comp.getComponent());
                notifyListeners(NOTIFICATION_COMPONENT_ADDED);
-
-               // outta here
-               return c;
        }
 
        /**
-        * Adds a component to the CytoPanel with a specified title.
-        *
-        * @param title     Component title.
-        * @param component Component reference.
-        * @return component Component reference.
-        */
-       public Component add(String title, Component component) {
-               // add tab to JTabbedPane (title, component)
-               Component c = tabbedPane.add(title, component);
-
-               // send out a notification
-               notifyListeners(NOTIFICATION_COMPONENT_ADDED);
-
-               // outta here
-               return c;
-       }
-
-       /**
-        * Adds a component to the CytoPanel with specified title and icon.
-        *
-        * @param title     Component title (can be null).
-        * @param icon      Component icon (can be null).
-        * @param component Component reference.
-        */
-       public void add(String title, Icon icon, Component component) {
-               // add tab to JTabbedPane (title, icon, component)
-               tabbedPane.addTab(title, icon, component);
-
-               // send out a notification
-               notifyListeners(NOTIFICATION_COMPONENT_ADDED);
-       }
-
-       /**
         * Adds a component to the CytoPanel with specified title, icon, and 
tool tip.
         *
         * @param title     Component title (can be null).
@@ -396,6 +336,10 @@
                notifyListeners(NOTIFICATION_COMPONENT_REMOVED);
        }
 
+       public void remove(CytoPanelComponent comp) {
+               tabbedPane.remove(comp.getComponent());
+       }
+
        /**
         * Removes the component from the CytoPanel at the specified index.
         *
@@ -476,33 +420,6 @@
        }
 
        /**
-        * Adds a CytoPanel listener.
-        *
-        * @param cytoPanelListener Reference to a CytoPanelListener.
-        */
-       public void addCytoPanelListener(CytoPanelListener cytoPanelListener) {
-               // nothing to do if listener is already in our list
-               if (cytoPanelListenerList.contains(cytoPanelListener)) {
-                       return;
-               }
-
-               // add listener to our list
-               cytoPanelListenerList.add(cytoPanelListener);
-       }
-
-       /**
-        * Removes a CytoPanel listener.
-        *
-        * @param cytoPanelListener Reference to a CytoPanelListener.
-        */
-       public void removeCytoPanelListener(CytoPanelListener 
cytoPanelListener) {
-               // remove listener if they exist in our list
-               if (cytoPanelListenerList.contains(cytoPanelListener)) {
-                       
cytoPanelListenerList.remove(cytoPanelListenerList.indexOf(cytoPanelListener));
-               }
-       }
-
-       /**
         * Our implementation of the ChangeListener interface,
         * to determine when new tab has been selected
         */
@@ -833,35 +750,32 @@
         * @param notificationType What type of notification to perform.
         */
        private void notifyListeners(int notificationType) {
-               // interate through all our listeners
-               for (int lc = 0; lc < cytoPanelListenerList.size(); lc++) {
-                       CytoPanelListener cytoPanelListener = 
(CytoPanelListener) cytoPanelListenerList.get(lc);
 
                        // determine what event to fire
                        switch (notificationType) {
                                case NOTIFICATION_STATE_CHANGE:
-                                       
cytoPanelListener.onStateChange(cytoPanelState);
+                                       cyEventHelper.fireSynchronousEvent(new 
CytoPanelStateChangedEvent(this,this,cytoPanelState));
 
                                        break;
 
                                case NOTIFICATION_COMPONENT_SELECTED:
 
                                        int selectedIndex = 
tabbedPane.getSelectedIndex();
-                                       
cytoPanelListener.onComponentSelected(selectedIndex);
+                                       cyEventHelper.fireSynchronousEvent(new 
CytoPanelComponentSelectedEvent(this,this,selectedIndex));
+                                       
//cytoPanelListener.onComponentSelected(selectedIndex);
 
                                        break;
 
                                case NOTIFICATION_COMPONENT_ADDED:
-                                       
cytoPanelListener.onComponentAdded(getCytoPanelComponentCount());
+                                       
//cytoPanelListener.onComponentAdded(getCytoPanelComponentCount());
 
                                        break;
 
                                case NOTIFICATION_COMPONENT_REMOVED:
-                                       
cytoPanelListener.onComponentRemoved(getCytoPanelComponentCount());
+                                       
//cytoPanelListener.onComponentRemoved(getCytoPanelComponentCount());
 
                                        break;
                        }
-               }
        }
 
        /**

Modified: 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoscapeDesktop.java
===================================================================
--- 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoscapeDesktop.java
  2010-11-10 22:32:39 UTC (rev 22807)
+++ 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoscapeDesktop.java
  2010-11-10 22:33:04 UTC (rev 22808)
@@ -34,7 +34,11 @@
 import org.cytoscape.view.CytoPanel;
 import org.cytoscape.view.CytoPanelName;
 import org.cytoscape.view.CytoPanelState;
+import org.cytoscape.view.CytoPanelComponent;
+import org.cytoscape.view.events.CytoPanelStateChangedListener;
 import org.cytoscape.view.CyAction;
+import org.cytoscape.event.CyEventHelper;
+import org.cytoscape.service.util.CyServiceRegistrar;
 
 import java.awt.BorderLayout;
 import java.awt.Component;
@@ -53,6 +57,7 @@
 import javax.swing.JTabbedPane;
 import javax.swing.WindowConstants;
 import java.util.Dictionary;
+import java.util.Properties;
 
 
 /**
@@ -101,17 +106,21 @@
        // Status Bar TODO: Move this to log-swing to avoid cyclic dependency.
        private JPanel main_panel;
        private final CytoscapeShutdown shutdown; 
+       private final CyEventHelper cyEventHelper;
+       private final CyServiceRegistrar registrar;
 
        /**
         * Creates a new CytoscapeDesktop object.
         */
-       public CytoscapeDesktop(CytoscapeMenus cyMenus, NetworkViewManager 
networkViewManager, NetworkPanel networkPanel, CytoscapeShutdown shut) {
+       public CytoscapeDesktop(CytoscapeMenus cyMenus, NetworkViewManager 
networkViewManager, NetworkPanel networkPanel, CytoscapeShutdown shut, 
CyEventHelper eh, CyServiceRegistrar registrar) {
                super("Cytoscape Desktop (New Session)");
 
                this.cyMenus = cyMenus;
                this.networkViewManager = networkViewManager;
                this.networkPanel = networkPanel;
                this.shutdown = shut;
+               this.cyEventHelper = eh;
+               this.registrar = registrar;
 
                
setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource(SMALL_ICON)));
 
@@ -131,7 +140,6 @@
                setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
 
                addWindowListener(new WindowAdapter() {
-                       // TODO should use shutdown handler!!!
                                public void windowClosing(WindowEvent we) {
                                        shutdown.exit(0);
                                }
@@ -174,7 +182,7 @@
         */
        private BiModalJSplitPane createTopRightPane(NetworkViewManager 
networkViewManager) {
                // create cytopanel with tabs along the top
-               cytoPanelEast = new CytoPanelImp(CytoPanelName.EAST, 
JTabbedPane.TOP, CytoPanelState.HIDE);
+               cytoPanelEast = new CytoPanelImp(CytoPanelName.EAST, 
JTabbedPane.TOP, CytoPanelState.HIDE, cyEventHelper);
 
                // determine proper network view manager component
                Component networkViewComp = (Component) 
networkViewManager.getDesktopPane();
@@ -204,7 +212,7 @@
        private BiModalJSplitPane createRightPane(BiModalJSplitPane 
topRightPane) {
                // create cytopanel with tabs along the bottom
                cytoPanelSouth = new CytoPanelImp(CytoPanelName.SOUTH, 
JTabbedPane.BOTTOM,
-                                                 CytoPanelState.HIDE);
+                                                 CytoPanelState.HIDE, 
cyEventHelper);
 
                // create the split pane - hidden by default
                BiModalJSplitPane splitPane = new BiModalJSplitPane(this, 
JSplitPane.VERTICAL_SPLIT,
@@ -228,7 +236,7 @@
                // create cytopanel with tabs along the top for manual layout
                cytoPanelSouthWest = new CytoPanelImp(CytoPanelName.SOUTH_WEST,
                                                      JTabbedPane.TOP,
-                                                     CytoPanelState.HIDE);
+                                                     CytoPanelState.HIDE, 
cyEventHelper);
 
         final BiModalJSplitPane split = new BiModalJSplitPane(this, 
JSplitPane.VERTICAL_SPLIT,
                                       BiModalJSplitPane.MODE_HIDE_SPLIT, new 
JPanel(),
@@ -241,7 +249,9 @@
 
         split.setDividerSize(DEVIDER_SIZE);
 
-               new ToolCytoPanelListener( split, (CytoPanelImp)cytoPanelWest, 
cytoPanelSouthWest );
+               ToolCytoPanelListener t = new ToolCytoPanelListener( split, 
cytoPanelWest, 
+                                                                    
cytoPanelSouthWest );
+               
registrar.registerService(t,CytoPanelStateChangedListener.class,new 
Properties());
        }
 
        /**
@@ -256,7 +266,7 @@
        private BiModalJSplitPane createMasterPane(NetworkPanel networkPanel,
                                                     BiModalJSplitPane 
rightPane) {
                // create cytopanel with tabs along the top
-               cytoPanelWest = new CytoPanelImp(CytoPanelName.WEST, 
JTabbedPane.TOP, CytoPanelState.DOCK);
+               cytoPanelWest = new CytoPanelImp(CytoPanelName.WEST, 
JTabbedPane.TOP, CytoPanelState.DOCK, cyEventHelper);
 
                // add the network panel to our tab
                String tab1Name = new String("Network");
@@ -314,20 +324,34 @@
        }
 
        public CytoPanel getCytoPanel(final CytoPanelName compassDirection) {
+               return getCytoPanelInternal(compassDirection);
+       }
+
+       private CytoPanelImp getCytoPanelInternal(final CytoPanelName 
compassDirection) {
                // return appropriate cytoPanel based on compass direction
                switch (compassDirection) {
                case SOUTH:
-                       return (CytoPanel)cytoPanelSouth;
+                       return cytoPanelSouth;
                case EAST:
-                       return (CytoPanel) cytoPanelEast;
+                       return cytoPanelEast;
                case WEST:
-                       return (CytoPanel) cytoPanelWest;
+                       return cytoPanelWest;
                case SOUTH_WEST:
-                       return (CytoPanel) cytoPanelSouthWest;
+                       return cytoPanelSouthWest;
                }
 
                // houston we have a problem
                throw new IllegalArgumentException("Illegal Argument:  " + 
compassDirection
                                                   + ".  Must be one of:  
{SOUTH,EAST,WEST,SOUTH_WEST}.");
        }
+
+       public void addCytoPanelComponent(CytoPanelComponent cp, Dictionary 
props) {
+               CytoPanelImp impl = getCytoPanelInternal(cp.getCytoPanelName());
+               impl.add(cp);
+       }
+
+       public void removeCytoPanelComponent(CytoPanelComponent cp, Dictionary 
props) {
+               CytoPanelImp impl = getCytoPanelInternal(cp.getCytoPanelName());
+               impl.remove(cp);
+       }
 }

Modified: 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoscapeMenuPopulator.java
===================================================================
--- 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoscapeMenuPopulator.java
    2010-11-10 22:32:39 UTC (rev 22807)
+++ 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/CytoscapeMenuPopulator.java
    2010-11-10 22:33:04 UTC (rev 22808)
@@ -54,6 +54,7 @@
 import org.cytoscape.task.NetworkViewTaskFactory;
 import org.cytoscape.task.NetworkCollectionTaskFactory;
 import org.cytoscape.task.NetworkViewCollectionTaskFactory;
+import org.cytoscape.service.util.CyServiceRegistrar;
 
 
 /**
@@ -68,6 +69,7 @@
        final private CySwingApplication app;
        final private GUITaskManager taskManager;
        final private CyApplicationManager appManager;
+       final private CyServiceRegistrar registrar;
 
        final private Map<TaskFactory, CyAction> taskMap;
 
@@ -77,18 +79,19 @@
         * but won't fill them with menu items and associated action listeners.
         */
        public CytoscapeMenuPopulator(final CySwingApplication app, final 
GUITaskManager taskManager,
-                                     final CyApplicationManager appManager)
+                                     final CyApplicationManager appManager, 
final CyServiceRegistrar registrar)
        {
                this.app = app;
                this.taskManager = taskManager;
                this.appManager = appManager;
+               this.registrar = registrar;
 
                taskMap = new HashMap<TaskFactory,CyAction>();
        }
 
        public void addTaskFactory(TaskFactory factory, Map props) {
                if (taskManager.hasTunables(factory))
-                       addFactory(new 
CytoPanelTaskFactoryTunableAction(factory, taskManager, app, props, 
appManager), factory, props);
+                       addFactory(new 
CytoPanelTaskFactoryTunableAction(factory, taskManager, props, appManager, 
registrar), factory, props);
                else
                        addFactory(new 
TaskFactoryTunableAction<TaskFactory>(taskManager, factory, props, appManager), 
factory, props);
        }

Modified: 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/ToolCytoPanelListener.java
===================================================================
--- 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/ToolCytoPanelListener.java
     2010-11-10 22:32:39 UTC (rev 22807)
+++ 
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/view/ToolCytoPanelListener.java
     2010-11-10 22:33:04 UTC (rev 22808)
@@ -36,7 +36,8 @@
 
 package org.cytoscape.internal.view;
 
-import org.cytoscape.view.CytoPanelListener;
+import org.cytoscape.view.events.CytoPanelStateChangedListener;
+import org.cytoscape.view.events.CytoPanelStateChangedEvent;
 import org.cytoscape.view.CytoPanelState;
 import org.cytoscape.view.CytoPanel;
 
@@ -49,23 +50,25 @@
  * but because tools panel is within another cytopanel, we have to handle 
things
  * separately.
  */
-class ToolCytoPanelListener implements CytoPanelListener {
+public class ToolCytoPanelListener implements CytoPanelStateChangedListener {
 
        BiModalJSplitPane split;
        CytoPanel southWest;
        CytoPanelImp west;
        
-       ToolCytoPanelListener(BiModalJSplitPane split, CytoPanelImp west, 
CytoPanel southWest) {
+       public ToolCytoPanelListener(BiModalJSplitPane split, CytoPanelImp 
west, CytoPanel southWest) {
                this.split = split;
                this.west = west;
                this.southWest = southWest;
-
-               southWest.addCytoPanelListener(this);
        }
 
 
-    public void onStateChange(CytoPanelState newState) {
+    public void handleEvent(CytoPanelStateChangedEvent e) {
+               if ( e.getCytoPanel() != southWest )
+                       return;
 
+               CytoPanelState newState = e.getNewState();
+
                if (newState == CytoPanelState.DOCK) 
                        west.addComponentToSouth(split);
                else 
@@ -74,8 +77,4 @@
 
                west.validate();
        }
-
-       public void onComponentSelected(int componentIndex) {}
-       public void onComponentAdded(int count) {}
-       public void onComponentRemoved(int count) {}
 }

Modified: 
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
       2010-11-10 22:32:39 UTC (rev 22807)
+++ 
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
       2010-11-10 22:33:04 UTC (rev 22808)
@@ -71,7 +71,10 @@
        <osgi:reference id="guiTaskManagerServiceRef" 
interface="org.cytoscape.work.swing.GUITaskManager">
        </osgi:reference>
 
+       <osgi:reference id="cyServiceRegistrarServiceRef" 
interface="org.cytoscape.service.util.CyServiceRegistrar">
+       </osgi:reference>
 
+
        <!-- define services that application provides -->
 
        <!-- <osgi:service id="proxyHandlerService" ref="proxyHandler"> -->
@@ -124,6 +127,12 @@
                        ref="cytoscapeDesktop" />
        </osgi:set>
 
+       <osgi:set id="cytoPanelComponentSet" 
interface="org.cytoscape.view.CytoPanelComponent"
+               cardinality="0..N">
+               <osgi:listener bind-method="addCytoPanelComponent" 
unbind-method="removeCytoPanelComponent"
+                       ref="cytoscapeDesktop" />
+       </osgi:set>
+
        <!-- task factories for CyMenuPopulator -->
        <osgi:set id="taskFactorySet" interface="org.cytoscape.work.TaskFactory"
                cardinality="0..N" >

Modified: 
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
--- 
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
    2010-11-10 22:32:39 UTC (rev 22807)
+++ 
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
    2010-11-10 22:33:04 UTC (rev 22808)
@@ -92,6 +92,8 @@
                <constructor-arg ref="networkViewManager" />
                <constructor-arg ref="networkPanel" />
                <constructor-arg ref="cytoscapeShutdown" />
+               <constructor-arg ref="cyEventHelperServiceRef" />
+               <constructor-arg ref="cyServiceRegistrarServiceRef" />
        </bean>
 
        <!-- session support -->
@@ -163,6 +165,7 @@
                <constructor-arg ref="cytoscapeDesktop" />
                <constructor-arg ref="guiTaskManagerServiceRef" />
                <constructor-arg ref="cyApplicationManagerServiceRef" />
+               <constructor-arg ref="cyServiceRegistrarServiceRef" />
        </bean>
 
        <bean id="settingsAction" 
class="org.cytoscape.internal.layout.ui.SettingsAction">

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