Commit 75a3182b36bf51b2f35b9779d505cc2fe10ba54f
1 parent
7d5742d0
Exists in
master
and in
109 other branches
special MyDataParamNode methods - from InteractiveNode.js to MyDataParamNode.js
Showing
2 changed files
with
249 additions
and
250 deletions
Show diff stats
js/app/models/InteractiveNode.js
@@ -200,22 +200,11 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -200,22 +200,11 @@ Ext.define('amdaModel.InteractiveNode', { | ||
200 | 200 | ||
201 | if (res.info) { | 201 | if (res.info) { |
202 | this.set('info',res.info); | 202 | this.set('info',res.info); |
203 | - } | ||
204 | - | ||
205 | - if (this.get('nodeType') == 'myDataParam') { | ||
206 | - if (res.isSpectra) { | ||
207 | - this.set('iconCls', 'icon-spectra'); | ||
208 | - } | ||
209 | - else { | ||
210 | - if (res.size > 1) this.set('iconCls', 'icon-unknowntype'); | ||
211 | - } | ||
212 | } | 203 | } |
213 | 204 | ||
214 | - // update my data on possibble mask change | ||
215 | - if (res.updateMyData) { | ||
216 | - this.updateMyData(); | ||
217 | - this.updateMask(res.mask); | ||
218 | - } | 205 | + // myDataParam special update |
206 | + this.specialUpdate(res, false); | ||
207 | + | ||
219 | // reload object into the view of corresponding Module | 208 | // reload object into the view of corresponding Module |
220 | var me = this; | 209 | var me = this; |
221 | myDesktopApp.getLoadedModule(this.get('moduleId'), true, function (module) { | 210 | myDesktopApp.getLoadedModule(this.get('moduleId'), true, function (module) { |
@@ -282,30 +271,10 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -282,30 +271,10 @@ Ext.define('amdaModel.InteractiveNode', { | ||
282 | if (res.info){ | 271 | if (res.info){ |
283 | // set the tooltip | 272 | // set the tooltip |
284 | this.set('info',res.info); | 273 | this.set('info',res.info); |
285 | - //set globalStart & global Stop to be used for time selection | ||
286 | - if (this.get('nodeType') == 'myDataParam') | ||
287 | - { | ||
288 | - var startStop = res.info.split("<br/>"); | ||
289 | - var globalStart = startStop[1].substr(0,19); | ||
290 | - var globalStop = startStop[1].substr(20); | ||
291 | - | ||
292 | - this.set('globalStart', globalStart); | ||
293 | - this.set('globalStop', globalStop); | ||
294 | - | ||
295 | - if (res.mask) | ||
296 | - this.set('linkedMask', res.mask); | ||
297 | - if (res.size) | ||
298 | - this.set('size', res.size); | ||
299 | - | ||
300 | - if (res.isSpectra) { | ||
301 | - this.set('iconCls', 'icon-spectra'); | ||
302 | - } | ||
303 | - else { | ||
304 | - if (res.size > 1) | ||
305 | - this.set('iconCls', 'icon-unknowntype'); | ||
306 | - } | ||
307 | - } | ||
308 | - } | 274 | + } |
275 | + //set globalStart & global Stop to be used for time selection | ||
276 | + this.specialUpdate(res, true); | ||
277 | + | ||
309 | //TODO do we need this commission ??? | 278 | //TODO do we need this commission ??? |
310 | // fix the modifications for object | 279 | // fix the modifications for object |
311 | this.get('object').commit(); | 280 | this.get('object').commit(); |
@@ -333,14 +302,6 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -333,14 +302,6 @@ Ext.define('amdaModel.InteractiveNode', { | ||
333 | opt.callback.call(scope,'create'); | 302 | opt.callback.call(scope,'create'); |
334 | } | 303 | } |
335 | }, this); | 304 | }, this); |
336 | - | ||
337 | - // myDataParamNode - update MyData subtree | ||
338 | - //TODO put this in mydataparamnode | ||
339 | - if (res.updateMyData) { | ||
340 | - this.updateMyData(); | ||
341 | - this.updateMask(res.mask); | ||
342 | - } | ||
343 | - | ||
344 | } | 305 | } |
345 | // error code from server; but e.status==true | 306 | // error code from server; but e.status==true |
346 | else { | 307 | else { |
@@ -359,6 +320,7 @@ Ext.define('amdaModel.InteractiveNode', { | @@ -359,6 +320,7 @@ Ext.define('amdaModel.InteractiveNode', { | ||
359 | },this); | 320 | },this); |
360 | }, | 321 | }, |
361 | 322 | ||
323 | + specialUpdate : function() {}, | ||
362 | /** | 324 | /** |
363 | * Generic part of Context Menu | 325 | * Generic part of Context Menu |
364 | * | 326 | * |
js/app/models/MyDataParamNode.js
@@ -27,225 +27,262 @@ Ext.define('amdaModel.MyDataParamNode', { | @@ -27,225 +27,262 @@ Ext.define('amdaModel.MyDataParamNode', { | ||
27 | objectName : 'Parameter' | 27 | objectName : 'Parameter' |
28 | }, | 28 | }, |
29 | 29 | ||
30 | - constructor : function(config) | ||
31 | - { | ||
32 | - this.callParent(arguments); | ||
33 | - this.set('moduleId',myDesktopApp.dynamicModules.my_data.id); | ||
34 | - this.set('objectDataModel','amdaModel.FileParamObject'); | ||
35 | - if (this.get('isParameter')) { | ||
36 | - if (this.get('size') == 1) this.set('iconCls', 'icon-scalar'); | ||
37 | - else this.set('iconCls', 'icon-unknowntype'); | ||
38 | - } | ||
39 | - //TODO this.set('iconCls', 'icon-vector'); | ||
40 | - if (this.get('isSpectra')) this.set('iconCls', 'icon-spectra'); | ||
41 | - }, | ||
42 | - | ||
43 | - localMenuItems : function() | ||
44 | - { | ||
45 | - var menuItems = | ||
46 | - [{ | ||
47 | - fnId : 'root-upload', | ||
48 | - text : 'Upload File', | ||
49 | - hidden : true | ||
50 | - }, { | ||
51 | - fnId : 'dire-upload', | ||
52 | - text : 'Upload File', | ||
53 | - hidden : true | ||
54 | - }, { | ||
55 | - fnId : 'leaf-upload', | ||
56 | - text : 'Upload File', | ||
57 | - hidden : true | ||
58 | - },{ | ||
59 | - fnId : 'leaf-plotParam', | ||
60 | - text : 'Plot Parameter', | ||
61 | - hidden : true | ||
62 | - }, { | ||
63 | - fnId : 'leaf-downParam', | ||
64 | - text : 'Download Parameter', | ||
65 | - hidden : true | ||
66 | - }, { | ||
67 | - fnId : 'para-plotParam', | ||
68 | - text : 'Plot Parameter', | ||
69 | - hidden : true | ||
70 | - }, { | ||
71 | - fnId : 'para-downParam', | ||
72 | - text : 'Download Parameter', | ||
73 | - hidden : true | ||
74 | - }]; | ||
75 | - return menuItems; | ||
76 | - }, | ||
77 | - | ||
78 | - getAllContextMenuItems: function() | ||
79 | - { | ||
80 | - var menuItems = this.allMenuItems('Parameter'); | ||
81 | - var locMenuItems = this.localMenuItems(); | 30 | + constructor : function(config) |
31 | + { | ||
32 | + this.callParent(arguments); | ||
33 | + this.set('moduleId',myDesktopApp.dynamicModules.my_data.id); | ||
34 | + this.set('objectDataModel','amdaModel.FileParamObject'); | ||
35 | + if (this.get('isParameter')) { | ||
36 | + if (this.get('size') == 1) | ||
37 | + this.set('iconCls', 'icon-scalar'); | ||
38 | + else if(this.get('size') == 3) | ||
39 | + this.set('iconCls', 'icon-vector'); | ||
40 | + else | ||
41 | + this.set('iconCls', 'icon-unknowntype'); | ||
42 | + } | ||
82 | 43 | ||
83 | - return Ext.Array.merge(menuItems,locMenuItems); | ||
84 | - }, | 44 | + if (this.get('isSpectra')) this.set('iconCls', 'icon-spectra'); |
45 | + }, | ||
46 | + | ||
47 | + localMenuItems : function() | ||
48 | + { | ||
49 | + var menuItems = | ||
50 | + [{ | ||
51 | + fnId : 'root-upload', | ||
52 | + text : 'Upload File', | ||
53 | + hidden : true | ||
54 | + }, { | ||
55 | + fnId : 'dire-upload', | ||
56 | + text : 'Upload File', | ||
57 | + hidden : true | ||
58 | + }, { | ||
59 | + fnId : 'leaf-upload', | ||
60 | + text : 'Upload File', | ||
61 | + hidden : true | ||
62 | + },{ | ||
63 | + fnId : 'leaf-plotParam', | ||
64 | + text : 'Plot Parameter', | ||
65 | + hidden : true | ||
66 | + }, { | ||
67 | + fnId : 'leaf-downParam', | ||
68 | + text : 'Download Parameter', | ||
69 | + hidden : true | ||
70 | + }, { | ||
71 | + fnId : 'para-plotParam', | ||
72 | + text : 'Plot Parameter', | ||
73 | + hidden : true | ||
74 | + }, { | ||
75 | + fnId : 'para-downParam', | ||
76 | + text : 'Download Parameter', | ||
77 | + hidden : true | ||
78 | + }]; | ||
79 | + return menuItems; | ||
80 | + }, | ||
85 | 81 | ||
86 | - onMenuItemClick : function(menu,item,event) | ||
87 | - { | ||
88 | - var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length); | 82 | + getAllContextMenuItems: function() |
83 | + { | ||
84 | + var menuItems = this.allMenuItems('Parameter'); | ||
85 | + var locMenuItems = this.localMenuItems(); | ||
89 | 86 | ||
90 | - switch (fnId) { | 87 | + return Ext.Array.merge(menuItems,locMenuItems); |
88 | + }, | ||
91 | 89 | ||
92 | - case 'deleteNode': | ||
93 | - this.deleteNode(); | ||
94 | - break; | 90 | + onMenuItemClick : function(menu,item,event) |
91 | + { | ||
92 | + var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length); | ||
95 | 93 | ||
96 | - case 'createDir': | ||
97 | - this.createDir(); | ||
98 | - break; | 94 | + switch (fnId) |
95 | + { | ||
96 | + case 'deleteNode': | ||
97 | + this.deleteNode(); | ||
98 | + break; | ||
99 | 99 | ||
100 | - case 'createLeaf': | ||
101 | - this.createLeaf(this); | ||
102 | - break; | 100 | + case 'createDir': |
101 | + this.createDir(); | ||
102 | + break; | ||
103 | 103 | ||
104 | - case 'renameNode': | ||
105 | - this.renameNode(); | ||
106 | - break; | 104 | + case 'createLeaf': |
105 | + this.createLeaf(this); | ||
106 | + break; | ||
107 | 107 | ||
108 | - case 'editLeaf': | ||
109 | - this.editLeaf(); | ||
110 | - break; | 108 | + case 'renameNode': |
109 | + this.renameNode(); | ||
110 | + break; | ||
111 | 111 | ||
112 | - case 'upload': | ||
113 | - this.uploadFile(); | ||
114 | - break; | ||
115 | - | ||
116 | - case 'plotParam': | ||
117 | - this.createPlot(this); | ||
118 | - break; | ||
119 | - | ||
120 | - case 'downParam': | ||
121 | - this.createDownload(this); | ||
122 | - break; | ||
123 | - | ||
124 | - default: | ||
125 | - break; | ||
126 | - } // switch end | 112 | + case 'editLeaf': |
113 | + this.editLeaf(); | ||
114 | + break; | ||
127 | 115 | ||
128 | - }, | 116 | + case 'upload': |
117 | + this.uploadFile(); | ||
118 | + break; | ||
119 | + | ||
120 | + case 'plotParam': | ||
121 | + this.createPlot(this); | ||
122 | + break; | ||
123 | + | ||
124 | + case 'downParam': | ||
125 | + this.createDownload(this); | ||
126 | + break; | ||
127 | + | ||
128 | + default: | ||
129 | + break; | ||
130 | + } // switch end | ||
131 | + }, | ||
129 | 132 | ||
130 | - uploadFile: function() { | ||
131 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.upload.id, true, function (module) { | ||
132 | - module.createWindow(); | ||
133 | - }); | ||
134 | - }, | 133 | + uploadFile: function() { |
134 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.upload.id, true, function (module) { | ||
135 | + module.createWindow(); | ||
136 | + }); | ||
137 | + }, | ||
135 | 138 | ||
136 | - editLeaf: function() { | ||
137 | - // load the rootNode and recursively all its child nodes | ||
138 | - // to know all names of DerivedParameters | ||
139 | - var me = this; | ||
140 | - amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), | ||
141 | - function() | ||
142 | - { | ||
143 | - if (me.get('object')) | ||
144 | - { | ||
145 | - if (me.get('fileObject')) | ||
146 | - // launch edition of parameter into parameter module | ||
147 | - me.editInModule(); | ||
148 | - else | ||
149 | - AmdaAction.getObject(me.get('object').get('file'), amdaModel.MyDataNode.nodeType, me.getFileObjectCallback, me); | ||
150 | - } | ||
151 | - else | ||
152 | - { | ||
153 | - // call the ext method to get the details of parameter | ||
154 | - // the edition of real parameter is done into callback method getObjectCallback | ||
155 | - AmdaAction.getObject(me.get('id'), me.get('nodeType'), me.getObjectCallback, me); | ||
156 | - } | ||
157 | - }); | ||
158 | - }, | 139 | + editLeaf: function() |
140 | + { | ||
141 | + // load the rootNode and recursively all its child nodes | ||
142 | + // to know all names of DerivedParameters | ||
143 | + var me = this; | ||
144 | + amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), | ||
145 | + function() | ||
146 | + { | ||
147 | + if (me.get('object')) | ||
148 | + { | ||
149 | + if (me.get('fileObject')) | ||
150 | + // launch edition of parameter into parameter module | ||
151 | + me.editInModule(); | ||
152 | + else | ||
153 | + AmdaAction.getObject(me.get('object').get('file'), amdaModel.MyDataNode.nodeType, me.getFileObjectCallback, me); | ||
154 | + } | ||
155 | + else | ||
156 | + { | ||
157 | + // call the ext method to get the details of parameter | ||
158 | + // the edition of real parameter is done into callback method getObjectCallback | ||
159 | + AmdaAction.getObject(me.get('id'), me.get('nodeType'), me.getObjectCallback, me); | ||
160 | + } | ||
161 | + }); | ||
162 | + }, | ||
159 | 163 | ||
160 | - // special case file object should be also loaded | ||
161 | - getObjectCallback : function(result,remoteEvent){//result, e) { | ||
162 | - var t = remoteEvent.getTransaction(); | ||
163 | - if (result) { | ||
164 | - if (result.id) { | ||
165 | - var paramObj = Ext.create(this.get('objectDataModel'), result); | ||
166 | - // set parameter into node | ||
167 | - this.set('object',paramObj); | ||
168 | - | ||
169 | - paramObj.set('tableDef', result['tableDef']); | ||
170 | - | ||
171 | - if (paramObj.get('mask')) var file = paramObj.get('mask'); | ||
172 | - else var file = paramObj.get('file'); | ||
173 | - | ||
174 | - AmdaAction.getObject(file, amdaModel.MyDataNode.nodeType, | ||
175 | - this.getFileObjectCallback, this); | ||
176 | - } | ||
177 | - else { | ||
178 | - myDesktopApp.errorMsg(result.error); | ||
179 | - } | ||
180 | - } | ||
181 | - else { | ||
182 | - // EXCEPTION : parameter not found !? | ||
183 | - myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '" | ||
184 | - +this.get('name')+"' found!"); | ||
185 | - //TODO: adding an error log | ||
186 | - } | ||
187 | - }, | 164 | + // special case file object should be also loaded |
165 | + getObjectCallback : function(result,remoteEvent){//result, e) { | ||
166 | + var t = remoteEvent.getTransaction(); | ||
167 | + if (result) { | ||
168 | + if (result.id) { | ||
169 | + var paramObj = Ext.create(this.get('objectDataModel'), result); | ||
170 | + // set parameter into node | ||
171 | + this.set('object',paramObj); | ||
172 | + | ||
173 | + paramObj.set('tableDef', result['tableDef']); | ||
174 | + | ||
175 | + if (paramObj.get('mask')) var file = paramObj.get('mask'); | ||
176 | + else var file = paramObj.get('file'); | ||
177 | + | ||
178 | + AmdaAction.getObject(file, amdaModel.MyDataNode.nodeType, | ||
179 | + this.getFileObjectCallback, this); | ||
180 | + } | ||
181 | + else { | ||
182 | + myDesktopApp.errorMsg(result.error); | ||
183 | + } | ||
184 | + } | ||
185 | + else { | ||
186 | + // EXCEPTION : parameter not found !? | ||
187 | + myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '" | ||
188 | + +this.get('name')+"' found!"); | ||
189 | + //TODO: adding an error log | ||
190 | + } | ||
191 | + }, | ||
188 | 192 | ||
189 | - getFileObjectCallback : function(result,remoteEvent){//result, e) { | ||
190 | - var t = remoteEvent.getTransaction(); | ||
191 | - if (result) { | ||
192 | - if (result.success) { | ||
193 | - var paramObj = Ext.create('amdaModel.FileObject', result); | ||
194 | - this.set('fileObject', paramObj); | ||
195 | - // Edition of parameter into parameter Module | ||
196 | - this.editInModule(); | ||
197 | - } | ||
198 | - else { | ||
199 | - myDesktopApp.errorMsg(result.error); | ||
200 | - } | ||
201 | - } | ||
202 | - else { | ||
203 | - // EXCEPTION : parameter not found !? | ||
204 | - myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '" | ||
205 | - +this.get('name')+"' found!"); | ||
206 | - } | ||
207 | - }, | 193 | + getFileObjectCallback : function(result,remoteEvent){//result, e) { |
194 | + var t = remoteEvent.getTransaction(); | ||
195 | + if (result) { | ||
196 | + if (result.success) { | ||
197 | + var paramObj = Ext.create('amdaModel.FileObject', result); | ||
198 | + this.set('fileObject', paramObj); | ||
199 | + // Edition of parameter into parameter Module | ||
200 | + this.editInModule(); | ||
201 | + } | ||
202 | + else { | ||
203 | + myDesktopApp.errorMsg(result.error); | ||
204 | + } | ||
205 | + } | ||
206 | + else { | ||
207 | + // EXCEPTION : parameter not found !? | ||
208 | + myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '" | ||
209 | + +this.get('name')+"' found!"); | ||
210 | + } | ||
211 | + }, | ||
208 | 212 | ||
209 | - /* | ||
210 | - * Mask was possibly changed update this info | ||
211 | - */ | ||
212 | - updateMask : function(mask) | ||
213 | - { | ||
214 | - var myParamRootNode = this.getRootNode(); | ||
215 | - if (myParamRootNode.isExpanded) { | ||
216 | - Ext.Array.each(myParamRootNode.childNodes, function(node) { | ||
217 | - if (node.get('linkedMask') && node.get('linkedMask').indexOf(mask) != -1 ) { | ||
218 | - node.set('linkedMask',mask); | ||
219 | - if (node.get('info')) { | ||
220 | - var info = node.get('info').split("<br/>"); | ||
221 | - node.set('info',info[0] + "<br/>" + info[1] + "<br/> Mask: " + mask); | ||
222 | - } | ||
223 | - } | ||
224 | - | ||
225 | - }); | ||
226 | - } | ||
227 | - | ||
228 | - }, | 213 | + /* |
214 | + * Mask was possibly changed update this info | ||
215 | + */ | ||
216 | + updateMask : function(mask) | ||
217 | + { | ||
218 | + var myParamRootNode = this.getRootNode(); | ||
219 | + if (myParamRootNode.isExpanded) { | ||
220 | + Ext.Array.each(myParamRootNode.childNodes, function(node) { | ||
221 | + if (node.get('linkedMask') && node.get('linkedMask').indexOf(mask) != -1 ) { | ||
222 | + node.set('linkedMask',mask); | ||
223 | + if (node.get('info')) { | ||
224 | + var info = node.get('info').split("<br/>"); | ||
225 | + node.set('info',info[0] + "<br/>" + info[1] + "<br/> Mask: " + mask); | ||
226 | + } | ||
227 | + } | ||
228 | + | ||
229 | + }); | ||
230 | + } | ||
231 | + }, | ||
229 | 232 | ||
230 | - updateMyData : function(){ | ||
231 | - // reload myFiles Tree in explorer | ||
232 | - var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | ||
233 | - if (explorerTree) { | ||
234 | - var explorerTreeStore = explorerTree.getStore(); | ||
235 | - var explorerRoot = explorerTreeStore.getRootNode().findChild('text','My Files'); | ||
236 | - | ||
237 | - var explorerPath = '/root/myData-treeRootNode/'; | ||
238 | - | ||
239 | - explorerTreeStore.reload({node : explorerRoot, | ||
240 | - params : { nodeType: 'myData'}, | ||
241 | - callback : function(){ | ||
242 | - explorerTree.selectPath(explorerPath); | ||
243 | - } | ||
244 | - }); | ||
245 | - } | ||
246 | - }, | 233 | + updateMyData : function(){ |
234 | + // reload myFiles Tree in explorer | ||
235 | + var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | ||
236 | + if (explorerTree) { | ||
237 | + var explorerTreeStore = explorerTree.getStore(); | ||
238 | + var explorerRoot = explorerTreeStore.getRootNode().findChild('text','My Files'); | ||
239 | + | ||
240 | + var explorerPath = '/root/myData-treeRootNode/'; | ||
241 | + | ||
242 | + explorerTreeStore.reload({node : explorerRoot, | ||
243 | + params : { nodeType: 'myData'}, | ||
244 | + callback : function(){ | ||
245 | + explorerTree.selectPath(explorerPath); | ||
246 | + } | ||
247 | + }); | ||
248 | + } | ||
249 | + }, | ||
247 | 250 | ||
248 | - isParameter : function(){ | ||
249 | - return this.get('isParameter'); | ||
250 | - } | 251 | + isParameter : function(){ |
252 | + return this.get('isParameter'); | ||
253 | + }, | ||
254 | + | ||
255 | + specialUpdate : function(res, timeUpdate) | ||
256 | + { | ||
257 | + if (timeUpdate && res.info) | ||
258 | + { | ||
259 | + var startStop = res.info.split("<br/>"); | ||
260 | + var globalStart = startStop[1].substr(0,19); | ||
261 | + var globalStop = startStop[1].substr(20); | ||
262 | + | ||
263 | + this.set('globalStart', globalStart); | ||
264 | + this.set('globalStop', globalStop); | ||
265 | + | ||
266 | + if (res.mask) | ||
267 | + this.set('linkedMask', res.mask); | ||
268 | + if (res.size) | ||
269 | + this.set('size', res.size); | ||
270 | + } | ||
271 | + | ||
272 | + if (res.isSpectra) { | ||
273 | + this.set('iconCls', 'icon-spectra'); | ||
274 | + } | ||
275 | + else if (res.size == 3) { | ||
276 | + this.set('iconCls', 'icon-vector'); | ||
277 | + } | ||
278 | + else if (res.size > 1) { | ||
279 | + this.set('iconCls', 'icon-unknowntype'); | ||
280 | + } | ||
281 | + | ||
282 | + // update my data on possible mask change | ||
283 | + if (res.updateMyData) { | ||
284 | + this.updateMyData(); | ||
285 | + this.updateMask(res.mask); | ||
286 | + } | ||
287 | + } | ||
251 | }); | 288 | }); |