01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.admin.dso;
05:
06: import com.tc.admin.common.XTreeModel;
07: import com.tc.admin.common.XTreeNode;
08: import com.tc.admin.ConnectionContext;
09:
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]),
23: rootNode, i);
24: }
25: }
26: }
27:
28: public void refresh() {
29: XTreeNode rootNode = (XTreeNode) getRoot();
30:
31: for (int i = rootNode.getChildCount() - 1; i >= 0; i--) {
32: ((RootTreeNode) getChild(rootNode, i)).refresh();
33: }
34: }
35:
36: public void add(DSORoot dsoRoot) {
37: XTreeNode parentNode = (XTreeNode) getRoot();
38: int index = parentNode.getChildCount();
39:
40: insertNodeInto(new RootTreeNode(m_cc, dsoRoot), parentNode,
41: index);
42: }
43: }
|