Blame view

js/app/models/RemoteParamNode.js 3.23 KB
10200969   Roipoussiere   Remove whitespace...
1
/**
16035364   Benjamin Renard   First commit
2
3
4
5
 * Project  : AMDA-NG4
 * Name     : RemoteParamNode.js
 * @class   amdaModel.RemoteParamNode
 * @extends amdaModel.LocalParamNode
74b77f58   Elena.Budnik   init remote branch
6
 * @author elena
16035364   Benjamin Renard   First commit
7
8
9
 */

Ext.define('amdaModel.RemoteParamNode', {
74b77f58   Elena.Budnik   init remote branch
10
	extend: 'amdaModel.LocalParamNode',
16035364   Benjamin Renard   First commit
11

74b77f58   Elena.Budnik   init remote branch
12
13
14
	statics:{
		nodeType: 'remoteParam'
	},
10200969   Roipoussiere   Remove whitespace...
15

74b77f58   Elena.Budnik   init remote branch
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
	fields: [{name: 'isRemoteDataSet', type:'boolean', persist: false, defaultValue: true},
			{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);
		}
	},
16035364   Benjamin Renard   First commit
32

74b77f58   Elena.Budnik   init remote branch
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
	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
42c574d9   Elena.Budnik   rm 5959; alias ex...
58
		},/*{
74b77f58   Elena.Budnik   init remote branch
59
60
			fnId : 'leaf-createAlias',
			text : 'Create/Edit Alias'
42c574d9   Elena.Budnik   rm 5959; alias ex...
61
		}, */{
74b77f58   Elena.Budnik   init remote branch
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
			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;
	},
10200969   Roipoussiere   Remove whitespace...
79

74b77f58   Elena.Budnik   init remote branch
80
81
82
83
84
	onMenuItemClick : function(menu,item,event) {
		if (item) {
			switch (item.fnId) {
				case 'root-collapseAll':
				case 'dire-collapseAll':
ef223c56   NathanaĆ«l Jourdane   Fix Close All bug...
85
				case 'miss-collapseAll':
74b77f58   Elena.Budnik   init remote branch
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
						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;
			}
		}
	},
10200969   Roipoussiere   Remove whitespace...
117

74b77f58   Elena.Budnik   init remote branch
118
119
120
121
122
123
124
125
	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);
	},
10200969   Roipoussiere   Remove whitespace...
126

74b77f58   Elena.Budnik   init remote branch
127
128
	addData : function() {
		if (this.get('disable')) return;
10200969   Roipoussiere   Remove whitespace...
129

74b77f58   Elena.Budnik   init remote branch
130
131
132
133
		var me = this;
		myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) {
			module.createWindow(me.getBaseId());
		});
10200969   Roipoussiere   Remove whitespace...
134
135
	},

74b77f58   Elena.Budnik   init remote branch
136
137
138
	// Depth of Base Root Node = 3 : root, Parameters, Remote Parameters, BaseName
	getBaseId : function() {
		if (this.getDepth() < 3) return 'root';
10200969   Roipoussiere   Remove whitespace...
139

74b77f58   Elena.Budnik   init remote branch
140
141
142
143
144
		var node = this;
		while (node.getDepth() > 3) {
			node = node.parentNode;
		}
		return node.get('id');
16035364   Benjamin Renard   First commit
145
	}
16035364   Benjamin Renard   First commit
146
});