01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package org.terracotta.dso.views;
05:
06: import com.terracottatech.config.DsoApplication;
07: import com.terracottatech.config.Root;
08: import com.terracottatech.config.Roots;
09:
10: public class RootsWrapper {
11: private DsoApplication fApp;
12: private RootWrapper[] children;
13:
14: RootsWrapper(DsoApplication app) {
15: fApp = app;
16: }
17:
18: RootWrapper[] createRootWrappers() {
19: int count = sizeOfRootArray();
20:
21: children = new RootWrapper[count];
22: for (int i = 0; i < count; i++) {
23: children[i] = new RootWrapper(this , i);
24: }
25:
26: return children;
27: }
28:
29: RootWrapper[] getChildren() {
30: return children;
31: }
32:
33: RootWrapper getChildAt(int index) {
34: return children != null ? children[index] : null;
35: }
36:
37: int sizeOfRootArray() {
38: Roots roots = fApp.getRoots();
39: return roots != null ? roots.sizeOfRootArray() : 0;
40: }
41:
42: Root getRootArray(int i) {
43: Roots roots = fApp.getRoots();
44: if (roots != null) {
45: return roots.getRootArray(i);
46: }
47: return null;
48: }
49:
50: void removeRoot(int i) {
51: Roots roots = fApp.getRoots();
52: if (roots != null) {
53: roots.removeRoot(i);
54: }
55: if (sizeOfRootArray() == 0) {
56: fApp.unsetRoots();
57: }
58: }
59: }
|