View Javadoc
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: OpenJMSConsumerFolder.java,v 1.3 2003/08/17 01:32:27 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 durable consumers for a particular 65 * server. 66 * 67 * @version $Revision: 1.3 $ $Date: 2003/08/17 01:32:27 $ 68 * @author <a href="mailto:jima@exolab.org">Jim Alateras</a> 69 */ 70 public class OpenJMSConsumerFolder 71 extends DefaultMutableTreeNode 72 implements OpenJMSNode { 73 74 // A reference to the tree this node belongs to. 75 static private JTree tree_ = null; 76 77 // A flag indicating if the menu has been created yet. 78 static private boolean commandsCreated_ = false; 79 80 // The popup menu for all consumers. 81 static private JPopupMenu commands_ = null; 82 83 /*** 84 * Construct an instance of this folder given the parent node. 85 * 86 * @param tree - The parent tree this consumer belons to. 87 */ 88 public OpenJMSConsumerFolder(JTree tree) { 89 if (!commandsCreated_) { 90 tree_ = tree; 91 createCommands(); 92 commandsCreated_ = true; 93 } 94 } 95 96 /*** 97 * Create the menu for all consumers and set up the Action events for 98 * each menu item. Since menus are shared, the callbacks called are 99 * static. Once a menu is slected, the slected node can be determined 100 * from the parent object. 101 * 102 */ 103 protected void createCommands() { 104 commands_ = new JPopupMenu(); 105 106 JMenuItem m = new JMenuItem("Create Consumer"); 107 m.addActionListener(new ActionListener() { 108 109 public void actionPerformed(ActionEvent evt) { 110 createConsumer(); 111 } 112 } 113 ); 114 commands_.add(m); 115 } 116 117 /*** 118 * Consumer folders are allowed on this node 119 * 120 * @return boolean Always returns true. 121 */ 122 public boolean getAllowsChildren() { 123 return true; 124 } 125 126 127 /*** 128 * The consumer folder is not a leaf node 129 * 130 * @return boolean Always returns false. 131 * 132 */ 133 public boolean isLeaf() { 134 return false; 135 } 136 137 /*** 138 * This node has been right clicked. The locations of this node is given 139 * by the loc object. Use this location to popup the consumer message 140 * menu. 141 * 142 * @param The location of this Consumer node. 143 * 144 */ 145 public void displayCommands(Rectangle loc) { 146 double x; 147 double y; 148 149 x = loc.getX(); 150 y = loc.getY(); 151 y += loc.getHeight(); 152 153 commands_.show(tree_, (int) x, (int) y); 154 } 155 156 /*** 157 * This node has changed. Inform the parent tree that it needs to be 158 * re-drawn. 159 * 160 */ 161 private void refresh() { 162 DefaultTreeModel model = (DefaultTreeModel) tree_.getModel(); 163 model.nodeStructureChanged((DefaultMutableTreeNode) this); 164 } 165 166 /*** 167 * Update all children belonging to this node. 168 * 169 */ 170 public void update() { 171 } 172 173 /*** 174 * The unique name of this queue/topic. 175 * 176 * @return String the queue/topic name. 177 * 178 */ 179 public String toString() { 180 return "Consumers"; 181 } 182 183 /*** 184 * Get the particular instance of the consumer that has been selected. 185 * 186 * @return OpenJMSConsumerFolder the instance selected. 187 * 188 */ 189 static private OpenJMSConsumerFolder getInstanceSelected() { 190 Object loc = tree_.getLastSelectedPathComponent(); 191 return (OpenJMSConsumerFolder) loc; 192 } 193 194 /*** 195 * Delete the selected consumer object. Display a confirmation dialog 196 * and wait for its return. If the user has confirmed the action, first 197 * delete it from the database and if that is successful remove the node 198 * from the tree. 199 * 200 */ 201 static private void createConsumer() { 202 } 203 } // End OpenJMSConsumerFolder

This page was automatically generated by Maven