Blame view

js/app/models/RemoteParamNode.js 4.32 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/** 
 * 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',
    
3a5f60a1   elena   proper use os sta...
15
16
17
18
     statics:{
        nodeType: 'remoteParam'
    },
        
16035364   Benjamin Renard   First commit
19
20
21
22
23
24
    fields: [
            {name: 'isRemoteDataSet', type:'boolean', persist: false, defaultValue: false},
            {name: 'isSimulation', type:'boolean', defaultValue: false}          
            ],
	   
    constructor : function(config){	   
3a5f60a1   elena   proper use os sta...
25
        this.callParent(arguments);       
16035364   Benjamin Renard   First commit
26
27
28
29
30
31
32
33
34
35
        //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);
        }
    },
    
3a5f60a1   elena   proper use os sta...
36
      
16035364   Benjamin Renard   First commit
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
    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');
    }
    
});