KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > client > tools > admin > QueueTreeNode


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA.
18  *
19  * Initial developer(s): ScalAgent DT
20  * Contributor(s):
21  */

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 JavaDoc e) {
65       try {
66         Object JavaDoc[] 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 JavaDoc 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