1 22 package org.objectweb.joram.client.tools.admin; 23 24 import javax.swing.*; 25 import javax.swing.tree.*; 26 27 import org.objectweb.joram.client.jms.Queue; 28 29 class QueueTreeNode extends DestinationTreeNode { 30 31 private MessageRootTreeNode msgRoot; 32 33 private Queue queue; 34 35 public QueueTreeNode(AdminController c, 36 Queue dest) { 37 super(c, dest); 38 msgRoot = new MessageRootTreeNode(); 39 queue = dest; 40 add(msgRoot); 41 } 42 43 public JPopupMenu getContextMenu() { 44 JPopupMenu popup = new JPopupMenu("Queue"); 45 46 ClearQueueAction cqa = new ClearQueueAction(); 47 if (! c.isAdminConnected()) 48 cqa.setEnabled(false); 49 popup.add(new JMenuItem(cqa)); 50 51 return popup; 52 } 53 54 public final MessageRootTreeNode getMessageRootTreeNode() { 55 return msgRoot; 56 } 57 58 private class ClearQueueAction extends AbstractAction { 59 60 public ClearQueueAction() { 61 super("Clear", AdminToolConstants.trashIcon); 62 } 63 64 public void actionPerformed(java.awt.event.ActionEvent e) { 65 try { 66 Object [] options = { "OK", "CANCEL" }; 67 int res = JOptionPane.showOptionDialog( 68 AdminTool.getInstance(), 69 "You are about to permanently remove all the messages " + 70 "from this queue. Please click OK to proceed.", 71 "Warning", JOptionPane.DEFAULT_OPTION, 72 JOptionPane.WARNING_MESSAGE, null, options, options[0]); 73 if (res == 0) 74 c.clearQueue(QueueTreeNode.this); 75 } catch (Exception x) { 76 x.printStackTrace(); 77 JOptionPane.showMessageDialog(null, x.getMessage()); 78 } 79 } 80 } 81 82 public final Queue getQueue() { 83 return queue; 84 } 85 } 86 | Popular Tags |