Blame view

js/app/views/PlotComponents/PlotElementPanel.js 7.44 KB
437c4dbc   Benjamin Renard   First implementat...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
 * Project   : AMDA-NG
 * Name      : PlotElementPanel.js
 * @class   amdaPlotComp.PlotElementPanel
 * @extends Ext.form.Panel
 * @brief   Element of a plot request definition
 * @author  Benjamin Renard
 * @version $Id: PlotElementPanel.js benjamin $
 */

Ext.define('amdaPlotComp.PlotElementPanel', {
	extend: 'Ext.form.Panel',
	
	requires: [
abe09878   Benjamin Renard   Add panels and ax...
15
16
17
18
19
	           'amdaPlotComp.PlotPageForm',
	           'amdaPlotComp.PlotPanelForm',
	           'amdaPlotComp.PlotBaseAxisForm',
	           'amdaPlotComp.PlotTimeAxisForm',
	           'amdaPlotComp.PlotEpochAxisForm',
17433635   Benjamin Renard   Add series and sp...
20
	           'amdaPlotComp.PlotColorAxisForm',
003ba315   Benjamin Renard   Add Epoch Plot an...
21
	           'amdaPlotComp.PlotParamForm',
94abdb37   Benjamin Renard   Add params legend...
22
	           'amdaPlotComp.PlotLayoutForm',
339866c4   Benjamin Renard   Add text legend d...
23
24
	           'amdaPlotComp.PlotLegendSeriesForm',
	           'amdaPlotComp.PlotLegendTextForm',
829160b3   Benjamin Renard   Add constants def...
25
26
	           'amdaPlotComp.PlotLegendsTextForm',
	           'amdaPlotComp.PlotDrawingObjectForm',
a8c54fb9   Benjamin Renard   Add text object p...
27
	           'amdaPlotComp.PlotConstantForm',
dbb7bcbe   Benjamin Renard   Add curves defint...
28
	           'amdaPlotComp.PlotTextForm',
486cc3c7   Benjamin Renard   Add fill elements...
29
30
31
	           'amdaPlotComp.PlotCurveForm',
	           'amdaPlotComp.PlotFillsForm',
	           'amdaPlotComp.PlotFillForm'
437c4dbc   Benjamin Renard   First implementat...
32
33
	],
	
abe09878   Benjamin Renard   Add panels and ax...
34
35
	elementFormsManager : new Ext.AbstractManager(),
	
abe09878   Benjamin Renard   Add panels and ax...
36
37
	crtTree   : null,
	
437c4dbc   Benjamin Renard   First implementat...
38
39
40
41
42
	constructor: function(config) {
		this.init(config);	    
		this.callParent(arguments);
	},
	
a971060f   Benjamin Renard   Fix some bugs
43
44
45
46
47
48
49
	destroy: function() {
		this.elementFormsManager.each(function (key, value, length) {
			this.elementFormsManager.unregister(value);
    	}, this);
		this.callParent();
	},
	
abe09878   Benjamin Renard   Add panels and ax...
50
51
	setElement: function(type, object, tree) {
		this.removeAll(false);
437c4dbc   Benjamin Renard   First implementat...
52
		
17433635   Benjamin Renard   Add series and sp...
53
		this.crtTree   = tree;
437c4dbc   Benjamin Renard   First implementat...
54
		
dbb7bcbe   Benjamin Renard   Add curves defint...
55
56
57
58
59
60
61
		var me =this;
		this.getElementForm(type, function (elementForm) {
			me.add(elementForm);
			elementForm.crtTree = tree;
			if (elementForm.setObject)
				elementForm.setObject(object);
		});
437c4dbc   Benjamin Renard   First implementat...
62
63
64
	},
	
	resetElement: function() {
17433635   Benjamin Renard   Add series and sp...
65
		this.setElement('',null,null);
abe09878   Benjamin Renard   Add panels and ax...
66
67
	},
	
dbb7bcbe   Benjamin Renard   Add curves defint...
68
	getElementForm: function(type, onFormReady) {
abe09878   Benjamin Renard   Add panels and ax...
69
70
71
		var formId = type;
		if (type == '')
			formId = 'none';
17433635   Benjamin Renard   Add series and sp...
72

abe09878   Benjamin Renard   Add panels and ax...
73
		formId += '-element-form';
dbb7bcbe   Benjamin Renard   Add curves defint...
74
75
76
		
		if (this.rendered)
			this.getEl().mask();
17433635   Benjamin Renard   Add series and sp...
77
			
dbb7bcbe   Benjamin Renard   Add curves defint...
78
		var me = this;
abe09878   Benjamin Renard   Add panels and ax...
79
80
81
82
83
84
85
		if (!this.elementFormsManager.get(formId))
		{
			//Create element form
			switch (type)
			{
			case 'page' :
				this.elementFormsManager.register(new amdaPlotComp.PlotPageForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
86
87
88
89
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
abe09878   Benjamin Renard   Add panels and ax...
90
91
92
				break;
			case 'panel' :
				this.elementFormsManager.register(new amdaPlotComp.PlotPanelForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
93
94
95
96
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
abe09878   Benjamin Renard   Add panels and ax...
97
98
99
				break;
			case 'time-axis' :
				this.elementFormsManager.register(new amdaPlotComp.PlotTimeAxisForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
100
101
102
103
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
abe09878   Benjamin Renard   Add panels and ax...
104
105
106
				break;
			case 'epoch-axis' :
				this.elementFormsManager.register(new amdaPlotComp.PlotEpochAxisForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
107
108
109
110
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
abe09878   Benjamin Renard   Add panels and ax...
111
112
113
				break;
			case 'color-axis' :
				this.elementFormsManager.register(new amdaPlotComp.PlotColorAxisForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
114
115
116
117
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
abe09878   Benjamin Renard   Add panels and ax...
118
119
120
121
122
				break;
			case 'x-axis' :
			case 'y-left-axis' :
			case 'y-right-axis' :
				this.elementFormsManager.register(new amdaPlotComp.PlotBaseAxisForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
123
124
125
126
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
abe09878   Benjamin Renard   Add panels and ax...
127
				break;
17433635   Benjamin Renard   Add series and sp...
128
129
			case 'param' :
				this.elementFormsManager.register(new amdaPlotComp.PlotParamForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
130
131
132
133
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
17433635   Benjamin Renard   Add series and sp...
134
				break;
003ba315   Benjamin Renard   Add Epoch Plot an...
135
136
			case 'layout' :
				this.elementFormsManager.register(new amdaPlotComp.PlotLayoutForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
137
138
139
140
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
003ba315   Benjamin Renard   Add Epoch Plot an...
141
				break;
94abdb37   Benjamin Renard   Add params legend...
142
143
			case 'series-legend' :
				this.elementFormsManager.register(new amdaPlotComp.PlotLegendSeriesForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
144
145
146
147
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
94abdb37   Benjamin Renard   Add params legend...
148
				break;
339866c4   Benjamin Renard   Add text legend d...
149
150
			case 'text-legend' :
				this.elementFormsManager.register(new amdaPlotComp.PlotLegendTextForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
151
152
153
154
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
339866c4   Benjamin Renard   Add text legend d...
155
156
157
				break;
			case 'text-legends' :
				this.elementFormsManager.register(new amdaPlotComp.PlotLegendsTextForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
158
159
160
161
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
339866c4   Benjamin Renard   Add text legend d...
162
				break;
829160b3   Benjamin Renard   Add constants def...
163
164
			case 'drawing-objects' :
				this.elementFormsManager.register(new amdaPlotComp.PlotDrawingObjectForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
165
166
167
168
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
829160b3   Benjamin Renard   Add constants def...
169
170
171
				break;
			case 'constant' :
				this.elementFormsManager.register(new amdaPlotComp.PlotConstantForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
172
173
174
175
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
829160b3   Benjamin Renard   Add constants def...
176
				break;
a8c54fb9   Benjamin Renard   Add text object p...
177
178
			case 'text-obj' :
				this.elementFormsManager.register(new amdaPlotComp.PlotTextForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
179
180
181
182
183
184
185
186
187
188
189
190
191
192
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
				break;
			case 'curve' :
				var curveForm = new amdaPlotComp.PlotCurveForm({id : formId});
				this.elementFormsManager.register(curveForm);
				curveForm.updateCurveList(function () {
					if (onFormReady != null)
						onFormReady(me.elementFormsManager.get(formId));
					if (me.rendered)
						me.getEl().unmask();
				});
a8c54fb9   Benjamin Renard   Add text object p...
193
				break;
486cc3c7   Benjamin Renard   Add fill elements...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
			case 'fills' :
				this.elementFormsManager.register(new amdaPlotComp.PlotFillsForm({id : formId}));
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
				break;
			case 'fill' :
				this.elementFormsManager.register(new amdaPlotComp.PlotFillForm({id : formId}));
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
				break;
abe09878   Benjamin Renard   Add panels and ax...
208
			case '' :
6528e350   Elena.Budnik   typo
209
				this.elementFormsManager.register(new Ext.form.Label({id : formId, text: 'Select an element in the tree to show options'}));
dbb7bcbe   Benjamin Renard   Add curves defint...
210
211
212
213
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
abe09878   Benjamin Renard   Add panels and ax...
214
215
216
				break;
			default :
				this.elementFormsManager.register(new Ext.form.Label({id : formId, text: 'No available options for this element'}));
dbb7bcbe   Benjamin Renard   Add curves defint...
217
218
219
220
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
abe09878   Benjamin Renard   Add panels and ax...
221
			}
dbb7bcbe   Benjamin Renard   Add curves defint...
222
			return;
abe09878   Benjamin Renard   Add panels and ax...
223
		}
dbb7bcbe   Benjamin Renard   Add curves defint...
224
225
226
227
228
229
		
		if (this.rendered)
			this.getEl().unmask();
		
		if (onFormReady != null)
			onFormReady(this.elementFormsManager.get(formId));
437c4dbc   Benjamin Renard   First implementat...
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
	},
	
	init : function(config) {
		var me = this;
		
		var myConf = {
				title : 'Selected element options',
	        	bodyStyle: { background : '#dfe8f6' },
	        	autoScroll: true,
				defaults: {
					border: false
				}
		};
		
		Ext.apply (this , Ext.apply (arguments, myConf));
	}
});