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;
05:
06: import com.tc.admin.common.XRootNode;
07: import com.tc.admin.common.XTreeModel;
08:
09: import javax.swing.tree.DefaultMutableTreeNode;
10:
11: public class WebAppTreeModel extends XTreeModel {
12: private SessionIntegratorFrame m_frame;
13:
14: public WebAppTreeModel(SessionIntegratorFrame frame,
15: WebApp[] webApps) {
16: super (new XRootNode("WebApps"));
17:
18: m_frame = frame;
19:
20: DefaultMutableTreeNode WebAppsNode = (DefaultMutableTreeNode) getRoot();
21: if (webApps != null) {
22: for (int i = 0; i < webApps.length; i++) {
23: insertNodeInto(new WebAppNode(webApps[i]), WebAppsNode,
24: i);
25: }
26: }
27: }
28:
29: public void remove(String name) {
30: XRootNode webAppsNode = (XRootNode) getRoot();
31: int childCount = webAppsNode.getChildCount();
32: WebAppNode webAppNode;
33:
34: for (int i = 0; i < childCount; i++) {
35: webAppNode = (WebAppNode) webAppsNode.getChildAt(i);
36:
37: if (webAppNode.getName().equals(name)) {
38: removeNodeFromParent(webAppNode);
39: return;
40: }
41: }
42: }
43:
44: public WebAppNode add(WebApp webApp) {
45: remove(webApp.getName());
46:
47: DefaultMutableTreeNode webAppsNode = (DefaultMutableTreeNode) getRoot();
48: int childCount = webAppsNode.getChildCount();
49: WebAppNode webAppNode = new WebAppNode(webApp);
50:
51: insertNodeInto(webAppNode, webAppsNode, childCount);
52:
53: return webAppNode;
54: }
55:
56: public void setRefreshEnabled(boolean enabled) {
57: XRootNode webAppsNode = (XRootNode) getRoot();
58: int childCount = webAppsNode.getChildCount();
59: WebAppNode webAppNode;
60:
61: for (int i = 0; i < childCount; i++) {
62: webAppNode = (WebAppNode) webAppsNode.getChildAt(i);
63: webAppNode.setRefreshEnabled(enabled);
64: }
65: }
66:
67: public void refresh(WebApp webApp) {
68: m_frame.refresh(webApp);
69: }
70:
71: public void setRemoveEnabled(boolean enabled) {
72: XRootNode webAppsNode = (XRootNode) getRoot();
73: int childCount = webAppsNode.getChildCount();
74: WebAppNode webAppNode;
75:
76: for (int i = 0; i < childCount; i++) {
77: webAppNode = (WebAppNode) webAppsNode.getChildAt(i);
78: webAppNode.setRemoveEnabled(enabled);
79: }
80: }
81:
82: public void remove(WebApp webApp) {
83: m_frame.remove(webApp);
84: }
85:
86: public void updateLinks(boolean tomcat1Ready, boolean tomcat2Ready) {
87: XRootNode webAppsNode = (XRootNode) getRoot();
88: int childCount = webAppsNode.getChildCount();
89: WebAppNode webAppNode;
90:
91: for (int i = 0; i < childCount; i++) {
92: webAppNode = (WebAppNode) webAppsNode.getChildAt(i);
93: webAppNode.updateLinks(tomcat1Ready, tomcat2Ready);
94: }
95: }
96: }
|