Blame view

js/app/views/PlotComponents/PlotElementPanel.js 7.27 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);
	},
	
abe09878   Benjamin Renard   Add panels and ax...
43
44
	setElement: function(type, object, tree) {
		this.removeAll(false);
437c4dbc   Benjamin Renard   First implementat...
45
		
17433635   Benjamin Renard   Add series and sp...
46
		this.crtTree   = tree;
437c4dbc   Benjamin Renard   First implementat...
47
		
dbb7bcbe   Benjamin Renard   Add curves defint...
48
49
50
51
52
53
54
		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...
55
56
57
	},
	
	resetElement: function() {
17433635   Benjamin Renard   Add series and sp...
58
		this.setElement('',null,null);
abe09878   Benjamin Renard   Add panels and ax...
59
60
	},
	
dbb7bcbe   Benjamin Renard   Add curves defint...
61
	getElementForm: function(type, onFormReady) {
abe09878   Benjamin Renard   Add panels and ax...
62
63
64
		var formId = type;
		if (type == '')
			formId = 'none';
17433635   Benjamin Renard   Add series and sp...
65

abe09878   Benjamin Renard   Add panels and ax...
66
		formId += '-element-form';
dbb7bcbe   Benjamin Renard   Add curves defint...
67
68
69
		
		if (this.rendered)
			this.getEl().mask();
17433635   Benjamin Renard   Add series and sp...
70
			
dbb7bcbe   Benjamin Renard   Add curves defint...
71
		var me = this;
abe09878   Benjamin Renard   Add panels and ax...
72
73
74
75
76
77
78
		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...
79
80
81
82
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
abe09878   Benjamin Renard   Add panels and ax...
83
84
85
				break;
			case 'panel' :
				this.elementFormsManager.register(new amdaPlotComp.PlotPanelForm({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 'time-axis' :
				this.elementFormsManager.register(new amdaPlotComp.PlotTimeAxisForm({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 'epoch-axis' :
				this.elementFormsManager.register(new amdaPlotComp.PlotEpochAxisForm({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 'color-axis' :
				this.elementFormsManager.register(new amdaPlotComp.PlotColorAxisForm({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
114
115
				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...
116
117
118
119
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
abe09878   Benjamin Renard   Add panels and ax...
120
				break;
17433635   Benjamin Renard   Add series and sp...
121
122
			case 'param' :
				this.elementFormsManager.register(new amdaPlotComp.PlotParamForm({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();
17433635   Benjamin Renard   Add series and sp...
127
				break;
003ba315   Benjamin Renard   Add Epoch Plot an...
128
129
			case 'layout' :
				this.elementFormsManager.register(new amdaPlotComp.PlotLayoutForm({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();
003ba315   Benjamin Renard   Add Epoch Plot an...
134
				break;
94abdb37   Benjamin Renard   Add params legend...
135
136
			case 'series-legend' :
				this.elementFormsManager.register(new amdaPlotComp.PlotLegendSeriesForm({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();
94abdb37   Benjamin Renard   Add params legend...
141
				break;
339866c4   Benjamin Renard   Add text legend d...
142
143
			case 'text-legend' :
				this.elementFormsManager.register(new amdaPlotComp.PlotLegendTextForm({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();
339866c4   Benjamin Renard   Add text legend d...
148
149
150
				break;
			case 'text-legends' :
				this.elementFormsManager.register(new amdaPlotComp.PlotLegendsTextForm({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
				break;
829160b3   Benjamin Renard   Add constants def...
156
157
			case 'drawing-objects' :
				this.elementFormsManager.register(new amdaPlotComp.PlotDrawingObjectForm({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();
829160b3   Benjamin Renard   Add constants def...
162
163
164
				break;
			case 'constant' :
				this.elementFormsManager.register(new amdaPlotComp.PlotConstantForm({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
				break;
a8c54fb9   Benjamin Renard   Add text object p...
170
171
			case 'text-obj' :
				this.elementFormsManager.register(new amdaPlotComp.PlotTextForm({id : formId}));
dbb7bcbe   Benjamin Renard   Add curves defint...
172
173
174
175
176
177
178
179
180
181
182
183
184
185
				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...
186
				break;
486cc3c7   Benjamin Renard   Add fill elements...
187
188
189
190
191
192
193
194
195
196
197
198
199
200
			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...
201
202
			case '' :
				this.elementFormsManager.register(new Ext.form.Label({id : formId, text: 'Select an element to the tree to show options'}));
dbb7bcbe   Benjamin Renard   Add curves defint...
203
204
205
206
				if (onFormReady != null)
					onFormReady(this.elementFormsManager.get(formId));
				if (this.rendered)
					this.getEl().unmask();
abe09878   Benjamin Renard   Add panels and ax...
207
208
209
				break;
			default :
				this.elementFormsManager.register(new Ext.form.Label({id : formId, text: 'No available options for this element'}));
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
			}
dbb7bcbe   Benjamin Renard   Add curves defint...
215
			return;
abe09878   Benjamin Renard   Add panels and ax...
216
		}
dbb7bcbe   Benjamin Renard   Add curves defint...
217
218
219
220
221
222
		
		if (this.rendered)
			this.getEl().unmask();
		
		if (onFormReady != null)
			onFormReady(this.elementFormsManager.get(formId));
437c4dbc   Benjamin Renard   First implementat...
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
	},
	
	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));
	}
});