1 package org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel; 2 3 import org.apache.ojb.broker.metadata.ClassDescriptor; 4 import org.apache.ojb.broker.metadata.CollectionDescriptor; 5 import org.apache.ojb.broker.metadata.DescriptorRepository; 6 import org.apache.commons.collections.iterators.ArrayIterator; 7 8 public class OjbMetaCollectionDescriptorNode extends OjbMetaTreeNode 9 { 10 private static java.util.ArrayList supportedActions = new java.util.ArrayList (); 11 12 13 private CollectionDescriptor collectionDescriptor; 14 28 public OjbMetaCollectionDescriptorNode( 29 DescriptorRepository pRepository, 30 OjbMetaDataTreeModel pTreeModel, 31 OjbMetaTreeNode pparent, 32 CollectionDescriptor pCollectionDescriptor) 33 { 34 super(pRepository, pTreeModel, pparent); 35 this.collectionDescriptor = pCollectionDescriptor; 36 } 37 38 41 protected boolean _load() 42 { 43 java.util.ArrayList newChildren = new java.util.ArrayList (); 44 ClassDescriptor itemClass = this.getRepository().getDescriptorFor(this.collectionDescriptor.getItemClassName()); 45 newChildren.add(getOjbMetaTreeModel().getClassDescriptorNodeForClassDescriptor(itemClass)); 46 47 System.err.println(toString()); 49 java.util.Iterator it; 50 try 51 { 52 it = new ArrayIterator(collectionDescriptor.getFksToThisClass()); 53 while (it.hasNext()) 54 newChildren.add(new javax.swing.tree.DefaultMutableTreeNode ("FksToThisClass: " + it.next().toString())); 55 it = new ArrayIterator(collectionDescriptor.getFksToItemClass()); 56 while (it.hasNext()) 57 newChildren.add(new javax.swing.tree.DefaultMutableTreeNode ("FksToItemClass: " + it.next().toString())); 58 59 } 60 catch (NullPointerException npe) 61 { 62 } 63 try 64 { 65 66 it = collectionDescriptor.getForeignKeyFields().iterator(); 67 while (it.hasNext()) 68 newChildren.add(new javax.swing.tree.DefaultMutableTreeNode ("FkFields: " + it.next().toString())); 69 } 70 catch (NullPointerException npe) 71 { 72 npe.printStackTrace(); 73 } 74 this.alChildren = newChildren; 75 this.getOjbMetaTreeModel().nodeStructureChanged(this); 76 return true; 77 } 78 79 83 public boolean load() 84 { 85 return _load(); 86 } 87 88 91 public boolean isLeaf() 92 { 93 return false; 94 } 95 96 99 public boolean getAllowsChildren() 100 { 101 return false; 102 } 103 104 107 public void setAttribute(String strKey, Object value) 108 { 109 } 110 111 114 public Object getAttribute(String strKey) 115 { 116 return null; 117 } 118 119 122 public Class getPropertyEditorClass() 123 { 124 return null; 125 } 126 127 public String toString() 128 { 129 if (collectionDescriptor.getItemClassName() == null) 131 return "CollectionDescriptor.getItemClass() == null"; 132 else return "CollectionDescriptor: " + collectionDescriptor.getItemClassName(); 133 } 134 135 138 public java.util.Iterator getActions() 139 { 140 return supportedActions.iterator(); 141 } 142 143 146 public boolean actionListCachable() 147 { 148 return true; 149 } 150 151 public boolean actionListStatic() 152 { 153 return true; 154 } 155 156 161 public Object getAssociatedDescriptor() 162 { 163 return collectionDescriptor; 164 } 165 166 } 167 168 | Popular Tags |