Blame view

js/app/models/LocalParamNode.js 6.6 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
/** 
 * Project  : AMDA-NG4
 * Name     : LocalParamNode.js
 * @class   amdaModel.LocalParamNode
 * @extends amdaModel.InteractiveNode
 * @brief   Basic Model of Node corresponding to a amda  parameter
 * @author  
 * @version $Id: LocalParamNode.js 2800 2015-02-27 16:23:06Z elena $  
 */

Ext.define('amdaModel.LocalParamNode', 
{
eec153c1   Elena.Budnik   formattage, netto...
13
14
15
16
17
18
	extend: 'amdaModel.InteractiveNode',

	statics:
	{
		nodeType: 'localParam'
	},
16035364   Benjamin Renard   First commit
19
    
eec153c1   Elena.Budnik   formattage, netto...
20
21
22
23
24
25
26
27
28
29
30
31
32
	fields: 
	[
		{name: 'alias', type:'string', persist: false},
		{name: 'isParameter', type: 'boolean', persist: false}, 
		{name: 'notyet', type: 'boolean', defaultValue: false, persist: false},
		{name: 'needsArgs', type: 'boolean', persist: false},
		{name: 'isSpectra', type: 'boolean', defaultValue: false, persist: false},
		{name: 'isStack', type: 'boolean', defaultValue: true, persist: false},
		{name: 'globalStart', type: 'string', persist: false},
		{name: 'globalStop', type: 'string', persist: false},
		{name: 'timeRestriction', type: 'boolean', persist: false},           
		{name: 'rank', type: 'integer', persist: false, defaultValue: null}
	],    
16035364   Benjamin Renard   First commit
33

eec153c1   Elena.Budnik   formattage, netto...
34
35
36
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
	constructor : function(config)
	{        
		this.callParent(arguments);

		this.set('allowDrop', true);
		this.set('moduleId',myDesktopApp.dynamicModules.param.id);
		this.set('objectDataModel',amdaModel.Parameter.$className);
			
		// if future missions or 'depending on mission'
		if (this.get('globalStart')) {          
		var now = Ext.Date.format(new Date(), 'Y/m/d');               
		if ( this.get('globalStart') > now )
			this.set('cls','predicted');
		}
		// time restriction on parameters
		if (this.get('timeRestriction')) { 
		//      this.set('cls','predicted');
			var id = this.get('id');
			var bracketPos =  id.indexOf("(");
			if (bracketPos > 0) {
				id = Ext.String.insert(id, '_restr', bracketPos);
			}
			else {
				id += '_restr'; 
			}
			this.set('id', id);
		}
	
		if (this.get('rank')) { 
			var rank = this.get('rank');
			if (rank == 1) this.set('iconCls', 'icon-mercury');
			if (rank == 2) this.set('iconCls', 'icon-venus');
			if (rank == 5) this.set('iconCls', 'icon-earth'); 
			if (rank == 6) this.set('iconCls', 'icon-earth');
			if (rank == 7) this.set('iconCls', 'icon-mars');
			if (rank == 8) this.set('iconCls', 'icon-jupiter');  
			if (rank == 9) this.set('iconCls', 'icon-saturn');
			if (rank == 93) this.set('iconCls', 'icon-comet');     
			if (rank == 3) this.set('iconCls', 'icon-sw');
			if (rank == 4) this.set('iconCls', 'icon-sw');
			if (rank >= 99) this.set('iconCls', 'icon-solarsystem');
		}
16035364   Benjamin Renard   First commit
76
                         
eec153c1   Elena.Budnik   formattage, netto...
77
78
79
80
81
82
83
84
85
86
87
		if (this.get('isParameter')) 
		{	
			if (this.get('leaf')) 
				this.set('iconCls', 'icon-scalar');	 
			else 
				this.set('iconCls', 'icon-vector');	
		
			if (this.get('isStack') || this.get('isSpectra')) 
				this.set('iconCls', 'icon-spectra');
		}
	},
16035364   Benjamin Renard   First commit
88

eec153c1   Elena.Budnik   formattage, netto...
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
	allMenuItems : function() 
	{
		var menuItems =
		[{
			fnId : 'root-collapseAll',
			text : 'Close All',
			hidden : true
		}, {
			fnId : 'dire-collapseAll',
			text : 'Close All',
			hidden : true
		}, {
			fnId : 'para-plotParam',
			text : 'Plot Parameter',
			hidden : true
		}, {
			fnId : 'para-downParam',
			text : 'Download Parameter',
			hidden : true
		},{
			fnId : 'leaf-createAlias',
			text : 'Create/Edit Alias',
			hidden : true 
		},{    
			fnId : 'leaf-createDerivedParam',
			text : 'Create Derived Parameter',
			hidden : true
		},{
			fnId : 'leaf-plotParam',
			text : 'Plot Parameter',
			hidden : true
		}, {
			fnId : 'leaf-downParam',
			text : 'Download Parameter',
			hidden : true
		}];
16035364   Benjamin Renard   First commit
125

eec153c1   Elena.Budnik   formattage, netto...
126
127
		return menuItems;
	},
d18b535d   elena   catalog draft + c...
128
   
eec153c1   Elena.Budnik   formattage, netto...
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
155
156
157
158
159
160
161
162
163
	onMenuItemClick : function(menu,item,event) 
	{
		switch (item.fnId) 
		{
			case 'root-collapseAll':
			case 'dire-collapseAll':
				if(this && !this.isLeaf()) {
					this.collapse(true);
				}
				break; 
			case 'leaf-plotParam':
			case 'para-plotParam':              
					this.createPlot(this);                
				break;
			case 'leaf-downParam':
			case 'para-downParam':                    
					this.createDownload(this);                
				break;
			case 'leaf-createDerivedParam':
				if (!this.get('notyet'))
					this.createLeaf(this); 
				else  
					myDesktopApp.warningMsg("Sorry! access to this parameter is restricted"); 
				break;
			case 'leaf-createAlias':	
				if (!this.get('notyet'))
					this.createAlias(this); 
				else
					myDesktopApp.warningMsg("Sorry! access to this parameter is restricted");
				
				break;
			default:
				break;
		}
	},
16035364   Benjamin Renard   First commit
164
      
eec153c1   Elena.Budnik   formattage, netto...
165
166
167
168
169
170
	createLeaf: function(node) 
	{                 
		// instanciate a Parameter object with the current data in his buidchain
		var param =  Ext.create(this.get('objectDataModel'));//, { buildchain: node.get('alias') ? "#"+node.get('alias') : node.get('id') });
		// instanciate a DerivedParamNode with this param object
		var newNode = Ext.create(amdaModel.DerivedParamNode.$className, {leaf : true, object : param}); 
16035364   Benjamin Renard   First commit
171

eec153c1   Elena.Budnik   formattage, netto...
172
173
174
175
176
177
178
179
180
181
		// edit newNode into Parameter Module with node as contextNode
		newNode.editInModule();
		
		var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id, true, function(module) {
			var paramName;
			var components = null;
			if (node.get('alias')!= "" )
				paramName = "#"+node.get('alias');
			else 
				paramName = node.get('id');
9fad5834   Elena.Budnik   redmine #4795
182
183
184
185
186
187
188
189
190
191
// 			var component_info = node.get('component_info');
// 			if (component_info && component_info.parentId) {
// 				//It's a component
// 				paramName = component_info.parentId;
// 				components = [];
// 				if (component_info.index1)
// 					components['index1'] = component_info.index1;
// 				if (component_info.index2)
// 					components['index2'] = component_info.index2;
// 			}
eec153c1   Elena.Budnik   formattage, netto...
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
			
			module.addParam(paramName,true,node.get('needsArgs'),components);   
		});		
	},

	createAlias: function(node) 
	{
		var win = myDesktopApp.desktop.getWindow('alias-win');     
		if (!node.get('needsArgs') && node.get('leaf'))
		{
			if(!win)
			{
				var win = myDesktopApp.desktop.createWindow(
				{
					border: false,
					id : 'alias-win',
					title : 'Create Alias',
					width : 400,
					height : 200,
					layout : 'border',
					maximizable : false,
					items : 
					[{
						xtype : 'alias',
						region : 'center',
						margins : 
						{
							top: 0,
							right: 5,
							bottom: 5,
							left: 5
						}, 
						paramNode : node,
						id : 'aliasUI'
					}]
				});	
			}
			else 
			{
				//Set data into Alias Widget
				win.items.items[0].paramNode = node;
				win.items.items[0].setAlias(node);	   
			}     
			win.show();	 
		}
		else 
		{
			var message = 'Sorry, parameter ' + node.get('id') + ' cannot have alias';
			Ext.Msg.alert('Impossible Create Alias', message); 
			if (win) win.close();
		}
	},
16035364   Benjamin Renard   First commit
244
    
eec153c1   Elena.Budnik   formattage, netto...
245
246
247
248
	isParameter : function()
	{
		return this.get('isParameter');
	}      
16035364   Benjamin Renard   First commit
249
});