summaryrefslogtreecommitdiff
path: root/java/src/IceGrid/TreeNode/ApplicationViewRoot.java
blob: 180dd2b21be19511c9ac428cbbb6d9010621c909 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// **********************************************************************
//
// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
package IceGrid.TreeNode;

import IceGrid.ApplicationDescriptor;
import IceGrid.ApplicationUpdateDescriptor;
import IceGrid.TreeModelI;
import IceGrid.Model;

public class ApplicationViewRoot extends Parent
{
    public ApplicationViewRoot(Model model)
    {
	super("Applications", model, TreeModelI.APPLICATION_VIEW);
    }

    //
    // The node view root must be (re-)initialized before the application view root
    // 
    public void init(java.util.List descriptors)
    {
	assert(_children.size() == 0);
	
	java.util.Iterator p = descriptors.iterator();
	while(p.hasNext())
	{
	    ApplicationDescriptor descriptor = (ApplicationDescriptor)p.next();
	    Application child = new Application(descriptor, _model, false);
	    addChild(child);
	    child.addParent(this);
	}

	//
	// Fire structure change for both application and node views
	//
	fireStructureChangedEvent(this);
	_model.getNodeViewRoot().fireStructureChangedEvent(this);
    }
    
    public void clear()
    {
	clearChildren();
	fireStructureChangedEvent(this);
    }

    public void applicationAdded(ApplicationDescriptor desc)
    {
	//
	// This always fires insert events on the node view for the new server
	// instances
	//
	Application child = new Application(desc, _model, true); 
	child.addParent(this);
	addChild(child, true);
    }
 
    public void applicationRemoved(String name)
    {
	Application application = (Application)findChild(name);
	if(application != null)
	{
	    application.removeFromNodes();
	}
	
	removeChild(name, true);
    }
    
    public void applicationUpdated(ApplicationUpdateDescriptor desc)
    {
	Application application = (Application)findChild(desc.name);
	application.update(desc);
    }
}