Blame view

js/app/views/ParameterUI.js 21.1 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
/**
 * Project   : AMDA-NG
 * Name      : ParameterUI.js
 * @class 	 amdaUI.ParameterUI
 * @extends  Ext.container.Container
 * @brief	 Parameter  Module UI definition (View)
 * @author 	  
3ab0bee9   Elena.Budnik   aprams with args ...
8
 * @version  $Id: ParameterUI.js 2257 2014-04-02 12:21:27Z elena $             
16035364   Benjamin Renard   First commit
9
10
 */

3ec6bc73   Erdogan Furkan   8950 - Positionne...
11
Ext.define('amdaUI.ParameterUI',
3ab0bee9   Elena.Budnik   aprams with args ...
12
	{
3ec6bc73   Erdogan Furkan   8950 - Positionne...
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
		extend: 'Ext.container.Container',

		alias: 'widget.panelParam',

		requires: [
			'amdaUI.AliasUI',
			'amdaUI.CalculatorUI',
			'extensions.SelectableTextArea',
			'amdaUI.ParamArgumentsPlug',
			'amdaModel.RequestParamObject'
		],

		constructor: function (config) {
			this.init(config);
			this.callParent(arguments);
			// load object into form
			this.formPanel.getForm().loadRecord(this.object);
			var paramArgsPlug = this.getPlugin('derived-param-arguments-plugin');
			if (paramArgsPlug)
				paramArgsPlug.onApply = this.onApplyParameterArgs;
		},

		addParamInEditor: function (param) {
			var selection = this.constructionField.getSelection();
			this.constructionField.setValue(selection.beforeText + param + selection.afterText);
			this.constructionField.focus();
			if (this.constructionField.getValue()[(selection.beforeText + param).length] == ',') {
				this.constructionField.setCaretPosition((selection.beforeText + param).length + 1);
3ab0bee9   Elena.Budnik   aprams with args ...
41
			}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
42
43
			else {
				this.constructionField.setCaretPosition(this.constructionField.getValue().length);
3ab0bee9   Elena.Budnik   aprams with args ...
44
			}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
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
		},

		onApplyParameterArgs: function (uiScope, paramRequestObject) {
			var fullParam = paramRequestObject.getParamFullName();
			uiScope.addParamInEditor(fullParam);
		},

		addParam: function (newParamName, isLeaf, needArgs, components) {
			//if (!isLeaf || needArgs || components)
			if (needArgs)
				this.editParameterArgs(newParamName, components);
			else
				this.addParamInEditor(newParamName);
		},

		editParameterArgs: function (name, components) {
			var paramObj = amdaModel.RequestParamObject.getEmptyObj();
			paramObj.paramid = name;

			if (components) {
				if (components['index1']) {
					paramObj['dim1-index'] = components['index1'];
					++paramObj['type'];
				}

				if (components['index2']) {
					paramObj['dim2-index'] = components['index2'];
					++paramObj['type'];
3ab0bee9   Elena.Budnik   aprams with args ...
73
74
				}
			}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
75
76
77
78
79

			var paramArgsPlug = this.getPlugin('derived-param-arguments-plugin');
			if (paramArgsPlug) {
				var workinRequestParamObject = Ext.create('amdaModel.RequestParamObject', paramObj);
				paramArgsPlug.show('derived-param-arguments-plugin', workinRequestParamObject);
3ab0bee9   Elena.Budnik   aprams with args ...
80
			}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
81
		},
16035364   Benjamin Renard   First commit
82

3ec6bc73   Erdogan Furkan   8950 - Positionne...
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
		setObject: function (object) {
			this.object = object;
			// load object into form
			this.formPanel.getForm().loadRecord(this.object);
		},

		/**
		* update this.object from form
		*/
		updateObject: function () {
			// get the basic form
			var basicForm = this.formPanel.getForm();
			var updateStatus = true;

			var fieldsWithoutName = basicForm.getFields().items;
			Ext.Array.each(fieldsWithoutName, function (item, index, allItems) {
				if (item !== this.fieldName) {
					if (!item.isValid()) {
						// set update isn't allowed
						updateStatus = false;
					}
				}
			}, this);
			// if the update is allowed
			if (updateStatus) {
				/// real object update
				// update TimeTable object with the content of form
				basicForm.updateRecord(this.object);
3ab0bee9   Elena.Budnik   aprams with args ...
111
			}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
			// return the update status
			return updateStatus;
		},

		updateConstruct: function (oldval, newval) {
			// update constructionField (Construct parameter) in window parameter
			var expression = this.constructionField.value;
			oldval = oldval.replace(/[(]/g, "\\(");
			oldval = oldval.replace(/[)]/g, "\\)");
			var reg = new RegExp(oldval, "g");
			expression = expression.replace(reg, newval);
			this.constructionField.setValue(expression);
		},


		/** 
		* Generate info for parameter desplay
		 */
		generateParamInfo: function (onSuccess) {
			var me = this;
			var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id);

			var obj = {
				paramId: 'ws_' + this.object.get('name'),
				buildchain: this.object.get('buildchain'),
				timestep: this.object.get('timestep'),
				reference_param: this.object.get('reference_param'),
				sampling_mode: this.object.get('sampling_mode')
			};
			loadMask.show();
			AmdaAction.generateParamInfo(obj, function (result, e) {
				if (!result || !result.success) {
					loadMask.hide();
					if (result.message)
						myDesktopApp.warningMsg(result.message);
					else
						myDesktopApp.warningMsg('Unknown error during parameter compilation');
					return;
				}
				loadMask.hide();
				paramModule.linkedNode.get('object').set('dim_1', parseInt(result.dimensions.dim_1));
				paramModule.linkedNode.get('object').set('dim_2', parseInt(result.dimensions.dim_2));
				if (onSuccess)
					onSuccess();
				/*                    paramModule.linkedNode.update({scope : me, 
										failure: function(record, operation) {
										    
										},
										callback: function() {
																   }
									});
					*/
			});
		},

		/**
		* save method called by Save button
		*/
		saveProcess: function (toRename) {
			if (this.object.dirty) {
				// Parameter Module
				var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id);
				// if the name has been modified this is a creation
				if (this.object.isModified('name')) {
					// if object already has an id : it's a 'rename' of an existing TimeTable
					if (this.object.get('id')) {
						// the context Node is the parent node of current edited one
						var contextNode = paramModule.linkedNode.parentNode;
						// link a new node to the TimeTableModule
						paramModule.createLinkedNode();
						// set the contextNode
						paramModule.linkedNode.set('contextNode', contextNode);
						// create a new object linked		   		  
						paramModule.createObject(this.object.getJsonValues());
						var paramobj = paramModule.linkedNode.get('object');
						//synchronize objects
						this.object = paramobj;
						if (toRename) paramModule.linkedNode.toRename = true;
					}
					this.generateParamInfo(function () {
						paramModule.linkedNode.set('isParameter', true);
						paramModule.linkedNode.create({
							scope: this, callback: function () {
							}
						});
					});
				} else {
					paramModule.linkedNode.set('contextNode', paramModule.contextNode);
					this.generateParamInfo(function () {
						paramModule.linkedNode.update({
							scope: this, callback: function () {
							}
						});
					});
				}
			}
		},

		/**
		* overwrite metod called by Save button
		*/
		overwriteProcess: function (btn) {
			if (btn == 'cancel') return;

			this.fieldName.clearInvalid();
			this.saveProcess(true);
		},

		/**
		*   Check if brackets are balanced
		*/
		isBalanced: function (str) {
			str = ("" + str).replace(/[^()\[\]{}]/g, "");
			var bracket = {
				"]": "[",
				"}": "{",
				")": "("
			},
				openBrackets = [],
				isClean = true,
				i = 0,
				len = str.length;

			for (; isClean && i < len; i++) {
				if (bracket[str[i]]) {
					isClean = (openBrackets.pop() === bracket[str[i]]);
				} else {
					openBrackets.push(str[i]);
				}
			}
			if (!(isClean && !openBrackets.length)) return 'Brackets are not balanced';

			return true;
		},

		/**
		 * Check if changes were made before closing window 
		 * @return true if changes
		 */
		fclose: function () {
			var isDirty = this.formPanel.getForm().isDirty();
			return isDirty;
		},

		init: function (config) {
			this.fieldName = new Ext.form.field.Text({
3ab0bee9   Elena.Budnik   aprams with args ...
258
				labelAlign: 'top', itemId: 'formParamName',
7cab5983   Benjamin Renard   Add modif. time f...
259
				labelPad: 0,
5e6d074f   Elena.Budnik   infobull for para...
260
				fieldLabel: 'Parameter Name',
3ec6bc73   Erdogan Furkan   8950 - Positionne...
261
262
				name: 'name',
				allowBlank: false, //blankText : 'Name is required',
5e6d074f   Elena.Budnik   infobull for para...
263
				emptyText: 'Please only low case!',
3ab0bee9   Elena.Budnik   aprams with args ...
264
265
266
267
268
				width: 150,
				validateOnChange: false,
				validateOnBlur: false,
				enableKeyEvents: true,
				validFlag: false,
3ec6bc73   Erdogan Furkan   8950 - Positionne...
269
				validator: function () {
3ab0bee9   Elena.Budnik   aprams with args ...
270
271
272
					return this.validFlag;
				},
				stripCharsRe: /(^\s+|\s+$)/g,
3ec6bc73   Erdogan Furkan   8950 - Positionne...
273
				listeners:
3ab0bee9   Elena.Budnik   aprams with args ...
274
				{
3ec6bc73   Erdogan Furkan   8950 - Positionne...
275
					keyUp: function (field, e, opt) {
3ab0bee9   Elena.Budnik   aprams with args ...
276
277
278
						this.setValue(this.getValue().toLowerCase());
					}
				}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
279
280
281
282
283
284
285
286
287
288
289
290
291
292
			});

			this.constructionField = new extensions.SelectableTextArea({
				labelAlign: 'top',
				labelPad: 0,
				itemId: 'formParamConstructParameter',
				fieldLabel: '<img amda_clicktip="constructParameter"  src="js/resources/images/16x16/info_mini.png"/>&nbsp;Construct Parameter',
				allowBlank: false, blankText: 'Construct Parameter is required',
				name: 'buildchain',
				flex: 0.6,
				validateOnChange: false,
				validateOnBlur: false,
				validator: this.isBalanced,
				listeners:
3ab0bee9   Elena.Budnik   aprams with args ...
293
				{
3ec6bc73   Erdogan Furkan   8950 - Positionne...
294
295
296
297
					render: function (o, op) {
						var me = this;
						var meEl = me.bodyEl;
						var dropTarget = Ext.create('Ext.dd.DropTarget', meEl,
3ab0bee9   Elena.Budnik   aprams with args ...
298
							{
3ec6bc73   Erdogan Furkan   8950 - Positionne...
299
300
301
302
303
304
305
306
307
308
309
310
								ddGroup: 'explorerTree',
								notifyEnter: function (ddSource, e, data) { },
								notifyOver: function (ddSource, e, data) {
									if (data.records[0].get('nodeType') == 'localParam' && data.records[0].get('notyet')) {
										this.valid = false;
										return this.dropNotAllowed;
									}

									if (((data.records[0].get('nodeType') == 'localParam') ||
										(data.records[0].get('nodeType') == 'remoteParam') ||
										(data.records[0].get('nodeType') == 'remoteSimuParam') ||
										(data.records[0].get('nodeType') == 'derivedParam') ||
9d88b61f   Erdogan Furkan   Forgot this file
311
										(data.records[0].get('nodeType') == 'specialParam') ||
3ec6bc73   Erdogan Furkan   8950 - Positionne...
312
										(data.records[0].get('nodeType') == 'myDataParam') ||
ae2e30bd   Erdogan Furkan   For now
313
										(data.records[0].get('nodeType') == 'timeTable') ||
07e4ac11   Erdogan Furkan   IHM part allowing...
314
315
316
										(data.records[0].get('nodeType') == 'catalog') ||
										(data.records[0].get('nodeType') == 'sharedtimeTable') ||
										(data.records[0].get('nodeType') == 'sharedcatalog') ||
3ec6bc73   Erdogan Furkan   8950 - Positionne...
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
										(data.records[0].get('nodeType') == 'alias')) &&
										(data.records[0].isLeaf() || data.records[0].get('isParameter')) &&
										!(data.records[0].data.disable)) {
										this.valid = true;
										return this.dropAllowed;
									}
									this.valid = false;
									return this.dropNotAllowed;
								},
								notifyDrop: function (ddSource, e, data) {
									if (!this.valid)
										return false;
									var nameToSent;
									var components = null;
									switch (data.records[0].get('nodeType')) {
										case 'localParam':
										case 'remoteParam':
										case 'remoteSimuParam':
											nameToSent = data.records[0].get('id');
											if (data.records[0].get('alias') != "")
												var nameToSent = "#" + data.records[0].get('alias');
											var component_info = data.records[0].get('component_info');
											if (component_info && component_info.parentId) {
												if (component_info.index1 && component_info.index2) {
													nameToSent = component_info.parentId;
													components = [];
													if (component_info.index1)
														components['index1'] = component_info.index1;
													if (component_info.index2)
														components['index2'] = component_info.index2;
												}
												if (data.records[0].get('needsArgs')) {
													nameToSent = component_info.parentId;
													if (component_info.index1) {
														components = [];
														components['index1'] = component_info.index1;
													}
												}
3ab0bee9   Elena.Budnik   aprams with args ...
355
											}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
356
357
358
359
360
361
362
											break;
										case 'alias':
											nameToSent = "#" + data.records[0].get('text');
											break;
										case 'derivedParam':
											nameToSent = "ws_" + data.records[0].get('text');
											break;
9d88b61f   Erdogan Furkan   Forgot this file
363
364
365
										case 'specialParam':
											nameToSent =  data.records[0].get('id');
											break;
ae2e30bd   Erdogan Furkan   For now
366
										case 'timeTable':
07e4ac11   Erdogan Furkan   IHM part allowing...
367
											nameToSent =  "tt_"+data.records[0].get('text');
ae2e30bd   Erdogan Furkan   For now
368
369
											break;
										case 'catalog':
07e4ac11   Erdogan Furkan   IHM part allowing...
370
371
372
373
374
375
376
											nameToSent =  "cat_"+data.records[0].get('text');
											break;
										case 'sharedtimeTable':
											nameToSent =  "sharedtimeTable"+data.records[0].get('text');
											break;
										case 'sharedcatalog':
											nameToSent =  "sharedcatalog_"+data.records[0].get('text');
ae2e30bd   Erdogan Furkan   For now
377
											break;
3ec6bc73   Erdogan Furkan   8950 - Positionne...
378
379
380
381
382
383
384
										case 'myDataParam':
											var name = data.records[0].get('text');
											nameToSent = "wsd_" + name;
											break;
										default:

											return false;
3ab0bee9   Elena.Budnik   aprams with args ...
385
									}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
386
387
388
389
									var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id);
									if (paramModule) {
										if (data.records[0].get('predefinedArgs')) {
											paramModule.parseTemplatedParam(nameToSent, function (param_info) {
7f23e0f7   Erdogan Furkan   #5119 -Done. Adde...
390
												paramModule.addParam(param_info.paramid, data.records[0].get('leaf'), true, components, param_info.template_args, null);
3ec6bc73   Erdogan Furkan   8950 - Positionne...
391
392
393
											});
										}
										else {
7f23e0f7   Erdogan Furkan   #5119 -Done. Adde...
394
											paramModule.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components,null,null);
3ec6bc73   Erdogan Furkan   8950 - Positionne...
395
396
397
										}
									}
									return true;
b1fab76f   Benjamin Renard   Give the possibil...
398
								}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
399
400
							});
					}
3ab0bee9   Elena.Budnik   aprams with args ...
401
				}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
				//TODO: ?validator on formula structure?
				//			listener : {
				//				valid : function(field) {
				//
				//				}
				//			}
			});

			var samplingmode_store = new Ext.data.ArrayStore({
				fields: ['id', 'name'],
				data: [
					['timestep', 'Time Step'],
					['refparam', 'Ref. Parameter']
				]
			});

			this.timeStepField = new Ext.form.NumberField({
				fieldLabel: '<img amda_clicktip="resamplingStep" src="js/resources/images/16x16/info_mini.png"/>&nbsp;Time Step (sec)',
				labelAlign: 'top',
				labelPad: 0,
				blankText: 'Time Step is required',
				name: 'timestep',
				minValue: 0.001,
				decimalPrecision: 10,
				hideTrigger: true,
				width: 150,
				validateOnBlur: false,
				allowBlank: false,
				isValid: function () {
					var me = this,
						disabled = me.disabled,
						validate = me.forceValidation || !disabled;

					if (!me.isVisible()) {
						return true;
					}

					return validate ? me.validateValue(me.processRawValue(me.getRawValue())) : disabled;
b78325f1   Benjamin Renard   Add validation fo...
440
				}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
441
			});
b78325f1   Benjamin Renard   Add validation fo...
442

3ec6bc73   Erdogan Furkan   8950 - Positionne...
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
			this.refParamField = new Ext.form.TextField({
				fieldLabel: '<img amda_clicktip="resamplingRefParam" src="js/resources/images/16x16/info_mini.png"/>&nbsp;Reference Param.',
				labelAlign: 'top',
				labelPad: 0,
				name: 'reference_param',
				width: 150,
				hidden: true,
				allowBlank: false,
				listeners: {
					afterrender: function (field, eOpts) {
						var paramTarget = new Ext.dd.DropTarget(field.el.dom,
							{
								ddGroup: 'explorerTree',
								notifyEnter: function (ddSource, e, data) {
								},
								notifyDrop: function (ddSource, e, data) {
									var selectedRecord = ddSource.dragData.records[0];
									switch (selectedRecord.$className) {
										case 'amdaModel.LocalParamNode':
										case 'amdaModel.RemoteParamNode':
										case 'amdaModel.RemoteSimuParamNode':
											if (!selectedRecord.get('isParameter') || selectedRecord.get('disable'))
												return false;
											if (selectedRecord.get('alias') != "")
												field.setValue("#" + selectedRecord.get('alias'));
											else
												field.setValue(selectedRecord.get('id'));
											return true;
										case 'amdaModel.AliasNode':
											if (!selectedRecord.isLeaf())
												return false;
											field.setValue("#" + selectedRecord.get('text'));
											return true;
										case 'amdaModel.DerivedParamNode':
											if (!selectedRecord.isLeaf())
												return false;
											field.setValue("ws_" + selectedRecord.get('text'));
											return true;
										case 'amdaModel.MyDataParamNode':
											if (!selectedRecord.isLeaf())
												return false;
											field.setValue("wsd_" + selectedRecord.get('text'));
											return true;
										default:
7cab5983   Benjamin Renard   Add modif. time f...
487
											return false;
3ec6bc73   Erdogan Furkan   8950 - Positionne...
488
489
									}
									return true;
7cab5983   Benjamin Renard   Add modif. time f...
490
								}
7cab5983   Benjamin Renard   Add modif. time f...
491
							}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
492
493
494
						);
					},
					scope: this
7cab5983   Benjamin Renard   Add modif. time f...
495
				},
3ec6bc73   Erdogan Furkan   8950 - Positionne...
496
497
498
499
500
501
502
503
				isValid: function () {
					var me = this,
						disabled = me.disabled,
						validate = me.forceValidation || !disabled;

					if (!me.isVisible()) {
						return true;
					}
b78325f1   Benjamin Renard   Add validation fo...
504

3ec6bc73   Erdogan Furkan   8950 - Positionne...
505
					return validate ? me.validateValue(me.processRawValue(me.getRawValue())) : disabled;
b78325f1   Benjamin Renard   Add validation fo...
506
				}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
507
			});
b78325f1   Benjamin Renard   Add validation fo...
508

3ec6bc73   Erdogan Furkan   8950 - Positionne...
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
			this.samplingDefContainer = new Ext.container.Container({
				border: false,
				items: [
					this.timeStepField,
					this.refParamField
				],
				width: 150
			});

			this.formPanel = new Ext.form.Panel({
				id: 'vbox-paramForm',
				bodyStyle: { background: '#dfe8f6' },
				border: false,
				buttonAlign: 'left',
				region: 'center',
				trackResetOnLoad: true, //reset to the last loaded record
				layout: {
					type: 'vbox',
					defaultMargins: { top: 5, left: 5, bottom: 10, right: 10 },
					align: 'stretch'
				},
				defaults: {
					border: false
				},
				items: [
16035364   Benjamin Renard   First commit
534
					{
3ab0bee9   Elena.Budnik   aprams with args ...
535
536
537
538
539
540
541
542
543
						flex: 1,
						xtype: 'container',
						border: false,
						layout: {
							type: 'table',
							columns: 3
						},
						defaultType: 'textfield',
						defaults: {
7cab5983   Benjamin Renard   Add modif. time f...
544
545
							labelAlign: 'top',
							labelPad: 0
3ab0bee9   Elena.Budnik   aprams with args ...
546
547
548
549
						},
						items: [
							this.fieldName,
							{
3ec6bc73   Erdogan Furkan   8950 - Positionne...
550
								xtype: 'component', width: 20
3ab0bee9   Elena.Budnik   aprams with args ...
551
552
							},
							{
7cab5983   Benjamin Renard   Add modif. time f...
553
554
								fieldLabel: 'Last modification',
								xtype: 'displayfield',
3ec6bc73   Erdogan Furkan   8950 - Positionne...
555
								name: 'last_update',
0f7460c1   Elena.Budnik   redmine 5518
556
								width: 150,
3ec6bc73   Erdogan Furkan   8950 - Positionne...
557
								renderer: function (value, field) {
7cab5983   Benjamin Renard   Add modif. time f...
558
559
560
									var tpl = new Ext.XTemplate('<p style="font-style:italic;color:gray;margin:0;">{date}</>');
									var mod_date = 'Not saved';
									if (value > 0)
3ec6bc73   Erdogan Furkan   8950 - Positionne...
561
562
										mod_date = Ext.Date.format(new Date(value * 1000), "Y-m-d\\TH:i:s");
									return tpl.apply({ date: mod_date });
7cab5983   Benjamin Renard   Add modif. time f...
563
								},
3ab0bee9   Elena.Budnik   aprams with args ...
564
							},
3ec6bc73   Erdogan Furkan   8950 - Positionne...
565
566
567
568
569
570
							{
								xtype: 'combo',
								fieldLabel: 'Sampling mode',
								name: 'sampling_mode',
								queryMode: 'local',
								editable: false,
7cab5983   Benjamin Renard   Add modif. time f...
571
572
573
574
575
								valueField: 'id',
								displayField: 'name',
								store: samplingmode_store,
								value: samplingmode_store.first(),
								listeners: {
3ec6bc73   Erdogan Furkan   8950 - Positionne...
576
									change: function (field, value) {
7cab5983   Benjamin Renard   Add modif. time f...
577
578
579
580
581
										this.timeStepField.setVisible(value != 'refparam');
										this.refParamField.setVisible(value == 'refparam');
									},
									scope: this
								}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
582
583
584
585
							},
							{
								xtype: 'component', width: 20
							},
7cab5983   Benjamin Renard   Add modif. time f...
586
							this.samplingDefContainer,
3ab0bee9   Elena.Budnik   aprams with args ...
587
							{
3ec6bc73   Erdogan Furkan   8950 - Positionne...
588
								itemId: 'formParamUnit',
3ab0bee9   Elena.Budnik   aprams with args ...
589
								fieldLabel: 'Units',
3ec6bc73   Erdogan Furkan   8950 - Positionne...
590
								name: 'units',
3ab0bee9   Elena.Budnik   aprams with args ...
591
592
593
								width: 150
							},
							{
3ec6bc73   Erdogan Furkan   8950 - Positionne...
594
								xtype: 'component', width: 20
3ab0bee9   Elena.Budnik   aprams with args ...
595
							},
3ec6bc73   Erdogan Furkan   8950 - Positionne...
596
597
							{
								itemId: 'formParamYTitle',
3ab0bee9   Elena.Budnik   aprams with args ...
598
								fieldLabel: 'Y Title for Plot',
3ec6bc73   Erdogan Furkan   8950 - Positionne...
599
								name: 'ytitle',
3ab0bee9   Elena.Budnik   aprams with args ...
600
601
602
								width: 150
							},
							{
3ab0bee9   Elena.Budnik   aprams with args ...
603
								itemId: 'formParamDescription',
3ec6bc73   Erdogan Furkan   8950 - Positionne...
604
605
606
								name: 'description',
								xtype: 'textarea', fieldLabel: 'Description',
								width: 320, height: 75,
3ab0bee9   Elena.Budnik   aprams with args ...
607
								colspan: 3
3ec6bc73   Erdogan Furkan   8950 - Positionne...
608
							}]
3ab0bee9   Elena.Budnik   aprams with args ...
609
610
					},
					this.constructionField
3ec6bc73   Erdogan Furkan   8950 - Positionne...
611
				],
16035364   Benjamin Renard   First commit
612
613
				fbar: [
					{
3ab0bee9   Elena.Budnik   aprams with args ...
614
						text: 'Save',
3ec6bc73   Erdogan Furkan   8950 - Positionne...
615
616
617
618
						scope: this,
						handler: function () {
							if (this.updateObject()) {
								var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id);
3ab0bee9   Elena.Budnik   aprams with args ...
619
620
621
								if (!paramModule)
									return;
								var me = this;
3ec6bc73   Erdogan Furkan   8950 - Positionne...
622
623
								paramModule.linkedNode.isValidName(this.fieldName.getValue(), function (res) {
									if (!res) {
3ab0bee9   Elena.Budnik   aprams with args ...
624
625
626
627
628
										me.fieldName.validFlag = 'Error during object validation';
										myDesktopApp.errorMsg(me.fieldName.validFlag);
										me.fieldName.validate();
										return;
									}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
629
630
631
632
633
634
635
636
637
638
639
640

									if (!res.valid) {
										if (res.error) {
											if (res.error.search('subtree') != -1) {
												Ext.MessageBox.show({
													title: 'Warning',
													msg: res.error + '<br/>Do you want to overwrite it?',
													width: 300,
													buttons: Ext.MessageBox.OKCANCEL,
													fn: me.overwriteProcess,
													icon: Ext.MessageBox.WARNING,
													scope: me
3ab0bee9   Elena.Budnik   aprams with args ...
641
642
643
644
645
646
												});
												me.fieldName.validFlag = true;
											}
											else
												me.fieldName.validFlag = res.error;
										}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
647
										else {
3ab0bee9   Elena.Budnik   aprams with args ...
648
649
650
651
652
653
											me.fieldName.validFlag = 'Invalid object name';
											myDesktopApp.errorMsg(me.fieldName.validFlag);
										}
										me.fieldName.validate();
										return;
									}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
654

3ab0bee9   Elena.Budnik   aprams with args ...
655
656
									me.fieldName.validFlag = true;
									me.fieldName.validate();
3ec6bc73   Erdogan Furkan   8950 - Positionne...
657
658
									me.saveProcess(false);
								});
3ab0bee9   Elena.Budnik   aprams with args ...
659
660
							}
						}
16035364   Benjamin Renard   First commit
661
662
					},
					{
3ab0bee9   Elena.Budnik   aprams with args ...
663
664
						text: 'Reset',
						scope: this,
3ec6bc73   Erdogan Furkan   8950 - Positionne...
665
666
						handler: function () {
							var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id);
3ab0bee9   Elena.Budnik   aprams with args ...
667
668
669
670
671
672
673
							paramModule.createLinkedNode();
							paramModule.createObject();
							this.setObject(paramModule.getLinkedNode().get('object'));
							/* reset with keeping old object
							this.formPanel.getForm().reset();
							*/
						}
16035364   Benjamin Renard   First commit
674
					}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
675
676
677
678
				]
			});

			var myConf = {
16035364   Benjamin Renard   First commit
679
680
681
682
				layout: 'border',
				border: false,
				defaults: { layout: 'fit', border: false },
				items: [
3ab0bee9   Elena.Budnik   aprams with args ...
683
684
685
686
687
					this.formPanel,
					{
						xtype: 'panel', region: 'south',
						title: 'Information',
						collapsible: true,
42863f42   Elena.Budnik   collapseMode: "he...
688
						collapseMode: 'header',
3ab0bee9   Elena.Budnik   aprams with args ...
689
690
691
692
693
						height: 100,
						autoHide: false,
						iconCls: 'icon-information',
						bodyStyle: 'padding:5px',
						loader: {
3ec6bc73   Erdogan Furkan   8950 - Positionne...
694
695
							autoLoad: true,
							url: helpDir + 'myParameterHOWTO'
3ab0bee9   Elena.Budnik   aprams with args ...
696
						}
3ec6bc73   Erdogan Furkan   8950 - Positionne...
697
698
699
700
					}],
				plugins: [
					{ ptype: 'calculator', myBtns: [], context: 'Parameter' },
					{ ptype: 'paramArgumentsPlugin', pluginId: 'derived-param-arguments-plugin' }
5e6d074f   Elena.Budnik   infobull for para...
701
				],
3ec6bc73   Erdogan Furkan   8950 - Positionne...
702
				listeners: {
5e6d074f   Elena.Budnik   infobull for para...
703
704
					click: {
						element: 'el',
3ec6bc73   Erdogan Furkan   8950 - Positionne...
705
						fn: function (e, t) {
5e6d074f   Elena.Budnik   infobull for para...
706
							var me = t,
3ec6bc73   Erdogan Furkan   8950 - Positionne...
707
								text = me.getAttribute('amda_clicktip');
5e6d074f   Elena.Budnik   infobull for para...
708
709
							if (text) {
								e.preventDefault();
3ec6bc73   Erdogan Furkan   8950 - Positionne...
710
								AmdaAction.getInfo({ name: text }, function (res, e) {
5e6d074f   Elena.Budnik   infobull for para...
711
									if (res.success) myDesktopApp.infoMsg(res.result);
3ec6bc73   Erdogan Furkan   8950 - Positionne...
712
								});
5e6d074f   Elena.Budnik   infobull for para...
713
714
715
716
							}
						}
					}
				}
16035364   Benjamin Renard   First commit
717
			};
3ec6bc73   Erdogan Furkan   8950 - Positionne...
718

16035364   Benjamin Renard   First commit
719
			Ext.apply(this, Ext.apply(arguments, myConf));
3ec6bc73   Erdogan Furkan   8950 - Positionne...
720
721
		}
	});