PlotConstantForm.js 1.62 KB
/**
 * Project   : AMDA-NG
 * Name      : PlotConstantForm.js
 * @class   amdaPlotComp.PlotConstantForm
 * @extends amdaPlotComp.PlotStandardForm
 * @brief   Form to define specifics Text legend options
 * @author  Benjamin Renard
 * @version $Id: PlotConstantForm.js benjamin $
 */

Ext.define('amdaPlotComp.PlotConstantForm', {
	extend: 'amdaPlotComp.PlotStandardForm',
	
	setObject : function(object) {
		this.object = object;
		if (this.object != null)
			this.loadRecord(this.object);
		this.updateOptions(this.object.get('constant-axis-id'), this.crtTree.getSelectedPlotType());
	},
	
	updateOptions: function(axisId, plotType) {
		var timeValueField = this.getForm().findField('constant-time-value');
		var floatValueField = this.getForm().findField('constant-float-value');
		var isTimePlot = (plotType == 'timePlot');
		timeValueField.setVisible(isTimePlot && (axisId == "x"));
		floatValueField.setVisible(!(isTimePlot && (axisId == "x")));
	},
	
	getFormItems: function() {
		var me = this;
		return [
		        this.addStandardCombo('constant-axis-id', 'Axis attachment', amdaDefaultConfigs.availableConstantAxes, function (name, value, oldValue) {
		        	if (me.object.get('constant-axis-id') != value)
		        	{
		        		me.updateOptions(value, me.crtTree.getSelectedPlotType());
		        		me.object.set('constant-axis-id', value);
		        		me.crtTree.refresh();
		        	}
		        }),
		        this.addStandardDate('constant-time-value', 'Value'),
		        this.addStandardText('constant-float-value', 'Value'),
		        this.addStandardFieldSet('Line', '', this.addStandardLineItems('constant-line'))
        ];
	}
});