RemoteParamNode.js 4.32 KB
/** 
 * Project  : AMDA-NG4
 * Name     : RemoteParamNode.js
 * @class   amdaModel.RemoteParamNode
 * @extends amdaModel.LocalParamNode
 * @brief    
 * @author  
 * @version $Id: RemoteParamNode.js 2544 2014-10-03 10:21:56Z elena $
 */

Ext.define('amdaModel.RemoteParamNode', {

    extend: 'amdaModel.LocalParamNode',
    
     statics:{
        nodeType: 'remoteParam'
    },
        
    fields: [
            {name: 'isRemoteDataSet', type:'boolean', persist: false, defaultValue: false},
            {name: 'isSimulation', type:'boolean', defaultValue: false}          
            ],
	   
    constructor : function(config){	   
        this.callParent(arguments);       
        //TODO only for INTEROPER TREE	
	if (!this.get('leaf')) this.set('allowDrag', false);
	if (this.get('isParameter')) this.set('allowDrag',true);
	if (this.get('leaf') && this.get('isSpectra')) this.set('iconCls', 'icon-spectra');  
        if (this.get('disable')) {
            this.set('cls', 'icon-disabled');
            this.set('allowDrag', false);
        }
    },
    
      
    allMenuItems : function() {
        var menuItems =
        [{
            fnId : 'dire-addData',
            text : 'Add Data'
        },{
            fnId : 'root-addData',
            text : 'Add Data'
        },{
            fnId : 'dire-deleteNode',
            text : 'Delete Data'
        },{
            fnId : 'root-collapseAll',
            text : 'Close All'
        }, {
            fnId : 'dire-collapseAll',
            text : 'Close All'
        }, {
            fnId : 'para-plotParam',
            text : 'Plot Parameter',
            hidden : true
        }, {
            fnId : 'para-downParam',
            text : 'Download Parameter',
            hidden : true
        },{
            fnId : 'leaf-createAlias',
            text : 'Create/Edit Alias'
        }, {    
            fnId : 'leaf-createDerivedParam',
            text : 'Create Derived Parameter'
        },{
            fnId : 'leaf-deleteNode',
            text : 'Delete Parameter'
        },{
            fnId : 'leaf-plotParam',
            text : 'Plot Parameter',
            hidden : true
        }, {
            fnId : 'leaf-downParam',
            text : 'Download Parameter',
            hidden : true
        }];

        return menuItems;
    } ,
    
    onMenuItemClick : function(menu,item,event) {
      
        if (item) {
            switch (item.fnId) {

            case 'root-collapseAll':
            case 'dire-collapseAll':
                if(this && !this.isLeaf()) {
                    this.collapse(true);
                }
                break;
            case 'leaf-createDerivedParam':
                this.createLeaf(this); 
                break;
            case 'leaf-createAlias':	   
                this.createAlias(this); 
                break;
            case  'leaf-deleteNode':
            case 'dire-deleteNode' :
                this.deleteData();
                break;
            case  'dire-addData':
            case  'root-addData':    
                this.addData();           
                break;
            case 'leaf-plotParam':
            case 'para-plotParam':                    
                    this.createPlot(this);                
                break;
            case 'leaf-downParam':
            case 'para-downParam':                    
                    this.createDownload(this);                
                break;    
            default:	 
                break;
            }
        }
    },
    
     deleteData : function() {
      //  var parent = this.parentNode;
	AmdaAction.deleteFromTree({nodeType: this.get('nodeType'), id : this.get('id')}, function(res,e){	      
	            //TODO  if () not error ??		 
		  this.remove();
		  this.destroy();				  
	      },this);		
     },
    
     addData : function() {
         
        if (this.get('disable')) return;
           
        var me = this;
        myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) {
        	module.createWindow(me.getBaseId());    
        });
	}, 
     
// Depth of Base Root Node = 3 : root, Parameters, Remote Parameters, BaseName    
    getBaseId : function() {
      
	if (this.getDepth() < 3) return 'root';
	    
	var node = this;
	while (node.getDepth() > 3) {
	  node = node.parentNode;
	}
	return node.get('id');
    }
    
});