/** * 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', 'amdaPlotComp.EraseTrigger' ], //Object associated to this form object: null, //Link to the tree crtTree: null, desableTickNumber: true, desableTickSpacing: true, 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 []; }, //Function called after element creation by PlotElementPanel updateElement: function (onAfterUpdate) { if (onAfterUpdate) onAfterUpdate(); }, // 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: 20, 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 } }; }, addStandardInteger: function (name, label, min, max, allowBlank, hidden, onChange) { allowBlank = (typeof allowBlank !== 'undefined') ? allowBlank : false; return { xtype: 'numberfield', name: name, fieldLabel: label, hidden: (hidden) ? true : false, regex: /^\d+$/, decimalPrecision: 20, 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 } }; }, addStandardFloat2: function (name, label, min, max, allowBlank, hidden, onChange) { allowBlank = (typeof allowBlank !== 'undefined') ? allowBlank : false; return { xtype: 'textfield', name: name, fieldLabel: label, regex: /[-+]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][-+]?\d+)?/, hidden: (hidden) ? true : false, validator: function (val) { var errMsg = null; if (!allowBlank && Ext.isEmpty(val)) { errMsg = 'Blank value not allowed'; } else if ((typeof min !== 'undefined') && (parseFloat(val) < min)) { errMsg = 'Min. allowed value is ' + min; } else if ((typeof max !== 'undefined') && (parseFloat(val) > max)) { errMsg = 'Max. allowed value is ' + max; } return errMsg ? errMsg : true; }, 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: [amdaPlotObj.PlotObjectConfig.fieldComboBox.key, amdaPlotObj.PlotObjectConfig.fieldComboBox.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) { if (onChange != null) onChange(name, newValue, oldValue); this.object.set(name, newValue); }, scope: this } }; }, addStandardCheck: function (name, label, onChange, tooltip) { 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); }, render: function (c) { if (tooltip) { Ext.create('Ext.tip.ToolTip', { target: c.getEl(), dismissDelay: 0, html: tooltip }); } }, scope: this } }; }, addStandardFieldSet: function (title, checkboxName, items, onChangeCheck) { return { xtype: 'fieldset', cls: 'child-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', '