KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > tools > mapping > reversedb2 > ojbmetatreemodel > OjbMetaObjectReferenceDescriptorNode


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.DescriptorRepository;
5 import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
6
7 public class OjbMetaObjectReferenceDescriptorNode extends OjbMetaTreeNode
8 {
9
10     private static java.util.ArrayList JavaDoc supportedActions = new java.util.ArrayList JavaDoc();
11     
12     private ObjectReferenceDescriptor objRefDescriptor;
13 /* Copyright 2002-2005 The Apache Software Foundation
14  *
15  * Licensed under the Apache License, Version 2.0 (the "License");
16  * you may not use this file except in compliance with the License.
17  * You may obtain a copy of the License at
18  *
19  * http://www.apache.org/licenses/LICENSE-2.0
20  *
21  * Unless required by applicable law or agreed to in writing, software
22  * distributed under the License is distributed on an "AS IS" BASIS,
23  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24  * See the License for the specific language governing permissions and
25  * limitations under the License.
26  */

27     public OjbMetaObjectReferenceDescriptorNode(
28         DescriptorRepository pRepository,
29         OjbMetaDataTreeModel pTreeModel,
30         OjbMetaTreeNode pparent,
31         ObjectReferenceDescriptor pObjRefDescriptor)
32     {
33         super(pRepository, pTreeModel, pparent);
34         this.objRefDescriptor = pObjRefDescriptor;
35     }
36
37     /**
38      * @see OjbMetaTreeNode#_load()
39      */

40     protected boolean _load()
41     {
42         java.util.ArrayList JavaDoc newChildren = new java.util.ArrayList JavaDoc();
43         ClassDescriptor itemClass = this.getRepository().getDescriptorFor(this.objRefDescriptor.getItemClassName());
44         newChildren.add(getOjbMetaTreeModel().getClassDescriptorNodeForClassDescriptor(itemClass));
45         this.alChildren = newChildren;
46         
47         java.util.Iterator JavaDoc it;
48             
49         // FK field indices are the the indices of the attributes in the class containing the reference descriptor.
50
try
51         {
52         
53             it = objRefDescriptor.getForeignKeyFields().iterator();
54             while (it.hasNext())
55                 newChildren.add(new javax.swing.tree.DefaultMutableTreeNode JavaDoc("FkFields: " + it.next().toString()));
56         }
57         catch (NullPointerException JavaDoc npe)
58         {
59             npe.printStackTrace();
60         }
61         
62         
63         this.getOjbMetaTreeModel().nodeStructureChanged(this);
64         return true;
65     }
66
67     /**
68      * Override load() of superClass to prevent recursive loading which would lead to an endless recursion
69      * because of OjbClassDescriptorNodes being children of this node
70      */

71     public boolean load()
72     {
73         return _load();
74     }
75
76     /**
77      * @see OjbMetaTreeNode#isLeaf()
78      */

79     public boolean isLeaf()
80     {
81         return false;
82     }
83
84     /**
85      * @see OjbMetaTreeNode#getAllowsChildren()
86      */

87     public boolean getAllowsChildren()
88     {
89         return false;
90     }
91
92     /**
93      * @see OjbMetaTreeNode#setAttribute(String, Object)
94      */

95     public void setAttribute(String JavaDoc strKey, Object JavaDoc value)
96     {
97     }
98
99     /**
100      * @see OjbMetaTreeNode#getAttribute(String)
101      */

102     public Object JavaDoc getAttribute(String JavaDoc strKey)
103     {
104         return null;
105     }
106
107     /**
108      * @see PropertyEditorTarget#getPropertyEditorClass()
109      */

110     public Class JavaDoc getPropertyEditorClass()
111     {
112         return null;
113     }
114     
115     public String JavaDoc toString()
116     {
117         if (objRefDescriptor.getItemClassName() != null)
118             return "ObjectReferenceDescriptor: " + objRefDescriptor.getItemClassName();
119         else
120             return "ObjectReference: .getItemClass() == null";
121     }
122     
123     /**
124      * @see ActionTarget#getActions()
125      */

126     public java.util.Iterator JavaDoc getActions()
127     {
128         return supportedActions.iterator();
129     }
130     
131     /**
132      * @see ActionTarget#actionListCacheable()
133      */

134     public boolean actionListCachable()
135     {
136         return true;
137     }
138     
139     public boolean actionListStatic()
140     {
141         return true;
142     }
143     
144     /**
145      * Return the descriptor object this node is associated with. E.g. if the
146      * node displays a class descriptor, the ClassDescriptor describing the class
147      * should be returned. Used for creating a Transferable.
148      */

149     public Object JavaDoc getAssociatedDescriptor()
150     {
151         return objRefDescriptor;
152     }
153
154 }
155
156
Popular Tags