1 15 16 package org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel; 17 18 import org.apache.commons.collections.iterators.ArrayIterator; 19 import org.apache.ojb.broker.metadata.ClassDescriptor; 20 import org.apache.ojb.broker.metadata.CollectionDescriptor; 21 import org.apache.ojb.broker.metadata.DescriptorRepository; 22 import org.apache.ojb.broker.metadata.FieldDescriptor; 23 import org.apache.ojb.broker.metadata.IndexDescriptor; 24 import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor; 25 26 27 31 public class OjbMetaClassDescriptorNode extends OjbMetaTreeNode implements javax.swing.tree.MutableTreeNode 32 { 33 34 private static java.util.ArrayList supportedActions = new java.util.ArrayList (); 35 36 37 private ClassDescriptor cld; 38 39 public OjbMetaClassDescriptorNode (DescriptorRepository pRepository, 40 OjbMetaDataTreeModel pTreeModel, 41 OjbMetaRootNode pparent, 42 ClassDescriptor pCld) 43 { 44 super(pRepository, pTreeModel, pparent); 45 this.cld = pCld; 46 } 47 48 public boolean getAllowsChildren () 49 { 50 return true; 51 } 52 53 public Object getAttribute (String key) 54 { 55 return null; 56 } 57 58 public Class getPropertyEditorClass () 59 { 60 return null; 61 } 62 63 public boolean isLeaf () 64 { 65 return false; 66 } 67 68 public void setAttribute (String key, Object value) 69 { 70 71 } 72 73 77 protected boolean _load () 78 { 79 java.util.ArrayList newChildren = new java.util.ArrayList (); 80 81 82 java.util.Iterator it = cld.getCollectionDescriptors().iterator(); 93 while (it.hasNext()) 94 { 95 CollectionDescriptor collDesc = (CollectionDescriptor)it.next(); 96 newChildren.add(new OjbMetaCollectionDescriptorNode( 97 this.getOjbMetaTreeModel().getRepository(), 98 this.getOjbMetaTreeModel(), 99 this, 100 collDesc)); 101 102 } 103 104 106 it = cld.getExtentClassNames().iterator(); 107 while (it.hasNext()) 108 { 109 String extentClassName = (String )it.next(); 110 newChildren.add(new OjbMetaExtentClassNode( 111 this.getOjbMetaTreeModel().getRepository(), 112 this.getOjbMetaTreeModel(), 113 this, 114 extentClassName)); 115 116 } 117 118 if (cld.getFieldDescriptions() != null) 120 { 121 it = new ArrayIterator(cld.getFieldDescriptions()); 122 while (it.hasNext()) 123 { 124 FieldDescriptor fieldDesc = (FieldDescriptor)it.next(); 125 newChildren.add(new OjbMetaFieldDescriptorNode( 126 this.getOjbMetaTreeModel().getRepository(), 127 this.getOjbMetaTreeModel(), 128 this, 129 fieldDesc)); 130 } 131 } 132 else 133 { 134 System.out.println(cld.getClassNameOfObject() + " does not have field descriptors"); 135 } 136 137 it = cld.getIndexes().iterator(); 139 while (it.hasNext()) 140 { 141 IndexDescriptor indexDesc = (IndexDescriptor)it.next(); 142 newChildren.add(new OjbMetaIndexDescriptorNode( 143 this.getOjbMetaTreeModel().getRepository(), 144 this.getOjbMetaTreeModel(), 145 this, 146 indexDesc)); 147 148 } 149 150 it = cld.getObjectReferenceDescriptors().iterator(); 152 while (it.hasNext()) 153 { 154 ObjectReferenceDescriptor objRefDesc = (ObjectReferenceDescriptor)it.next(); 155 newChildren.add(new OjbMetaObjectReferenceDescriptorNode( 156 this.getOjbMetaTreeModel().getRepository(), 157 this.getOjbMetaTreeModel(), 158 this, 159 objRefDesc)); 160 161 } 162 this.alChildren = newChildren; 164 this.getOjbMetaTreeModel().nodeStructureChanged(this); 165 return true; 166 } 167 168 public String toString() 169 { 170 return "ClassDescriptor:" + this.cld.getClassNameOfObject(); 171 } 173 174 177 public java.util.Iterator getActions() 178 { 179 return supportedActions.iterator(); 180 } 181 182 185 public boolean actionListCachable() 186 { 187 return true; 188 } 189 190 public boolean actionListStatic() 191 { 192 return true; 193 } 194 195 199 public void insert(javax.swing.tree.MutableTreeNode child, int index) 200 { 201 } 202 203 207 public void remove(javax.swing.tree.MutableTreeNode node) 208 { 209 } 210 211 214 public void remove(int index) 215 { 216 } 217 218 221 public void removeFromParent() 222 { 223 } 224 225 228 public void setParent(javax.swing.tree.MutableTreeNode newParent) 229 { 230 } 231 232 235 public void setUserObject(Object object) 236 { 237 } 238 239 244 public Object getAssociatedDescriptor() 245 { 246 return cld; 247 } 248 249 } 250 | Popular Tags |