1 45 package org.exolab.jms.tools.admin; 46 47 import java.awt.Rectangle ; 48 import java.text.SimpleDateFormat ; 49 50 import javax.swing.JPopupMenu ; 51 import javax.swing.JTree ; 52 import javax.swing.tree.DefaultMutableTreeNode ; 53 import javax.swing.tree.DefaultTreeModel ; 54 55 56 64 public abstract class OpenJMSObject extends DefaultMutableTreeNode 65 implements OpenJMSNode { 66 67 protected String _name; 69 70 protected boolean _isLeaf; 72 73 protected boolean _isExplored = false; 75 76 protected JPopupMenu _commands = null; 78 79 protected boolean _commandsCreated = false; 81 82 static protected SimpleDateFormat _dateFormat; 84 85 static protected JTree _tree = null; 87 88 89 100 public OpenJMSObject(String destinationName, JTree tree) { 101 _name = destinationName; 102 _isLeaf = false; 103 if (!_commandsCreated) { 104 _tree = tree; 105 createCommands(); 106 _commandsCreated = true; 107 _dateFormat = new SimpleDateFormat ("dd/MM/yyyy HH:mm:ss"); 108 _dateFormat.setLenient(false); 109 } 110 } 111 112 113 120 abstract protected void createCommands(); 121 122 127 public boolean getAllowsChildren() { 128 return true; 129 } 130 131 137 public boolean isLeaf() { 138 return _isLeaf; 139 } 140 141 148 public void displayCommands(Rectangle loc) { 149 double x; 150 double y; 151 152 x = loc.getX(); 153 y = loc.getY(); 154 y += loc.getHeight(); 155 156 _commands.show(_tree, (int) x, (int) y); 157 } 158 159 164 public String toString() { 165 return _name; 166 } 167 168 172 protected void refresh() { 173 DefaultTreeModel model = (DefaultTreeModel ) _tree.getModel(); 174 model.nodeStructureChanged((DefaultMutableTreeNode ) this); 175 } 176 177 182 static protected OpenJMSObject getInstanceSelected() { 183 Object loc = _tree.getLastSelectedPathComponent(); 184 return (OpenJMSObject) loc; 185 } 186 } 187 | Popular Tags |