Blame view

js/app/models/RemoteSimuParamNode.js 5.33 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
/** 
 * Project  : AMDA-NG4
 * Name     : RemoteSumuParamNode.js
 * @class   amdaModel.RemotSimuParamNode
 * @extends amdaModel.LocalParamNode
 * @brief    
 * @author  elena
 * @version $Id: RemoteSimuParamNode.js 2620 2014-11-05 09:00:34Z elena $
 */

Ext.define('amdaModel.RemoteSimuParamNode', {

9fad5834   Elena.Budnik   redmine #4795
13
	extend: 'amdaModel.LocalParamNode',
16035364   Benjamin Renard   First commit
14
    
9fad5834   Elena.Budnik   redmine #4795
15
16
17
	statics:{
		nodeType: 'remoteSimuParam'
	},
3a5f60a1   elena   proper use os sta...
18
        
9fad5834   Elena.Budnik   redmine #4795
19
20
21
22
23
24
25
26
27
	requires: 'amdaUI.InteropImpexUI',
						
	fields: [
			{name: 'isRemoteDataSet', type:'boolean', persist: false, defaultValue: true},
			{name: 'isSimulation', type:'boolean', defaultValue: true}, 
			{name: 'isAddable', type:'boolean', defaultValue: false},
			{name: 'isDeletable', type:'boolean', defaultValue: false},
			{name: 'rank', type: 'integer', persist: false, defaultValue: null}
			],
16035364   Benjamin Renard   First commit
28
	   
9fad5834   Elena.Budnik   redmine #4795
29
30
31
32
33
34
35
36
37
38
39
40
41
	constructor : function(config)
	{	   
		this.callParent(arguments); 
		
		if (this.get('isParameter')) 
			this.set('needsArgs',this.get('needsArgs'));
		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
42
        
9fad5834   Elena.Budnik   redmine #4795
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
		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
59
    
3a5f60a1   elena   proper use os sta...
60
       
3e80c968   Elena.Budnik   plt, download in ...
61
62
63
64
65
66
67
68
	allMenuItems : function() 
	{
		var menuItems =
		[ {
				fnId : 'root-collapseAll',
				text : 'Close All'
			}, 
			{
869a3e0d   Elena.Budnik   bug appeared when...
69
70
71
72
				fnId : 'miss-collapseAll',
				text : 'Close All'
			},
			{
3e80c968   Elena.Budnik   plt, download in ...
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
				fnId : 'dire-collapseAll',
				text : 'Close All'
			},
			{
				fnId : 'leaf-createAlias',
				text : 'Create/Edit Alias'
			}, 
			{    
				fnId : 'leaf-createDerivedParam',
				text : 'Create Derived Parameter'
			},
			{
				fnId : 'leaf-plotParam',
				text : 'Plot Parameter',
				hidden : true
			}, 
			{
				fnId : 'leaf-downParam',
				text : 'Download Parameter',
				hidden : true
bf74fc2d   Elena.Budnik   IMPEX
93
94
95
96
97
98
99
100
101
			}, {
            fnId : 'para-plotParam',
            text : 'Plot Parameter',
            hidden : true
        }, {
            fnId : 'para-downParam',
            text : 'Download Parameter',
            hidden : true
        }
3e80c968   Elena.Budnik   plt, download in ...
102
103
104
105
		];
		
		return menuItems;
	},
16035364   Benjamin Renard   First commit
106
     
3e80c968   Elena.Budnik   plt, download in ...
107
108
	getAllContextMenuItems: function()
	{
869a3e0d   Elena.Budnik   bug appeared when...
109
110
		if (this.get('isAddable')) { 
			if (this.getNodeKind() == amdaUI.ExplorerUI.ITEM_KIND_MISS )
3e80c968   Elena.Budnik   plt, download in ...
111
						return  Ext.Array.push(this.allMenuItems(),
869a3e0d   Elena.Budnik   bug appeared when...
112
															{ fnId : 'miss-addData',
3e80c968   Elena.Budnik   plt, download in ...
113
																text : 'Add Run'});
869a3e0d   Elena.Budnik   bug appeared when...
114
115
116
117
118
119
						
			else if (this.getNodeKind() == amdaUI.ExplorerUI.ITEM_KIND_DIRE )
						return  Ext.Array.push(this.allMenuItems(),
															{ fnId : 'dire-addData',
																text : 'Add Run'});		
		}
3e80c968   Elena.Budnik   plt, download in ...
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
		else if (this.get('isDeletable'))                                  
						return  Ext.Array.push(this.allMenuItems(),
															{ fnId : 'dire-deleteNode',
																text : 'Delete Run'});
															
		return this.allMenuItems();			
	},   
	
	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 'dire-deleteNode' :
				this.deleteData();
					break;
				case  'dire-addData':
869a3e0d   Elena.Budnik   bug appeared when...
150
				case  'miss-addData':	
3e80c968   Elena.Budnik   plt, download in ...
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
				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;
			}
		}
	},
16035364   Benjamin Renard   First commit
167
    
3e80c968   Elena.Budnik   plt, download in ...
168
169
170
171
172
173
174
175
176
	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);		
	},
16035364   Benjamin Renard   First commit
177
    
3e80c968   Elena.Budnik   plt, download in ...
178
179
180
181
182
183
184
185
186
187
188
189
190
191
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
	addData : function() 
	{		
		if (this.get('disable')) return;		
		var win = myDesktopApp.desktop.getWindow('impex-win'); 
		
		if(!win)
		{
			var win = myDesktopApp.desktop.createWindow(
			{
				border: false,
				id : 'impex-win',
				title : 'Find the most relevant run(s)',
				width : 600,
				height : 600,
				layout : 'border',
				//autoScroll: true,
				overflowY: 'scroll',
				maximizable : false,
				items : 
				[{
					xtype : 'interop_impex',
					region : 'center',
					margins : 
					{
							top: 0,
							right: 5,
							bottom: 5,
							left: 5                            
					}  
				}],
				listeners: {
					scope : this,
					show : function( ) {              
							win.items.getAt(0).setLinkedNode(this);                              
					}
				}
			});     
		}
		else 
		{

		}     
		win.show();              
	}        
16035364   Benjamin Renard   First commit
222
});