Blame view

js/app/models/RemoteSimuParamNode.js 4.75 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
	requires: 'amdaUI.InteropImpexUI',
						
	fields: [
			{name: 'isRemoteDataSet', type:'boolean', persist: false, defaultValue: true},
			{name: 'isSimulation', type:'boolean', defaultValue: true}, 
			{name: 'isAddable', type:'boolean', defaultValue: false},
218521cf   Elena.Budnik   remote herite fro...
25
			{name: 'isDeletable', type:'boolean', defaultValue: false}
9fad5834   Elena.Budnik   redmine #4795
26
			],
16035364   Benjamin Renard   First commit
27
	   
9fad5834   Elena.Budnik   redmine #4795
28
29
30
31
32
33
34
35
36
37
38
39
40
	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
41
        
9fad5834   Elena.Budnik   redmine #4795
42
43
		if (this.get('rank')) { 
			var rank = this.get('rank');
218521cf   Elena.Budnik   remote herite fro...
44
			this.set('iconCls', this.icons[rank]); 
9fad5834   Elena.Budnik   redmine #4795
45
46
		}
	},
16035364   Benjamin Renard   First commit
47
    
3a5f60a1   elena   proper use os sta...
48
       
3e80c968   Elena.Budnik   plt, download in ...
49
50
51
52
53
54
55
56
	allMenuItems : function() 
	{
		var menuItems =
		[ {
				fnId : 'root-collapseAll',
				text : 'Close All'
			}, 
			{
869a3e0d   Elena.Budnik   bug appeared when...
57
58
59
60
				fnId : 'miss-collapseAll',
				text : 'Close All'
			},
			{
3e80c968   Elena.Budnik   plt, download in ...
61
62
63
				fnId : 'dire-collapseAll',
				text : 'Close All'
			},
42c574d9   Elena.Budnik   rm 5959; alias ex...
64
65
66
67
// 			{
// 				fnId : 'leaf-createAlias',
// 				text : 'Create/Edit Alias'
// 			}, 
3e80c968   Elena.Budnik   plt, download in ...
68
69
70
71
72
73
74
75
76
77
78
79
80
			{    
				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
81
82
83
84
85
86
87
88
89
			}, {
            fnId : 'para-plotParam',
            text : 'Plot Parameter',
            hidden : true
        }, {
            fnId : 'para-downParam',
            text : 'Download Parameter',
            hidden : true
        }
3e80c968   Elena.Budnik   plt, download in ...
90
91
92
93
		];
		
		return menuItems;
	},
16035364   Benjamin Renard   First commit
94
     
3e80c968   Elena.Budnik   plt, download in ...
95
96
	getAllContextMenuItems: function()
	{
869a3e0d   Elena.Budnik   bug appeared when...
97
98
		if (this.get('isAddable')) { 
			if (this.getNodeKind() == amdaUI.ExplorerUI.ITEM_KIND_MISS )
3e80c968   Elena.Budnik   plt, download in ...
99
						return  Ext.Array.push(this.allMenuItems(),
869a3e0d   Elena.Budnik   bug appeared when...
100
															{ fnId : 'miss-addData',
3e80c968   Elena.Budnik   plt, download in ...
101
																text : 'Add Run'});
869a3e0d   Elena.Budnik   bug appeared when...
102
103
104
105
106
107
						
			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 ...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
		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':
ef223c56   NathanaĆ«l Jourdane   Fix Close All bug...
124
				case 'miss-collapseAll':
3e80c968   Elena.Budnik   plt, download in ...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
					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...
139
				case  'miss-addData':	
3e80c968   Elena.Budnik   plt, download in ...
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
				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
156
    
3e80c968   Elena.Budnik   plt, download in ...
157
158
159
160
161
162
163
164
165
	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
166
    
3e80c968   Elena.Budnik   plt, download in ...
167
168
169
170
171
172
173
174
175
176
177
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
	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
211
});