Blame view

js/app/views/PlotComponents/PlotLayoutForm.js 2.8 KB
003ba315   Benjamin Renard   Add Epoch Plot an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
 * Project   : AMDA-NG
 * Name      : PlotLayoutForm.js
 * @class   amdaPlotComp.PlotLayoutForm
 * @extends amdaPlotComp.PlotStandardForm
 * @brief   Form to define layout options
 * @author  Benjamin Renard
 * @version $Id: PlotLayoutForm.js benjamin $
 */

Ext.define('amdaPlotComp.PlotLayoutForm', {
	extend: 'amdaPlotComp.PlotStandardForm',

	requires: [
	   	    'amdaPlotComp.PlotLayoutVerticalForm',
	   	    'amdaPlotComp.PlotLayoutAutoForm',
	   	    'amdaPlotComp.PlotLayoutManualForm'
	],
	   	    
	layoutOptionsContainer: null,
	
	layoutOptionsFormsManager : new Ext.AbstractManager(),
	
a971060f   Benjamin Renard   Fix some bugs
24
25
	destroy: function() {
		this.layoutOptionsFormsManager.each(function (key, value, length) {
ecac355e   Benjamin Renard   Destroy plot elem...
26
27
28
    			this.layoutOptionsFormsManager.unregister(value);
			value.destroy();
    		}, this);
a971060f   Benjamin Renard   Fix some bugs
29
30
31
		this.callParent();
	},
	
003ba315   Benjamin Renard   Add Epoch Plot an...
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
	setObject : function(object) {
		this.object = object;
		this.loadRecord(this.object);
		this.updateLayoutOptions();
	},
	
	getLayoutOptionsForm: function(type) {
		var formId = '';
		if (!type || (type == ''))
			formId = 'none';
		else
			formId = type;
		
		formId += '-layout-options-form';
		
		if (!this.layoutOptionsFormsManager.get(formId))
		{
			switch(type)
			{
				//Create layout options form
				case 'vertical' :
					this.layoutOptionsFormsManager.register(new amdaPlotComp.PlotLayoutVerticalForm({id : formId}));
					break;
				case 'auto' :
					this.layoutOptionsFormsManager.register(new amdaPlotComp.PlotLayoutAutoForm({id : formId}));
					break;
				case 'manual' :
					this.layoutOptionsFormsManager.register(new amdaPlotComp.PlotLayoutManualForm({id : formId}));
					break;
 				default :
					this.layoutOptionsFormsManager.register(new Ext.form.Label({id : formId, text: 'No available options for this layout type'}));
			}
		}
		
		return this.layoutOptionsFormsManager.get(formId);
	
	},
	
a971060f   Benjamin Renard   Fix some bugs
70
	updateLayoutOptions: function() {
003ba315   Benjamin Renard   Add Epoch Plot an...
71
72
		var typeField = this.getForm().findField('page-layout-type');
		var layoutType = typeField.getValue();
a971060f   Benjamin Renard   Fix some bugs
73
		this.object.setLayout(layoutType);
003ba315   Benjamin Renard   Add Epoch Plot an...
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
		
		this.layoutOptionsContainer.removeAll(false);
		
		var layoutOptionsForm = this.getLayoutOptionsForm(layoutType);
		this.layoutOptionsContainer.add(layoutOptionsForm);
		layoutOptionsForm.crtTree = this.crtTree;
		if (layoutOptionsForm.setObject)
			layoutOptionsForm.setObject(this.object);
	},
	
	getFormItems: function() {
		var me = this;
		
		this.layoutOptionsContainer = Ext.create('Ext.container.Container', {
			layout: 'fit'
		});
		
		return [
4f728fd9   Erdogan Furkan   For now 2
92
		    this.addStandardCombo('page-layout-type', 'Layout type', amdaDefaultConfigs.availablePageLayouts, function(name, value, oldValue) {
a971060f   Benjamin Renard   Fix some bugs
93
94
95
		    	if (me.object.get('page-layout-type') != value)
		    	{
		    		me.updateLayoutOptions();
e84ed2cf   Benjamin Renard   Add Interval Tick...
96
97
		    		me.object.set('page-layout-type', value);
	        		me.crtTree.refresh();
a971060f   Benjamin Renard   Fix some bugs
98
		    	}
003ba315   Benjamin Renard   Add Epoch Plot an...
99
100
101
102
	        }),
	        this.layoutOptionsContainer
		];
	}
ecac355e   Benjamin Renard   Destroy plot elem...
103
});