From 888d59cee82f47404ca850bf8970712debeaaea1 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Wed, 22 Jul 2009 10:48:30 +0000 Subject: QPID-1999: ensure the Clear button in each VirtualHost Notifications area only clears the Notifications for that VirtualHost instead of all Notifications for the entire server. Add synchronized blocks to protect from concurrent modifications by the update thread and the clear action. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@796663 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/management/ui/jmx/JMXServerRegistry.java | 5 +++ .../ui/views/NotificationsTabControl.java | 50 ++++++++++++++++------ .../ui/views/VHNotificationsTabControl.java | 40 +++++++++++------ 3 files changed, 69 insertions(+), 26 deletions(-) (limited to 'qpid/java') diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java index f280e20fdd..575b98d48a 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java @@ -255,6 +255,11 @@ public class JMXServerRegistry extends ServerRegistry //iterate over all the notification lists for mbeans with subscribed notifications for (List list : _notificationsMap.values()) { + if(list == null || list.isEmpty()) + { + continue; + } + //Check the source vhost of the first notification NotificationObject notification = list.get(0); diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java index 516b0b3bbf..926bfa2a48 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java @@ -28,6 +28,7 @@ import static org.apache.qpid.management.ui.Constants.FONT_ITALIC; import static org.apache.qpid.management.ui.Constants.SUBSCRIBE_BUTTON; import static org.apache.qpid.management.ui.Constants.UNSUBSCRIBE_BUTTON; +import java.util.ArrayList; import java.util.List; import org.apache.qpid.management.ui.ApplicationRegistry; @@ -163,8 +164,8 @@ public class NotificationsTabControl extends VHNotificationsTabControl protected void addButtons() { Composite composite = _toolkit.createComposite(_form.getBody(), SWT.NONE); - composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); + composite.setLayout(new GridLayout(2,false)); // Add Clear Button _clearButton = _toolkit.createButton(composite, BUTTON_CLEAR, SWT.PUSH | SWT.CENTER); @@ -173,17 +174,36 @@ public class NotificationsTabControl extends VHNotificationsTabControl gridData.widthHint = 80; _clearButton.setLayoutData(gridData); _clearButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - if (_mbean == null) - return; - - IStructuredSelection ss = (IStructuredSelection)_tableViewer.getSelection(); - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); + { + public void widgetSelected(SelectionEvent e) + { + if (_mbean == null) + { + return; + } + + ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); + IStructuredSelection ss = (IStructuredSelection)_tableViewer.getSelection(); + if(!ss.isEmpty()) + { serverRegistry.clearNotifications(_mbean, ss.toList()); } - }); + else if(_notifications != null) + { + synchronized(this) + { + List newList = new ArrayList(); + newList.addAll(_notifications); + serverRegistry.clearNotifications(_mbean, newList); + } + } + + refresh(); + } + }); + //add description + Label desc = _toolkit.createLabel(composite,"Clears the selected Notifications, or all if none are selected"); + desc.setLayoutData(new GridData(SWT.LEFT,SWT.CENTER, false, false)); } @Override @@ -348,8 +368,10 @@ public class NotificationsTabControl extends VHNotificationsTabControl { ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); List newList = serverRegistry.getNotifications(_mbean); - _notifications = newList; - - _tableViewer.setInput(_notifications); + synchronized(this) + { + _notifications = newList; + _tableViewer.setInput(_notifications); + } } } diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java index 691ceedcf4..5ebe0013bf 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java @@ -119,8 +119,8 @@ public class VHNotificationsTabControl extends TabControl protected void addButtons() { Composite composite = _toolkit.createComposite(_form.getBody(), SWT.NONE); - composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); + composite.setLayout(new GridLayout(2,false)); // Add Clear Button _clearButton = _toolkit.createButton(composite, BUTTON_CLEAR, SWT.PUSH | SWT.CENTER); @@ -129,16 +129,29 @@ public class VHNotificationsTabControl extends TabControl gridData.widthHint = 80; _clearButton.setLayoutData(gridData); _clearButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - //TODO : Get selected rows and clear those - IStructuredSelection ss = (IStructuredSelection)_tableViewer.getSelection(); - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); + { + public void widgetSelected(SelectionEvent e) + { + ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); + IStructuredSelection ss = (IStructuredSelection)_tableViewer.getSelection(); + if(!ss.isEmpty()) + { serverRegistry.clearNotifications(null, ss.toList()); - refresh(); } - }); + else if(_notifications != null) + { + synchronized(this) + { + serverRegistry.clearNotifications(null, _notifications); + } + } + + refresh(); + } + }); + //add description + Label desc = _toolkit.createLabel(composite,"Clears the selected Notifications, or all if none are selected"); + desc.setLayoutData(new GridData(SWT.LEFT,SWT.CENTER, false, false)); } /** @@ -446,9 +459,12 @@ public class VHNotificationsTabControl extends TabControl ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); List newList = serverRegistry.getNotifications(virtualhost); - _notifications = newList; - _tableViewer.setInput(_notifications); + synchronized(this) + { + _notifications = newList; + _tableViewer.setInput(_notifications); + } } } -- cgit v1.2.1