KickJava   Java API By Example, From Geeks To Geeks.

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


1
2 package org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel;
3
4 /* Copyright 2002-2005 The Apache Software Foundation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 /**
20  * This represents the root of the repository.xml tree model. It contains
21  * the ClassDescriptor objects for this repository and the default JDBC
22  * connection.
23  *
24  * @author <a HREF="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
25  * @version $Id: OjbMetaRootNode.java,v 1.1.2.1 2005/12/21 22:32:38 tomdz Exp $
26  */

27 public class OjbMetaRootNode extends OjbMetaTreeNode
28 {
29     private java.util.ArrayList JavaDoc supportedActions = new java.util.ArrayList JavaDoc();
30
31     java.util.HashMap JavaDoc cldToNodes = new java.util.HashMap JavaDoc();
32
33     /** Creates a new instance of OjbMetaRootNode */
34     public OjbMetaRootNode(org.apache.ojb.broker.metadata.DescriptorRepository pRepository, OjbMetaDataTreeModel model)
35     {
36         super(pRepository, model, null);
37         supportedActions.add(new org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel.actions.ActionAddClassDescriptor(this));
38     }
39
40     public boolean getAllowsChildren ()
41     {
42         return true;
43     }
44
45     public Class JavaDoc getPropertyEditorClass ()
46     {
47         return null;
48     }
49
50     public boolean isLeaf ()
51     {
52         return false;
53     }
54
55     /** Get an attribute of this node as Object.
56      */

57     public Object JavaDoc getAttribute (String JavaDoc strKey)
58     {
59         return null;
60     }
61
62     /** Set an attribute of this node as Object.
63      */

64     public void setAttribute (String JavaDoc strKey, Object JavaDoc value)
65     {
66     }
67
68     public OjbMetaClassDescriptorNode getClassDescriptorNodeForClassDescriptor(org.apache.ojb.broker.metadata.ClassDescriptor cld)
69     {
70         return (OjbMetaClassDescriptorNode)this.cldToNodes.get(cld);
71     }
72
73     /** Purpose of this method is to fill the children of the node. It should
74      * replace all children in alChildren (the arraylist containing the children)
75      * of this node and notify the TreeModel that a change has occurred.
76      */

77     protected boolean _load ()
78     {
79         java.util.Iterator JavaDoc it =
80             this.getOjbMetaTreeModel ().getRepository().iterator();
81         java.util.ArrayList JavaDoc newChildren = new java.util.ArrayList JavaDoc();
82
83         /* @todo make this work */
84
85 // newChildren.add(new OjbMetaJdbcConnectionDescriptorNode(
86
// this.getOjbMetaTreeModel ().getRepository(),
87
// this.getOjbMetaTreeModel (),
88
// this,
89
// this.getOjbMetaTreeModel ().getRepository().getDefaultJdbcConnection()));
90

91         while (it.hasNext())
92         {
93             org.apache.ojb.broker.metadata.ClassDescriptor cld = (org.apache.ojb.broker.metadata.ClassDescriptor)it.next();
94             OjbMetaClassDescriptorNode cldNode =
95                 new OjbMetaClassDescriptorNode(this.getOjbMetaTreeModel ().getRepository(),
96                                                this.getOjbMetaTreeModel (),
97                                                this, cld);
98             cldToNodes.put(cld, cldNode);
99             newChildren.add(cldNode);
100         }
101         java.util.Collections.sort(newChildren);
102         this.alChildren = newChildren;
103         this.getOjbMetaTreeModel ().nodeStructureChanged(this);
104         return true;
105     }
106
107     public void addClassDescriptor(org.apache.ojb.broker.metadata.ClassDescriptor cld)
108     {
109         OjbMetaClassDescriptorNode cldNode =
110             new OjbMetaClassDescriptorNode(this.getOjbMetaTreeModel ().getRepository(),
111                                            this.getOjbMetaTreeModel (),
112                                            this, cld);
113         cldToNodes.put(cld, cldNode);
114         this.alChildren.add(cldNode);
115         this.getOjbMetaTreeModel().nodesWereInserted(this, new int[]{this.alChildren.size()-1});
116     }
117
118     /**
119      * @see ActionTarget#getActions()
120      */

121     public java.util.Iterator JavaDoc getActions()
122     {
123         return supportedActions.iterator();
124     }
125
126     /**
127      * @see ActionTarget#actionListCacheable()
128      */

129     public boolean actionListCachable()
130     {
131         return true;
132     }
133
134     /**
135      * @see ActionTarget
136      */

137     public boolean actionListStatic()
138     {
139         return false;
140     }
141
142     /**
143      * Return the descriptor object this node is associated with. E.g. if the
144      * node displays a class descriptor, the ClassDescriptor describing the class
145      * should be returned. Used for creating a Transferable. Null in this case
146      * because the root doesn't have any associated objects.
147      */

148     public Object JavaDoc getAssociatedDescriptor()
149     {
150         return null;
151     }
152
153 }
154
Popular Tags