Commit 237698499964e76b379a8ffb032cd72a851bdaa4
1 parent
f7af2e64
Exists in
master
and in
112 other branches
LoadObject in StatisticsUI
Showing
1 changed file
with
247 additions
and
237 deletions
Show diff stats
js/app/views/StatisticsUI.js
... | ... | @@ -7,18 +7,20 @@ |
7 | 7 | * @author elena |
8 | 8 | */ |
9 | 9 | |
10 | -Ext.define('amdaUI.StatisticsUI', { | |
10 | +Ext.define('amdaUI.StatisticsUI', | |
11 | +{ | |
11 | 12 | extend: 'Ext.container.Container', |
12 | 13 | alias: 'widget.panelStatistics', |
13 | 14 | |
14 | 15 | requires : [ |
15 | - // 'amdaModel.Function' | |
16 | + //'amdaModel.Function' | |
16 | 17 | 'amdaUI.TimeSelectorUI', |
17 | 18 | 'amdaUI.ParamArgumentsPlug', |
18 | 19 | 'amdaModel.DownloadParam' |
19 | 20 | ], |
20 | 21 | |
21 | - statics : { | |
22 | + statics : | |
23 | + { | |
22 | 24 | // functionStore : null |
23 | 25 | }, |
24 | 26 | |
... | ... | @@ -26,13 +28,22 @@ Ext.define('amdaUI.StatisticsUI', { |
26 | 28 | { |
27 | 29 | this.init(config); |
28 | 30 | this.callParent(arguments); |
29 | - // if (this.object) this.loadObject(); | |
30 | - // | |
31 | + this.loadObject(); | |
32 | + | |
31 | 33 | var paramArgsPlug = this.getPlugin('statistics-param-arguments-plugin'); |
32 | 34 | if (paramArgsPlug) |
33 | 35 | paramArgsPlug.onApply = this.onApplyParameterArgs; |
34 | 36 | }, |
35 | - | |
37 | + | |
38 | + loadObject : function() | |
39 | + { | |
40 | + // load object into form | |
41 | + var basicForm = this.formPanel.items.items[0].getForm(); | |
42 | + | |
43 | + basicForm.loadRecord(this.object); | |
44 | + | |
45 | + }, | |
46 | + | |
36 | 47 | onApplyParameterArgs : function(parentUI, paramObject) |
37 | 48 | { |
38 | 49 | parentUI.paramGrid.getView().refresh(); |
... | ... | @@ -69,7 +80,7 @@ Ext.define('amdaUI.StatisticsUI', { |
69 | 80 | |
70 | 81 | var r = Ext.create('amdaModel.DownloadParam', paramObj); |
71 | 82 | this.paramGrid.getStore().add(r); |
72 | - this.paramGrid.getSelectionModel().select(this.paramGrid.getStore().getCount()-1); | |
83 | + this.paramGrid.getSelectionModel().select(this.paramGrid.getStore().getCount()-1); | |
73 | 84 | // var pos = this.paramGrid.store.getCount(); |
74 | 85 | // this.paramGrid.store.insert(pos,r); |
75 | 86 | this.paramGrid.getView().refresh(); |
... | ... | @@ -78,7 +89,8 @@ Ext.define('amdaUI.StatisticsUI', { |
78 | 89 | this.editParameterArgs(r); |
79 | 90 | }, |
80 | 91 | |
81 | - editParameterArgs: function(record) { | |
92 | + editParameterArgs: function(record) | |
93 | + { | |
82 | 94 | var paramArgsPlug = this.getPlugin('statistics-param-arguments-plugin'); |
83 | 95 | |
84 | 96 | if (paramArgsPlug) |
... | ... | @@ -87,27 +99,28 @@ Ext.define('amdaUI.StatisticsUI', { |
87 | 99 | |
88 | 100 | addTT : function(TTname,TTid) |
89 | 101 | { |
90 | - this.timeSelector.addTT(TTname, TTid); ; | |
91 | - | |
102 | + this.timeSelector.addTT(TTname, TTid); ; | |
92 | 103 | }, |
93 | 104 | |
94 | - generateCatalog : function(){ | |
95 | - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.statistics.id); | |
96 | - if (module) | |
97 | - module.linkedNode.execute(); | |
105 | + generateCatalog : function() | |
106 | + { | |
107 | + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.statistics.id); | |
108 | + if (module) | |
109 | + module.linkedNode.execute(); | |
98 | 110 | }, |
99 | 111 | |
100 | - /* | |
101 | - * Update this.object from form | |
102 | - */ | |
103 | - updateObject : function(){ | |
112 | +/* | |
113 | +* Update this.object from form | |
114 | +*/ | |
115 | + updateObject : function() | |
116 | + { | |
104 | 117 | // get the basic form of the left |
105 | 118 | var basicForm = this.formPanel.items.items[0].getForm(); |
106 | 119 | var updateStatus = true; |
107 | 120 | |
108 | 121 | var formValues = basicForm.getValues(); |
109 | -// this.object.set('name',formValues.name); | |
110 | - this.object.set('description',formValues.description); | |
122 | + //this.object.set('name',formValues.name); | |
123 | + this.object.set('description',formValues.description); | |
111 | 124 | |
112 | 125 | var recs = this.paramGrid.getStore().getNewRecords(); |
113 | 126 | var paramArr = new Array(); |
... | ... | @@ -151,7 +164,8 @@ Ext.define('amdaUI.StatisticsUI', { |
151 | 164 | * Check if changes were made before closing window |
152 | 165 | * @return true if changes |
153 | 166 | */ |
154 | - fclose : function() { | |
167 | + fclose : function() | |
168 | + { | |
155 | 169 | if (this.status == null) |
156 | 170 | return false; |
157 | 171 | |
... | ... | @@ -162,8 +176,8 @@ Ext.define('amdaUI.StatisticsUI', { |
162 | 176 | /** |
163 | 177 | * View configuration |
164 | 178 | */ |
165 | - init : function (config) { | |
166 | - | |
179 | + init : function (config) | |
180 | + { | |
167 | 181 | // var functions = Ext.create('Ext.data.Store', { |
168 | 182 | // fields: ['id', 'name'], |
169 | 183 | // data : [ |
... | ... | @@ -200,231 +214,227 @@ Ext.define('amdaUI.StatisticsUI', { |
200 | 214 | fields: ['name', 'function'] |
201 | 215 | }); |
202 | 216 | |
203 | - this.paramGrid = Ext.create('Ext.grid.Panel', { | |
204 | - title: 'Select Parameter & Apply Function', | |
205 | - selType : 'rowmodel', | |
206 | -// flex: 2, | |
207 | - height :250, | |
208 | - store : store, | |
209 | - columns: [ | |
210 | - { xtype: 'rownumberer' }, | |
217 | + this.paramGrid = Ext.create('Ext.grid.Panel', | |
211 | 218 | { |
212 | - header: "Parameter Name", | |
213 | - dataIndex: 'name', | |
214 | - flex:1, | |
215 | - sortable: false, | |
216 | - menuDisabled : true , | |
217 | - renderer: function (val, meta, rec) { | |
218 | - return rec.getParamFullName(); | |
219 | - } | |
220 | - }, | |
221 | - // { header: 'parameter', dataIndex: 'name', menuDisabled : true, sortable : false }, | |
222 | - { header: 'function', dataIndex: 'function', menuDisabled : true, sortable : false, | |
223 | - editor: { | |
224 | - xtype: 'combo', queryMode : 'local', | |
225 | - // emptyText : 'please click to select function', | |
226 | - store: [ 'min', 'max', 'mean' ], | |
227 | - triggerAction: 'all', | |
228 | - // lazyInit: false, | |
229 | - listeners: { | |
230 | - focus: function(obj) { | |
231 | - obj.expand(); | |
219 | + title: 'Select Parameter & Apply Function', | |
220 | + selType : 'rowmodel', | |
221 | + // flex: 2, | |
222 | + height :250, | |
223 | + store : store, | |
224 | + columns: [ | |
225 | + { xtype: 'rownumberer' }, | |
226 | + { | |
227 | + header: "Parameter Name", | |
228 | + dataIndex: 'name', | |
229 | + flex:1, | |
230 | + sortable: false, | |
231 | + menuDisabled : true , | |
232 | + renderer: function (val, meta, rec) { | |
233 | + return rec.getParamFullName(); | |
234 | + } | |
235 | + }, | |
236 | + // { header: 'parameter', dataIndex: 'name', menuDisabled : true, sortable : false }, | |
237 | + { header: 'function', dataIndex: 'function', menuDisabled : true, sortable : false, | |
238 | + editor: | |
239 | + { | |
240 | + xtype: 'combo', queryMode : 'local', | |
241 | + //emptyText : 'please click to select function', | |
242 | + store: [ 'min', 'max', 'mean' ], | |
243 | + triggerAction: 'all', | |
244 | + //lazyInit: false, | |
245 | + listeners: { | |
246 | + focus: function(obj) { | |
247 | + obj.expand(); | |
248 | + } | |
249 | + } | |
250 | + }, | |
251 | + renderer: function(v) | |
252 | + { | |
253 | + if(v != null && v.length > 0 ) | |
254 | + return v; | |
255 | + else | |
256 | + return 'click to select'; | |
257 | + } | |
258 | + }, | |
259 | + { menuDisabled : true, width: 30, renderer: function(){ | |
260 | + return '<div class="icon-remover" style="width: 15px; height: 15px;"></div>'; | |
232 | 261 | } |
233 | 262 | } |
234 | - }, | |
235 | - renderer: function(v) | |
263 | + ], | |
264 | + plugins: [ Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 })], | |
265 | + listeners : | |
236 | 266 | { |
237 | - if(v != null && v.length > 0 ) | |
238 | - return v; | |
239 | - else | |
240 | - return 'click to select'; | |
241 | - } | |
242 | - }, | |
243 | - { menuDisabled : true, width: 30, renderer: function(){ | |
244 | - return '<div class="icon-remover" style="width: 15px; height: 15px;"></div>'; | |
245 | - } | |
246 | - } | |
247 | - ], | |
248 | - plugins: [ Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 })], | |
249 | - listeners : | |
250 | - { | |
251 | - render : function(o,op) | |
252 | - { | |
253 | - var me = this; | |
254 | - var el = me.body.dom; | |
255 | - var dropTarget = Ext.create('Ext.dd.DropTarget', el, { | |
256 | - ddGroup: 'explorerTree', | |
257 | - notifyOver : function(ddSource, e, data) | |
258 | - { | |
259 | - if (data.records[0].data.nodeType == 'localParam' && data.records[0].get('notyet')) { | |
260 | - this.valid = false; | |
261 | - return this.dropNotAllowed; | |
262 | - } | |
263 | - if (((data.records[0].data.nodeType == 'localParam') || | |
264 | - (data.records[0].data.nodeType == 'remoteParam') || | |
265 | - (data.records[0].data.nodeType == 'remoteSimuParam') || | |
266 | - (data.records[0].data.nodeType == 'derivedParam') || | |
267 | - (data.records[0].data.nodeType == 'myDataParam') || | |
268 | - (data.records[0].data.nodeType == 'alias'))&& | |
269 | - (data.records[0].isLeaf() || data.records[0].data.isParameter) && | |
270 | - !data.records[0].data.disable) | |
271 | - { | |
272 | - this.valid = true; | |
273 | - return this.dropAllowed; | |
274 | - } | |
275 | - | |
276 | - this.valid = false; | |
277 | - return this.dropNotAllowed; | |
278 | - }, | |
279 | - notifyDrop : function(ddSource, e, data) | |
280 | - { | |
281 | - if (!this.valid) | |
282 | - return false; | |
283 | - var nameToSent; | |
284 | - var components = null; | |
285 | - | |
286 | - switch (data.records[0].data.nodeType) | |
267 | + render : function(o,op) | |
287 | 268 | { |
288 | - case 'localParam' : | |
289 | - case 'remoteParam': | |
290 | - case 'remoteSimuParam': | |
291 | - nameToSent = data.records[0].get('id'); | |
292 | - if (data.records[0].get('alias')!= "" ) | |
293 | - var nameToSent = "#"+data.records[0].get('alias'); | |
294 | - var component_info = data.records[0].get('component_info'); | |
295 | - if (component_info && component_info.parentId) | |
296 | - { | |
297 | - if ( component_info.index1 && component_info.index2 ) | |
298 | - { | |
299 | - nameToSent = component_info.parentId; | |
300 | - components = []; | |
301 | - if (component_info.index1) | |
302 | - components['index1'] = component_info.index1; | |
303 | - if (component_info.index2) | |
304 | - components['index2'] = component_info.index2; | |
269 | + var me = this; | |
270 | + var el = me.body.dom; | |
271 | + var dropTarget = Ext.create('Ext.dd.DropTarget', el, { | |
272 | + ddGroup: 'explorerTree', | |
273 | + notifyOver : function(ddSource, e, data) | |
274 | + { | |
275 | + if (data.records[0].data.nodeType == 'localParam' && data.records[0].get('notyet')) { | |
276 | + this.valid = false; | |
277 | + return this.dropNotAllowed; | |
305 | 278 | } |
306 | - if ( data.records[0].get('needsArgs') ) | |
307 | - { | |
308 | - nameToSent = component_info.parentId; | |
309 | - if (component_info.index1) | |
310 | - { | |
311 | - components = []; | |
312 | - components['index1'] = component_info.index1; | |
313 | - } | |
314 | - } | |
279 | + if (((data.records[0].data.nodeType == 'localParam') || | |
280 | + (data.records[0].data.nodeType == 'remoteParam') || | |
281 | + (data.records[0].data.nodeType == 'remoteSimuParam') || | |
282 | + (data.records[0].data.nodeType == 'derivedParam') || | |
283 | + (data.records[0].data.nodeType == 'myDataParam') || | |
284 | + (data.records[0].data.nodeType == 'alias'))&& | |
285 | + (data.records[0].isLeaf() || data.records[0].data.isParameter) && | |
286 | + !data.records[0].data.disable) | |
287 | + { | |
288 | + this.valid = true; | |
289 | + return this.dropAllowed; | |
290 | + } | |
291 | + | |
292 | + this.valid = false; | |
293 | + return this.dropNotAllowed; | |
294 | + }, | |
295 | + notifyDrop : function(ddSource, e, data) | |
296 | + { | |
297 | + if (!this.valid) | |
298 | + return false; | |
299 | + var nameToSent; | |
300 | + var components = null; | |
301 | + | |
302 | + switch (data.records[0].data.nodeType) | |
303 | + { | |
304 | + case 'localParam' : | |
305 | + case 'remoteParam': | |
306 | + case 'remoteSimuParam': | |
307 | + nameToSent = data.records[0].get('id'); | |
308 | + if (data.records[0].get('alias')!= "" ) | |
309 | + var nameToSent = "#"+data.records[0].get('alias'); | |
310 | + var component_info = data.records[0].get('component_info'); | |
311 | + if (component_info && component_info.parentId) | |
312 | + { | |
313 | + if ( component_info.index1 && component_info.index2 ) | |
314 | + { | |
315 | + nameToSent = component_info.parentId; | |
316 | + components = []; | |
317 | + if (component_info.index1) | |
318 | + components['index1'] = component_info.index1; | |
319 | + if (component_info.index2) | |
320 | + components['index2'] = component_info.index2; | |
321 | + } | |
322 | + if ( data.records[0].get('needsArgs') ) | |
323 | + { | |
324 | + nameToSent = component_info.parentId; | |
325 | + if (component_info.index1) | |
326 | + { | |
327 | + components = []; | |
328 | + components['index1'] = component_info.index1; | |
329 | + } | |
330 | + } | |
331 | + } | |
332 | + break; | |
333 | + case 'alias' : | |
334 | + nameToSent = "#"+data.records[0].get('text'); | |
335 | + break; | |
336 | + case 'derivedParam' : | |
337 | + nameToSent = "ws_"+data.records[0].get('text'); | |
338 | + break; | |
339 | + case 'myDataParam' : | |
340 | + nameToSent = "wsd_"+data.records[0].get('text'); | |
341 | + break; | |
342 | + default : | |
343 | + return false; | |
344 | + } | |
345 | + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.statistics.id); | |
346 | + if (module) | |
347 | + { | |
348 | + module.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components); | |
349 | + } | |
350 | + return true; | |
315 | 351 | } |
316 | - break; | |
317 | - case 'alias' : | |
318 | - nameToSent = "#"+data.records[0].get('text'); | |
319 | - break; | |
320 | - case 'derivedParam' : | |
321 | - nameToSent = "ws_"+data.records[0].get('text'); | |
322 | - break; | |
323 | - case 'myDataParam' : | |
324 | - nameToSent = "wsd_"+data.records[0].get('text'); | |
325 | - break; | |
326 | - default : | |
327 | - return false; | |
352 | + }); | |
353 | + }, | |
354 | + cellclick : function(grid, cell, cellIndex, record){ | |
355 | + if (cellIndex == 3) | |
356 | + grid.getStore().remove(record); | |
328 | 357 | } |
329 | - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.statistics.id); | |
330 | - if (module) | |
331 | - { | |
332 | - module.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components); | |
333 | - } | |
334 | - return true; | |
335 | - } | |
336 | - }); | |
337 | - }, | |
338 | - cellclick : function(grid, cell, cellIndex, record){ | |
339 | - if (cellIndex == 3) | |
340 | - grid.getStore().remove(record); | |
341 | - } | |
342 | - } | |
343 | - }); | |
358 | + } | |
359 | + }); | |
344 | 360 | |
345 | 361 | |
346 | - this.formPanel = Ext.create('Ext.form.Panel', { | |
347 | - region: 'center', | |
348 | - layout: 'hbox', | |
349 | -// bodyStyle: {background : '#dfe8f6'}, | |
350 | - defaults: { bodyStyle: {background : '#dfe8f6'}, padding : '3'}, | |
351 | - fieldDefaults: { labelWidth: 80, labelAlign : 'top' }, | |
352 | - items: [ | |
353 | - { | |
354 | - xtype: 'form', | |
355 | - flex : 1, | |
356 | - layout: {type: 'vbox', pack: 'start', align: 'stretch'}, | |
357 | - items : [ | |
358 | - this.paramGrid, | |
359 | - this.timeSelector | |
360 | - ] | |
361 | - }, | |
362 | - { | |
363 | - xtype: 'form', | |
364 | - title: 'Additional Information', | |
365 | - flex : 1, | |
366 | - layout: {type: 'vbox', pack: 'start', align: 'stretch', padding : '3'}, | |
367 | - items : [ | |
368 | - this.fieldName, | |
369 | - { | |
370 | - xtype: 'textarea', | |
371 | - name: 'description', | |
372 | - fieldLabel: 'Description', | |
373 | - height: 200 | |
374 | - } | |
375 | - ], | |
376 | - fbar: | |
377 | - [ | |
378 | - { | |
379 | - type: 'button', | |
380 | - text: 'Generate Catalog', | |
381 | - scope : this, | |
382 | - handler: function(){ | |
383 | - // update object with user's values | |
384 | - // if the return is true (object had been updated) | |
385 | - if(this.updateObject()){ | |
386 | - this.updateObject(); | |
387 | - this.generateCatalog(); | |
388 | - } | |
389 | - } | |
362 | + this.formPanel = Ext.create('Ext.form.Panel', | |
363 | + { | |
364 | + region: 'center', | |
365 | + layout: 'hbox', | |
366 | + //bodyStyle: {background : '#dfe8f6'}, | |
367 | + defaults: { bodyStyle: {background : '#dfe8f6'}, padding : '3'}, | |
368 | + fieldDefaults: { labelWidth: 80, labelAlign : 'top' }, | |
369 | + items: [ | |
370 | + { | |
371 | + xtype: 'form', | |
372 | + flex : 1, | |
373 | + layout: {type: 'vbox', pack: 'start', align: 'stretch'}, | |
374 | + items : [ | |
375 | + this.paramGrid, | |
376 | + this.timeSelector | |
377 | + ] | |
390 | 378 | }, |
391 | - { | |
392 | - type: 'button', | |
393 | - text: 'Reset', | |
394 | - scope : this, | |
395 | - handler: function() { | |
396 | - } | |
397 | - } | |
398 | - ] | |
399 | - } | |
400 | - ] | |
401 | - }); | |
402 | - | |
379 | + { | |
380 | + xtype: 'form', | |
381 | + title: 'Additional Information', | |
382 | + flex : 1, | |
383 | + layout: {type: 'vbox', pack: 'start', align: 'stretch', padding : '3'}, | |
384 | + items : [ | |
385 | + this.fieldName, | |
386 | + { | |
387 | + xtype: 'textarea', | |
388 | + name: 'description', | |
389 | + fieldLabel: 'Description', | |
390 | + height: 200 | |
391 | + } | |
392 | + ], | |
393 | + fbar:[ | |
394 | + { | |
395 | + type: 'button', | |
396 | + text: 'Generate Catalog', | |
397 | + scope : this, | |
398 | + handler: function() | |
399 | + { | |
400 | + // update object with user's values | |
401 | + // if the return is true (object had been updated) | |
402 | + if(this.updateObject()){ | |
403 | + this.updateObject(); | |
404 | + this.generateCatalog(); | |
405 | + } | |
406 | + } | |
407 | + }, | |
408 | + { | |
409 | + type: 'button', | |
410 | + text: 'Reset', | |
411 | + scope : this, | |
412 | + handler: function() {} | |
413 | + }] | |
414 | + }] | |
415 | + }); | |
403 | 416 | |
404 | - | |
405 | - var myConf = { | |
406 | - layout: 'border', | |
407 | - items: [ | |
408 | - this.formPanel, | |
409 | - { | |
410 | - xtype: 'panel', | |
411 | - region: 'south', | |
412 | - title: 'Information', | |
413 | - collapsible: true, | |
414 | - height: 100, | |
415 | - autoHide: false, | |
416 | - bodyStyle: 'padding:5px', | |
417 | - iconCls: 'icon-information', | |
418 | - loader: { | |
419 | - autoLoad: true, | |
420 | - url: helpDir+'statisticsHOWTO' | |
421 | - } | |
422 | - } | |
423 | - ], | |
424 | - plugins: [ {ptype: 'paramArgumentsPlugin', pluginId: 'statistics-param-arguments-plugin'}] | |
425 | - }; | |
417 | + var myConf = { | |
418 | + layout: 'border', | |
419 | + items: [ | |
420 | + this.formPanel, | |
421 | + { | |
422 | + xtype: 'panel', | |
423 | + region: 'south', | |
424 | + title: 'Information', | |
425 | + collapsible: true, | |
426 | + height: 100, | |
427 | + autoHide: false, | |
428 | + bodyStyle: 'padding:5px', | |
429 | + iconCls: 'icon-information', | |
430 | + loader: { | |
431 | + autoLoad: true, | |
432 | + url: helpDir+'statisticsHOWTO' | |
433 | + } | |
434 | + }], | |
435 | + plugins: [ {ptype: 'paramArgumentsPlugin', pluginId: 'statistics-param-arguments-plugin'}] | |
436 | + }; | |
426 | 437 | |
427 | - Ext.apply (this, Ext.apply(arguments, myConf)); | |
428 | - } | |
429 | - | |
438 | + Ext.apply (this, Ext.apply(arguments, myConf)); | |
439 | + } | |
430 | 440 | }); |
... | ... |