/** * Project  : AMDA-NG * Name : ParamArgumentsPlug.js * @plugin amdaUI.ParamArgumentsPlug * @extends Ext.util.Observable * @ptype paramArgumentsPlugin * @brief Plugin to select arguments of a parameter * @author Benjamin * @version $Id: ParamArgumentsPlug.js ******************************************************************************** * FT Id : Date : Name - Description ******************************************************************************* * : */ Ext.define('amdaUI.ParamArgumentsPlug', { extend: 'Ext.util.Observable', alias: 'plugin.paramArgumentsPlugin', win : null, form : null, paramArgs: null, paramId: '', onApply: null, requires: [ 'amdaUI.ParamArgumentsUI' ], constructor: function(config) { Ext.apply(this, config); this.callParent(arguments); }, onDestroy : function() { this.win = null; }, init: function(cmp) { this.hostCmp = cmp; }, /** * creation of the window */ show : function(paramId, crtArgsValues) { if (!this.win) { this.win = new Ext.Window({ id: 'param-comp-win', width: 200, height: 150, x: 0, y: 0, baseCls:'x-panel', title: '', layout: 'fit', constrain: true, collapsible: true, resizable: false, ghost: false, renderTo: this.hostCmp.ownerCt.body, items: this.getFormConfig(), listeners: { scope: this, beforeclose: function() { Ext.PluginManager.unregister(this); } }, getConstrainVector: function(constrainTo){ var me = this; if (me.constrain || me.constrainHeader) { constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent(); return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo); } } }); this.win.on('destroy', this.onDestroy, this); Ext.PluginManager.register(this); } this.win.setTitle('Arguments for ' + paramId); this.paramId = paramId; this.paramArgs.editParameter(paramId, crtArgsValues, this.hostCmp); this.win.show(); }, close : function() { if (this.win == null) return; this.win.close(); }, /** * Main form */ getFormConfig: function(){ this.paramArgs = Ext.create('amdaUI.ParamArgumentsUI', { }); var me = this; this.form = new Ext.form.FormPanel( { frame: true, width: 230, height: 120, layout: { type: 'vbox', pack: 'start', align: 'stretch' }, fieldDefaults: { labelWidth: 60 }, items: [ this.paramArgs ], buttons: [ { text: 'Apply', scope : this, handler: function(bt,event) { if (me.paramArgs) { if (me.onApply) me.onApply(this.hostCmp, me.paramId, me.paramArgs.getValues()); } } }, { text: 'Reset', scope : this, handler: function(bt,event) { if (me.paramArgs) me.paramArgs.resetValues(); } } ] }); return this.form; } });