Blame view

js/app/views/PlotComponents/PlotLayoutForm.js 2.79 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
26
27
28
29
30
	destroy: function() {
		this.layoutOptionsFormsManager.each(function (key, value, length) {
    		this.layoutOptionsFormsManager.unregister(value);
    	}, this);
		this.callParent();
	},
	
003ba315   Benjamin Renard   Add Epoch Plot an...
31
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
	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
69
	updateLayoutOptions: function() {
003ba315   Benjamin Renard   Add Epoch Plot an...
70
71
		var typeField = this.getForm().findField('page-layout-type');
		var layoutType = typeField.getValue();
a971060f   Benjamin Renard   Fix some bugs
72
		this.object.setLayout(layoutType);
003ba315   Benjamin Renard   Add Epoch Plot an...
73
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 [
		    this.addStandardCombo('page-layout-type', 'Layout type', amdaPlotObj.PlotObjectConfig.availablePageLayouts, function(name, value, oldValue) {
a971060f   Benjamin Renard   Fix some bugs
92
93
94
		    	if (me.object.get('page-layout-type') != value)
		    	{
		    		me.updateLayoutOptions();
e84ed2cf   Benjamin Renard   Add Interval Tick...
95
96
		    		me.object.set('page-layout-type', value);
	        		me.crtTree.refresh();
a971060f   Benjamin Renard   Fix some bugs
97
		    	}
003ba315   Benjamin Renard   Add Epoch Plot an...
98
99
100
101
102
	        }),
	        this.layoutOptionsContainer
		];
	}
});