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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/* ************************************************************************
#module(Smokeping)
************************************************************************ */
/**
* a widget showing the smokeping target tree
*/
qx.Class.define('Smokeping.ui.TargetTree',
{
extend: qx.ui.tree.Tree,
/*
*****************************************************************************
CONSTRUCTOR
*****************************************************************************
*/
/**
* @param root_node {String} Name of the root node
* where will we find our RPC server.
*
* @param rpc {rpcObject} An rpc object providing access to the Smokeping service
*/
construct: function (rpc) {
with(this){
base(arguments,'root node');
setBackgroundColor('white');
setBorder('inset');
setOverflow('scrollY');
setWidth('100%');
setHeight('100%');
setPadding(5);
setHideNode(true);
};
var self = this;
var fill_tree = function(data,exc,id){
if (exc == null){
var nodes = data.length;
for(var i=0;i<nodes;i++){
Smokeping.ui.TargetTree.__fill_folder(self,data[i]);
}
}
else {
alert(exc);
}
};
this.getManager().addEventListener('changeSelection', function(e) {
if (e.getData().length > 0) {
if ( e.getData()[0].basename == 'TreeFolder' ){
qx.event.message.Bus.dispatch('sp.menu.folder',e.getData()[0].getUserData('ids'));
}
}
},this);
rpc.callAsync(fill_tree,'get_tree');
},
/*
*****************************************************************************
Statics
*****************************************************************************
*/
statics :
{
/*
---------------------------------------------------------------------------
CORE METHODS
---------------------------------------------------------------------------
*/
/**
* Create the tree based on input from the Server
*
* @type member
*
* @param {void}
*
* @return BaseUrl {Strings}
*/
__fill_folder: function(node,data){
// in data[0] we have the id of the folder
var folder = new qx.ui.tree.TreeFolder(data[1]);
node.add(folder);
var files = new Array();
var length = data.length;
for (var i=2;i<length;i++){
if(qx.util.Validation.isValidArray(data[i])){
Smokeping.ui.TargetTree.__fill_folder(folder,data[i]);
} else {
i++; // skip the node id for now
var file = new qx.ui.tree.TreeFile(data[i]);
files[files.length] = data[i-1];
folder.add(file);
}
}
folder.setUserData('ids',files);
}
}
});
|