1 22 package org.objectweb.joram.client.tools.admin; 23 24 import java.util.*; 25 import javax.swing.*; 26 import javax.swing.tree.*; 27 28 import org.objectweb.joram.client.jms.admin.*; 29 30 class MessageTreeNode extends DefaultMutableTreeNode 31 implements AdminTreeNode { 32 33 private AdminController c; 34 35 private String msgId; 36 37 public MessageTreeNode(AdminController c, 38 String msgId) { 39 super(msgId); 40 this.c = c; 41 this.msgId = msgId; 42 } 43 44 47 public String getDescription() { 48 return ""; 49 } 50 51 55 public ImageIcon getImageIcon() { 56 return null; 57 } 58 59 63 public void refresh(DefaultTreeModel treeModel) { 64 65 } 66 67 public JPopupMenu getContextMenu() { 68 JPopupMenu popup = new JPopupMenu("Message"); 69 70 DeleteMessageAction dma = new DeleteMessageAction(); 71 if (! c.isAdminConnected()) 72 dma.setEnabled(false); 73 popup.add(new JMenuItem(dma)); 74 75 return popup; 76 } 77 78 public final String getMessageId() { 79 return msgId; 80 } 81 82 public boolean getAllowsChildren() { 83 return false; 84 } 85 86 private class DeleteMessageAction extends AbstractAction { 87 88 public DeleteMessageAction() { 89 super("Delete", AdminToolConstants.trashIcon); 90 } 91 92 public void actionPerformed(java.awt.event.ActionEvent e) { 93 try { 94 Object [] options = { "OK", "CANCEL" }; 95 int res = JOptionPane.showOptionDialog( 96 AdminTool.getInstance(), 97 "You are about to permanently remove this message " + 98 "from this subscription. Please click OK to proceed.", 99 "Warning", JOptionPane.DEFAULT_OPTION, 100 JOptionPane.WARNING_MESSAGE, null, options, options[0]); 101 if (res == 0) 102 c.deleteMessage(MessageTreeNode.this); 103 } catch (Exception x) { 104 x.printStackTrace(); 105 JOptionPane.showMessageDialog(null, x.getMessage()); 106 } 107 } 108 } 109 } 110 | Popular Tags |