1 /***
2 * Redistribution and use of this software and associated documentation
3 * ("Software"), with or without modification, are permitted provided
4 * that the following conditions are met:
5 *
6 * 1. Redistributions of source code must retain copyright
7 * statements and notices. Redistributions must also contain a
8 * copy of this document.
9 *
10 * 2. Redistributions in binary form must reproduce the
11 * above copyright notice, this list of conditions and the
12 * following disclaimer in the documentation and/or other
13 * materials provided with the distribution.
14 *
15 * 3. The name "Exolab" must not be used to endorse or promote
16 * products derived from this Software without prior written
17 * permission of Exoffice Technologies. For written permission,
18 * please contact info@exolab.org.
19 *
20 * 4. Products derived from this Software may not be called "Exolab"
21 * nor may "Exolab" appear in their names without prior written
22 * permission of Exoffice Technologies. Exolab is a registered
23 * trademark of Exoffice Technologies.
24 *
25 * 5. Due credit should be given to the Exolab Project
26 * (http://www.exolab.org/).
27 *
28 * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
29 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32 * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39 * OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * Copyright 2000 (C) Exoffice Technologies Inc. All Rights Reserved.
42 *
43 * $Id: OpenJMSQueueFolder.java,v 1.1 2004/11/26 01:51:15 tanderson Exp $
44 *
45 * Date Author Changes
46 * $Date jimm Created
47 */
48
49
50 package org.exolab.jms.tools.admin;
51
52 import java.awt.Rectangle;
53 import java.awt.event.ActionEvent;
54 import java.awt.event.ActionListener;
55
56 import javax.swing.JMenuItem;
57 import javax.swing.JPopupMenu;
58 import javax.swing.JTree;
59 import javax.swing.tree.DefaultMutableTreeNode;
60 import javax.swing.tree.DefaultTreeModel;
61
62
63 /***
64 * This is a folder node, which holds all administered topics
65 *
66 * @version $Revision: 1.1 $ $Date: 2004/11/26 01:51:15 $
67 * @author <a href="mailto:jima@exolab.org">Jim Alateras</a>
68 **/
69 public class OpenJMSQueueFolder
70 extends DefaultMutableTreeNode
71 implements OpenJMSNode {
72
73
74 static private JTree tree_ = null;
75
76
77 static private boolean commandsCreated_ = false;
78
79
80 static private JPopupMenu commands_ = null;
81
82 /***
83 * Construct an instance of this folder given the parent node.
84 *
85 * @param tree - The parent tree this consumer belons to.
86 */
87 public OpenJMSQueueFolder(JTree tree) {
88 if (!commandsCreated_) {
89 tree_ = tree;
90 createCommands();
91 commandsCreated_ = true;
92 }
93 }
94
95 /***
96 * Create the menu for all consumers and set up the Action events for
97 * each menu item. Since menus are shared, the callbacks called are
98 * static. Once a menu is slected, the slected node can be determined
99 * from the parent object.
100 *
101 */
102 protected void createCommands() {
103 commands_ = new JPopupMenu();
104
105 JMenuItem m = new JMenuItem("Create Queue");
106 m.addActionListener(new ActionListener() {
107
108 public void actionPerformed(ActionEvent evt) {
109 createQueue();
110 }
111 }
112 );
113 commands_.add(m);
114 }
115
116 /***
117 * Queue folders are allowed on this node
118 *
119 * @return boolean Always returns true.
120 */
121 public boolean getAllowsChildren() {
122 return true;
123 }
124
125
126 /***
127 * The consumer folder is not a leaf node
128 *
129 * @return boolean Always returns false.
130 *
131 */
132 public boolean isLeaf() {
133 return false;
134 }
135
136 /***
137 * This node has been right clicked. The locations of this node is given
138 * by the loc object. Use this location to popup the consumer message
139 * menu.
140 *
141 * @param The location of this Queue node.
142 *
143 */
144 public void displayCommands(Rectangle loc) {
145 double x;
146 double y;
147
148 x = loc.getX();
149 y = loc.getY();
150 y += loc.getHeight();
151
152 commands_.show(tree_, (int) x, (int) y);
153 }
154
155 /***
156 * This node has changed. Inform the parent tree that it needs to be
157 * re-drawn.
158 *
159 */
160 private void refresh() {
161 DefaultTreeModel model = (DefaultTreeModel) tree_.getModel();
162 model.nodeStructureChanged((DefaultMutableTreeNode) this);
163 }
164
165 /***
166 * Update all children belonging to this node.
167 *
168 */
169 public void update() {
170 }
171
172 /***
173 * The unique name of this queue/topic.
174 *
175 * @return String the queue/topic name.
176 *
177 */
178 public String toString() {
179 return "Queues";
180 }
181
182 /***
183 * Get the particular instance of the consumer that has been selected.
184 *
185 * @return OpenJMSQueueFolder the instance selected.
186 *
187 */
188 static private OpenJMSQueueFolder getInstanceSelected() {
189 Object loc = tree_.getLastSelectedPathComponent();
190 return (OpenJMSQueueFolder) loc;
191 }
192
193 /***
194 * Delete the selected consumer object. Display a confirmation dialog
195 * and wait for its return. If the user has confirmed the action, first
196 * delete it from the database and if that is successful remove the node
197 * from the tree.
198 *
199 */
200 static private void createQueue() {
201 }
202 }