Blame view

js/app/views/PlotComponents/PlotElementPanel.js 4.4 KB
437c4dbc   Benjamin Renard   First implementat...
1
2
3
4
5
6
7
8
9
10
11
12
/**
 * 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',
495fc7a3   Benjamin Renard   Adapt plot UI in ...
13

437c4dbc   Benjamin Renard   First implementat...
14
	
abe09878   Benjamin Renard   Add panels and ax...
15
16
	elementFormsManager : new Ext.AbstractManager(),
	
abe09878   Benjamin Renard   Add panels and ax...
17
18
	crtTree   : null,
	
437c4dbc   Benjamin Renard   First implementat...
19
20
21
22
23
	constructor: function(config) {
		this.init(config);	    
		this.callParent(arguments);
	},
	
a971060f   Benjamin Renard   Fix some bugs
24
25
26
	destroy: function() {
		this.elementFormsManager.each(function (key, value, length) {
			this.elementFormsManager.unregister(value);
ecac355e   Benjamin Renard   Destroy plot elem...
27
28
			value.destroy();
    		}, this);
a971060f   Benjamin Renard   Fix some bugs
29
30
31
		this.callParent();
	},
	
abe09878   Benjamin Renard   Add panels and ax...
32
33
	setElement: function(type, object, tree) {
		this.removeAll(false);
437c4dbc   Benjamin Renard   First implementat...
34
		
17433635   Benjamin Renard   Add series and sp...
35
		this.crtTree   = tree;
437c4dbc   Benjamin Renard   First implementat...
36
		
dbb7bcbe   Benjamin Renard   Add curves defint...
37
38
39
40
41
42
43
		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...
44
45
46
	},
	
	resetElement: function() {
17433635   Benjamin Renard   Add series and sp...
47
		this.setElement('',null,null);
abe09878   Benjamin Renard   Add panels and ax...
48
49
	},
	
dbb7bcbe   Benjamin Renard   Add curves defint...
50
	getElementForm: function(type, onFormReady) {
abe09878   Benjamin Renard   Add panels and ax...
51
52
53
		var formId = type;
		if (type == '')
			formId = 'none';
17433635   Benjamin Renard   Add series and sp...
54

abe09878   Benjamin Renard   Add panels and ax...
55
		formId += '-element-form';
dbb7bcbe   Benjamin Renard   Add curves defint...
56
57
58
		
		if (this.rendered)
			this.getEl().mask();
17433635   Benjamin Renard   Add series and sp...
59
			
dbb7bcbe   Benjamin Renard   Add curves defint...
60
		var me = this;
abe09878   Benjamin Renard   Add panels and ax...
61
62
63
		if (!this.elementFormsManager.get(formId))
		{
			//Create element form
0a295c3e   Benjamin Renard   Dynamic load of p...
64
65
			var element_name = '';
			var element_text = '';
abe09878   Benjamin Renard   Add panels and ax...
66
67
68
			switch (type)
			{
			case 'page' :
0a295c3e   Benjamin Renard   Dynamic load of p...
69
				element_name = 'amdaPlotComp.PlotPageForm';
abe09878   Benjamin Renard   Add panels and ax...
70
71
				break;
			case 'panel' :
0a295c3e   Benjamin Renard   Dynamic load of p...
72
				element_name = 'amdaPlotComp.PlotPanelForm';
abe09878   Benjamin Renard   Add panels and ax...
73
74
				break;
			case 'time-axis' :
0a295c3e   Benjamin Renard   Dynamic load of p...
75
				element_name = 'amdaPlotComp.PlotTimeAxisForm';
abe09878   Benjamin Renard   Add panels and ax...
76
77
				break;
			case 'epoch-axis' :
0a295c3e   Benjamin Renard   Dynamic load of p...
78
				element_name = 'amdaPlotComp.PlotEpochAxisForm';
abe09878   Benjamin Renard   Add panels and ax...
79
80
				break;
			case 'color-axis' :
0a295c3e   Benjamin Renard   Dynamic load of p...
81
				element_name = 'amdaPlotComp.PlotColorAxisForm';
abe09878   Benjamin Renard   Add panels and ax...
82
83
84
85
				break;
			case 'x-axis' :
			case 'y-left-axis' :
			case 'y-right-axis' :
0a295c3e   Benjamin Renard   Dynamic load of p...
86
				element_name = 'amdaPlotComp.PlotBaseAxisForm';
abe09878   Benjamin Renard   Add panels and ax...
87
				break;
17433635   Benjamin Renard   Add series and sp...
88
			case 'param' :
0a295c3e   Benjamin Renard   Dynamic load of p...
89
				element_name = 'amdaPlotComp.PlotParamForm';
17433635   Benjamin Renard   Add series and sp...
90
				break;
003ba315   Benjamin Renard   Add Epoch Plot an...
91
			case 'layout' :
0a295c3e   Benjamin Renard   Dynamic load of p...
92
				element_name = 'amdaPlotComp.PlotLayoutForm';
003ba315   Benjamin Renard   Add Epoch Plot an...
93
				break;
94abdb37   Benjamin Renard   Add params legend...
94
			case 'series-legend' :
0a295c3e   Benjamin Renard   Dynamic load of p...
95
				element_name = 'amdaPlotComp.PlotLegendSeriesForm';
94abdb37   Benjamin Renard   Add params legend...
96
				break;
339866c4   Benjamin Renard   Add text legend d...
97
			case 'text-legend' :
0a295c3e   Benjamin Renard   Dynamic load of p...
98
				element_name = 'amdaPlotComp.PlotLegendTextForm';
339866c4   Benjamin Renard   Add text legend d...
99
100
				break;
			case 'text-legends' :
0a295c3e   Benjamin Renard   Dynamic load of p...
101
				element_name = 'amdaPlotComp.PlotLegendsTextForm';
339866c4   Benjamin Renard   Add text legend d...
102
				break;
829160b3   Benjamin Renard   Add constants def...
103
			case 'drawing-objects' :
0a295c3e   Benjamin Renard   Dynamic load of p...
104
				element_name = 'amdaPlotComp.PlotDrawingObjectForm';
829160b3   Benjamin Renard   Add constants def...
105
106
				break;
			case 'constant' :
0a295c3e   Benjamin Renard   Dynamic load of p...
107
				element_name = 'amdaPlotComp.PlotConstantForm';
829160b3   Benjamin Renard   Add constants def...
108
				break;
a8c54fb9   Benjamin Renard   Add text object p...
109
			case 'text-obj' :
0a295c3e   Benjamin Renard   Dynamic load of p...
110
				element_name = 'amdaPlotComp.PlotTextForm';
dbb7bcbe   Benjamin Renard   Add curves defint...
111
112
				break;
			case 'curve' :
0a295c3e   Benjamin Renard   Dynamic load of p...
113
				element_name = 'amdaPlotComp.PlotCurveForm';
a8c54fb9   Benjamin Renard   Add text object p...
114
				break;
486cc3c7   Benjamin Renard   Add fill elements...
115
			case 'fills' :
0a295c3e   Benjamin Renard   Dynamic load of p...
116
				element_name = 'amdaPlotComp.PlotFillsForm';
486cc3c7   Benjamin Renard   Add fill elements...
117
118
				break;
			case 'fill' :
0a295c3e   Benjamin Renard   Dynamic load of p...
119
				element_name = 'amdaPlotComp.PlotFillForm';
486cc3c7   Benjamin Renard   Add fill elements...
120
				break;
abe09878   Benjamin Renard   Add panels and ax...
121
			case '' :
0a295c3e   Benjamin Renard   Dynamic load of p...
122
123
				element_name = 'Ext.form.Label';
				element_text = 'Select an element in the tree to show options';
abe09878   Benjamin Renard   Add panels and ax...
124
125
				break;
			default :
0a295c3e   Benjamin Renard   Dynamic load of p...
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
				element_name = 'Ext.form.Label';
				element_text = 'No available options for this element';
			}
			
			var create_func = function() {
				var formArgs = {
						id: formId
				};
				
				if (element_text != '')
					formArgs.text = element_text;
				
				var new_element_form = Ext.create(element_name, formArgs);
				me.elementFormsManager.register(new_element_form);
				
				if (new_element_form.updateElement) {
					new_element_form.updateElement(function () {
						if (onFormReady != null)
							onFormReady(me.elementFormsManager.get(formId));
						if (me.rendered)
							me.getEl().unmask();
					});
				}
				else {
					if (onFormReady != null)
						onFormReady(me.elementFormsManager.get(formId));
					if (me.rendered)
						me.getEl().unmask();
				}
			};
			
			if (!Ext.ClassManager.get(element_name)) {
				var me = this;
				//Load class source code
				Ext.require(element_name, function() {
					//Create element
					create_func();
				});
abe09878   Benjamin Renard   Add panels and ax...
164
			}
0a295c3e   Benjamin Renard   Dynamic load of p...
165
166
167
168
			else
				//Create element
				create_func();
				
dbb7bcbe   Benjamin Renard   Add curves defint...
169
			return;
abe09878   Benjamin Renard   Add panels and ax...
170
		}
dbb7bcbe   Benjamin Renard   Add curves defint...
171
172
173
174
175
176
		
		if (this.rendered)
			this.getEl().unmask();
		
		if (onFormReady != null)
			onFormReady(this.elementFormsManager.get(formId));
437c4dbc   Benjamin Renard   First implementat...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
	},
	
	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));
	}
ecac355e   Benjamin Renard   Destroy plot elem...
193
});