KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > admin > dso > RootTreeModel


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.admin.dso;
5
6 import com.tc.admin.common.XTreeModel;
7 import com.tc.admin.common.XTreeNode;
8 import com.tc.admin.ConnectionContext;
9
10 public class RootTreeModel extends XTreeModel {
11   private ConnectionContext m_cc;
12
13   public RootTreeModel(ConnectionContext cc, DSORoot[] roots) {
14     super();
15
16     m_cc = cc;
17
18     XTreeNode rootNode = (XTreeNode)getRoot();
19
20     if(roots != null && roots.length > 0) {
21       for(int i = 0; i < roots.length; i++) {
22         insertNodeInto(new RootTreeNode(m_cc, roots[i]), rootNode, i);
23       }
24     }
25   }
26
27   public void refresh() {
28     XTreeNode rootNode = (XTreeNode)getRoot();
29
30     for(int i = rootNode.getChildCount()-1; i >= 0; i--) {
31       ((RootTreeNode)getChild(rootNode, i)).refresh();
32     }
33   }
34
35   public void add(DSORoot dsoRoot) {
36     XTreeNode parentNode = (XTreeNode)getRoot();
37     int index = parentNode.getChildCount();
38
39     insertNodeInto(new RootTreeNode(m_cc, dsoRoot), parentNode, index);
40   }
41 }
42
Popular Tags