MyDataNode.js
6.91 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/**
* Project : AMDA-NG4
* Name : MyDataParamNode.js
* @class amdaModel.MyDataParamNode
* @extends amdaModel.InteractiveNode
* @brief
* @author
* @version $Id: MyDataNode.js 2267 2014-04-03 10:13:16Z elena $
* @todo
*******************************************************************************
* FT Id : Date : Name - Description
*******************************************************************************
*
*/
Ext.define('amdaModel.MyDataNode', {
extend: 'amdaModel.InteractiveNode',
statics:{
nodeType: 'myData'
},
fields:
[
{name: 'globalStart', type: 'string', persist: false},
{name: 'globalStop', type: 'string', persist: false}
],
dependentRootNodeId : 'myDataParam-treeRootNode',
constructor : function(config){
this.callParent(arguments);
this.set('moduleId',myDesktopApp.dynamicModules.my_data.id);
this.set('objectDataModel','amdaModel.FileObject');
},
localMenuItems : function() {
var menuItems =
[{
fnId : 'root-upload',
text : 'Upload File',
hidden : true
}, {
fnId : 'dire-upload',
text : 'Upload File',
hidden : true
}, {
fnId : 'dire-deleteNode',
text : 'Delete Folder',
hidden : true
}, {
fnId : 'leaf-editLeaf',
text : 'Edit File'
}, {
fnId : 'leaf-deleteNode',
text : 'Delete File'
}
];
return menuItems;
},
getAllContextMenuItems: function(){
// var menuItems = this.allMenuItems('File');
var locMenuItems = this.localMenuItems();
// return Ext.Array.merge(menuItems,locMenuItems);
return locMenuItems;
},
onMenuItemClick : function(menu,item,event) {
var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length);
switch (fnId) {
case 'deleteNode':
this.deleteMyDataNode();
break;
case 'editLeaf':
this.editLeaf(this);
break;
case 'upload':
this.uploadFile();
break;
default:
break;
} // switch end
},
uploadFile: function() {
var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.upload.id, true, function (module) {
module.createWindow();
});
},
// delete empty folders
deleteMyDataNode : function() {
if (this.isLeaf()) {
if (this.parentNode) {
var emptyFolder = this.parentNode.childNodes.length == 1;
if (emptyFolder && this.parentNode.getDepth() == 2) {
this.parentNode.realDelete();
}
else {
this.deleteNode();
}
}
}
else {
this.deleteNode();
}
},
// file has been already added at server side!!!
create : function(folderName, fileDesc, folderDesc) {
// if ownerTree panel is not active
if (this.myGetOwnerTree().ownerCt.getActiveTab()!==this.myGetOwnerTree()){
// set ownerTree panel as the active tab
this.myGetOwnerTree().ownerCt.setActiveTab(this.myGetOwnerTree());
// to enable selection of this node his ownerTree must have a view
}
this.getRootNode().expand(false, function() {
if (!this.get('contextNode')) {
// set the root node of 'my data' tree as contextNode
var folder = folderName ? this.getRootNode().findChild('text', folderName) : this.getRootNode();
this.set('contextNode', folder);
}
// expand the contextNode - new node will be added automatically
if (!this.get('contextNode').isExpanded()){
this.get('contextNode').expand(false);
}
else {
if (!this.get('contextNode').findChild('text', this.get('text')))
this.get('contextNode').appendChild(this);
}
if (folderDesc) this.get('contextNode').set('info',folderDesc);
if (fileDesc) this.set('info',fileDesc);
// select the new node
this.myGetOwnerTree().getSelectionModel().select(this);
}, this);
},
/*
* Delete myDataParams
*/
deleteDependence : function(params) {
// CLOSE MyDataUI
var myDataModule = myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.my_data.id);
if (myDataModule) {
myDataModule.close();
}
var myParamRootNode = this.myGetOwnerTree().getRootNode().firstChild.findChild('id',this.dependentRootNodeId);
if (myParamRootNode.isExpanded) {
Ext.Array.each(params, function(param) {
var paramNode = myParamRootNode.findChild('id', param, true);
if (paramNode) paramNode.parentNode.removeChild(paramNode);
});
}
else {
myParamRootNode.expand(true,true);
}
myDesktopApp.warningMsg("Attention! Parameters which are made from these files have been deleted");
},
/*
* Update myDataParams Info only if node is exapnded
*/
updateMyDataParam : function(mask, maskDesc){
var myParamRootNode = this.myGetOwnerTree().getRootNode().firstChild.findChild('id',this.dependentRootNodeId);
if (myParamRootNode.isExpanded) {
Ext.Array.each(myParamRootNode.childNodes, function(node) {
if (node.get('linkedMask') && node.get('linkedMask') == mask) {
var globalStart = maskDesc.substr(0,16);
var globalStop = maskDesc.substr(17,16);
node.set('globalStart', globalStart);
node.set('globalStop', globalStop);
if (node.get('info')) {
var info = node.get('info').split("<br/>");
node.set('info',info[0] + "<br/>" + globalStart + "-" + globalStop + "<br/> Mask: " + mask);
}
}
});
}
}
});