You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2009/06/26 18:20:35 UTC

svn commit: r788755 - in /qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui: actions/ views/ views/type/

Author: robbie
Date: Fri Jun 26 16:20:34 2009
New Revision: 788755

URL: http://svn.apache.org/viewvc?rev=788755&view=rev
Log:
QPID-1942: initial Queue/Exchange/Connection selection work.

Only remove items from the navigation tree config file if removal initiated by the user, not if caused by mbean unregistration. Notify MBeanView explicitly when mbeans are unregistered because new Queue etc selection allows opening Queues etc without adding to the navigation tree, so the previous tree selectionListener is no longer sufficient on its own. Add new refresh method to MBeanView to decouple it from the display of new mbeans based on tree selection, to allow viewing and refreshing mbeans not in the navigation tree.


Added:
    qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/
    qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ConnectionTypeTabControl.java   (contents, props changed)
      - copied, changed from r788746, qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ConnectionTypeTabControl.java
    qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ExchangeTypeTabControl.java   (contents, props changed)
      - copied, changed from r788746, qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ExchangeTypeTabControl.java
    qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/MBeanTypeTabControl.java   (contents, props changed)
      - copied, changed from r788746, qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java
    qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/QueueTypeTabControl.java   (contents, props changed)
      - copied, changed from r788746, qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java
Removed:
    qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ConnectionTypeTabControl.java
    qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ExchangeTypeTabControl.java
    qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java
    qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java
Modified:
    qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java
    qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTabFolderFactory.java
    qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java
    qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java

Modified: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java
URL: http://svn.apache.org/viewvc/qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java?rev=788755&r1=788754&r2=788755&view=diff
==============================================================================
--- qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java (original)
+++ qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java Fri Jun 26 16:20:34 2009
@@ -42,7 +42,7 @@
             MBeanView mbeanview = (MBeanView)_window.getActivePage().findView(MBeanView.ID);
             try
             {
-                mbeanview.refreshMBeanView();
+                mbeanview.refresh();
             }
             catch (Exception ex)
             {

Modified: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTabFolderFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTabFolderFactory.java?rev=788755&r1=788754&r2=788755&view=diff
==============================================================================
--- qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTabFolderFactory.java (original)
+++ qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTabFolderFactory.java Fri Jun 26 16:20:34 2009
@@ -21,7 +21,10 @@
 package org.apache.qpid.management.ui.views;
 
 import static org.apache.qpid.management.ui.Constants.ATTRIBUTES;
+import static org.apache.qpid.management.ui.Constants.CONNECTION;
+import static org.apache.qpid.management.ui.Constants.EXCHANGE;
 import static org.apache.qpid.management.ui.Constants.NOTIFICATIONS;
+import static org.apache.qpid.management.ui.Constants.QUEUE;
 
 import java.util.EnumSet;
 import java.util.HashMap;
@@ -37,6 +40,9 @@
 import org.apache.qpid.management.ui.model.OperationData;
 import org.apache.qpid.management.ui.model.OperationDataModel;
 import org.apache.qpid.management.ui.views.queue.QueueOperationsTabControl;
+import org.apache.qpid.management.ui.views.type.ConnectionTypeTabControl;
+import org.apache.qpid.management.ui.views.type.ExchangeTypeTabControl;
+import org.apache.qpid.management.ui.views.type.QueueTypeTabControl;
 import org.apache.qpid.management.ui.views.users.UserManagementTabControl;
 import org.apache.qpid.management.ui.views.logging.ConfigurationFileTabControl;
 import org.apache.qpid.management.ui.views.logging.RuntimeTabControl;
@@ -205,6 +211,55 @@
         tab.setControl(controller.getControl());
     }
     
+    /**
+     * Creates TabFolder and tabs for each mbeantype (eg Connection, Queue, Exchange)
+     */
+    public static TabFolder generateMBeanTypeTabFolder(final Composite parent)
+    {
+        TabFolder tabFolder = new TabFolder(parent, SWT.NONE);
+        FormData layoutData = new FormData();
+        layoutData.left = new FormAttachment(0);
+        layoutData.top = new FormAttachment(0);
+        layoutData.right = new FormAttachment(100);
+        layoutData.bottom = new FormAttachment(100);
+        tabFolder.setLayoutData(layoutData);
+
+        TabItem tab;
+        TabControl controller;
+              
+        tab = new TabItem(tabFolder, SWT.NONE);
+        tab.setText(CONNECTION); 
+        controller = new ConnectionTypeTabControl(tabFolder);
+        tab.setData(TabControl.CONTROLLER, controller);
+        tab.setControl(controller.getControl());
+        
+        tab = new TabItem(tabFolder, SWT.NONE);
+        tab.setText(EXCHANGE);      
+        controller = new ExchangeTypeTabControl(tabFolder);
+        tab.setData(TabControl.CONTROLLER, controller);
+        tab.setControl(controller.getControl());
+        
+        tab = new TabItem(tabFolder, SWT.NONE);
+        tab.setText(QUEUE);  
+        controller = new QueueTypeTabControl(tabFolder);
+        tab.setData(TabControl.CONTROLLER, controller);
+        tab.setControl(controller.getControl());
+        
+        tabFolder.addListener(SWT.Selection, new Listener()
+        {
+            public void handleEvent(Event evt)
+            {
+                TabItem tab = (TabItem)evt.item;        
+                TabControl controller = (TabControl)tab.getData(TabControl.CONTROLLER);
+                if(controller != null)
+                {
+                    controller.refresh(null);
+                }
+            }
+        });
+        
+        return tabFolder;
+    }
 
     private enum QpidMBeanType
     {

Modified: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java
URL: http://svn.apache.org/viewvc/qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java?rev=788755&r1=788754&r2=788755&view=diff
==============================================================================
--- qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java (original)
+++ qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java Fri Jun 26 16:20:34 2009
@@ -36,8 +36,6 @@
 import org.eclipse.swt.layout.FormData;
 import org.eclipse.swt.layout.FormLayout;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.TabFolder;
 import org.eclipse.swt.widgets.TabItem;
 import org.eclipse.ui.ISelectionListener;
@@ -85,16 +83,43 @@
             // mbean should be set to null. A selection done on the navigation view can be either an mbean or
             // an mbeantype. For mbeantype selection(eg Connection, Queue, Exchange) _mbean will remain null.
             _mbean = null;
-            setInvisible();
+            clearView();
             
             // If a selected node(mbean) gets unregistered from mbean server, mbeanview should 
             // make the tabfolber for that mbean invisible
-            if (_selectedNode == null)            
+            if (_selectedNode == null)
+            {
                 return;
+            }
             
             setServer();
-            refreshMBeanView();
-            setFormTitle();            
+            showRelevantTabView();
+            setFormTitle();
+        }
+    }
+    
+    public void openMBean(ManagedBean mbean)
+    {
+        if(mbean == null)
+        {
+            return;
+        }
+        
+        _mbean = mbean;
+        
+        try
+        {
+            clearView();
+            showMBean(mbean);
+            
+            _form.layout(true);
+            _form.getBody().layout(true, true);
+            
+            setFormTitle();
+        }
+        catch(Exception ex)
+        {
+            MBeanUtility.handleException(mbean, ex);
         }
     }
     
@@ -123,7 +148,7 @@
         _form.setText(_formText);
     }
     
-    public void refreshMBeanView()
+    public void showRelevantTabView()
     {
         try
         {
@@ -131,23 +156,26 @@
             {
                 return;
             }
-            else if (NODE_TYPE_TYPEINSTANCE.equals(_selectedNode.getType()))
+            
+            String mbeanType = _selectedNode.getType();
+            
+            if (NODE_TYPE_TYPEINSTANCE.equals(mbeanType))
             {
                 // An virtual host instance is selected
                 refreshTypeTabFolder(_typeTabFolder.getItem(0));
             }
-            else if (NODE_TYPE_MBEANTYPE.equals(_selectedNode.getType()))
+            else if (NODE_TYPE_MBEANTYPE.equals(mbeanType))
             {
                 refreshTypeTabFolder(_selectedNode.getName());
             } 
-            else if (NOTIFICATIONS.equals(_selectedNode.getType()))
+            else if (NOTIFICATIONS.equals(mbeanType))
             {
                 refreshNotificationPage();
             }
-            else if (MBEAN.equals(_selectedNode.getType()))
+            else if (MBEAN.equals(mbeanType))
             {
                 _mbean = (ManagedBean)_selectedNode.getManagedObject(); 
-                showSelectedMBean();
+                showMBean(_mbean);
             }
             
             _form.layout(true);
@@ -202,15 +230,15 @@
         return _virtualHostName;
     }
     
-    private void showSelectedMBean() throws Exception
+    private void showMBean(ManagedBean mbean) throws Exception
     {           
         try
         {                
-            MBeanUtility.getMBeanInfo(_mbean);     
+            MBeanUtility.getMBeanInfo(mbean);     
         }
         catch(Exception ex)
         {
-            MBeanUtility.handleException(_mbean, ex);
+            MBeanUtility.handleException(mbean, ex);
             return;
         }
 
@@ -219,7 +247,7 @@
             _tabFolder.dispose();
         }
         
-        _tabFolder = MBeanTabFolderFactory.generateMBeanTabFolder(_form.getBody(),(JMXManagedObject)_mbean,_mbsc);
+        _tabFolder = MBeanTabFolderFactory.generateMBeanTabFolder(_form.getBody(),(JMXManagedObject)mbean,_mbsc);
         
         int tabIndex = 0;
         if (NOTIFICATIONS.equals(_selectedNode.getType()))
@@ -247,7 +275,8 @@
         
         // Add mbeantype TabFolder. This will list all the mbeans under a mbeantype (eg Queue, Exchange).
         // Using this list mbeans will be added in the navigation view
-        createMBeanTypeTabFolder();
+        _typeTabFolder = MBeanTabFolderFactory.generateMBeanTypeTabFolder(_form.getBody());
+        _typeTabFolder.setVisible(false);
         
         createNotificationsTabFolder();
     }
@@ -260,7 +289,8 @@
         }
         
         TabControl controller = (TabControl)tab.getData(TabControl.CONTROLLER);
-        if(controller != null){
+        if(controller != null)
+        {
             controller.refresh(_mbean);
         }
     }
@@ -276,54 +306,6 @@
         super.dispose();
     }
     
-    /**
-     * Creates TabFolder and tabs for each mbeantype (eg Connection, Queue, Exchange)
-     */
-    private void createMBeanTypeTabFolder()
-    {
-        _typeTabFolder = new TabFolder(_form.getBody(), SWT.NONE);
-        FormData layoutData = new FormData();
-        layoutData.left = new FormAttachment(0);
-        layoutData.top = new FormAttachment(0);
-        layoutData.right = new FormAttachment(100);
-        layoutData.bottom = new FormAttachment(100);
-        _typeTabFolder.setLayoutData(layoutData);
-        _typeTabFolder.setVisible(false);
-              
-        TabItem tab = new TabItem(_typeTabFolder, SWT.NONE);
-        tab.setText(CONNECTION); 
-        MBeanTypeTabControl controller = new ConnectionTypeTabControl(_typeTabFolder);
-        tab.setData(TabControl.CONTROLLER, controller);
-        tab.setControl(controller.getControl());
-        
-        tab = new TabItem(_typeTabFolder, SWT.NONE);
-        tab.setText(EXCHANGE);      
-        controller = new ExchangeTypeTabControl(_typeTabFolder);
-        tab.setData(TabControl.CONTROLLER, controller);
-        tab.setControl(controller.getControl());
-        
-        tab = new TabItem(_typeTabFolder, SWT.NONE);
-        tab.setText(QUEUE);  
-        controller = new QueueTypeTabControl(_typeTabFolder);
-        tab.setData(TabControl.CONTROLLER, controller);
-        tab.setControl(controller.getControl());
-        
-        _typeTabFolder.addListener(SWT.Selection, new Listener()
-        {
-            public void handleEvent(Event evt)
-            {
-                TabItem tab = (TabItem)evt.item;     
-                try
-                {
-                    refreshTypeTabFolder(tab);
-                }
-                catch (Exception ex)
-                {
-                    MBeanUtility.handleException(ex);
-                }
-            }
-        });
-    }
     
     private void createNotificationsTabFolder()
     {
@@ -359,13 +341,8 @@
      */
     private void refreshTypeTabFolder(TabItem tab) throws Exception
     {
-        if (tab == null)
-        {
-            return;
-        }
+        refreshTab(tab);
         _typeTabFolder.setSelection(tab);
-        MBeanTypeTabControl controller = (MBeanTypeTabControl)tab.getData(TabControl.CONTROLLER);
-        controller.refresh();
         _typeTabFolder.setVisible(true);
     }
     
@@ -385,22 +362,84 @@
         }
     }
 
-    private void setInvisible()
+    private void clearView()
     {
-        if (_tabFolder != null)
+        if (_tabFolder != null && !_tabFolder.isDisposed())
         {
             _tabFolder.setVisible(false);
         }
         
-        if (_typeTabFolder != null)
+        if (_typeTabFolder != null && !_typeTabFolder.isDisposed())
         {
             _typeTabFolder.setVisible(false);
         }
         
-        if (_notificationTabFolder != null)
+        if (_notificationTabFolder != null && !_notificationTabFolder.isDisposed())
         {
             _notificationTabFolder.setVisible(false);
         }
+        
+        _form.setText(APPLICATION_NAME);
+    }
+    
+    public void mbeanUnregistered(ManagedBean mbean)
+    {
+        //if the mbean is actually open, clear the view
+        if(mbean == _mbean)
+        {
+            clearView();
+            ViewUtility.popupInfoMessage("MBean Unregistered", 
+                    "The open MBean was been unregistered from the server.");
+        }
+    }
+    
+    public void refresh()
+    {
+        if (_tabFolder != null && !_tabFolder.isDisposed())
+        {
+            if(_tabFolder.getVisible())
+            {
+                int selectedTab = _tabFolder.getSelectionIndex();
+                TabItem tab = _tabFolder.getItem(selectedTab);
+                TabControl controller = (TabControl) tab.getData(TabControl.CONTROLLER);
+                if(controller != null)
+                {
+                    controller.refresh(_mbean);
+                }
+                return;
+            }
+        }
+        
+        if (_typeTabFolder != null && !_typeTabFolder.isDisposed())
+        {
+            
+            if(_typeTabFolder.getVisible())
+            {
+                int selectedTab = _typeTabFolder.getSelectionIndex();
+                TabItem tab = _typeTabFolder.getItem(selectedTab);
+                TabControl controller = (TabControl) tab.getData(TabControl.CONTROLLER);
+                if(controller != null)
+                {
+                    controller.refresh(_mbean);
+                }
+                return;
+            }
+        }
+        
+        if (_notificationTabFolder != null && !_notificationTabFolder.isDisposed())
+        {
+            if(_notificationTabFolder.getVisible())
+            {
+                int selectedTab = _notificationTabFolder.getSelectionIndex();
+                TabItem tab = _notificationTabFolder.getItem(selectedTab);
+                TabControl controller = (TabControl) tab.getData(TabControl.CONTROLLER);
+                if(controller != null)
+                {
+                    controller.refresh(_mbean);
+                }
+                return;
+            }
+        }
     }
     
 }

Modified: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java
URL: http://svn.apache.org/viewvc/qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java?rev=788755&r1=788754&r2=788755&view=diff
==============================================================================
--- qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java (original)
+++ qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java Fri Jun 26 16:20:34 2009
@@ -62,6 +62,8 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.part.ViewPart;
 
 /**
@@ -190,7 +192,7 @@
                         {
                             public void handleEvent(Event e)
                             {
-                                removeManagedObject(parentNode, (ManagedBean) selectedNode.getManagedObject());
+                                removeManagedObject(parentNode, (ManagedBean) selectedNode.getManagedObject(), true);
                                 _treeViewer.refresh();
                                 // set the selection to the parent node
                                 _treeViewer.setSelection(new StructuredSelection(parentNode));
@@ -675,7 +677,7 @@
      * @param parent
      * @param mbean
      */
-    private void removeManagedObject(TreeObject parent, ManagedBean mbean)
+    private void removeManagedObject(TreeObject parent, ManagedBean mbean, boolean removeFromConfigFile)
     {
         List<TreeObject> list = parent.getChildren();
         TreeObject objectToRemove = null;
@@ -693,14 +695,17 @@
             }
             else
             {
-                removeManagedObject(child, mbean);
+                removeManagedObject(child, mbean, removeFromConfigFile);
             }
         }
 
         if (objectToRemove != null)
         {
             list.remove(objectToRemove);
-            removeItemFromConfigFile(objectToRemove);
+            if(removeFromConfigFile)
+            {
+                removeItemFromConfigFile(objectToRemove);
+            }
         }
 
     }
@@ -1201,11 +1206,20 @@
                     {
                         public void run()
                         {
+                            IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); 
+                            final MBeanView view = (MBeanView)window.getActivePage().findView(MBeanView.ID);
+                            
                             for (ManagedBean mbean : removalList)
                             {
                                 TreeObject treeServerObject = _managedServerMap.get(mbean.getServer());
 
-                                removeManagedObject(treeServerObject, mbean);
+                                if(view != null)
+                                {
+                                    //notify the MBeanView in case the unregistered mbean is being viewed
+                                    view.mbeanUnregistered(mbean);
+                                }
+                                
+                                removeManagedObject(treeServerObject, mbean, false);
                             }
 
                             _treeViewer.refresh();

Copied: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ConnectionTypeTabControl.java (from r788746, qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ConnectionTypeTabControl.java)
URL: http://svn.apache.org/viewvc/qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ConnectionTypeTabControl.java?p2=qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ConnectionTypeTabControl.java&p1=qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ConnectionTypeTabControl.java&r1=788746&r2=788755&rev=788755&view=diff
==============================================================================
--- qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ConnectionTypeTabControl.java (original)
+++ qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ConnectionTypeTabControl.java Fri Jun 26 16:20:34 2009
@@ -18,42 +18,36 @@
  * under the License.
  *
  */
+package org.apache.qpid.management.ui.views.type;
 
-package org.apache.qpid.management.ui.views;
+import java.util.List;
+
+import static org.apache.qpid.management.ui.Constants.CONNECTION;
 
 import org.apache.qpid.management.ui.ApplicationRegistry;
-import org.apache.qpid.management.ui.Constants;
 import org.apache.qpid.management.ui.ManagedBean;
 import org.apache.qpid.management.ui.ServerRegistry;
+import org.apache.qpid.management.ui.views.MBeanView;
 import org.eclipse.swt.widgets.TabFolder;
 
 /**
  * Controller class, which takes care of displaying appropriate information and widgets for Connections.
  * This allows user to select Connections and add those to the navigation view
  */
+
 public class ConnectionTypeTabControl extends MBeanTypeTabControl
 {
 
     public ConnectionTypeTabControl(TabFolder tabFolder)
     {
-        super(tabFolder, Constants.CONNECTION);
-        createWidgets();
-    }
-    
-    protected void createWidgets()
-    {
-        createHeaderComposite(getFormComposite());
-        createButtonsComposite(getFormComposite());
-        createListComposite(getFormComposite());
-    }
-    
-    protected void populateList() throws Exception
-    {
-        // map should be cleared before populating it with new values
-        getMBeansMap().clear();
-        
-        ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer());
-        java.util.List<ManagedBean> list = serverRegistry.getConnections(MBeanView.getVirtualHost());
-        getListWidget().setItems(getItems(list));  
+        super(tabFolder,CONNECTION);
     }
+
+        @Override
+        protected List<ManagedBean> getMbeans()
+        {
+            ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer());
+            return serverRegistry.getConnections(MBeanView.getVirtualHost());
+        }
+
 }

Propchange: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ConnectionTypeTabControl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ConnectionTypeTabControl.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ExchangeTypeTabControl.java (from r788746, qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ExchangeTypeTabControl.java)
URL: http://svn.apache.org/viewvc/qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ExchangeTypeTabControl.java?p2=qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ExchangeTypeTabControl.java&p1=qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ExchangeTypeTabControl.java&r1=788746&r2=788755&rev=788755&view=diff
==============================================================================
--- qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ExchangeTypeTabControl.java (original)
+++ qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ExchangeTypeTabControl.java Fri Jun 26 16:20:34 2009
@@ -18,43 +18,31 @@
  * under the License.
  *
  */
+package org.apache.qpid.management.ui.views.type;
 
-package org.apache.qpid.management.ui.views;
+import java.util.List;
+
+import static org.apache.qpid.management.ui.Constants.EXCHANGE;
 
 import org.apache.qpid.management.ui.ApplicationRegistry;
-import org.apache.qpid.management.ui.Constants;
 import org.apache.qpid.management.ui.ManagedBean;
 import org.apache.qpid.management.ui.ServerRegistry;
+import org.apache.qpid.management.ui.views.MBeanView;
 import org.eclipse.swt.widgets.TabFolder;
 
-/**
- * Controller class, which takes care of displaying appropriate information and widgets for Exchanges.
- * This allows user to select Exchanges and add those to the navigation view
- * @author Bhupendra Bhardwaj
- */
 public class ExchangeTypeTabControl extends MBeanTypeTabControl
 {
-
+    
     public ExchangeTypeTabControl(TabFolder tabFolder)
     {
-        super(tabFolder, Constants.EXCHANGE);
-        createWidgets();
+        super(tabFolder,EXCHANGE);
     }
-    
-    protected void createWidgets()
-    {   
-        createHeaderComposite(getFormComposite());
-        createButtonsComposite(getFormComposite());
-        createListComposite(getFormComposite());
-    }
-    
-    protected void populateList() throws Exception
+
+    @Override
+    protected List<ManagedBean> getMbeans()
     {
-        // map should be cleared before populating it with new values
-        getMBeansMap().clear();
-        
         ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer());
-        java.util.List<ManagedBean> list = serverRegistry.getExchanges(MBeanView.getVirtualHost());
-        getListWidget().setItems(getItems(list));         
+        return serverRegistry.getExchanges(MBeanView.getVirtualHost());
     }
+
 }

Propchange: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ExchangeTypeTabControl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/ExchangeTypeTabControl.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/MBeanTypeTabControl.java (from r788746, qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java)
URL: http://svn.apache.org/viewvc/qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/MBeanTypeTabControl.java?p2=qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/MBeanTypeTabControl.java&p1=qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java&r1=788746&r2=788755&rev=788755&view=diff
==============================================================================
--- qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java (original)
+++ qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/MBeanTypeTabControl.java Fri Jun 26 16:20:34 2009
@@ -18,324 +18,389 @@
  * under the License.
  *
  */
+package org.apache.qpid.management.ui.views.type;
 
-package org.apache.qpid.management.ui.views;
 
-import static org.apache.qpid.management.ui.Constants.BUTTON_REFRESH;
-import static org.apache.qpid.management.ui.Constants.FONT_BOLD;
-import static org.apache.qpid.management.ui.Constants.FONT_ITALIC;
-import static org.apache.qpid.management.ui.Constants.FONT_NORMAL;
+import java.util.List;
 
-import java.util.Collections;
-import java.util.HashMap;
-
-import org.apache.qpid.management.ui.ApplicationRegistry;
 import org.apache.qpid.management.ui.ManagedBean;
 import org.apache.qpid.management.ui.jmx.MBeanUtility;
-import org.apache.qpid.management.ui.model.AttributeData;
+import org.apache.qpid.management.ui.views.MBeanView;
+import org.apache.qpid.management.ui.views.NavigationView;
+import org.apache.qpid.management.ui.views.TabControl;
+
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
 import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.forms.widgets.Form;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 
-/**
- * Abstract class to be extended by the Controller classes for different MBean types (Connection, Queue, Exchange)
- */
-public abstract class MBeanTypeTabControl
+public abstract class MBeanTypeTabControl extends TabControl
 {
-    private FormToolkit  _toolkit = null;
-    private Form _form = null;
-    private TabFolder _tabFolder = null;
-    private Composite _composite = null;
-    private Composite _headerComposite = null;
-    private Composite _listComposite = null;
-    private Label _labelName = null;
-    private Label _labelDesc = null;
-    private Label _labelList = null;
-    
-    private org.eclipse.swt.widgets.List _list = null;
-    private Button _refreshButton = null;
-    private Button _addButton = null;
-    
-    private String _type = null;
-    
-    // maps an mbean name with the mbean object. Required to get mbean object when an mbean
-    // is to be added to the navigation view. 
-    private HashMap<String, ManagedBean> _objectsMap = new HashMap<String, ManagedBean>();
-    private Sorter _sorterByName = new Sorter();
+    private FormToolkit _toolkit;
+    private Form        _form;
+    protected Table _table = null;
+    protected TableViewer _tableViewer = null;
+
+    private List<ManagedBean> _mbeans = null;
+    private String _type;
+    
     
     public MBeanTypeTabControl(TabFolder tabFolder, String type)
     {
+        super(tabFolder);
         _type = type;
-        _tabFolder = tabFolder;
         _toolkit = new FormToolkit(_tabFolder.getDisplay());
         _form = _toolkit.createForm(_tabFolder);
-        createFormComposite();
-    }
-    
-    public FormToolkit getToolkit()
-    {
-        return _toolkit;
+        _form.getBody().setLayout(new GridLayout());
+        createWidgets();
     }
-    
+
+    /**
+     * @see TabControl#getControl()
+     */
     public Control getControl()
     {
         return _form;
     }
     
-    public String getType()
+    /**
+     * @see TabControl#setFocus()
+     */
+    public void setFocus()
     {
-        return _type;
+        _table.setFocus();
     }
     
-    protected List getListWidget()
+    public void refresh()
     {
-        return _list;
+        refresh(null);
     }
     
-    protected HashMap<String, ManagedBean> getMBeansMap()
-    {
-        return _objectsMap;
-    }
     
-    public Sorter getMBeanNameSorter()
+    @Override
+    public void refresh(ManagedBean mbean)
     {
-        return _sorterByName;
+        _mbeans = getMbeans();
+        _form.setVisible(false);
+        _tableViewer.setInput(_mbeans);
+        _form.setVisible(true);
+        layout();
     }
     
-    public Button getAddButton()
+    public void layout()
     {
-        return _addButton;
+        _form.layout(true);
+        _form.getBody().layout(true, true);
     }
     
-    public Button getRefreshButton()
+    protected abstract List<ManagedBean> getMbeans();
+    
+    protected void createTable(Composite tableComposite)
     {
-        return _refreshButton;
-    }
+        _table = new Table (tableComposite, SWT.SINGLE | SWT.SCROLL_LINE | SWT.BORDER | SWT.FULL_SELECTION);
+        _table.setLinesVisible (true);
+        _table.setHeaderVisible (true);
+        GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+        _table.setLayoutData(data);
         
-    /**
-     * Creates the main Composite, which will contain all other Composites and Widgets
-     */
-    protected void createFormComposite()
-    {
-        _form.getBody().setLayout(new GridLayout());
-        _composite = _toolkit.createComposite(_form.getBody(), SWT.NONE);
-        _composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-        GridLayout layout = new GridLayout();
-        layout.verticalSpacing = 10;
-        layout.horizontalSpacing = 0;
-        _composite.setLayout(layout);
+        _tableViewer = new TableViewer(_table);
+        final TableSorter tableSorter = new TableSorter();
+        
+        String[] titles = { "Name"};
+        int[] bounds = { 310};
+        for (int i = 0; i < titles.length; i++) 
+        {
+            final int index = i;
+            final TableViewerColumn viewerColumn = new TableViewerColumn(_tableViewer, SWT.NONE);
+            final TableColumn column = viewerColumn.getColumn();
+
+            column.setText(titles[i]);
+            column.setWidth(bounds[i]);
+            column.setResizable(true);
+
+            //Setting the right sorter
+            column.addSelectionListener(new SelectionAdapter() 
+            {
+                @Override
+                public void widgetSelected(SelectionEvent e) 
+                {
+                    tableSorter.setColumn(index);
+                    final TableViewer viewer = _tableViewer;
+                    int dir = viewer .getTable().getSortDirection();
+                    if (viewer.getTable().getSortColumn() == column) 
+                    {
+                        dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
+                    } 
+                    else 
+                    {
+                        dir = SWT.UP;
+                    }
+                    viewer.getTable().setSortDirection(dir);
+                    viewer.getTable().setSortColumn(column);
+                    viewer.refresh();
+                }
+            });
+
+        }
+        
+        _tableViewer.setContentProvider(new ContentProviderImpl());
+        _tableViewer.setLabelProvider(new LabelProviderImpl());
+        _tableViewer.setSorter(tableSorter);
+        _table.setSortColumn(_table.getColumn(0));
+        _table.setSortDirection(SWT.UP);
     }
     
-    protected Composite getFormComposite()
-    {
-        return _composite;
-    }
     
-    /**
-     * Creates the header composite, which has MBean type name and description
-     * @param parentComposite
-     */
-    protected void createHeaderComposite(Composite parentComposite)
-    {
-        _headerComposite = _toolkit.createComposite(parentComposite);
-        _headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-        GridLayout layout = new GridLayout();
-        layout.verticalSpacing = 10;
-        layout.horizontalSpacing = 0;
-        _headerComposite.setLayout(layout);
-        
-        _labelName = _toolkit.createLabel(_headerComposite, "Type:", SWT.NONE);
-        GridData gridData = new GridData(SWT.CENTER, SWT.TOP, true, false);
-        _labelName.setLayoutData(gridData);
-        _labelName.setFont(ApplicationRegistry.getFont(FONT_BOLD));
-        
-        _labelDesc = _toolkit.createLabel(_headerComposite, " ", SWT.NONE);
-        _labelDesc.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
-        _labelDesc.setFont(ApplicationRegistry.getFont(FONT_ITALIC));
-        
-        _headerComposite.layout();
-    }
     
-    /**
-     * Creates Composite, which contains the common buttons - Add and Refresh.
-     * @param parentComposite
-     */
-    protected void createButtonsComposite(Composite parentComposite)
+    private void createWidgets()
     {
-        Composite composite = _toolkit.createComposite(parentComposite);
-        composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-        GridLayout layout = new GridLayout(2, true);
-        layout.verticalSpacing = 10;
-        layout.horizontalSpacing = 20;
-        composite.setLayout(layout);
+        Composite mainComposite = _toolkit.createComposite(_form.getBody(), SWT.NONE);
+        mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        mainComposite.setLayout(new GridLayout());
         
-        createAddButton(composite);
-        createRefreshButton(composite);
-    }
-    
-    /**
-     * Creates the Add button, which adds the selected item to the navigation view
-     * @param parentComposite
-     */
-    protected void createAddButton(Composite parentComposite)
-    {
-        Button _addButton = _toolkit.createButton(parentComposite, "<- Add selected " + _type + "(s) to navigation tree", SWT.PUSH);
-        GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
-        _addButton.setLayoutData(gridData);
-        _addButton.addSelectionListener(new SelectionAdapter(){
+        Composite buttonComposite = _toolkit.createComposite(mainComposite, SWT.NONE);
+        GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
+        buttonComposite.setLayoutData(gridData);
+        buttonComposite.setLayout(new GridLayout(2,true));
+        
+        final Button favouritesButton = _toolkit.createButton(buttonComposite, 
+                                                    "<-- Add " + _type + " to favourites", SWT.PUSH);
+        gridData = new GridData(SWT.LEFT, SWT.CENTER, true, false);
+        favouritesButton.setLayoutData(gridData);
+        favouritesButton.addSelectionListener(new SelectionAdapter()
+        {
             public void widgetSelected(SelectionEvent e)
             {
-                if (_list.getSelectionCount() == 0)
-                    return;
-                
-                String[] selectedItems = _list.getSelection();
-                for (int i = 0; i < selectedItems.length; i++)
+                int selectionIndex = _table.getSelectionIndex();
+
+                if (selectionIndex != -1)
                 {
-                    String name = selectedItems[i];
-                    int nameEnd = name.indexOf(" (");                	
-                    if (nameEnd != -1)
-                    {
-                        name = name.substring(0, nameEnd);                		
-                    }                	
-                    // pass the ManagedBean to the navigation view to be added
-                    ManagedBean mbean = _objectsMap.get(name);
+                    final ManagedBean selectedMBean = (ManagedBean)_table.getItem(selectionIndex).getData();
+                    
                     IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); 
                     NavigationView view = (NavigationView)window.getActivePage().findView(NavigationView.ID);
                     try
                     {
-                        view.addManagedBean(mbean);
+                        view.addManagedBean(selectedMBean);
                     }
                     catch (Exception ex)
                     {
-                        MBeanUtility.handleException(mbean, ex);
+                        MBeanUtility.handleException(selectedMBean, ex);
                     }
+
                 }
             }
         });
-    }
-    
-    /**
-     * Creates the Refresh button, which gets syncs the items with the broker server
-     * @param parentComposite
-     */
-    protected void createRefreshButton(Composite parentComposite)
-    {
-        Button _refreshButton = _toolkit.createButton(parentComposite, BUTTON_REFRESH, SWT.PUSH);
-        GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
-        gridData.widthHint = 120;
-        _refreshButton.setLayoutData(gridData);
-        _refreshButton.addSelectionListener(new SelectionAdapter(){
+        
+        final Button openButton = _toolkit.createButton(buttonComposite, "Open selected " + _type, SWT.PUSH);
+        gridData = new GridData(SWT.RIGHT, SWT.CENTER, true, false);
+        openButton.setLayoutData(gridData);
+        openButton.addSelectionListener(new SelectionAdapter()
+        {
             public void widgetSelected(SelectionEvent e)
             {
-                try
+                int selectionIndex = _table.getSelectionIndex();
+
+                if (selectionIndex != -1)
                 {
-                    // refresh the list from the broker server
-                    populateList();
+                    final ManagedBean selectedMBean = (ManagedBean)_table.getItem(selectionIndex).getData();
+                    
+                    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); 
+                    MBeanView view = (MBeanView) window.getActivePage().findView(MBeanView.ID);
+                    try
+                    {
+                        view.openMBean(selectedMBean);
+                    }
+                    catch (Exception ex)
+                    {
+                        MBeanUtility.handleException(selectedMBean, ex);
+                    }
                 }
-                catch (Exception ex)
+            }
+        });
+        
+        Composite tableComposite = _toolkit.createComposite(mainComposite);
+        gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+        tableComposite.setLayoutData(gridData);
+        tableComposite.setLayout(new GridLayout(1,false));
+        
+        createTable(tableComposite);
+        
+        favouritesButton.setEnabled(false);
+        openButton.setEnabled(false);
+        
+        _tableViewer.addSelectionChangedListener(new ISelectionChangedListener(){
+            public void selectionChanged(SelectionChangedEvent evt)
+            {
+                int selectionIndex = _table.getSelectionIndex();
+
+                if (selectionIndex != -1)
+                {
+                    favouritesButton.setEnabled(true);
+                    openButton.setEnabled(true);
+                }
+                else
                 {
-                    MBeanUtility.handleException(ex);
+                    favouritesButton.setEnabled(false);
+                    openButton.setEnabled(false);
                 }
             }
         });
+        
+        _table.addMouseListener(new MouseListener()                                              
+        {
+            // MouseListener implementation
+            public void mouseDoubleClick(MouseEvent event)
+            {
+                int selectionIndex = _table.getSelectionIndex();
+
+                if (selectionIndex != -1)
+                {
+                    final ManagedBean selectedMBean = (ManagedBean)_table.getItem(selectionIndex).getData();
+                    
+                    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); 
+                    MBeanView view = (MBeanView) window.getActivePage().findView(MBeanView.ID);
+                    try
+                    {
+                        view.openMBean(selectedMBean);
+                    }
+                    catch (Exception ex)
+                    {
+                        MBeanUtility.handleException(selectedMBean, ex);
+                    }
+                }
+            }
+
+            public void mouseDown(MouseEvent e){}
+            public void mouseUp(MouseEvent e){}
+        });
     }
     
     /**
-     * Creates the Composite, which contains the items ( Connections, Exchanges or Queues)
-     * @param parentComposite
+     * Content Provider class for the table viewer
      */
-    protected void createListComposite(Composite parentComposite)
+    private class ContentProviderImpl  implements IStructuredContentProvider
     {
-        // Composite to contain the item list 
-        _listComposite = _toolkit.createComposite(parentComposite);
-        GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
-        _listComposite.setLayoutData(gridData);
-        GridLayout layout = new GridLayout();
-        layout.verticalSpacing = 0;
-        _listComposite.setLayout(layout);
-        
-        // Label for item name
-        _labelList = _toolkit.createLabel(_listComposite, " ", SWT.CENTER);
-        gridData = new GridData(SWT.CENTER, SWT.TOP, true, false, 1, 1);
-        _labelList.setLayoutData(gridData);
-        _labelList.setFont(ApplicationRegistry.getFont(FONT_NORMAL));
-        
-        _list = new List(_listComposite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
-        gridData = new GridData(SWT.FILL, SWT.FILL, true, true,1, 1);
-        _list.setLayoutData(gridData);
         
+        public void inputChanged(Viewer v, Object oldInput, Object newInput)
+        {
+            
+        }
+        
+        public void dispose()
+        {
+            
+        }
+        
+        @SuppressWarnings("unchecked")
+        public Object[] getElements(Object parent)
+        {
+            return ((List<ManagedBean>) parent).toArray();
+        }
     }
     
     /**
-     * This is called from MBean View to refresh the tab contents
-     * @throws Exception
+     * Label Provider class for the table viewer
      */
-    public void refresh() throws Exception
-    {        
-        setLabelValues();
-        populateList();
-        layout();
-    }
-    
-    protected void setLabelValues()
+    private class LabelProviderImpl extends LabelProvider implements ITableLabelProvider
     {
-        _labelName.setText("Type : " + _type);        
-        _labelDesc.setText("Select the " + _type + "(s) to add to the navigation tree for further interaction.");
-        _labelList.setText("-- List of " + _type + "s --");
-    }
-    
-    protected abstract void populateList() throws Exception;
-    
-    public void layout()
-    {
-        _form.layout(true);
-        _form.getBody().layout(true, true);
-    }
-    
-    // sets the map with appropriate mbean and name
-    protected String[] getItems(java.util.List<ManagedBean> list)
-    {
-        if (list == null)
-            return new String[0];
+        @Override
+        public String getColumnText(Object element, int columnIndex)
+        {
+            switch (columnIndex)
+            {
+                case 0 : // name column 
+                    return ((ManagedBean) element).getName();
+                default:
+                    return "-";
+            }
+        }
         
-        Collections.sort(list, _sorterByName);
-        String[] items = new String[list.size()];
-        int i = 0;
-        for (ManagedBean mbean : list)
+        @Override
+        public Image getColumnImage(Object element, int columnIndex)
         {
-            items[i++] = mbean.getName();
-            _objectsMap.put(mbean.getName(), mbean);
+            return null;
         }
-        return items;
+        
     }
-    
-    protected class ComparatorImpl implements java.util.Comparator<AttributeData>
+
+    /**
+     * Sorter class for the table viewer.
+     *
+     */
+    private class TableSorter extends ViewerSorter
     {
-        public int compare(AttributeData data1, AttributeData data2)
+        private int column;
+        private static final int ASCENDING = 0;
+        private static final int DESCENDING = 1;
+
+        private int direction;
+
+        public TableSorter()
         {
-            Integer int1 = Integer.parseInt(data1.getValue().toString());
-            Integer int2 = Integer.parseInt(data2.getValue().toString());
-            return int1.compareTo(int2) * -1;
+            this.column = 0;
+            direction = ASCENDING;
         }
-    }
-    
-    protected class Sorter implements java.util.Comparator<ManagedBean>
-    {
-        public int compare(ManagedBean mbean1, ManagedBean mbean2)
+
+        public void setColumn(int column)
+        {
+            if(column == this.column)
+            {
+                // Same column as last sort; toggle the direction
+                direction = 1 - direction;
+            }
+            else
+            {
+                // New column; do an ascending sort
+                this.column = column;
+                direction = ASCENDING;
+            }
+        }
+
+        @Override
+        public int compare(Viewer viewer, Object e1, Object e2)
         {
-            return mbean1.getName().compareTo(mbean2.getName());
+            ManagedBean mbean1 = (ManagedBean) e1;
+            ManagedBean mbean2 = (ManagedBean) e2;
+            
+            int comparison = 0;
+            switch(column)
+            {
+                case 0:
+                    comparison = mbean1.getName().compareTo(mbean2.getName());
+                    break;
+                default:
+                    comparison = 0;
+            }
+            // If descending order, flip the direction
+            if(direction == DESCENDING)
+            {
+                comparison = -comparison;
+            }
+            return comparison;
         }
     }
 }

Propchange: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/MBeanTypeTabControl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/MBeanTypeTabControl.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/QueueTypeTabControl.java (from r788746, qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java)
URL: http://svn.apache.org/viewvc/qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/QueueTypeTabControl.java?p2=qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/QueueTypeTabControl.java&p1=qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java&r1=788746&r2=788755&rev=788755&view=diff
==============================================================================
--- qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java (original)
+++ qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/QueueTypeTabControl.java Fri Jun 26 16:20:34 2009
@@ -18,13 +18,13 @@
  * under the License.
  *
  */
-
-package org.apache.qpid.management.ui.views;
+package org.apache.qpid.management.ui.views.type;
 
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+
+import static org.apache.qpid.management.ui.Constants.QUEUE;
 
 import org.apache.qpid.management.ui.ApplicationRegistry;
 import org.apache.qpid.management.ui.Constants;
@@ -32,256 +32,183 @@
 import org.apache.qpid.management.ui.ServerRegistry;
 import org.apache.qpid.management.ui.jmx.MBeanUtility;
 import org.apache.qpid.management.ui.model.AttributeData;
+import org.apache.qpid.management.ui.views.MBeanView;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
 
-/**
- * Controller class, which takes care of displaying appropriate information and widgets for Queues.
- * This allows user to select Queues and add those to the navigation view
- */
 public class QueueTypeTabControl extends MBeanTypeTabControl
-{
-    private boolean _showTempQueues = false;
-    private Button _sortBySizeButton = null;
-    private Button _sortByConsumercountButton = null;
-    private Button _sortByNameButton = null;
-    private Button _showTempQueuesButton = null;
-    
-    private ComparatorImpl _sorterByAttribute = new ComparatorImpl();
-    
-    // Map required for sorting queues based on attribute values
-    private Map<AttributeData, ManagedBean> _queueDepthMap = new LinkedHashMap<AttributeData, ManagedBean>();
-    // Map used for sorting Queues based on consumer count
-    private Map<AttributeData, ManagedBean> _queueConsumerCountMap = new LinkedHashMap<AttributeData, ManagedBean>();
+{   
+    private HashMap<ManagedBean, Long> _queueDepths = new HashMap<ManagedBean, Long>();
+    private HashMap<ManagedBean, Long> _activeConsumerCounts = new HashMap<ManagedBean, Long>();
 
     
     public QueueTypeTabControl(TabFolder tabFolder)
     {
-        super(tabFolder, Constants.QUEUE);
-        createWidgets();
-    }
-    
-    protected void createWidgets()
-    {        
-        createHeaderComposite(getFormComposite());
-        createButtonsComposite(getFormComposite());
-        createListComposite();
+        super(tabFolder,QUEUE);
     }
     
     @Override
-    public void refresh() throws Exception
+    protected List<ManagedBean> getMbeans()
     {
-        setLabelValues();
-        selectDefaultSortingButton();
-        populateList();
-        layout();
-    }
-    
-    /**
-     * populates the map with mbean name and the mbean object.
-     * @throws Exception
-     */
-    protected void populateList() throws Exception
-    {
-        // map should be cleared before populating it with new values
-        getMBeansMap().clear();
-        _queueDepthMap.clear();
-        _queueConsumerCountMap.clear();
-        
         ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer());
-        String[] items = null;
-        java.util.List<ManagedBean> list = null;
-        
-        // populate the map and list with appropriate mbeans
-        list = serverRegistry.getQueues(MBeanView.getVirtualHost());
-        items = getQueueItems(list);
-        // sort the refreshed list in the selected order
-        if (_sortBySizeButton.getSelection())
+        try
         {
-            sortQueuesByQueueDepth();
+            return extractQueueDetails(serverRegistry.getQueues(MBeanView.getVirtualHost()));
         }
-        else if (_sortByConsumercountButton.getSelection())
+        catch(Exception e)
         {
-            sortQueuesByConsumerCount();
+            MBeanUtility.handleException(null, e);
+            return null;
         }
-        else
-        {
-            getListWidget().setItems(items);
-        }      
+       
     }
     
-    private void selectDefaultSortingButton()
+    private List<ManagedBean> extractQueueDetails(List<ManagedBean> list) throws Exception
     {
-        _sortByNameButton.setSelection(true);
-        _sortBySizeButton.setSelection(false);
-        _sortByConsumercountButton.setSelection(false);
+        _queueDepths.clear();
+        _activeConsumerCounts.clear();
         
-        _showTempQueues = false;
-        _showTempQueuesButton.setSelection(_showTempQueues);
+        List<ManagedBean> items = new ArrayList<ManagedBean>();
+        for (ManagedBean mbean : list)
+        {         
+            AttributeData data = MBeanUtility.getAttributeData(mbean, Constants.ATTRIBUTE_QUEUE_DEPTH);
+            _queueDepths.put(mbean, Long.valueOf(data.getValue().toString()));
+            data = MBeanUtility.getAttributeData(mbean, Constants.ATTRIBUTE_QUEUE_CONSUMERCOUNT);
+            _activeConsumerCounts.put(mbean, Long.valueOf(data.getValue().toString()));
+            
+            items.add(mbean);
+        }
+
+        return items;
     }
-     
-    protected void createListComposite()
+    
+    @Override
+    protected void createTable(Composite tableComposite)
     {
-        // Composite to contain the item list 
-        Composite composite = getToolkit().createComposite(getFormComposite());
-        GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
-        composite.setLayoutData(gridData);
-        GridLayout layout = new GridLayout(2, true);
-        layout.verticalSpacing = 0;
-        composite.setLayout(layout);
-        
-        createListComposite(composite);        
-        
-        // Composite to contain buttons like - Sort by size
-        Composite _sortingComposite = getToolkit().createComposite(composite);
-        gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
-        _sortingComposite.setLayoutData(gridData);
-        GridLayout gridLayout = new GridLayout();
-        gridLayout.verticalSpacing = 20;
-        _sortingComposite.setLayout(gridLayout);
-        
-        Group sortingGroup = new Group(_sortingComposite, SWT.SHADOW_NONE);
-        sortingGroup.setBackground(_sortingComposite.getBackground());
-        sortingGroup.setText(" Sort List By ");
-        sortingGroup.setFont(ApplicationRegistry.getFont(Constants.FONT_BOLD));
-        gridData = new GridData(SWT.CENTER, SWT.TOP, true, false);
-        sortingGroup.setLayoutData(gridData);
-        sortingGroup.setLayout(new GridLayout());
-        
-        _sortByNameButton = getToolkit().createButton(sortingGroup, Constants.QUEUE_SORT_BY_NAME, SWT.RADIO);
-        gridData = new GridData(SWT.LEAD, SWT.CENTER, true, false);
-        _sortByNameButton.setLayoutData(gridData);     
-        _sortByNameButton.addSelectionListener(new SelectionAdapter(){
-            public void widgetSelected(SelectionEvent e)
-            {
-                try
-                {
-                    // sort the stored list of items
-                    java.util.List<String> list = new ArrayList<String>(getMBeansMap().keySet());
-                    Collections.sort(list);
-                    getListWidget().setItems(list.toArray(new String[0]));
-                }
-                catch (Exception ex)
-                {
-                    MBeanUtility.handleException(ex);
-                }
-            }
-        });
-               
-        _sortBySizeButton = getToolkit().createButton(sortingGroup, Constants.QUEUE_SORT_BY_DEPTH, SWT.RADIO);
-        gridData = new GridData(SWT.LEAD, SWT.CENTER, true, false);
-        _sortBySizeButton.setLayoutData(gridData);     
-        _sortBySizeButton.addSelectionListener(new SelectionAdapter(){
-            public void widgetSelected(SelectionEvent e)
-            {
-                try
-                {
-                    // sort the stored list of items
-                    sortQueuesByQueueDepth();
-                }
-                catch (Exception ex)
-                {
-                    MBeanUtility.handleException(ex);
-                }
-            }
-        });
-        
-        _sortByConsumercountButton = getToolkit().createButton(sortingGroup, Constants.QUEUE_SORT_BY_CONSUMERCOUNT, SWT.RADIO);
-        gridData = new GridData(SWT.LEAD, SWT.CENTER, true, false);
-        _sortByConsumercountButton.setLayoutData(gridData);
-        _sortByConsumercountButton.addSelectionListener(new SelectionAdapter(){
-            public void widgetSelected(SelectionEvent e)
+        _table = new Table (tableComposite, SWT.SINGLE | SWT.SCROLL_LINE | SWT.BORDER | SWT.FULL_SELECTION);
+        _table.setLinesVisible (true);
+        _table.setHeaderVisible (true);
+        GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+        _table.setLayoutData(data);
+        
+        _tableViewer = new TableViewer(_table);
+        final TableSorter tableSorter = new TableSorter();
+        
+        String[] titles = { "Name", "QueueDepth", "Active Consumer Count"};
+        int[] bounds = { 250, 175, 175};
+        for (int i = 0; i < titles.length; i++) 
+        {
+            final int index = i;
+            final TableViewerColumn viewerColumn = new TableViewerColumn(_tableViewer, SWT.NONE);
+            final TableColumn column = viewerColumn.getColumn();
+
+            column.setText(titles[i]);
+            column.setWidth(bounds[i]);
+            column.setResizable(true);
+
+            //Setting the right sorter
+            column.addSelectionListener(new SelectionAdapter() 
             {
-                try
+                @Override
+                public void widgetSelected(SelectionEvent e) 
                 {
-                    sortQueuesByConsumerCount();
+                    tableSorter.setColumn(index);
+                    final TableViewer viewer = _tableViewer;
+                    int dir = viewer .getTable().getSortDirection();
+                    if (viewer.getTable().getSortColumn() == column) 
+                    {
+                        dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
+                    } 
+                    else 
+                    {
+                        dir = SWT.UP;
+                    }
+                    viewer.getTable().setSortDirection(dir);
+                    viewer.getTable().setSortColumn(column);
+                    viewer.refresh();
                 }
-                catch (Exception ex)
-                {
-                    MBeanUtility.handleException(ex);
-                }
-            }
-        });
+            });
+
+        }
         
-        _showTempQueuesButton = getToolkit().createButton(_sortingComposite, Constants.QUEUE_SHOW_TEMP_QUEUES, SWT.CHECK);
-        _showTempQueuesButton.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
-        _showTempQueuesButton.addSelectionListener(new SelectionAdapter(){
-            public void widgetSelected(SelectionEvent e)
-            {
-                Button button = (Button)e.widget;
-                _showTempQueues = button.getSelection();
-                try
-                {
-                    populateList();
-                }
-                catch (Exception ex)
-                {
-                    MBeanUtility.handleException(ex);
-                }
-            }
-        });
+        _tableViewer.setContentProvider(new ContentProviderImpl());
+        _tableViewer.setLabelProvider(new LabelProviderImpl());
+        _tableViewer.setSorter(tableSorter);
+        _table.setSortColumn(_table.getColumn(0));
+        _table.setSortDirection(SWT.UP);
     }
     
-
-    private String[] getQueueItems(java.util.List<ManagedBean> list) throws Exception
+    /**
+     * Content Provider class for the table viewer
+     */
+    private class ContentProviderImpl  implements IStructuredContentProvider
     {
-        if (list == null)
-            return new String[0];
         
-        // Sort the list. It will keep the mbeans in sorted order in the _queueMap, which is required for
-        // sorting the queue according to size etc
-        Collections.sort(list, getMBeanNameSorter());
-        java.util.List<String> items = new ArrayList<String>();;
-        int i = 0;
-        for (ManagedBean mbean : list)
+        public void inputChanged(Viewer v, Object oldInput, Object newInput)
         {
-            if ((!_showTempQueues && mbean.isTempQueue()))
-            {
-                continue;
-            }
-            String value = mbean.getName();
-            items.add(value);
-            getMBeansMap().put(value, mbean);
-            AttributeData data = MBeanUtility.getAttributeData(mbean, Constants.ATTRIBUTE_QUEUE_DEPTH);
-            _queueDepthMap.put(data, mbean);
-            data = MBeanUtility.getAttributeData(mbean, Constants.ATTRIBUTE_QUEUE_CONSUMERCOUNT);
-            _queueConsumerCountMap.put(data, mbean);
-            i++;
+            
         }
         
-        return items.toArray(new String[0]);
-    }
-    
-    
-    private void sortQueuesByQueueDepth()
-    {
-        // Queues are already in the alphabetically sorted order in _queueMap, now sort for queueDepth
-        java.util.List<AttributeData> list = new ArrayList<AttributeData>(_queueDepthMap.keySet());
-        Collections.sort(list, _sorterByAttribute);
+        public void dispose()
+        {
+            
+        }
         
-        String[] items = new String[list.size()];
-        int i = 0;
-        for (AttributeData data : list)
+        @SuppressWarnings("unchecked")
+        public Object[] getElements(Object parent)
         {
-            ManagedBean mbean = _queueDepthMap.get(data);
-            items[i++] = mbean.getName() + " (" + getQueueDepthString(mbean, data) + ")";
+            return ((List<ManagedBean>) parent).toArray();
         }
-        getListWidget().setItems(items);
     }
     
-    private String getQueueDepthString(ManagedBean mbean, AttributeData data)
+    /**
+     * Label Provider class for the table viewer
+     */
+    private class LabelProviderImpl extends LabelProvider implements ITableLabelProvider
     {
-        if (mbean.getVersion() == 1)  //mbean returns KB
+        @Override
+        public String getColumnText(Object element, int columnIndex)
         {
-            Long value = (Long)data.getValue();
+            ManagedBean mbean = (ManagedBean) element;
             
+            switch (columnIndex)
+            {
+                case 0 : // name column 
+                    return mbean.getName();
+                case 1 : // queue depth column 
+                    return getQueueDepthString(mbean, _queueDepths.get(mbean));
+                case 2 : // consumer count column
+                    return String.valueOf(_activeConsumerCounts.get(mbean));
+                default:
+                    return "-";
+            }
+        }
+        
+        @Override
+        public Image getColumnImage(Object element, int columnIndex)
+        {
+            return null;
+        }    
+    }
+    
+    private String getQueueDepthString(ManagedBean mbean, Long value)
+    {
+        if (mbean.getVersion() == 1)  //mbean is v1 and returns KB
+        {           
             Double mb = 1024.0;
             
             if(value > mb) //MB
@@ -290,13 +217,11 @@
             }
             else //KB
             {
-                return data.getValue().toString() + " KB";
+                return value + " KB";
             }
         }
-        else //mbean returns Bytes
+        else  //mbean is v2+ and returns Bytes
         {
-            Long value = (Long)data.getValue();
-            
             double mb = 1024.0 * 1024.0;
             double kb = 1024.0;
             
@@ -310,24 +235,72 @@
             }
             else //Bytes
             {
-                return data.getValue().toString() + " Bytes";
+                return value + " Bytes";
             }
         }
-    }    
-    
-    private void sortQueuesByConsumerCount()
+    }
+
+    /**
+     * Sorter class for the table viewer.
+     *
+     */
+    private class TableSorter extends ViewerSorter
     {
-        java.util.List<AttributeData> list = new ArrayList<AttributeData>(_queueConsumerCountMap.keySet());
-        Collections.sort(list, _sorterByAttribute);
-        
-        String[] items = new String[list.size()];
-        int i = 0;
-        for (AttributeData data : list)
-        {
-            ManagedBean mbean = _queueConsumerCountMap.get(data);
-            String value = data.getValue().toString();
-            items[i++] = mbean.getName() + " (" + value + ")";
+        private int column;
+        private static final int ASCENDING = 0;
+        private static final int DESCENDING = 1;
+
+        private int direction;
+
+        public TableSorter()
+        {
+            this.column = 0;
+            direction = ASCENDING;
+        }
+
+        public void setColumn(int column)
+        {
+            if(column == this.column)
+            {
+                // Same column as last sort; toggle the direction
+                direction = 1 - direction;
+            }
+            else
+            {
+                // New column; do an ascending sort
+                this.column = column;
+                direction = ASCENDING;
+            }
+        }
+
+        @Override
+        public int compare(Viewer viewer, Object e1, Object e2)
+        {
+            ManagedBean mbean1 = (ManagedBean) e1;
+            ManagedBean mbean2 = (ManagedBean) e2;
+            
+            int comparison = 0;
+            switch(column)
+            {
+                case 0: //name
+                    comparison = mbean1.getName().compareTo(mbean2.getName());
+                    break;
+                case 1: //queue depth
+                    comparison = _queueDepths.get(mbean1).compareTo(_queueDepths.get(mbean2));
+                    break;
+                case 2: //active consumer count
+                    comparison = _activeConsumerCounts.get(mbean1).compareTo(_activeConsumerCounts.get(mbean2));
+                    break;
+                default:
+                    comparison = 0;
+            }
+            // If descending order, flip the direction
+            if(direction == DESCENDING)
+            {
+                comparison = -comparison;
+            }
+            return comparison;
         }
-        getListWidget().setItems(items);
     }
+
 }

Propchange: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/QueueTypeTabControl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/branches/jmx_mc_gsoc09/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/type/QueueTypeTabControl.java
------------------------------------------------------------------------------
    svn:mergeinfo = 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org