/** * Project : AMDA-NG * Name : PlotStandardForm.js * @class amdaPlotComp.PlotStandardForm * @extends Ext.form.Panel * @brief Standard Form used to define some options for a plot element * @author Benjamin Renard * @version $Id: PlotStandardForm.js benjamin $ */ Ext.define('amdaPlotComp.PlotStandardForm', { extend: 'Ext.form.Panel', requires : [ 'amdaPlotObj.PlotObjectConfig' ], //Object associated to this form object: null, //Link to the tree crtTree: null, constructor: function(config) { this.init(config); this.callParent(arguments); }, setObject : function(object) { this.object = object; this.loadRecord(this.object); }, //To override to add form components getFormItems: function() { return []; }, addStandardText: function(name, label, onChange) { return { xtype: 'textfield', name: name, fieldLabel: label, listeners: { change: function(field, newValue, oldValue, eOpts) { this.object.set(name, newValue); if (onChange != null) onChange(name, newValue, oldValue); }, scope: this } }; }, addStandardFloat: function(name, label, min, max, allowBlank, onChange) { allowBlank = (typeof allowBlank !== 'undefined') ? allowBlank : false; return { xtype: 'numberfield', name: name, fieldLabel: label, decimalPrecision : 3, minValue : min, maxValue : max, allowBlank : allowBlank, listeners: { change: function(field, newValue, oldValue, eOpts) { this.object.set(name, newValue); if (onChange != null) onChange(name, newValue, oldValue); }, scope: this } }; }, addStandardCombo: function(name, label, availableData, onChange) { var comboStore = Ext.create('Ext.data.Store', { fields: ['key', 'value'], data : availableData }); return { xtype: 'combo', name: name, fieldLabel: label, store: comboStore, queryMode: 'local', displayField: 'value', valueField: 'key', editable: false, listeners: { change: function(combo, newValue, oldValue, eOpts) { this.object.set(name, newValue); if (onChange != null) onChange(name, newValue, oldValue); }, scope: this } }; }, addStandardCheck: function(name, label, onChange) { return { xtype: 'checkbox', name: name, boxLabel: label, listeners: { change: function(combo, newValue, oldValue, eOpts) { this.object.set(name, newValue); if (onChange != null) onChange(name, newValue, oldValue); }, scope: this } }; }, addStandardFieldSet: function(title, checkboxName, items, onChangeCheck) { return { xtype: 'fieldset', title: title, collapsible: true, collapsed: true, checkboxName: checkboxName, checkboxToggle: checkboxName != '', layout: { type: 'vbox', pack: 'start', align: 'stretch' }, items: items, listeners: { expand: function(fieldset, eOpts) { if (checkboxName != '') { this.object.set(checkboxName, true); if (onChangeCheck != null) onChangeCheck(checkboxName, true, false); } }, collapse: function(fieldset, eOpts) { if (checkboxName != '') { this.object.set(checkboxName, false); if (onChangeCheck != null) onChangeCheck(checkboxName, false, true); } }, scope: this } }; }, addStandardFont: function(namePrefix) { var fontItems = [ this.addStandardCombo(namePrefix+'-name', 'Name', amdaPlotObj.PlotObjectConfig.availableFontNames), { xtype : 'toolbar', bodyStyle: { background : '#dfe8f6' }, border: false, items : [ { xtype: 'numberfield', name: namePrefix+'-size', fieldLabel: 'Size', labelWidth: 60, width: 150, maxValue: 32, minValue: 6, value: 12, listeners: { change: function(field, newValue, oldValue, eOpts) { this.object.set(namePrefix+'-size', newValue); }, scope: this } }, ' ', { xtype: 'checkbox', name: namePrefix+'-bold', boxLabel: 'B', width: 30, listeners: { change: function(combo, newValue, oldValue, eOpts) { this.object.set(namePrefix+'-bold', newValue); }, scope: this } }, { xtype: 'checkbox', name: namePrefix+'-italic', boxLabel: 'I', width: 30, listeners: { change: function(combo, newValue, oldValue, eOpts) { this.object.set(namePrefix+'-italic', newValue); }, scope: this } } ] } ]; return this.addStandardFieldSet('Font', namePrefix+'-activated', fontItems); }, addStandardColor: function(name, label, availableData, onChange) { var comboStore = Ext.create('Ext.data.Store', { fields: ['color', 'value'], data : availableData }); return { xtype: 'combo', name: name, fieldLabel: label, store: comboStore, queryMode: 'local', displayField: 'value', valueField: 'color', editable: false, tpl: Ext.create('Ext.XTemplate', '