Blame view

js/app/views/MyDataUI.js 25.9 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
/**
 * Project   : AMDA-NG
 * Name      : MyDataUI.js
 * @class    : amdaUI.MyDataUI
 * @extends  Ext.container.Container 
 * @brief    MyData Module UI definition (View)
 * @author Elena 
 * @version  $Id: MyDataUI.js 2895 2015-05-05 14:38:28Z elena $	          
 */
 
 
Ext.define('amdaUI.MyDataUI', {
655e355f   Elena.Budnik   disable "predefin...
13
14
15
16
	extend: 'Ext.container.Container',
	alias: 'widget.panelMyData',
	
	requires: [
a19578d1   Erdogan Furkan   Status for parame...
17
18
			'amdaUI.TableDefPlugUI',
			'amdaUI.StatusModalWindow'
655e355f   Elena.Budnik   disable "predefin...
19
	],
16035364   Benjamin Renard   First commit
20

655e355f   Elena.Budnik   disable "predefin...
21
22
23
24
25
26
27
28
29
30
31
32
33
34
	object : null,	
	fileObject : null,
	
	module : null,
	
	fields : [],
	columns : [],
	
	constructor: function(config) {	
				this.module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.my_data.id);	   
				this.init(config);
				this.callParent(arguments);
				this.setObject(this.module.linkedNode.get('object'));
	},
16035364   Benjamin Renard   First commit
35
 
655e355f   Elena.Budnik   disable "predefin...
36
37
38
39
40
41
42
43
44
45
	/*
	* linked node should be MyDataParamNode
	*/	 	
	resetLinkedNode: function() 
	{
		this.linkedNode = null;	    		      
		this.module.createLinkedNode();
		this.module.createObject();
		this.module.linkedNode.set('fileObject',this.fileObject); 
	},
16035364   Benjamin Renard   First commit
46
	
655e355f   Elena.Budnik   disable "predefin...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
	getObjectCallback: function(result,remoteEvent)
	{
		var t = remoteEvent.getTransaction();
		if (result && !result.error) {   	         	      	      	     
				//this.tmpNode.set('contextNode',mask!!! if exists	  
				this.fileObject = Ext.create('amdaModel.FileObject', result);
				var panelConfig = this.initPanel();
		} 
		else {	   
				// EXCEPTION : parameter not found !
				myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '"
					+this.tmpNode.get('text')+"' found!");	     
		}  
	},
655e355f   Elena.Budnik   disable "predefin...
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
	/*
	*  Update info in the form on another parameter selection (cdf, cef formats);
	*/
	updateInfo : function(res, e) 
	{	    
		if (res.success){ 
				// info panel     
				this.items.getAt(1).update(res.info.name+': '+res.info.type+' '+res.info.size+' '+res.info.n_records);	    
				var form = this.items.getAt(0).getForm();
		
				//keep old name and mask if they exist 
				if (this.object.get('format') == 'vot')
				{
				res.info.ytitle = res.info.name;
				if ((res.info.id === this.object.get('realvar'))) { 
					if (this.object.get('realvar') != this.object.get('name')) {
						res.info.name = this.object.get('name');
					}
					if (res.info.mask != this.object.get('mask')) {
						res.info.mask = this.object.get('mask');
					}
				}
				}
				else
				{
				if ((res.info.name === this.object.get('realvar'))) { 
					if (this.object.get('realvar') != this.object.get('name')) {
						res.info.name = this.object.get('name');
					}
					if (res.info.mask != this.object.get('mask')) {
						res.info.mask = this.object.get('mask');
					}
				}
				res.info.ytitle = res.info.name;
				}

			form.setValues(res.info);       
		}
		else {
				myDesktopApp.errorMsg("System Error <br/> Error at AMDA Server");
		}
48a8a598   Elena.Budnik   merge with master
102
	},        
655e355f   Elena.Budnik   disable "predefin...
103
104
105
106
107
108
109
	/*
	* Check if changes were made before closing window 
	* @return false
	*/	
	fclose : function() {
				return false;
	},
16035364   Benjamin Renard   First commit
110
	
655e355f   Elena.Budnik   disable "predefin...
111
112
113
114
115
116
117
118
	/**
	* set object into form
	*/
	setObject : function (object) 
	{
		// edit in module from  FileUpload Module and ExplorerModule (edit param)
		if (this.module.linkedNode) { 
				if (this.module.linkedNode.get('fileObject')) {		
3d7c42ed   Elena.Budnik   disable fields pr...
119
					this.fileObject = this.module.linkedNode.get('fileObject');
655e355f   Elena.Budnik   disable "predefin...
120
121
				} 
				// edit in module from Explorer Module (edit file)
3d7c42ed   Elena.Budnik   disable fields pr...
122
123
				else if (this.module.linkedNode.get('object')) { 					
					this.fileObject = this.module.linkedNode.get('object');	
655e355f   Elena.Budnik   disable "predefin...
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
					this.resetLinkedNode();
				}
				else {	      
					myDesktopApp.errorMsg("System Error <br/> No FileObject and Object");
				}	      
		}	    
		else {  
				myDesktopApp.errorMsg("System Error <br/> No Linked Node"); 
		}
		
		var form = this.down('form');
		form.getForm().reset();
		// remove and DESTROY right panel if it exists
		if (form.items.length == 2) 
					form.remove(form.items.getAt(1),true);
		// create right panel depending on file	  
		var rightPanel = this.initPanel();
		form.add(rightPanel);
		this.object = this.module.linkedNode.get('object'); 
16035364   Benjamin Renard   First commit
143

655e355f   Elena.Budnik   disable "predefin...
144
145
146
147
148
149
150
151
152
153
		// load object into form
		if (object.$className == 'amdaModel.FileObject' || !this.object.get('name')) {
					form.getForm().loadRecord(this.fileObject);
					if (this.fileObject.get('format') == 'txt')
							this.disablePredefined(false);
					else
							this.disablePredefined(true);
		}
		else
					form.getForm().loadRecord(this.object);
16035364   Benjamin Renard   First commit
154

655e355f   Elena.Budnik   disable "predefin...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
		// if it is not newly created empty myParamData node	  
		if (this.object.get('name')) {
				// file panel work around	   
				if (this.fileObject.get('format') == 'txt') {    		 
					form.getForm().findField('start').setValue(this.object.get('realvar'));	
					this.disablePredefined(false);	 
				}
				else if (this.object.get('format') == 'vot')
				{
					var radio = this.down('radiogroup');
					radio.setValue({'votvar' : this.object.get('realvar')});
				}
				else { // cdf, cef, nc
					// select parameter
3d7c42ed   Elena.Budnik   disable fields pr...
169
170
171
172
					var radio = this.down('radiogroup');
					radio.suspendEvent('change');
					radio.setValue({'cdfvar' : this.object.get('realvar')}); 
					radio.resumeEvent('change');
655e355f   Elena.Budnik   disable "predefin...
173
174
175
176
					// disable form fields defined in file
					this.disablePredefined(true);
				}
		}
3d7c42ed   Elena.Budnik   disable fields pr...
177
		
655e355f   Elena.Budnik   disable "predefin...
178
179
180
181
		//Set table definition
		if (object.get('tableDef'))
			this.getPlugin('tabledef').setTableDefinition(object.get('tableDef'));
	},
16035364   Benjamin Renard   First commit
182
	
655e355f   Elena.Budnik   disable "predefin...
183
184
185
186
187
188
189
	/*
	*   // disable form fields defined in file ( cdf, nc, cef ) 
	*/	
	disablePredefined: function(disable)
	{
		var form = this.down('form');
		form.getForm().findField('start').setDisabled(disable);
3d7c42ed   Elena.Budnik   disable fields pr...
190
191
		form.getForm().findField('size').setReadOnly(disable);
		this.down('combobox').setReadOnly(disable);
655e355f   Elena.Budnik   disable "predefin...
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
	},
	
	/*
	*  highlight selected columns in case of param (ASCII) edit
	*/
	updateSelection: function()
	{                    
		var start = parseInt(this.object.get('realvar'));
		var size =  parseInt(this.object.get('size'));
		
		if (start && size) {
				var columns = this.down('gridpanel').columns;
				for (var i = start; i < start+size; i++) {	   
					var selected = Ext.select(columns[i].getCellSelector(i));
					selected.addCls('meow');
					columns[i].selected = true;
				}
		}
	},

	/*
	* update this.object from form
	*/
	updateObject : function(nameField)
	{    
		// get the basic form
		var basicForm =  this.down('form').getForm();	  
		var updateStatus = true;
		var fieldsWithoutName = basicForm.getFields().items;
		
		Ext.Array.each(fieldsWithoutName, function(item, index,allItems){
				if(item !== nameField) { 		     
					if (!item.isValid()) {
						// set update isn't allowed
						updateStatus = false;    
					}
				}
		}, this);
		
		// if the update is allowed
		if (updateStatus) {
				// real object update
				// updateobject with the content of form
				var values = basicForm.getValues(); 
				basicForm.updateRecord(this.object);
				this.object.set('file',this.fileObject.get('fileName')); 
				this.object.set('format', this.fileObject.get('format'));
				if (this.object.get('format') == 'cdf' || this.object.get('format') == 'cef' || this.object.get('format') == 'nc') this.object.set('realvar',values.cdfvar);
				if (this.object.get('format') == 'vot') this.object.set('realvar',values.votvar);
				if (this.object.get('format') == 'txt') this.object.set('realvar',values.start);
				this.object.set('tableDef', this.getPlugin('tabledef').getTableDefinitionObject());
		}
		// return the update status
		return updateStatus;	    
	},
16035364   Benjamin Renard   First commit
247
	        
655e355f   Elena.Budnik   disable "predefin...
248
249
250
251
252
253
254
255
	/**
	* Check mask - length, existed....
	* @return true/false
	*/     
	validateMask : function(value)
	{
		// length
		if (value.length < 6) return 'mask length is too small (< 6)';
16035364   Benjamin Renard   First commit
256

655e355f   Elena.Budnik   disable "predefin...
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
		// first *
		if (value.indexOf('*') === 0)  return '"*" could not be the first letter in mask';
		
		// several *
		if (value.indexOf('*') !== value.lastIndexOf('*')) return 'several "*" are not allowed in mask';
		
		// less common            
		var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.my_data.id); 
		var oldmask = paramModule.linkedNode.get('object').get('mask');
		// no old mask
		if (oldmask.length === 0) return true;
		if (value.length > oldmask.length) return 'new mask is less common than old one';
		
		return true;
	},

	/*
	*  save parameter
	*/        
	saveProcess : function(toRename)
	{          
		var values = this.down('form').getForm().getValues();              	 
		// Parameter Module
		var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.my_data.id);   
			
		// if the name has been modified this is a creation
		if (this.object.isModified('name'))
		{                
			var contextNode = paramModule.linkedNode.parentNode;        
			// if object already has an id : it's a 'rename' of an existing  	
			if (this.object.get('id'))
			{
				// get file object of the first node linked this file
				var fileObject = paramModule.linkedNode.get('fileObject');
				
				paramModule.createLinkedNode();                         
				// create a new object linked	                      
				var paramobj = Ext.create(paramModule.linkedNode.get('objectDataModel'), values);
							
				paramobj.set('format', this.fileObject.get('format'));                   
				if (paramobj.get('format') == 'cdf' || paramobj.get('format') == 'cef' ||
						paramobj.get('format') == 'nc')
														paramobj.set('realvar',values.cdfvar);
				if (paramobj.get('format') == 'vot') 
														paramobj.set('realvar',values.votvar);
				if (paramobj.get('format') == 'txt') 
														paramobj.set('realvar',values.start);

				paramobj.set('file', this.fileObject.get('fileName'));
				
				paramobj.set('tableDef', this.getPlugin('tabledef').getTableDefinitionObject());

				paramModule.linkedNode.set('object',paramobj);
				//synchronize objects
				this.object = paramobj; 
				
				paramModule.linkedNode.set('fileObject',fileObject);
				
				if (toRename) 
								paramModule.linkedNode.toRename = true;
			}
			paramModule.linkedNode.set('contextNode',contextNode);                 
			paramModule.linkedNode.create();
		
			paramModule.linkedNode.set('isParameter', true);
			
			if (values.size == 1) {
							paramModule.linkedNode.set('iconCls', 'icon-scalar');  
							paramModule.linkedNode.set('isSpectra', false);
			}
3d7c42ed   Elena.Budnik   disable fields pr...
327
328
329
330
			else if (values.size == 3) {
							paramModule.linkedNode.set('iconCls', 'icon-vector');  
							paramModule.linkedNode.set('isSpectra', false);
			}
655e355f   Elena.Budnik   disable "predefin...
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
			else {
				if (values.plottype == 'Spectra') {
							paramModule.linkedNode.set('isSpectra', true);
							paramModule.linkedNode.set('iconCls', 'icon-spectra'); 
				}
				else {
							paramModule.linkedNode.set('iconCls', 'icon-unknowntype'); 
							paramModule.linkedNode.set('isSpectra', false);
						}
			}                                                   
		} else {  		  
			paramModule.linkedNode.set('contextNode',paramModule.contextNode); 
			paramModule.linkedNode.update();		  
		}                  
	}, 
16035364   Benjamin Renard   First commit
346
            
655e355f   Elena.Budnik   disable "predefin...
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
	/* 
	*       overwrite method called by Save button
	*/
	overwriteProcess : function(btn){
			if (btn == 'cancel') return;
			var basicForm = this.down('form').getForm();
			basicForm.clearInvalid();
			this.saveProcess(true);        
	},

	updateForm : function() {
			var basicForm = this.down('form').getForm();
			var columns = this.down('gridpanel').columns;
			
			var start;
			var size = 0;
			Ext.Array.each(columns, function(column,index){
				if (!start && column.selected) start = index;
				if (column.selected) size += 1;
			});
			
			basicForm.setValues({start: start, size : size});
	},
16035364   Benjamin Renard   First commit
370
    
4d7cc210   Elena.Budnik   redmine 6430 - ch...
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
	checkMask : function(mask) {
		if (mask.indexOf('*') < 0) {
			if (mask.length < 6) {
				myDesktopApp.warningMsg('Mask cannot be shorter than 6 letters');
				return false;
			}
				if (this.fileObject.get('fileName').indexOf(mask) !== 0) {
					myDesktopApp.warningMsg('No correspondance between '+mask+' and '+this.fileObject.get('fileName')); 
					return false;	
			}
		}
		
		if (mask.indexOf('*') == 0) {
			myDesktopApp.warningMsg("Mask should not start with *");
			return false;
		}
		
		if (mask.indexOf('*') != mask.lastIndexOf('*')) {
			myDesktopApp.warningMsg("Mask can include only one *");
			return false;
		}
		
		var maskParts = mask.split('*');
		if (this.fileObject.get('fileName').indexOf(maskParts[0]) !== 0) {
			myDesktopApp.warningMsg('No correspondance between '+mask+' and '+this.fileObject.get('fileName')); 
			return false;	
		}

		if (maskParts.length == 2) {
09625436   Elena.Budnik   redmine 6852; myd...
400
401
402
403
404
405
406
407
408
			if (this.fileObject.get('fileName').indexOf(maskParts[1]) < 0) {
				myDesktopApp.warningMsg('No correspondance between ' +mask+' and '+this.fileObject.get('fileName')); 
				return false; 
			}
		  
			if ((maskParts[0].length + maskParts[1].length) < 6) {
				myDesktopApp.warningMsg('Mask cannot be shorter than 6 letters');
				return false;
			}
4d7cc210   Elena.Budnik   redmine 6430 - ch...
409
410
411
412
413
		}

		return true;
	},
	
655e355f   Elena.Budnik   disable "predefin...
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
	/*
	*         Configurations 
	* 
	*/     
	initPanel : function() 
	{
		var format = this.fileObject.get('format');	  
		if (format == 'cdf' || format == 'cef' || format == 'nc') return this.cdfPanel(format);
		if (format == 'txt')  return this.txtPanel();
		if (format == 'vot') return this.votPanel();
	},
	
	txtPanel: function() 
	{	  
		var fileName = this.fileObject.get('fileName');
16035364   Benjamin Renard   First commit
429
		
655e355f   Elena.Budnik   disable "predefin...
430
431
432
433
434
435
436
437
438
439
		//FOR INFO
		// Null out built in convert functions for performance *because the raw data is known to be valid*
		// Specifying defaultValue as undefined will also save code. 
		// As long as there will always be values in the data, or the app tolerates undefined field values*
		
		// Dynamically created fields and columns	    
		var n_col = this.fileObject.get('vars'); 
		// reset	  
		this.fields = [];
		this.columns = [];
16035364   Benjamin Renard   First commit
440
	  
655e355f   Elena.Budnik   disable "predefin...
441
442
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
487
488
489
490
491
492
493
494
495
496
497
		for (var i = 0; i < n_col; i++)
		{    
			var name = i === 0 ? 'Time' : 'n'+i;
			//TODO width dependent on data?	  
			var width = i === 0 ? 120 : 75;
			
			this.fields[i] = { name: name };
			this.columns[i] = { text: name, sortable : false,  dataIndex: name, width : width, 
				menuDisabled: true, selected : false,
				listeners: 
				{
					scope : this,
					headerclick: function(ct, column)
					{
						if (column.text != 'Time') {
							var selected = Ext.select(column.getCellSelector(1));
							if (column.selected) {				      
								selected.removeCls('meow');
								column.selected = false;
							}
							else {
								selected.addCls('meow');
								column.selected = true;
							}
							this.updateForm();
						}
					}
				}
			};  
		}
			
		// Dynamically created model	  
		Ext.define('myData', {
				extend: 'Ext.data.Model',
				fields: this.fields,
				idProperty: 'Time' 
		});
		
		var store = Ext.create('Ext.data.ArrayStore', {
				model: 'myData',
				autoLoad: true,
				proxy: {
				type: 'direct',
				directFn: AmdaAction.getAsciiFile		   
				},
				listeners: {
					scope: this,
					beforeload: function(store){
						store.proxy.extraParams = {
						fileName: this.fileObject.get('fileName') 
						};
					},
					load: function(store, records, successful, eOpts) {
						this.updateSelection();
					}
				}
		});
16035364   Benjamin Renard   First commit
498
	  
655e355f   Elena.Budnik   disable "predefin...
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
		// Dynamically created columns dependent of myData model
		var panelConfig = {
				xtype : 'gridpanel',
				store : store,
				title : fileName,
				height: '100%',
				flex : 2,
				columnLines: true,
				columns: this.columns,
				listeners: 
				{
					scope : this,
					cellclick: function(view,td,cellIndex,record,tr,rowIndex,e)
					{
						var column = view.getGridColumns()[cellIndex];
						if (cellIndex > 0) {
								var selected = Ext.select(column.getCellSelector(cellIndex));
								if (column.selected) {
									selected.removeCls('meow');
									column.selected = false;			  
								}
								else {
									selected.addCls('meow');
									column.selected = true;
								}
								this.updateForm();
						}
					},
					select: function(selmodel, record, index, e) {
						selmodel.deselectAll();
					}	
				}
		};
16035364   Benjamin Renard   First commit
532
            
655e355f   Elena.Budnik   disable "predefin...
533
534
		return panelConfig;
	},
16035364   Benjamin Renard   First commit
535
	
655e355f   Elena.Budnik   disable "predefin...
536
537
538
539
540
541
542
	cdfPanel : function(format) 
	{
		var vars = this.fileObject.get('vars');
		var fileName = this.fileObject.get('fileName'); 
		var items = [];	   
		Ext.Array.each(vars, function(name, index) {
				if (name) {
3d7c42ed   Elena.Budnik   disable fields pr...
543
					items[index] = { boxLabel: name, name: 'cdfvar', inputValue: name }	
655e355f   Elena.Budnik   disable "predefin...
544
545
				}
		}, this);
16035364   Benjamin Renard   First commit
546
	 	
069584d5   Elena.Budnik   scrollbar to cdf/...
547
548
549
550
551
552
553
554
555
556
557
558
		var panelConfig = {
			xtype : 'fieldset', 
			bodyStyle: { background : '#dfe8f6'},
			flex : 2,
			autoScroll : true,
			height : '100%',
			title: fileName,
			items : [{
				xtype: 'radiogroup', 
				cls: 'x-check-group-alt',
				columns: 2,
				vertical: true,	                     
3d7c42ed   Elena.Budnik   disable fields pr...
559
560
561
562
563
564
565
566
567
568
				items: items, 
				listeners : {
					scope: this,
					change: function (cb, nv, ov) {
						if (nv.cdfvar) { 
							AmdaAction.getMyParamInfo({format: format, file : fileName, varName : nv.cdfvar},
							this.updateInfo, this);
						}  
					}
				}
069584d5   Elena.Budnik   scrollbar to cdf/...
569
570
			}]
		};
16035364   Benjamin Renard   First commit
571
	    
069584d5   Elena.Budnik   scrollbar to cdf/...
572
573
		return panelConfig;
	},
16035364   Benjamin Renard   First commit
574
	
655e355f   Elena.Budnik   disable "predefin...
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
	votPanel : function() 
	{                    
		var vars = this.fileObject.get('vars');
		var fileName = this.fileObject.get('fileName');
		
		var items = [];	  
		
		if (this.fileObject.get('foundTime'))
		{
				Ext.Array.each(vars, function(obj, index) {
					items[index] = { boxLabel: obj.name, name: 'votvar',  inputValue: obj.id,
						listeners: 
						{
							scope: this,
							change: function (cb, nv, ov) {					     
									if (nv) {						
									AmdaAction.getMyParamInfo({format: 'vot', file : fileName, varName : cb.inputValue},						
											this.updateInfo, this); 
								}					   							 						  
							}
						}
				};
			}, this);
		}
		else
				myDesktopApp.errorMsg("Cannot find a valid time field!");	       
						
069584d5   Elena.Budnik   scrollbar to cdf/...
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
		var panelConfig = {
			xtype : 'fieldset', 
			bodyStyle: { background : '#dfe8f6'},
			flex : 2, 
			autoScroll : true,
			height : '100%',
			title: fileName,
			items : [{
				xtype: 'radiogroup', 
				cls: 'x-check-group-alt',
				columns: 2,
				vertical: true,	                                                
				items: items
			}]
		};
		
		return panelConfig;
	},
16035364   Benjamin Renard   First commit
620
	
069584d5   Elena.Budnik   scrollbar to cdf/...
621
	init : function(config) {	 
16035364   Benjamin Renard   First commit
622
            
069584d5   Elena.Budnik   scrollbar to cdf/...
623
624
625
626
627
628
629
630
631
		var store = Ext.create('Ext.data.Store', {
			fields: ['value', 'name'],
			data : [
			{"value": "FLOAT", "name":"FLOAT"},
			{"value": "INTEGER", "name":"INTEGER"},
			{"value": "DOUBLE", "name":"DOUBLE"},
			{"value": "SHORT", "name":"SHORT"}
			]
		}); 
16035364   Benjamin Renard   First commit
632
                    
655e355f   Elena.Budnik   disable "predefin...
633
634
635
636
637
638
639
640
641
642
643
		var combo =   { 
				xtype: 'combo',
				fieldLabel: 'Parameter Data Type',
				store: store,
				queryMode: 'local',
				displayField: 'name',
				valueField: 'value',
				name: 'type',		
				editable: false,
				value: 'FLOAT'
		};
16035364   Benjamin Renard   First commit
644
            
655e355f   Elena.Budnik   disable "predefin...
645
646
647
648
649
650
651
		var store1 = Ext.create('Ext.data.Store', {
					fields: ['value', 'name'],
					data : [
						{"value": "TimeSerie", "name":"Time Serie"},                   
						{"value": "Spectra", "name":"Spectra"}
					]
		}); 
16035364   Benjamin Renard   First commit
652
                    
655e355f   Elena.Budnik   disable "predefin...
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
		var comboPlotType =   { 
				xtype: 'combo',
				fieldLabel: 'Display Type',
				store: store1,
				queryMode: 'local',
				displayField: 'name',
				valueField: 'value',
				name: 'plottype',           
				editable: false,
				value: 'Time Series'
		};
	
	// Parameter Form	  
		var panelLeft =  {
			bodyStyle: { background : '#dfe8f6'},	      
			flex : 1,	 
			defaults: {
				xtype:'textfield',
				validateOnChange: false,
				validateOnBlur: false,
				padding : '0 10 0 5',
				inputWidth : 80
			},
			items: [
			{
				id: 'mydataName',
				fieldLabel: 'Parameter Name',
				labelAlign: 'top',
				name: 'name',
				allowBlank : false,
				stripCharsRe: /(^\s+|\s+$)/g,
				validFlag: false,
				validator : function() {
					return this.validFlag;
				},
				inputWidth : 180
			}, 
			{
				fieldLabel: 'File Name/Mask&nbsp;<img amda_clicktip="fileMask" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', 
				labelAlign: 'top',             
				name: 'mask',
				inputWidth : 180,
				validator : this.validateMask
			}, 
			combo, 
			{
				xtype:'numberfield',
				fieldLabel: 'Parameter Start Position',              
				name: 'start',
				minValue : 1,
				//	  maxValue : maxSize,
				listeners : 
				{
					scope : this,
					change : function(field, newValue, oldValue){
						var grid = this.down('gridpanel');
						if (!grid) return;
						if (newValue && newValue != oldValue) 
						{
							var size = field.prev().value;
							var columns = grid.columns;
							Ext.Array.each(columns, function(column,index){
								var selected = Ext.select(column.getCellSelector(index));
								if (index < newValue)
								{
									if (column.selected) {
										selected.removeCls('meow');
										column.selected = false;				 
									}
								}
								else if (index == newValue) {
									if (!column.selected) {
										selected.addCls('meow');
										column.selected = true;				 
									}
								}
								else {
									if (column.selected) {
										selected.removeCls('meow');
										column.selected = false;				 
									} 
								}
							});
						}
					}
				}
			}, 
			{ 
				xtype:'numberfield',
				fieldLabel: 'Parameter Size',              
				name: 'size',
				minValue: 1,
				//	  maxValue : maxSize,
				listeners : 
				{
					scope : this,
					change : function(field, newValue, oldValue){
						var grid =  this.down('gridpanel');
						if (!grid) return;
						var start =  field.prev().value;
						var columns = grid.columns;
						Ext.Array.each(columns, function(column,index){
							var selected = Ext.select(column.getCellSelector(index));
							if (index <= start) {}
							else if (index - start < newValue) {
								if (!column.selected){
									selected.addCls('meow');
									column.selected = true;	
								}
							}
							else {
								if (column.selected){
									selected.removeCls('meow');
									column.selected = false;	
								}
							}
						});
					}
				}
			}, 
			{
				xtype:'numberfield',
				fieldLabel: 'Min Sampling',              
				name: 'minsampling'
			},
			{
				xtype:'numberfield',
				fieldLabel: 'Max Sampling',              
				name: 'maxsampling'
			},
			{
				fieldLabel: 'Filling Value',              
				name: 'fillvalue'
			},
			{
				fieldLabel: 'Units',              
				name: 'units'
			},  
			comboPlotType, 
			{
				fieldLabel: 'Y Title',              
				name: 'ytitle'
			},
			{
				fieldLabel: 'Legend',              
				name: 'legend'
			}],
			listeners: 
			{
				click: {
					element: 'el',
					fn: function(e,t) {	 		 
						var me = t,
						text = me.getAttribute('amda_clicktip');
						if (text) {
								e.preventDefault();
								AmdaAction.getInfo({name : text}, function(res,e) {					    					   
									if (res.success) myDesktopApp.infoMsg(res.result);
								}); 
						}
					}
				}			
			}
		};
48a8a598   Elena.Budnik   merge with master
817

655e355f   Elena.Budnik   disable "predefin...
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
		var myConf = {
			layout: 'border',		 
			items: [ 
				{   
					xtype : 'form',
					bodyStyle: { background : '#dfe8f6'},
					layout: 'hbox',   
					region: 'center',
					buttonAlign:'left',
					items : [
							panelLeft 
					],
					buttons: [
					{
						scope : this,  
						text: 'Show/Hide Table definition',   
						handler: function() 
						{
							this.getPlugin('tabledef').showHide();
						}
a19578d1   Erdogan Furkan   Status for parame...
838
839
840
841
842
843
844
					},'-',
					{
						text: 'Edit Status',
						scope:this,
						handler: function(item,e) {
							Ext.create('amdaUI.StatusModalWindow', {object : this.object, type:'upload',status : this.object.data.status}).show();
						}
655e355f   Elena.Budnik   disable "predefin...
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
					},
					'->',
					{  
						scope : this,  
						text: 'Save',
						handler: function() 
						{   
							var form = this.down('form').getForm();     
							// check if variable was selected
							// cdf,...
							var radio = this.down('radiogroup');            
							if (radio && radio.getChecked().length == 0) {
								myDesktopApp.warningMsg('Select variable from the file, please');
								return;
							}
							// ascii
							if (!radio && this.columns.length > 0) {                                  
								if (!form.findField('start').getValue() || !form.findField('size').getValue()) {                                    
								myDesktopApp.warningMsg('Select column[s] from the file, please');
								return;
								}                                  
							}
4d7cc210   Elena.Budnik   redmine 6430 - ch...
867
868
869
870
871
872
873
874
875
							
							var maskName = form.findField('mask').getValue();
							if (maskName !== this.fileObject.get('fileName')) {
								if (!this.checkMask(maskName)) {
									form.findField('mask').setValue(this.fileObject.get('fileName'));
									return;
								}
							}
							
655e355f   Elena.Budnik   disable "predefin...
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
							var nameField = form.findField('mydataName'); 
							if (this.updateObject(nameField))
							{
								var myDataModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.my_data.id);	
								if (!myDataModule)
										return;
								var me = this;
								myDataModule.linkedNode.isValidName(nameField.getValue(), function (res) {
									if (!res) {
										nameField.validFlag = 'Error during object validation';
										myDesktopApp.errorMsg(nameField.validFlag);
										nameField.validate();
										return;
									}
									
									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
												});
												nameField.validFlag = true;
											}
											else
												nameField.validFlag = res.error;
										}
										else
										{
											nameField.validFlag = 'Invalid object name';
											myDesktopApp.errorMsg(nameField.validFlag);
										}
										nameField.validate();
										return;
									}
								
									nameField.validFlag = true;
									nameField.validate();
									me.saveProcess();
								});
							}
						}
					},
					{
						scope : this,
						text: 'Reset',
						handler: function(){				      
							this.down('form').getForm().reset();
						}
					}]
				},
				{
					xtype: 'panel', 
					region: 'south',
					title: 'Information',
					collapsible: true,
					height: 100,
					autoHide: false,
					iconCls: 'icon-information',
					bodyStyle: 'padding:5px',
					loader: {
							autoLoad: true,
							url: helpDir+'myDataHOWTO'
					}  
				}],
			  
				plugins: [ {ptype: 'tabledef', pluginId: 'tabledef'} ]
		};

		Ext.apply (this, Ext.apply(arguments, myConf));
	},
48a8a598   Elena.Budnik   merge with master
953
    
655e355f   Elena.Budnik   disable "predefin...
954
955
956
957
958
	getParameterSize : function()
	{
		var form = this.down('form').getForm();
		return form.findField('size').getValue();
	}
16035364   Benjamin Renard   First commit
959
});