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/07/21 11:17:24 UTC

svn commit: r796206 - /qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java

Author: robbie
Date: Tue Jul 21 09:17:23 2009
New Revision: 796206

URL: http://svn.apache.org/viewvc?rev=796206&view=rev
Log:
QPID-1968: add deleteMessages() support to the QueueOperations tab

Modified:
    qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java

Modified: qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java?rev=796206&r1=796205&r2=796206&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java (original)
+++ qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java Tue Jul 21 09:17:23 2009
@@ -417,6 +417,30 @@
         {
             copyMessagesButton = null;
         }
+
+        final Button deleteMessagesButton;
+        if(_ApiVersion.greaterThanOrEqualTo(1, 3))//if the server supports Qpid JMX API 1.3
+        {
+            deleteMessagesButton = _toolkit.createButton(buttonsComposite, "Delete Message(s) ...", SWT.PUSH);
+            deleteMessagesButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
+            deleteMessagesButton.setEnabled(false);
+            deleteMessagesButton.addSelectionListener(new SelectionAdapter()
+            {
+                public void widgetSelected(SelectionEvent e)
+                {
+                    if (_table.getSelectionIndex() == -1)
+                    {
+                        return;
+                    }
+
+                    deleteMessages(deleteMessagesButton.getShell());
+                }
+            });
+        }
+        else
+        {
+            deleteMessagesButton = null;
+        }
                 
         final Button clearQueueButton = _toolkit.createButton(buttonsComposite, "Clear Queue", SWT.PUSH);
         clearQueueButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
@@ -504,6 +528,10 @@
                     {
                         copyMessagesButton.setEnabled(false);
                     }
+                    if(deleteMessagesButton != null)
+                    {
+                        deleteMessagesButton.setEnabled(false);
+                    }
 
                     return;
                 }
@@ -514,6 +542,10 @@
                     {
                         copyMessagesButton.setEnabled(true);
                     }
+                    if(deleteMessagesButton != null)
+                    {
+                        deleteMessagesButton.setEnabled(true);
+                    }
                     
                     final CompositeData selectedMsg = (CompositeData)_table.getItem(selectionIndex).getData();
                     Boolean redelivered = (Boolean) selectedMsg.get(MSG_REDELIVERED);
@@ -850,6 +882,75 @@
         shell.open();
     }
     
+    private void deleteMessages(final Shell parent)
+    {
+        final ArrayList<Long> rangeStarts = new ArrayList<Long>();
+        final ArrayList<Long> rangeEnds = new ArrayList<Long>();
+
+        gatherSelectedAMQMsgIDRanges(rangeStarts,rangeEnds);
+        String rangeString = getRangesString(rangeStarts,rangeEnds);
+        
+        final Shell shell = ViewUtility.createModalDialogShell(parent, "Delete Messages");
+
+        Composite idComposite = _toolkit.createComposite(shell, SWT.NONE);
+        idComposite.setBackground(shell.getBackground());
+        idComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+        idComposite.setLayout(new GridLayout());
+        
+        _toolkit.createLabel(idComposite,"Delete message(s) with AMQ ID:").setBackground(shell.getBackground());
+        _toolkit.createLabel(idComposite,rangeString).setBackground(shell.getBackground());
+
+        Composite okCancelButtonsComp = _toolkit.createComposite(shell);
+        okCancelButtonsComp.setBackground(shell.getBackground());
+        okCancelButtonsComp.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true));
+        okCancelButtonsComp.setLayout(new GridLayout(2,false));
+        
+        Button okButton = _toolkit.createButton(okCancelButtonsComp, "OK", SWT.PUSH);
+        okButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
+        Button cancelButton = _toolkit.createButton(okCancelButtonsComp, "Cancel", SWT.PUSH);
+        cancelButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
+        
+        okButton.addSelectionListener(new SelectionAdapter()
+        {
+            public void widgetSelected(SelectionEvent e)
+            {
+                shell.dispose();
+                
+                try
+                {
+                    for(int i=0 ; i < rangeStarts.size() ; i++)
+                    {
+                        Long from = rangeStarts.get(i);
+                        Long to = rangeEnds.get(i);
+                        
+                        _qmb.deleteMessages(Long.valueOf(from), Long.valueOf(to));
+                    }
+
+                    ViewUtility.operationResultFeedback(null, "Messages deleted", null);
+                }
+                catch (Exception e4)
+                {
+                    ViewUtility.operationFailedStatusBarMessage("Error deleting messages");
+                    MBeanUtility.handleException(_mbean, e4);
+                }
+
+                refresh(_mbean);
+            }
+        });
+
+        cancelButton.addSelectionListener(new SelectionAdapter()
+        {
+            public void widgetSelected(SelectionEvent e)
+            {
+                shell.dispose();
+            }
+        });
+
+        shell.setDefaultButton(okButton);
+        shell.pack();
+        shell.open();
+    }
+    
     private void gatherSelectedAMQMsgIDRanges(ArrayList<Long> starts, ArrayList<Long> ends)
     {
         SortedSet<Long> amqIDs = new TreeSet<Long>();



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