Commit bb6e93d91f8c67d5e52bab3b87fb390f2bbd926e

Authored by Benjamin Renard
1 parent 0314bd32

Implement templated parameters for download, data mining and derived parameter

js/app/controllers/ExplorerModule.js
... ... @@ -302,11 +302,41 @@ Ext.define('amdaDesktop.ExplorerModule', {
302 302 },this);
303 303 },
304 304  
305   - getParamInfoInRegistry : function(paramId) {
306   - return this.paramInfoRegistry[paramId];
307   - },
308   -
309   - addParamInfoInRegistry : function(paramId, paramInfo) {
310   - this.paramInfoRegistry[paramId] = paramInfo;
  305 + getParamInfo : function(paramId, onReady) {
  306 + if (this.paramInfoRegistry[paramId]) {
  307 + if (onReady)
  308 + onReady(this.paramInfoRegistry[paramId]);
  309 + return this.paramInfoRegistry[paramId];
  310 + }
  311 +
  312 + var me = this;
  313 + AmdaAction.getParamInfo({"paramId" : paramId}, function (result, e) {
  314 + var paramInfo = null;
  315 + if (e.status === true)
  316 + {
  317 + if (!result.success)
  318 + {
  319 + //No available info for this parameter. Do not display an error message
  320 + /*if (result.message && result.message != '')
  321 + Ext.Msg.show({title:'Get parameter arguments error ', msg: result.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
  322 + else
  323 + Ext.Msg.show({title:'Get parameter arguments error', msg: 'Unknown error', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});*/
  324 + }
  325 + else
  326 + {
  327 + //Store parameter info in registry
  328 + me.paramInfoRegistry[paramId] = result;
  329 + paramInfo = result;
  330 + }
  331 + }
  332 + else
  333 + {
  334 + Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
  335 + }
  336 +
  337 + if (onReady)
  338 + onReady(paramInfo);
  339 + });
  340 + return null;
311 341 }
312 342 });
... ...
js/app/models/Download.js
... ... @@ -80,9 +80,9 @@ Ext.define('amdaModel.Download', {
80 80 var list = this.get('list');
81 81 myValues.list=[];
82 82  
83   - Ext.each(list, function(item, index){
84   - myValues.list[index] = {'name' : item.get('name'), 'type' : item.get('type'), 'dim1' : item.get('dim1'), 'dim2' : item.get('dim2')};
85   - });
  83 + Ext.each(list, function(item, index){
  84 + myValues.list[index] = item.getJsonValues();
  85 + });
86 86 }
87 87 myValues.fileformat = this.get('fileformat');
88 88 myValues.timeformat = this.get('timeformat');
... ...
js/app/models/DownloadNode.js
... ... @@ -82,7 +82,7 @@ Ext.define('amdaModel.DownloadNode', {
82 82 fullObject.tabs().each(function (tab) {
83 83 tab.panels().each(function (panel) {
84 84 panel.params().each(function (param) {
85   - myValues.list[i] = param.get('param-id');
  85 + myValues.list[i] = param.get('paramid');
86 86 ++i;
87 87 });
88 88 });
... ...
js/app/models/DownloadParam.js
... ... @@ -3,7 +3,7 @@
3 3 * Name : DownloadParam.js
4 4 * Description : Download Param Business Object Definition
5 5 * @class amdaModel.DownloadParam
6   - * @extends amdaModel.AmdaObject
  6 + * @extends amdaModel.RequestParamObject
7 7 *
8 8 * @author benjamin
9 9 * @version $Id: Download.js 2068 2016-04-21 11:27:38Z benjamin $
... ... @@ -15,12 +15,5 @@
15 15  
16 16  
17 17 Ext.define('amdaModel.DownloadParam', {
18   - extend: 'amdaModel.AmdaObject',
19   -
20   - fields : [
21   - {name: 'type', type: 'int'},
22   - {name: 'dim1', type: 'string'},
23   - {name: 'dim2', type: 'string'}
24   - ]
25   -
  18 + extend: 'amdaModel.RequestParamObject'
26 19 });
... ...
js/app/models/PlotObjects/PlotPanelObject.js
... ... @@ -276,7 +276,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
276 276 var emptyPanel = (this.params().getCount() == 0);
277 277  
278 278 var recs = this.params().add({id : this.get('last-param-id')});
279   - recs[0].set('param-id', paramId);
  279 + recs[0].set('paramid', paramId);
280 280  
281 281 var me = this;
282 282 amdaPlotObj.PlotObjectConfig.getParamConfig(paramId, function (success, data) {
... ...
js/app/models/PlotObjects/PlotParamObject.js
... ... @@ -2,7 +2,7 @@
2 2 * Projectย  : AMDA-NG
3 3 * Name : PlotParamObject.js
4 4 * @class amdaPlotObj.PlotParamObject
5   - * @extends Ext.data.Model
  5 + * @extends amdaModel.RequestParamObject
6 6 * @brief Plot Param Business Object Definition
7 7 * @author Benjamin Renard
8 8 * @version $Id: PlotParamObject.js benjamin $
... ... @@ -14,8 +14,7 @@
14 14  
15 15  
16 16 Ext.define('amdaPlotObj.PlotParamObject', {
17   - extend: 'Ext.data.Model',
18   - idProperty: 'id',
  17 + extend: 'amdaModel.RequestParamObject',
19 18  
20 19 requires: [
21 20 'amdaPlotObj.PlotObjectConfig',
... ... @@ -29,14 +28,8 @@ Ext.define('amdaPlotObj.PlotParamObject', {
29 28 ],
30 29  
31 30 fields : [
32   - {name: 'id', type: 'int'},
33   - {name: 'param-id', type: 'string'},
34   - {name: 'param-type', type: 'int'},
35   - {name: 'param-dim-1', type: 'string'},
36   - {name: 'param-dim-2', type: 'string'},
37 31 {name: 'param-drawing-type', type: 'string'},
38   - {name: 'param-drawing-object', type: 'auto'},
39   - {name: 'param-template-args', type: 'auto'}
  32 + {name: 'param-drawing-object', type: 'auto'}
40 33 ],
41 34  
42 35 associations : [
... ... @@ -152,35 +145,9 @@ Ext.define('amdaPlotObj.PlotParamObject', {
152 145 var availableDrawingObjects = this.getAvailableDrawingObjectByPlotType(plotType);
153 146 var type = amdaPlotObj.PlotObjectConfig.getValueByKey(availableDrawingObjects, this.get('param-drawing-type'));
154 147  
155   - var info = '';
156   -
157   - var paramIndexes = '';
158   - switch (this.get('param-type')) {
159   - case 0:
160   - //scalar - nothing to do
161   - break;
162   - case 1:
163   - //Tab1D
164   - if ((this.get('param-dim-1') != '') && (this.get('param-dim-1') != '*'))
165   - paramIndexes = '('+this.get('param-dim-1')+')';
166   - else if ((this.get('param-dim-2') != '') && (this.get('param-dim-2') != '*'))
167   - paramIndexes = '('+this.get('param-dim-2')+')';
168   - break;
169   - case 2:
170   - //Tab2D
171   - var dim1 = this.get('param-dim-1') != '' ? this.get('param-dim-1') : "*";
172   - var dim2 = this.get('param-dim-2') != '' ? this.get('param-dim-2') : "*";
173   - if ((dim1 != '*') || (dim2 != '*'))
174   - paramIndexes = '('+dim1+','+dim2+')';
175   - }
  148 + var fullName = this.getParamFullName();
176 149  
177   - var template_args = "";
178   - if (this.get('param-template-args')) {
179   - Ext.Object.each(this.get('param-template-args'), function (argKey, argValue) {
180   - template_args += "_";
181   - template_args += argValue;
182   - });
183   - }
  150 + var info = '';
184 151  
185 152 switch (plotType)
186 153 {
... ... @@ -188,16 +155,16 @@ Ext.define('amdaPlotObj.PlotParamObject', {
188 155 if (this.get('param-drawing-type') == 'orbit-serie')
189 156 {
190 157 var projection = amdaPlotObj.PlotObjectConfig.getValueByKey(amdaPlotObj.PlotObjectConfig.availableOrbitSerieProjections, this.get('param-drawing-object').get('serie-projection'));
191   - info = this.get('param-id')+template_args+paramIndexes+', '+projection;
  158 + info = fullName+', '+projection;
192 159 }
193 160 else
194   - info = this.get('param-id')+template_args+paramIndexes+' = f('+this.get('param-drawing-object').get('serie-xaxis-param')+', t)';
  161 + info = fullName+' = f('+this.get('param-drawing-object').get('serie-xaxis-param')+', t)';
195 162 break;
196 163 case 'instantPlot' :
197   - info = this.get('param-id')+template_args+paramIndexes;
  164 + info = fullName;
198 165 break;
199 166 default :
200   - info = this.get('param-id')+template_args+paramIndexes+' = f(t)';
  167 + info = fullName+' = f(t)';
201 168 }
202 169  
203 170 info += ', '+type;
... ... @@ -229,26 +196,12 @@ Ext.define('amdaPlotObj.PlotParamObject', {
229 196  
230 197 getJsonValues : function()
231 198 {
232   - var paramValues = new Object();
  199 + var paramValues = this.callParent(arguments);
233 200  
234   - paramValues['id'] = this.get('id');
235   -
236   - paramValues['param-id'] = this.get('param-id');
237   - paramValues['param-type'] = this.get('param-type');
238   - paramValues['param-dim-1'] = this.get('param-dim-1');
239   - paramValues['param-dim-2'] = this.get('param-dim-2');
240 201 paramValues['param-drawing-type'] = this.get('param-drawing-type');
241   -
242 202 if (this.get('param-drawing-object') != null)
243 203 paramValues['param-drawing-object'] = this.get('param-drawing-object').getJsonValues();
244 204  
245   - if (this.get('param-template-args') != null) {
246   - paramValues['param-template-args'] = new Object();
247   - Ext.Object.each(this.get('param-template-args'), function (argKey, argValue) {
248   - paramValues['param-template-args'][argKey] = argValue;
249   - });
250   - }
251   -
252 205 return paramValues;
253 206 }
254 207 });
255 208 \ No newline at end of file
... ...
js/app/models/RequestParamObject.js 0 โ†’ 100644
... ... @@ -0,0 +1,83 @@
  1 +/**
  2 + * Projectย  : AMDA-NG
  3 + * Name : RequestParamObject.js
  4 + * Description : Request Param Business Object Definition
  5 + * @class amdaModel.RequestParamObject
  6 + * @extends amdaModel.AmdaObject
  7 + *
  8 + * @author benjamin
  9 + * @version $Id: $
  10 + ******************************************************************************
  11 + * FT Id : Date : Name - Description
  12 + ******************************************************************************
  13 + * : :13/06/2016: benjamin โ€“ creation
  14 + */
  15 +
  16 +
  17 +Ext.define('amdaModel.RequestParamObject', {
  18 + extend: 'amdaModel.AmdaObject',
  19 +
  20 + idProperty: 'id',
  21 +
  22 + fields : [
  23 + {name: 'type', type: 'int'},
  24 + {name: 'paramid', type: 'string'},
  25 + {name: 'dim1', type: 'string'},
  26 + {name: 'dim2', type: 'string'},
  27 + {name: 'template_args', type: 'auto', defaultValue: null}
  28 + ],
  29 +
  30 + getParamFullName : function() {
  31 + var paramIndexes = '';
  32 + switch (this.get('type')) {
  33 + case 0:
  34 + //scalar - nothing to do
  35 + break;
  36 + case 1:
  37 + //Tab1D
  38 + if ((this.get('dim1') != '') && (this.get('dim1') != '*'))
  39 + paramIndexes = '('+this.get('dim1')+')';
  40 + else if ((this.get('dim2') != '') && (this.get('dim2') != '*'))
  41 + paramIndexes = '('+this.get('dim2')+')';
  42 + break;
  43 + case 2:
  44 + //Tab2D
  45 + var dim1 = this.get('dim1') != '' ? this.get('dim1') : "*";
  46 + var dim2 = this.get('dim2') != '' ? this.get('dim2') : "*";
  47 + if ((dim1 != '*') || (dim2 != '*'))
  48 + paramIndexes = '('+dim1+','+dim2+')';
  49 + }
  50 +
  51 + var template_args = "";
  52 + if (this.get('template_args')) {
  53 + Ext.Object.each(this.get('template_args'), function (argKey, argValue) {
  54 + template_args += "_";
  55 + template_args += argValue;
  56 + });
  57 + }
  58 +
  59 + return this.get('paramid')+template_args+paramIndexes;
  60 + },
  61 +
  62 + getJsonValues : function()
  63 + {
  64 + var paramValues = new Object();
  65 +
  66 + paramValues['id'] = this.get('id');
  67 + paramValues['paramid'] = this.get('paramid');
  68 + paramValues['name'] = this.get('name');
  69 + paramValues['dim1'] = this.get('dim1');
  70 + paramValues['dim2'] = this.get('dim2');
  71 + paramValues['type'] = this.get('type');
  72 +
  73 + if (this.get('template_args') != null) {
  74 + paramValues['template_args'] = new Object();
  75 + Ext.Object.each(this.get('template_args'), function (argKey, argValue) {
  76 + paramValues['template_args'][argKey] = argValue;
  77 + });
  78 + }
  79 +
  80 + return paramValues;
  81 + }
  82 +
  83 +});
0 84 \ No newline at end of file
... ...
js/app/views/DownloadUI.js
... ... @@ -40,7 +40,7 @@ Ext.define('amdaUI.DownloadUI', {
40 40 },
41 41  
42 42 addTT : function(newTTName,newTTid)
43   - {
  43 + {
44 44 var tabPanel = this.formPanel.down();
45 45 var downloadSrc = tabPanel.items.indexOf(tabPanel.getActiveTab());
46 46  
... ... @@ -84,18 +84,15 @@ Ext.define('amdaUI.DownloadUI', {
84 84 this.timeSelector.intervalSel.updateDuration();
85 85 },
86 86  
87   - addParam : function(newParamName,isLeaf)
  87 + addParam : function(paramId,isArgsToDefined)
88 88 {
89   - // search for an existing record in store with this unique name
90   - var existingIndex = this.paramGrid.store.findExact('name', newParamName);
91   - // if no corresponding parameter found
92   - if (existingIndex == -1){
93   - // adding the parameter to the paramGrid
94   - var r = Ext.create('amdaModel.DownloadParam', {name: newParamName, type: 0, dim1: '', dim2: '' });
95   - var pos = newParamName.indexOf('ws_',0) == -1 ? 0 :this.paramGrid.store.getCount();
96   - this.paramGrid.store.insert(pos,r);
97   - this.paramGrid.getView().refresh();
98   - }
  89 + // adding the parameter to the paramGrid
  90 + var r = Ext.create('amdaModel.DownloadParam', {paramid: paramId, type: 0, dim1: '', dim2: '', template_args: {} });
  91 + var pos = paramId.indexOf('ws_',0) == -1 ? 0 :this.paramGrid.store.getCount();
  92 + this.paramGrid.store.insert(pos,r);
  93 + this.paramGrid.getView().refresh();
  94 + if (isArgsToDefined)
  95 + this.editParameterArgs(r);
99 96 },
100 97  
101 98 addParams: function(arrayParams)
... ... @@ -108,12 +105,12 @@ Ext.define('amdaUI.DownloadUI', {
108 105 Ext.Array.each(arrayParams,function(item){
109 106 if (Ext.isObject(item)) {
110 107 // for Parameter Name in Download Module
111   - var r = Ext.create('amdaModel.DownloadParam', { name: item.get('name'), type: item.get('type'), dim1: item.get('dim1'), dim2: item.get('dim2')});
  108 + var r = Ext.create('amdaModel.DownloadParam', { paramid: item.get('paramid'), type: item.get('type'), dim1: item.get('dim1'), dim2: item.get('dim2')});
112 109 }
113 110 else {
114 111 // for Download By Request in Operations menu
115 112 //ToDo BRE - Components selection
116   - var r = Ext.create('amdaModel.DownloadParam', { name: item });
  113 + var r = Ext.create('amdaModel.DownloadParam', { paramid: item });
117 114 }
118 115 arrayRec.push(r);
119 116 });
... ... @@ -262,23 +259,20 @@ Ext.define('amdaUI.DownloadUI', {
262 259  
263 260  
264 261 actionItem: function(grid, cell, cellIndex, record, row, recordIndex, e){
  262 + this.paramGrid.getView().select(row);
265 263 if (cellIndex == 3)
266 264 grid.getStore().remove(record);
267 265 else if (cellIndex == 2)
268   - this.editParameterArgs(record.get('name'));
  266 + this.editParameterArgs(record);
269 267 },
270 268  
271   - editParameterArgs: function(name) {
  269 + editParameterArgs: function(record) {
272 270 var paramArgsPlug = this.getPlugin('download-param-arguments-plugin');
273 271 if (paramArgsPlug)
274   - paramArgsPlug.show(name);
  272 + paramArgsPlug.show('download-param-arguments-plugin', record);
275 273 },
276 274  
277   - onApplyParameterArgs : function(parentUI, paramId, values) {
278   - var selection = parentUI.paramGrid.getView().getSelectionModel().getSelection()[0];
279   - selection.set('type', values.type ? values.type : 0);
280   - selection.set('dim1', values.dim_1 ? values.dim_1 : '');
281   - selection.set('dim2', values.dim_2 ? values.dim_2 : '');
  275 + onApplyParameterArgs : function(parentUI, paramObject) {
282 276 parentUI.paramGrid.getView().refresh();
283 277 },
284 278  
... ... @@ -330,26 +324,7 @@ Ext.define('amdaUI.DownloadUI', {
330 324 sortable: false,
331 325 menuDisabled : true ,
332 326 renderer: function (val, meta, rec) {
333   - var fullVal = val;
334   - switch (rec.get('type')) {
335   - case 0:
336   - //scalar - nothing to do
337   - break;
338   - case 1:
339   - //Tab1D
340   - if ((rec.get('dim1') != '') && (rec.get('dim1') != '*'))
341   - fullVal += '('+rec.get('dim1')+')';
342   - else if ((rec.get('dim2') != '') && (rec.get('dim2') != '*'))
343   - fullVal += '('+rec.get('dim2')+')';
344   - break;
345   - case 2:
346   - //Tab2D
347   - var dim1 = rec.get('dim1') != '' ? rec.get('dim1') : "*";
348   - var dim2 = rec.get('dim2') != '' ? rec.get('dim2') : "*";
349   - if ((dim1 != '*') || (dim2 != '*'))
350   - fullVal += '('+dim1+','+dim2+')';
351   - }
352   - return fullVal;
  327 + return rec.getParamFullName();
353 328 }
354 329 },
355 330 {
... ... @@ -400,31 +375,31 @@ Ext.define('amdaUI.DownloadUI', {
400 375 {
401 376 if (!this.valid)
402 377 return false;
403   - var nameToSent;
  378 + var idToSent;
404 379 switch (data.records[0].data.nodeType)
405 380 {
406 381 case 'localParam' :
407 382 case 'remoteParam':
408 383 case 'remoteSimuParam':
409   - nameToSent = data.records[0].get('id');
  384 + idToSent = data.records[0].get('id');
410 385 if (data.records[0].get('alias')!= "" )
411   - var nameToSent = "#"+data.records[0].get('alias');
  386 + var idToSent = "#"+data.records[0].get('alias');
412 387 break;
413 388 case 'alias' :
414   - nameToSent = "#"+data.records[0].get('text');
  389 + idToSent = "#"+data.records[0].get('text');
415 390 break;
416 391 case 'derivedParam' :
417   - nameToSent = "ws_"+data.records[0].get('text');
  392 + idToSent = "ws_"+data.records[0].get('text');
418 393 break;
419 394 case 'myDataParam' :
420   - nameToSent = "wsd_"+data.records[0].get('text');
  395 + idToSent = "wsd_"+data.records[0].get('text');
421 396 break;
422 397 default :
423 398 return false;
424 399 }
425 400 var downModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id);
426 401 if (downModule)
427   - downModule.addParam(nameToSent,true);
  402 + downModule.addParam(idToSent,!data.records[0].get('leaf') || data.records[0].get('needsArgs'));
428 403 return true;
429 404 }
430 405 });
... ...
js/app/views/ParamArgumentsPlug.js
... ... @@ -20,8 +20,8 @@ Ext.define('amdaUI.ParamArgumentsPlug', {
20 20  
21 21 win : null,
22 22 form : null,
  23 + paramObject: null,
23 24 paramArgs: null,
24   - paramId: '',
25 25  
26 26 onApply: null,
27 27  
... ... @@ -45,11 +45,11 @@ Ext.define('amdaUI.ParamArgumentsPlug', {
45 45 /**
46 46 * creation of the window
47 47 */
48   - show : function(paramId, crtArgsValues) {
  48 + show : function(prefixId, paramRequestObject) {
49 49 if (!this.win)
50 50 {
51   - this.win = new Ext.Window({
52   - id: 'param-comp-win',
  51 + this.win = new Ext.Window({
  52 + id: prefixId + '-param-arg-win',
53 53 width: 200,
54 54 height: 150,
55 55 x: 0, y: 0,
... ... @@ -61,7 +61,8 @@ Ext.define('amdaUI.ParamArgumentsPlug', {
61 61 resizable: false,
62 62 ghost: false,
63 63 renderTo: this.hostCmp.ownerCt.body,
64   - items: this.getFormConfig(),
  64 + items: this.getFormConfig(),
  65 + closeAction: 'hide',
65 66 listeners: {
66 67 scope: this,
67 68 beforeclose: function() {
... ... @@ -77,16 +78,21 @@ Ext.define('amdaUI.ParamArgumentsPlug', {
77 78 }
78 79 }
79 80 });
80   -
  81 +
81 82 this.win.on('destroy', this.onDestroy, this);
82 83  
83 84 Ext.PluginManager.register(this);
84 85 }
85 86  
86   - this.win.setTitle('Arguments for ' + paramId);
  87 + this.win.setTitle('Arguments for ' + paramRequestObject.get('paramid'));
87 88  
88   - this.paramId = paramId;
89   - this.paramArgs.editParameter(paramId, crtArgsValues, this.hostCmp);
  89 + //Work with a clone of the request para object.
  90 + this.paramObject = paramRequestObject;
  91 + var workingParamObject = this.paramObject.copy();
  92 + var me = this;
  93 + this.paramArgs.editParameter(workingParamObject, this.hostCmp, function() {
  94 + me.win.setHeight(me.paramArgs.items.getCount() * 30 + 75);
  95 + });
90 96  
91 97 this.hostCmp.setDisabled(true);
92 98 this.win.show();
... ... @@ -119,17 +125,18 @@ Ext.define('amdaUI.ParamArgumentsPlug', {
119 125 labelWidth: 60
120 126 },
121 127 items: [
122   - this.paramArgs
  128 + me.paramArgs
123 129 ],
124 130 buttons: [
125 131 {
126 132 text: 'Apply',
127 133 scope : this,
128 134 handler: function(bt,event) {
129   - if (me.paramArgs) {
130   - if (me.onApply)
131   - me.onApply(this.hostCmp, me.paramId, me.paramArgs.getValues());
132   - }
  135 + //Set modification
  136 + if (me.paramObject)
  137 + me.paramObject = me.paramArgs.paramRequestObject;
  138 + if (me.onApply)
  139 + me.onApply(me.hostCmp, me.paramArgs.paramRequestObject);
133 140 me.close();
134 141 }
135 142 },
... ...
js/app/views/ParamArgumentsUI.js
... ... @@ -15,6 +15,7 @@ Ext.define('amdaUI.ParamArgumentsUI', {
15 15  
16 16 regexp_istemplate: /^template_(.*)/,
17 17  
  18 + paramRequestObject: null,
18 19 onChange: null,
19 20  
20 21 // -1 -> unknown, 0 -> scalar, 1 -> Tab1D, 2 -> Tab2D
... ... @@ -36,7 +37,8 @@ Ext.define('amdaUI.ParamArgumentsUI', {
36 37 Ext.apply (this , Ext.apply (arguments, myConf));
37 38 },
38 39  
39   - editParameter: function(paramId, crtArgsValues, uiScope, onReady) {
  40 + editParameter: function(paramRequestObject, uiScope, onReady) {
  41 + this.paramRequestObject = paramRequestObject;
40 42 var me = this;
41 43 me.mask();
42 44 me.resetArguments();
... ... @@ -44,94 +46,68 @@ Ext.define('amdaUI.ParamArgumentsUI', {
44 46 var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id);
45 47  
46 48 if (explorerModule) {
47   - paramInfo = explorerModule.getParamInfoInRegistry(paramId);
48   - if (paramInfo) {
49   - //Re-use already loaded param info
50   - me.rebuildAll(paramInfo, crtArgsValues, uiScope);
51   - if (onReady)
  49 + explorerModule.getParamInfo(paramRequestObject.get('paramid'), function (paramInfo) {
  50 + if (paramInfo)
  51 + me.rebuildAll(paramInfo, uiScope);
  52 + if (onReady)
52 53 onReady(uiScope);
53   - me.unmask();
54   - return;
55   - }
  54 + me.unmask();
  55 + });
56 56 }
57   -
58   - //Ajax request to get parameter info
59   - AmdaAction.getParamInfo({"paramId" : paramId}, function (result, e) {
60   - if (e.status === true)
61   - {
62   - if (!result.success)
63   - {
64   - if (result.message && result.message != '')
65   - Ext.Msg.show({title:'Get parameter arguments error ', msg: result.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
66   - else
67   - Ext.Msg.show({title:'Get parameter arguments error', msg: 'Unknown error', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
68   - }
69   - else
70   - {
71   - //Store parameter info in registry
72   - if (explorerModule)
73   - explorerModule.addParamInfoInRegistry(paramId, result);
74   -
75   - me.rebuildAll(result, crtArgsValues, uiScope);
76   -
77   - if (onReady)
78   - onReady(uiScope);
79   - }
80   - }
81   - else
82   - {
83   - Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
84   - }
  57 + else
85 58 me.unmask();
86   - });
87 59 },
88 60  
89   - rebuildAll: function(paramInfoResult, crtArgsValues, uiScope) {
  61 + rebuildAll: function(paramInfoResult , uiScope) {
90 62 //Rebuild arguments selection
91 63 this.rebuildArguments(paramInfoResult, uiScope);
92 64  
93   - //Set values
94   - var argsValues = crtArgsValues;
95   - if (!argsValues)
96   - argsValues = {};
  65 + //Set parameter type (scalar, vector or Tab2D)
  66 + this.paramRequestObject.set('type', this.paramType);
  67 +
  68 + //Add default template args values
  69 + var templateArgsValues = this.paramRequestObject.get('template_args');
  70 + if (!templateArgsValues)
  71 + templateArgsValues = {};
97 72 if (paramInfoResult.template && paramInfoResult.template.arguments) {
98   - if (!argsValues['template_args'])
99   - argsValues['template_args'] = {};
100   -
101 73 //Add default template args definition if needed
102 74 Ext.Object.each(paramInfoResult.template.arguments, function (argKey, argDef) {
103   - if (!argsValues['template_args'][argKey])
104   - argsValues['template_args'][argKey] = argDef['default'];
  75 + if (!templateArgsValues[argKey])
  76 + templateArgsValues[argKey] = argDef['default'];
105 77 }, this);
  78 +
  79 + this.paramRequestObject.set('template_args', templateArgsValues);
106 80 }
107   - this.setValues(argsValues);
108   - },
109   -
110   - setValues: function(values) {
111   - this.items.each(function (item) {
112   - if (this.regexp_istemplate.test(item.getId())) {
113   - var arg_key = this.regexp_istemplate.exec(item.getId())[1];
114   - if (values['template_args'] && values['template_args'][arg_key])
115   - item.setValue(values['template_args'][arg_key]);
  81 +
  82 +
  83 + //Init values in interface
  84 + this.items.each(function (item) {
  85 + if (!item.argId)
  86 + return;
  87 + if (this.regexp_istemplate.test(item.argId)) {
  88 + var arg_key = this.regexp_istemplate.exec(item.argId)[1];
  89 +
  90 + if (this.paramRequestObject.get('template_args') && this.paramRequestObject.get('template_args')[arg_key])
  91 + item.setValue(this.paramRequestObject.get('template_args')[arg_key]);
116 92 }
117   - else if (values[item.getId()])
118   - item.setValue(values[item.getId()]);
  93 + else if (this.paramRequestObject.get(item.argId))
  94 + item.setValue(this.paramRequestObject.get(item.argId));
119 95 }, this);
120 96 },
121 97  
122 98 getValues: function() {
123 99 var values = {type : this.paramType};
124 100 this.items.each(function(item) {
125   - if (item.getId() == 'no-arg')
  101 + if (!item.argId)
126 102 return;
127   - if (this.regexp_istemplate.test(item.getId())) {
128   - var arg_key = this.regexp_istemplate.exec(item.getId())[1];
  103 + if (this.regexp_istemplate.test(item.argId)) {
  104 + var arg_key = this.regexp_istemplate.exec(item.argId)[1];
129 105 if (!values['template_args'])
130 106 values['template_args'] = {};
131 107 values['template_args'][arg_key] = item.getValue();
132 108 }
133 109 else
134   - values[item.getId()] = item.getValue();
  110 + values[item.argId] = item.getValue();
135 111 }, this);
136 112  
137 113 return values;
... ... @@ -146,7 +122,7 @@ Ext.define('amdaUI.ParamArgumentsUI', {
146 122 resetArguments: function(noArgsMsg) {
147 123 this.removeAll();
148 124 if (!noArgsMsg)
149   - this.add(new Ext.form.Label({text: 'No argument for this parameter', id: 'no-arg'}));
  125 + this.add(new Ext.form.Label({text: 'No argument for this parameter', argId: null}));
150 126 },
151 127  
152 128 rebuildArguments: function(result, uiScope) {
... ... @@ -156,11 +132,11 @@ Ext.define('amdaUI.ParamArgumentsUI', {
156 132 if (result.data && result.data.dimensions) {
157 133 this.paramType = 0;
158 134 if (result.data.dimensions.dim_1 && (parseInt(result.data.dimensions.dim_1) > 1)) {
159   - this.buildDimIndexSelection("dim_1", result.data, uiScope);
  135 + this.buildDimIndexSelection("dim1", result.data, uiScope);
160 136 ++this.paramType;
161 137 }
162 138 if (result.data.dimensions.dim_2 && (parseInt(result.data.dimensions.dim_2) > 1)) {
163   - this.buildDimIndexSelection("dim_2", result.data, uiScope);
  139 + this.buildDimIndexSelection("dim2", result.data, uiScope);
164 140 ++this.paramType;
165 141 }
166 142 }
... ... @@ -201,15 +177,15 @@ Ext.define('amdaUI.ParamArgumentsUI', {
201 177 }
202 178 else {
203 179 //Else, use components
204   - if (relatedDim == "dim_1")
  180 + if (relatedDim == "dim1")
205 181 title = 'Dim. 1';
206   - else if (relatedDim == "dim_2")
  182 + else if (relatedDim == "dim2")
207 183 title = 'Dim. 2';
208 184  
209 185 Ext.Object.each(data.components, function (index, component) {
210   - if (relatedDim == "dim_1" && component.index_1 != "")
  186 + if (relatedDim == "dim1" && component.index_1 != "")
211 187 indexes.push({'key' : component.index_1, 'value' : index + ' : ' + component.name});
212   - else if (relatedDim == "dim_2" && component.index_2 != "")
  188 + else if (relatedDim == "dim2" && component.index_2 != "")
213 189 indexes.push({'key' : component.index_2, 'value' : index + ' : ' + component.name});
214 190 });
215 191 }
... ... @@ -228,9 +204,10 @@ Ext.define('amdaUI.ParamArgumentsUI', {
228 204 valueField: 'key',
229 205 value: '*',
230 206 editable: false,
231   - id: relatedDim,
  207 + argId: relatedDim,
232 208 listeners: {
233 209 change: function(field, newValue, oldValue, eOpts) {
  210 + this.paramRequestObject.set(relatedDim, newValue);
234 211 if (this.onChange != null)
235 212 this.onChange(uiScope, relatedDim, newValue, oldValue, false);
236 213 },
... ... @@ -250,13 +227,18 @@ Ext.define('amdaUI.ParamArgumentsUI', {
250 227 switch (argument.type) {
251 228 case 'float' :
252 229 var argumentField = Ext.create('Ext.form.NumberField', {
253   - id: 'template_' + key,
  230 + argId: 'template_' + key,
254 231 fieldLabel: argument.name,
255 232 decimalPrecision : 3,
256 233 allowBlank : false,
257 234 value: parseFloat(argument.default),
258 235 listeners: {
259 236 change: function(field, newValue, oldValue, eOpts) {
  237 + var template_args = me.paramRequestObject.get('template_args');
  238 + if (!template_args)
  239 + template_args = {};
  240 + template_args[key] = newValue;
  241 + me.paramRequestObject.set('template_args', template_args);
260 242 if (me.onChange != null)
261 243 me.onChange(uiScope, key, newValue, oldValue, true);
262 244 },
... ... @@ -285,10 +267,15 @@ Ext.define('amdaUI.ParamArgumentsUI', {
285 267 valueField: 'key',
286 268 value: argument.default,
287 269 editable: false,
288   - id: 'template_' + key,
  270 + argId: 'template_' + key,
289 271 listeners: {
290 272 change: function(field, newValue, oldValue, eOpts) {
291   - if (me.onChange != null)
  273 + var template_args = me.paramRequestObject.get('template_args');
  274 + if (!template_args)
  275 + template_args = {};
  276 + template_args[key] = newValue;
  277 + me.paramRequestObject.set('template_args', template_args);
  278 + if (me.onChange != null)
292 279 me.onChange(uiScope, key, newValue, oldValue, true);
293 280 },
294 281 scope: me
... ...
js/app/views/ParameterUI.js
... ... @@ -41,28 +41,9 @@ Ext.define('amdaUI.ParameterUI', {
41 41 this.constructionField.setCaretPosition(this.constructionField.getValue().length);
42 42 },
43 43  
44   - onApplyParameterArgs : function(uiScope, paramId, values) {
45   - var fullParam = paramId;
46   - switch (values['type']) {
47   - case 0:
48   - //scalar - nothing to do
49   - break;
50   - case 1:
51   - //Tab1D
52   - if (values['dim_1'] && (values['dim_1'] != '') && (values['dim_1'] != '*'))
53   - fullParam += '('+values['dim_1']+')';
54   - else if (values['dim_2'] && (values['dim_2'] != '') && (values['dim_2'] != '*'))
55   - fullParam += '('+values['dim_2']+')';
56   - break;
57   - case 2:
58   - //Tab2D
59   - var dim1 = (values['dim_1'] && (values['dim_1'] != '')) ? values['dim_1'] : "*";
60   - var dim2 = (values['dim_2'] && (values['dim_2'] != '')) ? values['dim_2'] : "*";
61   - if ((dim1 != '*') || (dim2 != '*'))
62   - fullParam += '('+dim1+','+dim2+')';
63   - }
64   -
65   - uiScope.addParamInEditor(fullParam);
  44 + onApplyParameterArgs : function(uiScope, paramRequestObject) {
  45 + var fullParam = paramRequestObject.getParamFullName();
  46 + uiScope.addParamInEditor(fullParam);
66 47 },
67 48  
68 49 addParam : function(newParamName, isArgsToDefined) {
... ... @@ -74,8 +55,10 @@ Ext.define('amdaUI.ParameterUI', {
74 55  
75 56 editParameterArgs: function(name) {
76 57 var paramArgsPlug = this.getPlugin('derived-param-arguments-plugin');
77   - if (paramArgsPlug)
78   - paramArgsPlug.show(name);
  58 + if (paramArgsPlug) {
  59 + var workinRequestParamObject = Ext.create('amdaModel.RequestParamObject', {paramid: name, type: 0, dim1: '', dim2: '', template_args: {} });
  60 + paramArgsPlug.show('derived-param-arguments-plugin', workinRequestParamObject);
  61 + }
79 62 },
80 63  
81 64 setObject : function (object) {
... ...
js/app/views/PlotComponents/PlotParamForm.js
... ... @@ -38,7 +38,7 @@ Ext.define('amdaPlotComp.PlotParamForm', {
38 38 setObject : function(object) {
39 39 this.object = object;
40 40 this.loadRecord(this.object);
41   - this.updateDrawingOptions(this.object.get('param-drawing-type'), this.object.get('param-id'));
  41 + this.updateDrawingOptions(this.object.get('param-drawing-type'), this.object.get('paramid'));
42 42 },
43 43  
44 44 getDrawingOptionsForm: function(type) {
... ... @@ -103,29 +103,12 @@ Ext.define('amdaPlotComp.PlotParamForm', {
103 103 drawingOptionsForm.setObject(this.object);
104 104  
105 105 if (this.paramArgs && paramId)
106   - this.paramArgs.editParameter(paramId, {'dim_1' : this.object.get('param-dim-1'), 'dim_2' : this.object.get('param-dim-2'), 'template_args' : this.object.get('param-template-args')}, this, function (uiScope) {
107   - uiScope.object.set('param-type', uiScope.paramArgs.paramType);
108   - var crtValues = uiScope.paramArgs.getValues();
109   - if (crtValues && crtValues['template_args'])
110   - uiScope.object.set('param-template-args', crtValues['template_args']);
  106 + this.paramArgs.editParameter(this.object, this, function (uiScope) {
111 107 uiScope.crtTree.refresh();
112 108 });
113 109 },
114 110  
115 111 onChangeParamArgs: function(uiScope, args_key, newValue, oldValue, isTemplateArg) {
116   - if (!isTemplateArg) {
117   - if (args_key == 'dim_1')
118   - uiScope.object.set('param-dim-1', newValue);
119   - else if (args_key == 'dim_2')
120   - uiScope.object.set('param-dim-2', newValue);
121   - }
122   - else {
123   - var templateArgs = uiScope.object.get('param-template-args');
124   - if (!templateArgs)
125   - templateArgs = {};
126   - templateArgs[args_key] = newValue;
127   - uiScope.object.set('param-template-args', templateArgs);
128   - }
129 112 uiScope.crtTree.refresh();
130 113 },
131 114  
... ...
js/app/views/PlotComponents/PlotTree.js
... ... @@ -67,13 +67,13 @@ Ext.define('amdaPlotComp.PlotTree', {
67 67 this.buildPanelsNode();
68 68 },
69 69  
70   - buildPanelsNode: function() {
  70 + buildPanelsNode: function(paramNodeToSelect) {
71 71 if (this.panelsNode.hasChildNodes())
72 72 this.panelsNode.removeAll();
73 73  
74 74 var me = this;
75 75 this.tabObject.panels().each(function (panelObject) {
76   - me.addPanelNode(panelObject);
  76 + me.addPanelNode(panelObject, paramNodeToSelect);
77 77 });
78 78 },
79 79  
... ... @@ -280,7 +280,7 @@ Ext.define('amdaPlotComp.PlotTree', {
280 280 this.getSelectionModel().select(selectedFillNode);
281 281 },
282 282  
283   - addPanelNode: function(panelObject) {
  283 + addPanelNode: function(panelObject, paramNodeToSelect) {
284 284 var panelNode = this.panelsNode.appendChild(new amdaPlotObj.PlotPanelTreeNode({object : panelObject}));
285 285 if (!this.tabObject.get('tree-simplified-view'))
286 286 {
... ... @@ -290,7 +290,7 @@ Ext.define('amdaPlotComp.PlotTree', {
290 290 this.buildPanelAdditionalObjectsNode(panelObject);
291 291 }
292 292 //Params node
293   - this.buildPanelParamsNode(panelObject);
  293 + this.buildPanelParamsNode(panelObject, paramNodeToSelect);
294 294 return panelNode;
295 295 },
296 296  
... ... @@ -629,8 +629,8 @@ Ext.define('amdaPlotComp.PlotTree', {
629 629 var me = this;
630 630 panelObject.createNewParam(paramId, function (newParamObject) {
631 631 //Rebuild params node
632   - me.buildPanelsNode();
633   - //me.buildPanelParamsNode(panelObject, newParamObject.get('id'));
  632 + me.buildPanelsNode(newParamObject.getId());
  633 + //BRE newParamObject
634 634 });
635 635 },
636 636  
... ...
js/app/views/SearchUI.js
... ... @@ -54,34 +54,17 @@ Ext.define('amdaUI.SearchUI', {
54 54 this.constructionField.setCaretPosition(this.constructionField.getValue().length);
55 55 },
56 56  
57   - onApplyParameterArgs : function(uiScope, paramId, values) {
58   - var fullParam = paramId;
59   - switch (values['type']) {
60   - case 0:
61   - //scalar - nothing to do
62   - break;
63   - case 1:
64   - //Tab1D
65   - if (values['dim_1'] && (values['dim_1'] != '') && (values['dim_1'] != '*'))
66   - fullParam += '('+values['dim_1']+')';
67   - else if (values['dim_2'] && (values['dim_2'] != '') && (values['dim_2'] != '*'))
68   - fullParam += '('+values['dim_2']+')';
69   - break;
70   - case 2:
71   - //Tab2D
72   - var dim1 = (values['dim_1'] && (values['dim_1'] != '')) ? values['dim_1'] : "*";
73   - var dim2 = (values['dim_2'] && (values['dim_2'] != '')) ? values['dim_2'] : "*";
74   - if ((dim1 != '*') || (dim2 != '*'))
75   - fullParam += '('+dim1+','+dim2+')';
76   - }
77   -
  57 + onApplyParameterArgs : function(uiScope, paramRequestObject) {
  58 + var fullParam = paramRequestObject.getParamFullName();
78 59 uiScope.addParamInEditor(fullParam);
79 60 },
80 61  
81 62 editParameterArgs: function(name) {
82 63 var paramArgsPlug = this.getPlugin('search-param-components-plugin');
83   - if (paramArgsPlug)
84   - paramArgsPlug.show(name);
  64 + if (paramArgsPlug) {
  65 + var workinRequestParamObject = Ext.create('amdaModel.RequestParamObject', {paramid: name, type: 0, dim1: '', dim2: '', template_args: {} });
  66 + paramArgsPlug.show('search-param-components-plugin', workinRequestParamObject);
  67 + }
85 68 },
86 69  
87 70 /**
... ...