01: package com.sun.portal.netfile.applet.java2.model;
02:
03: import java.util.Vector;
04: import java.util.Hashtable;
05: import java.util.List;
06: import java.util.ArrayList;
07:
08: public class RootNode extends NetFileNode {
09:
10: private static RootNode instance;
11:
12: private static final String ICON_NAME = "Neighborhood_16.gif";
13: private static final String OPEN_ICON_NAME = "Neighborhood_16.gif";
14:
15: private static String NAME = "Network Neighborhood";
16:
17: public static void setName(String name) {
18: NAME = name;
19: }
20:
21: private RootNode() {
22: super (NAME, ICON_NAME, OPEN_ICON_NAME);
23: }
24:
25: public void addSystemNode(SystemNode systemNode) {
26: addChildNode(systemNode);
27: }
28:
29: public SystemNode getSystemNode(String systemName) {
30: return (SystemNode) getChildNode(systemName);
31: }
32:
33: public SystemNode removeSystemNode(String systemName) {
34: return (SystemNode) removeChildNode(systemName);
35:
36: }
37:
38: public SystemNode[] getAllSystemNodes() {
39: return (SystemNode[]) getAllChildren(new SystemNode[0]);
40: }
41:
42: public SystemNode[] getAllUserSystemNodes() {
43: SystemNode[] sysNodes = getAllSystemNodes();
44: ArrayList listUserSystemNodes = new ArrayList();
45: for (int i = 0; i < sysNodes.length; i++) {
46: if (sysNodes[i].isCommonHost())
47: continue;
48: if (!sysNodes[i].isAllowedSystemNode())
49: continue;
50: listUserSystemNodes.add(sysNodes[i]);
51: }
52: return (SystemNode[]) listUserSystemNodes
53: .toArray(new SystemNode[0]);
54: }
55:
56: public static RootNode getInstance() {
57: if (instance == null) {
58: instance = new RootNode();
59: }
60: return instance;
61: }
62:
63: public String getFQName() {
64: return "";
65: }
66:
67: public Hashtable toHashtable() {
68: return new Hashtable();
69: }
70:
71: public List getAllSystemNodeNamesAsList() {
72: SystemNode[] systemNodes = getAllSystemNodes();
73: ArrayList ret = new ArrayList(systemNodes.length);
74: for (int i = 0; i < systemNodes.length; i++) {
75: ret.add(systemNodes[i].getName());
76: }
77: return ret;
78: }
79:
80: // Fix for Bug #6279911
81: // Invalidate the Root Node instance whenever the applet closes.
82: // When another user logs in and invokes the netfile, this fix
83: // ensures that no cache info is displayed.
84:
85: public static void invalidateInstance() {
86: instance = null;
87: }
88: }
|