Blame view

js/app/views/PlotComponents/PlotParamForm.js 4.67 KB
17433635   Benjamin Renard   Add series and sp...
1
2
3
4
/**
 * Project   : AMDA-NG
 * Name      : PlotParamForm.js
 * @class   amdaPlotComp.PlotParamForm
a0bf9157   Benjamin Renard   Add tick plot and...
5
 * @extends amdaPlotComp.amdaPlotComp.PlotStandardForm
17433635   Benjamin Renard   Add series and sp...
6
7
8
9
10
11
12
13
14
15
 * @brief   Form to define specifics param options
 * @author  Benjamin Renard
 * @version $Id: PlotParamForm.js benjamin $
 */

Ext.define('amdaPlotComp.PlotParamForm', {
	extend: 'amdaPlotComp.PlotStandardForm',
	
	requires: [
	    'amdaPlotComp.PlotSerieForm',
e84ed2cf   Benjamin Renard   Add Interval Tick...
16
	    'amdaPlotComp.PlotOrbitSerieForm',
a0bf9157   Benjamin Renard   Add tick plot and...
17
18
	    'amdaPlotComp.PlotSpectroForm',
	    'amdaPlotComp.PlotStatusBarForm',
6a801541   Benjamin Renard   Add possibility t...
19
20
	    'amdaPlotComp.PlotTickBarForm',
	    'amdaPlotComp.PlotInstantSerieForm',
7ac3ce50   Benjamin Renard   First implementat...
21
22
	    'amdaPlotComp.PlotInstantSpectroForm',
	    'amdaUI.ParamArgumentsUI'
17433635   Benjamin Renard   Add series and sp...
23
24
25
26
27
28
	],
	
	drawingOptionsContainer: null,
	
	drawingOptionsFormsManager : new Ext.AbstractManager(),
	
7ac3ce50   Benjamin Renard   First implementat...
29
30
	paramArgs : null,
	
a971060f   Benjamin Renard   Fix some bugs
31
32
33
34
35
36
37
	destroy: function() {
		this.drawingOptionsFormsManager.each(function (key, value, length) {
    		this.drawingOptionsFormsManager.unregister(value);
    	}, this);
		this.callParent();
	},
	
17433635   Benjamin Renard   Add series and sp...
38
39
40
	setObject : function(object) {
		this.object = object;
		this.loadRecord(this.object);
7ac3ce50   Benjamin Renard   First implementat...
41
		this.updateDrawingOptions(this.object.get('param-drawing-type'), this.object.get('param-id'));
17433635   Benjamin Renard   Add series and sp...
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
	},
	
	getDrawingOptionsForm: function(type) {
		var formId = '';
		if (!type || (type == ''))
			formId = 'none';
		else
			formId = type;
		
		formId += '-drawing-options-form';
		
		if (!this.drawingOptionsFormsManager.get(formId))
		{
			switch(type)
			{
				//Create drawing options form
				case 'serie' :
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotSerieForm({id : formId}));
					break;
e84ed2cf   Benjamin Renard   Add Interval Tick...
61
62
63
				case 'orbit-serie' :
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotOrbitSerieForm({id : formId}));
					break;
17433635   Benjamin Renard   Add series and sp...
64
65
66
				case 'spectro' :
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotSpectroForm({id : formId}));
					break;
a0bf9157   Benjamin Renard   Add tick plot and...
67
68
69
70
71
72
				case 'status-bar' :
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotStatusBarForm({id : formId}));
					break;
				case 'tick-bar' :
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotTickBarForm({id : formId}));
					break;
6a801541   Benjamin Renard   Add possibility t...
73
74
75
76
77
78
				case 'iserie' :
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotInstantSerieForm({id : formId}));
					break;
				case 'ispectro' :
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotInstantSpectroForm({id : formId}));
					break;
a0bf9157   Benjamin Renard   Add tick plot and...
79
 				default :
17433635   Benjamin Renard   Add series and sp...
80
81
82
83
84
85
86
87
					this.drawingOptionsFormsManager.register(new Ext.form.Label({id : formId, text: 'No available options for this drawing type'}));
			}
		}
		
		return this.drawingOptionsFormsManager.get(formId);
	
	},
	
7ac3ce50   Benjamin Renard   First implementat...
88
	updateDrawingOptions: function(drawingType, paramId) {
17433635   Benjamin Renard   Add series and sp...
89
90
		var typeField = this.getForm().findField('param-drawing-type');
		
a0bf9157   Benjamin Renard   Add tick plot and...
91
92
		var availableDrawingObjects = this.object.getAvailableDrawingObjectByPlotType(this.crtTree.getSelectedPlotType());
		typeField.getStore().loadData(availableDrawingObjects);
a971060f   Benjamin Renard   Fix some bugs
93
94
95
		typeField.suspendEvents();
		typeField.setValue(drawingType);
		typeField.resumeEvents(false);
17433635   Benjamin Renard   Add series and sp...
96
97
98
		
		this.drawingOptionsContainer.removeAll(false);
		
a0bf9157   Benjamin Renard   Add tick plot and...
99
		var drawingOptionsForm = this.getDrawingOptionsForm(drawingType);
17433635   Benjamin Renard   Add series and sp...
100
101
102
103
		this.drawingOptionsContainer.add(drawingOptionsForm);
		drawingOptionsForm.crtTree = this.crtTree;
		if (drawingOptionsForm.setObject)
			drawingOptionsForm.setObject(this.object);
7ac3ce50   Benjamin Renard   First implementat...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
		
		if (this.paramArgs && paramId)
			this.paramArgs.editParameter(paramId, {'dim_1' : this.object.get('param-dim-1'), 'dim_2' : this.object.get('param-dim-2')}, this, function (uiScope) {
				uiScope.object.set('param-type', uiScope.paramArgs.paramType);
				uiScope.crtTree.refresh();
			});
	},
	
	onChangeParamArgs: function(uiScope, args_key, newValue, oldValue) {
		if (args_key == 'dim_1')
			uiScope.object.set('param-dim-1', newValue);
		else if (args_key == 'dim_2')
			uiScope.object.set('param-dim-2', newValue);
		uiScope.crtTree.refresh();
17433635   Benjamin Renard   Add series and sp...
118
119
120
121
122
123
124
125
126
	},
	
	getFormItems: function() {
		var me = this;
		
		this.drawingOptionsContainer = Ext.create('Ext.container.Container', {
			layout: 'fit'
		});
		
7ac3ce50   Benjamin Renard   First implementat...
127
128
129
130
131
132
133
134
135
136
		this.paramArgs = Ext.create('amdaUI.ParamArgumentsUI', {
			onChange : me.onChangeParamArgs,
			scope: me
		});
		
		//ToDoparamArgsPlug
		
		var paramInfoFieldSet = this.addStandardFieldSet('Arguments', '', [this.paramArgs]);
		paramInfoFieldSet.collapsed = false;
		
17433635   Benjamin Renard   Add series and sp...
137
		return [
7ac3ce50   Benjamin Renard   First implementat...
138
		    paramInfoFieldSet,
a0bf9157   Benjamin Renard   Add tick plot and...
139
		    this.addStandardCombo('param-drawing-type', 'Drawing type', [{'key' : '', 'value' : 'None'}], function(name, value, oldValue) {
a971060f   Benjamin Renard   Fix some bugs
140
141
142
		    	if (me.object.get('param-drawing-type') != value)
		    	{
		    		me.object.changeDrawingType(value);
e84ed2cf   Benjamin Renard   Add Interval Tick...
143
144
		    		me.object.set('param-drawing-type', value);
	        		me.crtTree.refresh();
a971060f   Benjamin Renard   Fix some bugs
145
146
		    		me.updateDrawingOptions(value);
		    	}
17433635   Benjamin Renard   Add series and sp...
147
148
149
150
151
	        }),
	        this.drawingOptionsContainer
		];
	}
});