/** * Project : AMDA-NG4 * Name : DerivedParamNode.js * @class amdaModel.DerivedParamNode * @extends amdaModel.InteractiveNode * @brief Model of Node corresponding to a derived parameter * @author CDA * @version $Id: DerivedParamNode.js 2544 2014-10-03 10:21:56Z elena $ */ Ext.define('amdaModel.DerivedParamComponentNode', { extend: 'amdaModel.InteractiveNode', text: '', constructor : function(config) { this.callParent(arguments); this.set('text', config && config.text ? config.text : this.text); this.set('iconCls', 'icon-scalar'); this.set('leaf',true); this.set('isParameter',true); }, localMenuItems : function(){ var menuItems= [{ fnId : 'leaf-plotParam', text : 'Plot Parameter', hidden : true }, { fnId : 'leaf-downParam', text : 'Download Parameter', hidden : true }] return menuItems; }, getAllContextMenuItems: function(){ return this.localMenuItems (); }, }); Ext.define('amdaModel.DerivedParamNode', { extend: 'amdaModel.InteractiveNode', requires:[], fields : [ { name : 'dim_1', type:'number', defaultValue:1, persist: false}, { name : 'dim_2', type:'number', defaultValue:1, persist: false} ], statics:{ nodeType: 'derivedParam', objectName: 'Parameter' }, constructor : function(config){ this.callParent(arguments); this.set('moduleId',myDesktopApp.dynamicModules.param.id); this.set('objectDataModel',amdaModel.Parameter.$className); this.set('ownerTreeId',amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); this.updateIcon(); this.updateComponents(); }, updateIcon: function() { if (this.get('isParameter')) { if( (this.get('dim_1') == 3 && this.get('dim_2') == 1) || (this.get('dim_1') == 1 && this.get('dim_2') == 3)){ this.set('iconCls', 'icon-vector'); } else if( (this.get('dim_1') == 2 && this.get('dim_2') == 1) || (this.get('dim_1') == 1 && this.get('dim_2') == 2)){ this.set('iconCls', 'icon-vector'); } else if ( (this.get('dim_1') > 1 && this.get('dim_2') >=1)|| (this.get('dim_1') >=1 && this.get('dim_2') >1)) { this.set('iconCls','icon-spectra'); } else { this.set('iconCls', 'icon-scalar'); } } }, updateComponents: function() { this.removeAll(); if (!this.get('isParameter')) { return; } if( (this.get('dim_1') == 3 && this.get('dim_2') == 1) || (this.get('dim_1') == 1 && this.get('dim_2') == 3) || (this.get('dim_1') == 2 && this.get('dim_2') == 1) || (this.get('dim_1') == 1 && this.get('dim_2') == 2)) { for (var i = 0; i < this.get('dim_1') *this.get('dim_2'); ++i) { var ch=new amdaModel.DerivedParamComponentNode({text: this.get('text') + '(' + i + ')' }); ch.set('nodeType','derivedParam'); this.appendChild(ch); } } }, localMenuItems : function() { var menuItems = [{ fnId : 'leaf-plotParam', text : 'Plot Parameter', hidden : true }, { fnId : 'leaf-downParam', text : 'Download Parameter', hidden : true }]; return menuItems; }, getAllContextMenuItems: function(){ var menuItems = this.allMenuItems(); var locMenuItems = this.localMenuItems(); return Ext.Array.merge(menuItems,locMenuItems); }, isParameter : function(){ return this.get('isParameter'); }, specialUpdate : function(res, timeUpdate) { if (res && res.dim_1) { this.set('dim_1', res.dim_1); } if (res && res.dim_2) { this.set('dim_2', res.dim_2); } this.updateIcon(); this.updateComponents(); } });