SpecialParamNode.js 3.13 KB
/** 
 * Project  : AMDA-NG4
 * Name     : SpecialParamNode.js
 * @class   amdaModel.SpecialParamNode
 * @extends amdaModel.InteractiveNode
 * @brief    
 * @author  
 * @version $Id: MyDataNode.js 2267 2014-04-03 10:13:16Z elena $
 * @todo
 *******************************************************************************
 *    FT Id     :   Date   : Name - Description
 *******************************************************************************
 * 
 */

Ext.define('amdaModel.SpecialParamNode', {
  
    extend: 'amdaModel.InteractiveNode',
    
    statics:{
        nodeType: 'specialParam'
    },
    
    fields: 
    [
    ],
    
    dependentRootNodeId :  'specialParam-treeRootNode',
    
    constructor : function(config){
        this.callParent(arguments);

        this.set('moduleId',myDesktopApp.dynamicModules.param.id);
        this.set('objectDataModel',amdaModel.Parameter.$className);
    },
       
    localMenuItems : function() {
        var menuItems =
        [{
            fnId: 'leaf-plotParam',
            text: 'Plot Parameter',
            hidden: true
        }, {
            fnId: 'leaf-downParam',
            text: 'Download Parameter',
            hidden: true
        }, {
            fnId: 'para-plotParam',
            text: 'Plot Parameter',
            hidden: true
        }, {
            fnId: 'para-downParam',
            text: 'Download Parameter',
            hidden: true
        },{
			fnId : 'leaf-createDerivedParam',
			text : 'Create Derived Parameter',
			hidden : true
		},];
        return menuItems;
    },

    getAllContextMenuItems: function(){
        var locMenuItems = this.localMenuItems();
        return  locMenuItems;
    },

    onMenuItemClick : function(menu,item,event) {
        var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length);
        if(item){
            switch (item.fnId)
        {
            case 'root-collapseAll':
				case 'dire-collapseAll':
				case 'miss-collapseAll':
						if(this && !this.isLeaf()) {
							this.collapse(true);
						}
						break;
            case 'leaf-createDerivedParam':
                this.createLeaf(this);
                break;
            case 'leaf-plotParam':
            case 'para-plotParam':
                this.createPlot(this);
                break;
            case 'leaf-downParam':
            case 'para-downParam':
                this.createDownload(this);
                break;
            default:
                break;
        } // switch end 
        }
        
    },

    createLeaf: function(node)
	{
		myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id, true, function(module) {
			if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.param.id)) {               
				var param =  Ext.create(node.get('objectDataModel')); 
				var newNode = Ext.create(amdaModel.DerivedParamNode.$className, {leaf : true, object : param});              
				// edit newNode into Parameter Module with node as contextNode
				newNode.editInModule();
			}  
			var paramName = node.get('id');
			var components = null;
			module.addParam(paramName,node.get('leaf'),node.get('needsArgs'),components, null, null);
		});
	},

});