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

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