summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBhupendra Bhusman Bhardwaj <bhupendrab@apache.org>2007-02-19 15:42:01 +0000
committerBhupendra Bhusman Bhardwaj <bhupendrab@apache.org>2007-02-19 15:42:01 +0000
commit625170d9a3f64970987161c59a60497065c4bef6 (patch)
treea1d3314decb95178ec43db519c0078c1523f4032
parente14993ebab6c2f2ed5984de30fe03ce320cf4c0c (diff)
downloadqpid-python-625170d9a3f64970987161c59a60497065c4bef6.tar.gz
QPID-374
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@509223 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java4
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java5
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java1
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientListener.java5
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java11
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java15
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ConnectionTypeTabControl.java39
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ExchangeTypeTabControl.java39
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java424
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java86
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java2
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java36
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java276
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java91
14 files changed, 637 insertions, 397 deletions
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
index e3e22aa7ee..7beb9c9b49 100644
--- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
@@ -67,6 +67,10 @@ public class Constants
public final static String ACTION_ADDSERVER = "New Connection";
+ public final static String QUEUE_SORT_BY_NAME = "Queue Name";
+ public final static String QUEUE_SORT_BY_DEPTH = "Queue Depth";
+ public final static String QUEUE_SORT_BY_CONSUMERCOUNT = "Consumer Count";
+ public final static String QUEUE_SHOW_TEMP_QUEUES= "show temporary queues";
public final static String SUBSCRIBE_BUTTON = "Subscribe";
public final static String UNSUBSCRIBE_BUTTON = "Unsubscribe";
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java
index 41c33e6934..38c3e8f413 100644
--- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java
@@ -118,4 +118,9 @@ public abstract class ManagedBean extends ManagedObject
{
return _type.endsWith(Constants.EXCHANGE);
}
+
+ public boolean isTempQueue()
+ {
+ return (isQueue() && getName().startsWith("tmp_"));
+ }
}
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
index 2586369515..3724dfb33f 100644
--- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
@@ -132,6 +132,7 @@ public class AddServer/* extends Action*/ implements IWorkbenchWindowActionDeleg
Display display = Display.getCurrent();
final Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE);
shell.setText(Constants.ACTION_ADDSERVER);
+ shell.setImage(ApplicationRegistry.getImage(Constants.CONSOLE_IMAGE));
shell.setLayout(new GridLayout());
int x = display.getBounds().width;
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientListener.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientListener.java
index 6a23051a9e..82447d645e 100644
--- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientListener.java
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientListener.java
@@ -45,6 +45,11 @@ public class ClientListener implements NotificationListener
{
ObjectName objName = null;
String type = notification.getType();
+ if (MBeanUtility.isDebug())
+ {
+ System.out.println(type + ":" + objName);
+ }
+
if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(type))
{
objName = ((MBeanServerNotification)notification).getMBeanName();
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
index c5988fd480..919cc7718e 100644
--- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
@@ -131,7 +131,7 @@ public class JMXServerRegistry extends ServerRegistry
public void addManagedObject(ManagedBean mbean)
{
- if (mbean.isQueue() && !mbean.getName().startsWith("tmp_"))
+ if (mbean.isQueue())
{
addQueueMBean(mbean);
}
@@ -149,6 +149,11 @@ public class JMXServerRegistry extends ServerRegistry
public void removeManagedObject(ManagedBean mbean)
{
+ if (MBeanUtility.isDebug())
+ {
+ System.out.println("Removing MBean:" + mbean.getUniqueName());
+ }
+
if (mbean.isQueue())
{
removeQueueMBean(mbean);
@@ -333,8 +338,7 @@ public class JMXServerRegistry extends ServerRegistry
*/
public void registerManagedObject(ObjectName objName)
{
- JMXManagedObject managedObject = new JMXManagedObject(objName);
-
+ JMXManagedObject managedObject = new JMXManagedObject(objName);
managedObject.setServer(getManagedServer());
addManagedObject(managedObject);
}
@@ -347,6 +351,7 @@ public class JMXServerRegistry extends ServerRegistry
public void unregisterManagedObject(ObjectName objName)
{
ManagedBean mbean = _mbeansMap.get(objName.toString());
+ removeManagedObject(mbean);
// Check if mbean was not available in the map. It can happen if mbean unregistration
// notification is received and the mbean is not added in the map.
if (mbean != null)
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java
index e7361ddec7..8b4fd3afb5 100644
--- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java
@@ -59,6 +59,12 @@ import org.apache.qpid.management.ui.views.ViewUtility;
*/
public class MBeanUtility
{
+ private static boolean _debug;
+ static
+ {
+ String debug = System.getProperty("debug");
+ _debug = "true".equalsIgnoreCase(debug) ? true : false;
+ }
/**
* Retrieves the MBeanInfo from MBeanServer and stores in the application registry
* @param mbean managed bean
@@ -429,4 +435,13 @@ public class MBeanUtility
String[] domains = mbsc.getDomains();
return Arrays.asList(domains);
}
+
+ /**
+ * return true if System property is set to true -Ddebug=true
+ * @return
+ */
+ public static boolean isDebug()
+ {
+ return _debug;
+ }
}
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ConnectionTypeTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ConnectionTypeTabControl.java
new file mode 100644
index 0000000000..4e3a7c29ca
--- /dev/null
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ConnectionTypeTabControl.java
@@ -0,0 +1,39 @@
+package org.apache.qpid.management.ui.views;
+
+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.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
+ * @author Bhupendra Bhardwaj
+ */
+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));
+ }
+}
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ExchangeTypeTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ExchangeTypeTabControl.java
new file mode 100644
index 0000000000..711dc6ce3d
--- /dev/null
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ExchangeTypeTabControl.java
@@ -0,0 +1,39 @@
+package org.apache.qpid.management.ui.views;
+
+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.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();
+ }
+
+ 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.getExchanges(MBeanView.getVirtualHost());
+ getListWidget().setItems(getItems(list));
+ }
+}
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java
index 31650295ed..4c57ebb6af 100644
--- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java
@@ -1,15 +1,11 @@
package org.apache.qpid.management.ui.views;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
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.jmx.MBeanUtility;
import org.apache.qpid.management.ui.model.AttributeData;
import org.eclipse.swt.SWT;
@@ -20,7 +16,6 @@ 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.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.TabFolder;
@@ -30,19 +25,17 @@ import org.eclipse.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.FormToolkit;
/**
- * Class to create widgets and control display for mbeantype(eg Connection, Queue, Exchange) selection
- * on the navigation view.
+ * Abstract class to be extended by the Controller classes for different MBean types (Connection, Queue, Exchange)
* @author Bhupendra Bhardwaj
- *
*/
-public class MBeanTypeTabControl
+public abstract class MBeanTypeTabControl
{
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 Composite _sortingComposite = null;
private Label _labelName = null;
private Label _labelDesc = null;
private Label _labelList = null;
@@ -50,30 +43,26 @@ public class MBeanTypeTabControl
private org.eclipse.swt.widgets.List _list = null;
private Button _refreshButton = null;
private Button _addButton = null;
- private Button _sortBySizeButton = null;
- private Button _sortByConsumercountButton = null;
- private Button _sortByNameButton = 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>();
- // 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 Sorter _sorterByName = new Sorter();
- private ComparatorImpl _sorterByAttribute = new ComparatorImpl();
- public MBeanTypeTabControl(TabFolder tabFolder)
+ public MBeanTypeTabControl(TabFolder tabFolder, String type)
{
+ _type = type;
_tabFolder = tabFolder;
_toolkit = new FormToolkit(_tabFolder.getDisplay());
_form = _toolkit.createForm(_tabFolder);
- createWidgets();
- addListeners();
+ createFormComposite();
+ }
+
+ public FormToolkit getToolkit()
+ {
+ return _toolkit;
}
public Control getControl()
@@ -81,11 +70,106 @@ public class MBeanTypeTabControl
return _form;
}
+ public String getType()
+ {
+ return _type;
+ }
+
+ protected List getListWidget()
+ {
+ return _list;
+ }
+
+ protected HashMap<String, ManagedBean> getMBeansMap()
+ {
+ return _objectsMap;
+ }
+
+ public Sorter getMBeanNameSorter()
+ {
+ return _sorterByName;
+ }
+
+ public Button getAddButton()
+ {
+ return _addButton;
+ }
+
+ public Button getRefreshButton()
+ {
+ return _refreshButton;
+ }
+
+ /**
+ * 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);
+ }
+
+ protected Composite getFormComposite()
+ {
+ return _composite;
+ }
+
/**
- * Adds listeners to all the buttons
+ * Creates the header composite, which has MBean type name and description
+ * @param parentComposite
*/
- private void addListeners()
+ 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(Constants.FONT_BOLD));
+
+ _labelDesc = _toolkit.createLabel(_headerComposite, " ", SWT.NONE);
+ _labelDesc.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
+ _labelDesc.setFont(ApplicationRegistry.getFont(Constants.FONT_ITALIC));
+
+ _headerComposite.layout();
+ }
+
+ /**
+ * Creates Composite, which contains the common buttons - Add and Refresh.
+ * @param parentComposite
+ */
+ protected void createButtonsComposite(Composite parentComposite)
+ {
+ 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);
+
+ 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 to Navigation", SWT.PUSH);
+ GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
+ _addButton.setLayoutData(gridData);
_addButton.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e)
{
@@ -111,7 +195,18 @@ public class MBeanTypeTabControl
}
}
});
-
+ }
+
+ /**
+ * 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, Constants.BUTTON_REFRESH, SWT.PUSH);
+ GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
+ gridData.widthHint = 120;
+ _refreshButton.setLayoutData(gridData);
_refreshButton.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e)
{
@@ -126,224 +221,64 @@ public class MBeanTypeTabControl
}
}
});
-
- _sortByNameButton.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e)
- {
- try
- {
- // sort the stored list of items
- java.util.List<String> list = new ArrayList<String>(_objectsMap.keySet());
- Collections.sort(list);
- _list.setItems(list.toArray(new String[0]));
- }
- catch (Exception ex)
- {
- MBeanUtility.handleException(ex);
- }
- }
- });
-
- _sortBySizeButton.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e)
- {
- try
- {
- // sort the stored list of items
- sortQueuesByQueueDepth();
- }
- catch (Exception ex)
- {
- MBeanUtility.handleException(ex);
- }
- }
- });
-
- _sortByConsumercountButton.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e)
- {
- try
- {
- sortQueuesByConsumerCount();
- }
- catch (Exception ex)
- {
- MBeanUtility.handleException(ex);
- }
- }
- });
}
- private void createWidgets()
+ /**
+ * Creates the Composite, which contains the items ( Connections, Exchanges or Queues)
+ * @param parentComposite
+ */
+ protected void createListComposite(Composite parentComposite)
{
- /* _form
- * |
- * _composite
- * |
- * ---------------------------------------------------------------------
- * | | |
- * _labelName, _labelDesc, _listComposite _sortingComposite
- * _addButton, _refreshButton | |
- * _labelList, _list sortingGroup
- * |
- * sorting radio buttons
- */
- _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(2, true);
- layout.verticalSpacing = 10;
- layout.horizontalSpacing = 0;
- _composite.setLayout(layout);
-
- _labelName = _toolkit.createLabel(_composite, "Type:", SWT.NONE);
- GridData gridData = new GridData(SWT.CENTER, SWT.TOP, true, false, 2, 1);
- _labelName.setLayoutData(gridData);
- _labelName.setFont(ApplicationRegistry.getFont(Constants.FONT_BOLD));
-
- _labelDesc = _toolkit.createLabel(_composite, " ", SWT.NONE);
- _labelDesc.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false, 2, 1));
- _labelDesc.setFont(ApplicationRegistry.getFont(Constants.FONT_ITALIC));
-
- _addButton = _toolkit.createButton(_composite, "<- Add to Navigation", SWT.PUSH);
- gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
- _addButton.setLayoutData(gridData);
-
- _refreshButton = _toolkit.createButton(_composite, Constants.BUTTON_REFRESH, SWT.PUSH);
- gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
- gridData.widthHint = 120;
- _refreshButton.setLayoutData(gridData);
-
// Composite to contain the item list
- _listComposite = _toolkit.createComposite(_composite);
- gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ _listComposite = _toolkit.createComposite(parentComposite);
+ GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
_listComposite.setLayoutData(gridData);
- layout = new GridLayout();
+ GridLayout layout = new GridLayout();
layout.verticalSpacing = 0;
_listComposite.setLayout(layout);
// Label for item name
- _labelList = _toolkit.createLabel(_listComposite, " ", SWT.NONE);
- _labelList.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
+ _labelList = _toolkit.createLabel(_listComposite, " ", SWT.CENTER);
+ gridData = new GridData(SWT.CENTER, SWT.TOP, true, false, 1, 1);
+ _labelList.setLayoutData(gridData);
_labelList.setFont(ApplicationRegistry.getFont(Constants.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);
+ gridData = new GridData(SWT.FILL, SWT.FILL, true, true,1, 1);
_list.setLayoutData(gridData);
-
- // Composite to contain buttons like - Sort by size
- _sortingComposite = _toolkit.createComposite(_composite);
- gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
- _sortingComposite.setLayoutData(gridData);
- _sortingComposite.setLayout(new 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, true);
- sortingGroup.setLayoutData(gridData);
- sortingGroup.setLayout(new GridLayout());
-
- _sortByNameButton = _toolkit.createButton(sortingGroup, "Queue Name", SWT.RADIO);
- gridData = new GridData(SWT.LEAD, SWT.CENTER, true, false);
- _sortByNameButton.setLayoutData(gridData);
-
- _sortBySizeButton = _toolkit.createButton(sortingGroup, "Queue Depth", SWT.RADIO);
- gridData = new GridData(SWT.LEAD, SWT.CENTER, true, false);
- _sortBySizeButton.setLayoutData(gridData);
-
- _sortByConsumercountButton = _toolkit.createButton(sortingGroup, "Consumer Count", SWT.RADIO);
- gridData = new GridData(SWT.LEAD, SWT.CENTER, true, false);
- _sortByConsumercountButton.setLayoutData(gridData);
- }
-
- private void selectDefaultSortingButton()
- {
- _sortByNameButton.setSelection(true);
- _sortBySizeButton.setSelection(false);
- _sortByConsumercountButton.setSelection(false);
}
- public void refresh(String typeName) throws Exception
- {
- _type = typeName;
- setHeader();
- selectDefaultSortingButton();
+ /**
+ * This is called from MBean View to refresh the tab contents
+ * @throws Exception
+ */
+ public void refresh() throws Exception
+ {
+ setLabelValues();
populateList();
-
- _listComposite.layout();
- _composite.layout();
- _form.layout();
+ layout();
}
- private void setHeader()
+ protected void setLabelValues()
{
_labelName.setText("Type : " + _type);
_labelDesc.setText("Select the " + _type + "(s) to add in the Navigation View");
_labelList.setText("-- List of " + _type + "s --");
}
- /**
- * populates the map with mbean name and the mbean object.
- * @throws Exception
- */
- private void populateList() throws Exception
+ protected abstract void populateList() throws Exception;
+
+ public void layout()
{
- // map should be cleared before populating it with new values
- _objectsMap.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
- if (_type.equals(Constants.QUEUE))
- {
- list = serverRegistry.getQueues(MBeanView.getVirtualHost());
- items = getQueueItems(list);
- // sort the refreshed list in the selected order
- if (_sortBySizeButton.getSelection())
- {
- sortQueuesByQueueDepth();
- }
- else if (_sortByConsumercountButton.getSelection())
- {
- sortQueuesByConsumerCount();
- }
- else
- {
- _list.setItems(items);
- }
- _sortingComposite.setVisible(true);
- }
- else
- {
- if (_type.equals(Constants.EXCHANGE))
- {
- list = serverRegistry.getExchanges(MBeanView.getVirtualHost());
- items = getItems(list);
- _sortingComposite.setVisible(false);
- }
- else if (_type.equals(Constants.CONNECTION))
- {
- list = serverRegistry.getConnections(MBeanView.getVirtualHost());
- items = getItems(list);
- _sortingComposite.setVisible(false);
- }
- else
- {
- throw new Exception("Unknown mbean type " + _type);
- }
- _list.setItems(items);
- }
+ _headerComposite.layout();
+ _listComposite.layout();
+ _composite.layout();
+ _form.layout();
}
// sets the map with appropriate mbean and name
- private String[] getItems(java.util.List<ManagedBean> list)
+ protected String[] getItems(java.util.List<ManagedBean> list)
{
if (list == null)
return new String[0];
@@ -359,64 +294,7 @@ public class MBeanTypeTabControl
return items;
}
- private String[] getQueueItems(java.util.List<ManagedBean> list) throws Exception
- {
- 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, _sorterByName);
- String[] items = new String[list.size()];
- int i = 0;
- for (ManagedBean mbean : list)
- {
- AttributeData data = MBeanUtility.getAttributeData(mbean, Constants.ATTRIBUTE_QUEUE_DEPTH);
- String value = data.getValue().toString();
- items[i] = mbean.getName() + " (" + value + " KB)";
- _objectsMap.put(items[i], mbean);
- _queueDepthMap.put(data, mbean);
- data = MBeanUtility.getAttributeData(mbean, Constants.ATTRIBUTE_QUEUE_CONSUMERCOUNT);
- _queueConsumerCountMap.put(data, mbean);
- i++;
- }
- return items;
- }
-
- 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);
-
- String[] items = new String[list.size()];
- int i = 0;
- for (AttributeData data : list)
- {
- ManagedBean mbean = _queueDepthMap.get(data);
- String value = data.getValue().toString();
- items[i++] = mbean.getName() + " (" + value + " KB)";
- }
- _list.setItems(items);
- }
-
- private void sortQueuesByConsumerCount()
- {
- 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 + " )";
- }
- _list.setItems(items);
- }
-
- private class ComparatorImpl implements java.util.Comparator<AttributeData>
+ protected class ComparatorImpl implements java.util.Comparator<AttributeData>
{
public int compare(AttributeData data1, AttributeData data2)
{
@@ -426,7 +304,7 @@ public class MBeanTypeTabControl
}
}
- private class Sorter implements java.util.Comparator<ManagedBean>
+ protected class Sorter implements java.util.Comparator<ManagedBean>
{
public int compare(ManagedBean mbean1, ManagedBean mbean2)
{
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java
index cdb4aa99a8..52de47bfda 100644
--- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java
@@ -39,7 +39,6 @@ import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.TabFolder;
@@ -59,6 +58,7 @@ import org.eclipse.ui.part.ViewPart;
public class MBeanView extends ViewPart
{
public static final String ID = "org.apache.qpid.management.ui.mbeanView";
+ private static final String CONTROLLER = "CONTROLLER";
private FormToolkit _toolkit = null;
private Form _form = null;
@@ -66,14 +66,11 @@ public class MBeanView extends ViewPart
private TreeObject _selectedNode = null;
private ManagedBean _mbean = null;
private static String _virtualHostName = null;
- // This map contains a TabFolder for each kind of MBean. TabFolder is mapped with mbeantype(eg Connection, Queue etc)
+ // This map contains a TabFolder for each kind of MBean.
+ // TabFolder is mapped with mbeantype(Connection, Queue and Exchange)
private HashMap<String, TabFolder> tabFolderMap = new HashMap<String, TabFolder>();
private ISelectionListener selectionListener = new SelectionListenerImpl();
-
- private static final String ATTRIBUTES_CONTROL = "AttributesTabControl";
- private static final String OPERATIONS_CONTROL = "OperationsTabControl";
- private static final String NOTIFICATIONS_CONTROL = "NotificationsTabControl";
-
+
// TabFolder to list all the mbeans for a given mbeantype(eg Connection, Queue, Exchange)
private TabFolder typeTabFolder = null;
/*
@@ -196,7 +193,7 @@ public class MBeanView extends ViewPart
*/
if (tabFolder == null)
{
- tabFolder = createTabFolder();
+ tabFolder = createMBeanTabFolder();
}
String text = _mbean.getType();
@@ -232,7 +229,7 @@ public class MBeanView extends ViewPart
// 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
- createTypeTabFolder();
+ createMBeanTypeTabFolder();
}
public void refreshMBeanView() throws Exception
@@ -264,7 +261,7 @@ public class MBeanView extends ViewPart
_form.layout();
}
- private TabFolder createTabFolder()
+ private TabFolder createMBeanTabFolder()
{
TabFolder tabFolder = new TabFolder(_form.getBody(), SWT.NONE);
FormData layoutData = new FormData();
@@ -304,34 +301,8 @@ public class MBeanView extends ViewPart
if (tab == null)
return;
- TabFolder tabFolder = tab.getParent();
- // If an operation tab is selected, the operation data is attached with the tab
- if (tab.getData() != null && (tab.getData() instanceof OperationData))
- {
- // Refresh selected operation tab
- TabControl control = (TabControl)tabFolder.getData(OPERATIONS_CONTROL);
- if (control == null)
- return;
-
- control.refresh(_mbean, (OperationData)tab.getData());
- }
- else if (tab.getText().equals(Constants.NOTIFICATION))
- {
- TabControl control = (TabControl)tabFolder.getData(NOTIFICATIONS_CONTROL);
- if (control == null)
- return;
-
- control.refresh(_mbean);
- }
- else if (tab.getText().equals(Constants.ATTRIBUTES))
- {
- TabControl control = (TabControl)tabFolder.getData(ATTRIBUTES_CONTROL);
- if (control == null)
- return;
-
- control.refresh(_mbean);
- }
-
+ TabControl controller = (TabControl)tab.getData(CONTROLLER);
+ controller.refresh(_mbean);
}
public void setFocus()
@@ -355,9 +326,9 @@ public class MBeanView extends ViewPart
TabItem tab = new TabItem(tabFolder, SWT.NONE);
tab.setText(Constants.ATTRIBUTES);
- AttributesTabControl control = new AttributesTabControl(tabFolder);
- tab.setControl(control.getControl());
- tabFolder.setData(ATTRIBUTES_CONTROL, control);
+ AttributesTabControl controller = new AttributesTabControl(tabFolder);
+ tab.setControl(controller.getControl());
+ tab.setData(CONTROLLER, controller);
}
private void createOperationTabs(TabFolder tabFolder)
@@ -369,15 +340,14 @@ public class MBeanView extends ViewPart
return;
}
- OperationTabControl control = new OperationTabControl(tabFolder);
- tabFolder.setData(OPERATIONS_CONTROL, control);
-
OperationDataModel operationModel = serverRegistry.getOperationModel(_mbean);
for (OperationData operationData : operationModel.getOperations())
{
TabItem operationTab = new TabItem(tabFolder, SWT.NONE);
operationTab.setText(ViewUtility.getDisplayText(operationData.getName()));
operationTab.setData(operationData);
+ OperationTabControl control = new OperationTabControl(tabFolder, operationData);
+ operationTab.setData(CONTROLLER, control);
operationTab.setControl(control.getControl());
}
}
@@ -385,10 +355,10 @@ public class MBeanView extends ViewPart
private void createNotificationsTab(TabFolder tabFolder)
{
NotificationsTabControl controller = new NotificationsTabControl(tabFolder);
- tabFolder.setData(NOTIFICATIONS_CONTROL, controller);
TabItem tab = new TabItem(tabFolder, SWT.NONE);
tab.setText(Constants.NOTIFICATION);
+ tab.setData(CONTROLLER, controller);
tab.setControl(controller.getControl());
}
@@ -416,7 +386,8 @@ public class MBeanView extends ViewPart
throw new InfoRequiredException("Please select the attribute to be edited");
}
- AttributesTabControl tabControl = (AttributesTabControl)tabFolder.getData(ATTRIBUTES_CONTROL);
+ TabItem tab = tabFolder.getItem(0);
+ AttributesTabControl tabControl = (AttributesTabControl)tab.getData(CONTROLLER);
AttributeData attribute = tabControl.getSelectionAttribute();
if (attribute == null)
throw new InfoRequiredException("Please select the attribute to be edited");
@@ -427,7 +398,7 @@ public class MBeanView extends ViewPart
/**
* Creates TabFolder and tabs for each mbeantype (eg Connection, Queue, Exchange)
*/
- private void createTypeTabFolder()
+ private void createMBeanTypeTabFolder()
{
typeTabFolder = new TabFolder(_form.getBody(), SWT.NONE);
FormData layoutData = new FormData();
@@ -437,20 +408,23 @@ public class MBeanView extends ViewPart
layoutData.bottom = new FormAttachment(100);
typeTabFolder.setLayoutData(layoutData);
typeTabFolder.setVisible(false);
-
- MBeanTypeTabControl controller = new MBeanTypeTabControl(typeTabFolder);
- typeTabFolder.setData("CONTROLLER", controller);
-
+
TabItem tab = new TabItem(typeTabFolder, SWT.NONE);
- tab.setText(Constants.CONNECTION);
+ tab.setText(Constants.CONNECTION);
+ MBeanTypeTabControl controller = new ConnectionTypeTabControl(typeTabFolder);
+ tab.setData(CONTROLLER, controller);
tab.setControl(controller.getControl());
tab = new TabItem(typeTabFolder, SWT.NONE);
- tab.setText(Constants.EXCHANGE);
+ tab.setText(Constants.EXCHANGE);
+ controller = new ExchangeTypeTabControl(typeTabFolder);
+ tab.setData(CONTROLLER, controller);
tab.setControl(controller.getControl());
tab = new TabItem(typeTabFolder, SWT.NONE);
- tab.setText(Constants.QUEUE);
+ tab.setText(Constants.QUEUE);
+ controller = new QueueTypeTabControl(typeTabFolder);
+ tab.setData(CONTROLLER, controller);
tab.setControl(controller.getControl());
typeTabFolder.addListener(SWT.Selection, new Listener()
@@ -483,8 +457,8 @@ public class MBeanView extends ViewPart
return;
}
typeTabFolder.setSelection(tab);
- MBeanTypeTabControl controller = (MBeanTypeTabControl)typeTabFolder.getData("CONTROLLER");
- controller.refresh(tab.getText());
+ MBeanTypeTabControl controller = (MBeanTypeTabControl)tab.getData(CONTROLLER);
+ controller.refresh();
typeTabFolder.setVisible(true);
}
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java
index aee016202e..1f9e2e67fb 100644
--- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java
@@ -851,7 +851,7 @@ public class NavigationView extends ViewPart
}
}
removeManagedObject(domain, mbean);
- serverRegistry.removeManagedObject(mbean);
+ //serverRegistry.removeManagedObject(mbean);
}
_treeViewer.refresh();
}
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
index 7298e287ae..0103efbcd1 100644
--- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
@@ -27,7 +27,6 @@ import java.util.Map.Entry;
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.jmx.MBeanUtility;
import org.apache.qpid.management.ui.model.OperationData;
import org.apache.qpid.management.ui.model.ParameterData;
@@ -91,12 +90,15 @@ public class OperationTabControl extends TabControl
private HashMap<Text, Text> headerBindingHashMap = null;
private String _virtualHostName = null;
- public OperationTabControl(TabFolder tabFolder)
+ public OperationTabControl(TabFolder tabFolder, OperationData opData)
{
super(tabFolder);
_toolkit = new FormToolkit(_tabFolder.getDisplay());
_form = _toolkit.createForm(_tabFolder);
_form.getBody().setLayout(new GridLayout());
+ _opData = opData;
+ createComposites();
+ setHeader();
}
/**
@@ -144,15 +146,6 @@ public class OperationTabControl extends TabControl
public void refresh(ManagedBean mbean)
{
_mbean = mbean;
- ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(mbean);
- _opData = serverRegistry.getOperationModel(mbean).getOperations().get(0);
- refresh(_mbean, _opData);
- }
-
- public void refresh(ManagedBean mbean, OperationData opData)
- {
- _mbean = mbean;
- _opData = opData;
_virtualHostName = _mbean.getVirtualHostName();
// Setting the form to be invisible. Just in case the mbean server connection
@@ -160,30 +153,38 @@ public class OperationTabControl extends TabControl
// instead of having half the widgets displayed.
_form.setVisible(false);
- ViewUtility.disposeChildren(_form.getBody());
- createComposites();
- setHeader();
+ ViewUtility.disposeChildren(_paramsComposite);
createParameterWidgets();
// Set button text and add appropriate listener to button.
// If there are no parameters and it is info operation, then operation gets executed
// and result is displayed
- List<ParameterData> params = opData.getParameters();
+ List<ParameterData> params = _opData.getParameters();
if (params != null && !params.isEmpty())
{
setButton(Constants.BUTTON_EXECUTE);
}
- else if (opData.getImpact() == Constants.OPERATION_IMPACT_ACTION)
+ else if (_opData.getImpact() == Constants.OPERATION_IMPACT_ACTION)
{
setButton(Constants.BUTTON_EXECUTE);
}
- else if (opData.getImpact() == Constants.OPERATION_IMPACT_INFO)
+ else if (_opData.getImpact() == Constants.OPERATION_IMPACT_INFO)
{
setButton(Constants.BUTTON_REFRESH);
executeAndShowResults();
}
_form.setVisible(true);
+ layout();
+ }
+
+ public void layout()
+ {
+ _headerComposite.layout();
+ if (_paramsComposite != null && !_paramsComposite.isDisposed())
+ {
+ _paramsComposite.layout();
+ }
_form.layout();
}
@@ -485,6 +486,7 @@ public class OperationTabControl extends TabControl
int width = 600;
int height = 400;
Shell shell = ViewUtility.createPopupShell(Constants.RESULT, width, height);
+ shell.setImage(ApplicationRegistry.getImage(Constants.CONSOLE_IMAGE));
ViewUtility.populateCompositeWithData(_toolkit, shell, result);
shell.open();
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java
new file mode 100644
index 0000000000..04688f1091
--- /dev/null
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java
@@ -0,0 +1,276 @@
+package org.apache.qpid.management.ui.views;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+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.jmx.MBeanUtility;
+import org.apache.qpid.management.ui.model.AttributeData;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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;
+
+/**
+ * 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
+ * @author Bhupendra Bhardwaj
+ */
+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>();
+
+
+ public QueueTypeTabControl(TabFolder tabFolder)
+ {
+ super(tabFolder, Constants.QUEUE);
+ createWidgets();
+ }
+
+ protected void createWidgets()
+ {
+ createHeaderComposite(getFormComposite());
+ createButtonsComposite(getFormComposite());
+ createListComposite();
+ }
+
+ @Override
+ public void refresh() throws Exception
+ {
+ 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())
+ {
+ sortQueuesByQueueDepth();
+ }
+ else if (_sortByConsumercountButton.getSelection())
+ {
+ sortQueuesByConsumerCount();
+ }
+ else
+ {
+ getListWidget().setItems(items);
+ }
+ }
+
+ private void selectDefaultSortingButton()
+ {
+ _sortByNameButton.setSelection(true);
+ _sortBySizeButton.setSelection(false);
+ _sortByConsumercountButton.setSelection(false);
+
+ _showTempQueues = false;
+ _showTempQueuesButton.setSelection(_showTempQueues);
+ }
+
+ protected void createListComposite()
+ {
+ // 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)
+ {
+ try
+ {
+ sortQueuesByConsumerCount();
+ }
+ 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);
+ }
+ }
+ });
+ }
+
+
+ private String[] getQueueItems(java.util.List<ManagedBean> list) throws Exception
+ {
+ 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)
+ {
+ if ((!_showTempQueues && mbean.isTempQueue()))
+ {
+ continue;
+ }
+ AttributeData data = MBeanUtility.getAttributeData(mbean, Constants.ATTRIBUTE_QUEUE_DEPTH);
+ String value = mbean.getName() + " (" + data.getValue().toString() + " KB)";
+ items.add(value);
+ //items[i] = mbean.getName() + " (" + value + " KB)";
+ getMBeansMap().put(value, mbean);
+ _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);
+
+ String[] items = new String[list.size()];
+ int i = 0;
+ for (AttributeData data : list)
+ {
+ ManagedBean mbean = _queueDepthMap.get(data);
+ String value = data.getValue().toString();
+ items[i++] = mbean.getName() + " (" + value + " KB)";
+ }
+ getListWidget().setItems(items);
+ }
+
+ private void sortQueuesByConsumerCount()
+ {
+ 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 + " )";
+ }
+ getListWidget().setItems(items);
+ }
+}
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java
index c21be5d68c..9625a58f20 100644
--- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java
@@ -309,66 +309,63 @@ public class ViewUtility
for (String itemName : itemNames)
{
OpenType itemType = data.getCompositeType().getType(itemName);
- if (compositeHolder.getData(itemName) == null)
- {
- Label keyLabel = toolkit.createLabel(compositeHolder, itemName, SWT.TRAIL);
- GridData layoutData = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
- layoutData.minimumWidth = 70;
- keyLabel.setLayoutData(layoutData);
+ Label keyLabel = toolkit.createLabel(compositeHolder, itemName, SWT.TRAIL);
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
+ layoutData.minimumWidth = 70;
+ keyLabel.setLayoutData(layoutData);
- if (itemType.isArray())
+ if (itemType.isArray())
+ {
+ OpenType type = ((ArrayType)itemType).getElementOpenType();
+ // If Byte array and mimetype is text, convert to text string
+ if (type.getClassName().equals(Byte.class.getName()))
{
- OpenType type = ((ArrayType)itemType).getElementOpenType();
- // If Byte array and mimetype is text, convert to text string
- if (type.getClassName().equals(Byte.class.getName()))
+ String mimeType = null;
+ String encoding = null;
+ if (data.containsKey("MimeType"))
{
- String mimeType = null;
- String encoding = null;
- if (data.containsKey("MimeType"))
+ mimeType = (String)data.get("MimeType");
+ encoding = (String)data.get("Encoding");
+ if (encoding == null || encoding.length() == 0)
{
- mimeType = (String)data.get("MimeType");
- encoding = (String)data.get("Encoding");
- if (encoding == null || encoding.length() == 0)
- {
- encoding = Charset.defaultCharset().name();
- }
-
- if (mimeType.equals("text/plain"))
- {
- displayByteArray(toolkit, compositeHolder, data, itemName, encoding);
- }
+ encoding = Charset.defaultCharset().name();
}
- else
- {
- displayNotSupportedDataType(toolkit, compositeHolder);
- }
}
- // If array of any other supported type, show as a list of String array
- else if (SUPPORTED_ARRAY_DATATYPES.contains(type.getClassName()))
+
+ if ("text/plain".equals(mimeType))
{
- displayArrayItem(compositeHolder, data, itemName);
+ convertByteArray(toolkit, compositeHolder, data, itemName, encoding);
}
else
{
- displayNotSupportedDataType(toolkit, compositeHolder);
- }
+ setNotSupportedDataType(toolkit, compositeHolder);
+ }
}
- else if (itemType instanceof TabularType)
+ // If array of any other supported type, show as a list of String array
+ else if (SUPPORTED_ARRAY_DATATYPES.contains(type.getClassName()))
{
- Composite composite = toolkit.createComposite(compositeHolder, SWT.NONE);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1));
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- composite.setLayout(layout);
- createTabularDataHolder(toolkit, composite, (TabularDataSupport)data.get(itemName));
+ convertArrayItemForDisplay(compositeHolder, data, itemName);
}
else
{
- Text valueText = toolkit.createText(compositeHolder, String.valueOf(data.get(itemName)), SWT.READ_ONLY | SWT.BORDER);
- valueText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1));
+ setNotSupportedDataType(toolkit, compositeHolder);
}
}
+ else if (itemType instanceof TabularType)
+ {
+ Composite composite = toolkit.createComposite(compositeHolder, SWT.NONE);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1));
+ layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+ createTabularDataHolder(toolkit, composite, (TabularDataSupport)data.get(itemName));
+ }
+ else
+ {
+ Text valueText = toolkit.createText(compositeHolder, String.valueOf(data.get(itemName)), SWT.READ_ONLY | SWT.BORDER);
+ valueText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1));
+ }
}
// layout the composite after creating new widgets.
@@ -376,7 +373,7 @@ public class ViewUtility
} //end of method
- private static void displayByteArray(FormToolkit toolkit, Composite compositeHolder, CompositeData data, String itemName, String encoding)
+ private static void convertByteArray(FormToolkit toolkit, Composite compositeHolder, CompositeData data, String itemName, String encoding)
{
Byte[] arrayItems = (Byte[])data.get(itemName);
byte[] byteArray = new byte[arrayItems.length];
@@ -486,7 +483,7 @@ public class ViewUtility
* @param data - containing the array item value
* @param itemName - item name
*/
- private static void displayArrayItem(Composite compositeHolder, CompositeData data, String itemName)
+ private static void convertArrayItemForDisplay(Composite compositeHolder, CompositeData data, String itemName)
{
Object[] arrayItems = (Object[])data.get(itemName);
String[] items = new String[arrayItems.length];
@@ -501,9 +498,9 @@ public class ViewUtility
list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
}
- private static void displayNotSupportedDataType(FormToolkit toolkit, Composite compositeHolder)
+ private static void setNotSupportedDataType(FormToolkit toolkit, Composite compositeHolder)
{
- Text valueText = toolkit.createText(compositeHolder, "Format is not supported to be displayed", SWT.READ_ONLY);
+ Text valueText = toolkit.createText(compositeHolder, "--- Content can not be displayed ---", SWT.READ_ONLY);
valueText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1));
}