1 47 48 49 package org.exolab.jms.tools.admin; 50 51 import java.awt.Rectangle ; 52 import java.text.SimpleDateFormat ; 53 54 import javax.swing.JPopupMenu ; 55 import javax.swing.JTree ; 56 import javax.swing.tree.DefaultMutableTreeNode ; 57 import javax.swing.tree.DefaultTreeModel ; 58 59 60 67 abstract public class OpenJMSDestination extends DefaultMutableTreeNode 68 implements OpenJMSNode { 69 70 protected String destinationName_; 72 73 protected boolean isLeaf_; 75 76 protected boolean isExplored_ = false; 78 79 protected JPopupMenu commands_ = null; 81 82 protected boolean commandsCreated_ = false; 84 85 static protected SimpleDateFormat dateFormat_; 87 88 static protected JTree tree_ = null; 90 91 92 103 public OpenJMSDestination(String destinationName, JTree tree) { 104 destinationName_ = destinationName; 105 isLeaf_ = false; 106 if (!commandsCreated_) { 107 tree_ = tree; 108 createCommands(); 109 commandsCreated_ = true; 110 dateFormat_ = new SimpleDateFormat ("dd/MM/yyyy HH:mm:ss"); 111 dateFormat_.setLenient(false); 112 } 113 } 114 115 116 123 abstract protected void createCommands(); 124 125 131 public boolean getAllowsChildren() { 132 return true; 133 } 134 135 142 public boolean isLeaf() { 143 return isLeaf_; 144 } 145 146 154 public void displayCommands(Rectangle loc) { 155 double x; 156 double y; 157 158 x = loc.getX(); 159 y = loc.getY(); 160 y += loc.getHeight(); 161 162 commands_.show(tree_, (int) x, (int) y); 163 } 164 165 171 public String toString() { 172 return destinationName_; 173 } 174 175 180 protected void refresh() { 181 DefaultTreeModel model = (DefaultTreeModel ) tree_.getModel(); 182 model.nodeStructureChanged((DefaultMutableTreeNode ) this); 183 } 184 185 191 static protected OpenJMSDestination getInstanceSelected() { 192 Object loc = tree_.getLastSelectedPathComponent(); 193 return (OpenJMSDestination) loc; 194 } 195 } 196 | Popular Tags |