KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bluecubs > xinco > client > XincoClientRepository


1 /**
2  *Copyright 2004 blueCubs.com
3  *
4  *Licensed under the Apache License, Version 2.0 (the "License");
5  *you may not use this file except in compliance with the License.
6  *You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *Unless required by applicable law or agreed to in writing, software
11  *distributed under the License is distributed on an "AS IS" BASIS,
12  *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *See the License for the specific language governing permissions and
14  *limitations under the License.
15  *
16  *************************************************************
17  * This project supports the blueCubs vision of giving back
18  * to the community in exchange for free software!
19  * More information on: http://www.bluecubs.org
20  *************************************************************
21  *
22  * Name: XincoClientRepository
23  *
24  * Description: repository on client side
25  *
26  * Original Author: Alexander Manes
27  * Date: 2004
28  *
29  * Modifications:
30  *
31  * Who? When? What?
32  * - - -
33  *
34  *************************************************************
35  */

36
37 package com.bluecubs.xinco.client;
38
39 import javax.swing.tree.*;
40
41 import com.bluecubs.xinco.core.*;
42 import com.bluecubs.xinco.service.*;
43
44 public class XincoClientRepository {
45     
46     public DefaultTreeModel treemodel = null;
47
48     public XincoClientRepository() {
49         treemodel = new DefaultTreeModel(new XincoMutableTreeNode("root"));
50     }
51     
52     public void assignObject2TreeNode(XincoMutableTreeNode node, XincoCoreNode object, Xinco service, XincoCoreUser user, int depth) {
53         int i = 0;
54         depth--;
55         //if node = root -> create new tree
56
//if (node.isRoot()) {
57
node.removeAllChildren();
58             //treemodel.reload(node);
59
//treemodel.nodeChanged(node);
60
//} else {
61
//}
62
node.setUserObject(object);
63         for (i=0;i<object.getXinco_core_nodes().size();i++) {
64             XincoMutableTreeNode temp_xmtn = new XincoMutableTreeNode(object.getXinco_core_nodes().elementAt(i));
65             treemodel.insertNodeInto(temp_xmtn, node, node.getChildCount());
66             //expand one more level
67
//check for children only if none have been found yet
68
if (depth > 0) {
69                 try {
70                     XincoCoreNode xnode = service.getXincoCoreNode((XincoCoreNode)object.getXinco_core_nodes().elementAt(i), user);
71                     if (xnode != null) {
72                         this.assignObject2TreeNode(temp_xmtn, xnode, service, user, depth);
73                     } else {
74                     }
75                 } catch (Exception JavaDoc rmie) {
76                 }
77             }
78         }
79         for (i=0;i<object.getXinco_core_data().size();i++) {
80             treemodel.insertNodeInto(new XincoMutableTreeNode(object.getXinco_core_data().elementAt(i)), node, node.getChildCount());
81         }
82         treemodel.reload(node);
83         treemodel.nodeChanged(node);
84     }
85
86 }
87
Popular Tags