Blame view

js/app/views/PlotComponents/PlotElementPanel.js 4.5 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();
	},
	
59d845ce   Benjamin Renard   Keep parentObject...
32
	setElement: function(type, object, tree, parentObject) {
abe09878   Benjamin Renard   Add panels and ax...
33
		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
		var me =this;
		this.getElementForm(type, function (elementForm) {
			me.add(elementForm);
			elementForm.crtTree = tree;
8caed468   Benjamin Renard   Fix axes ranges d...
41
			if (elementForm.setParentObject) 
59d845ce   Benjamin Renard   Keep parentObject...
42
				elementForm.setParentObject(parentObject);
86e018f7   Benjamin Renard   Fix bug with pare...
43
44
			if (elementForm.setObject)
				elementForm.setObject(object);
dbb7bcbe   Benjamin Renard   Add curves defint...
45
		});
437c4dbc   Benjamin Renard   First implementat...
46
47
48
	},
	
	resetElement: function() {
59d845ce   Benjamin Renard   Keep parentObject...
49
		this.setElement('',null,null, null);
abe09878   Benjamin Renard   Add panels and ax...
50
51
	},
	
dbb7bcbe   Benjamin Renard   Add curves defint...
52
	getElementForm: function(type, onFormReady) {
abe09878   Benjamin Renard   Add panels and ax...
53
54
55
		var formId = type;
		if (type == '')
			formId = 'none';
17433635   Benjamin Renard   Add series and sp...
56

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