Blame view

js/app/controllers/ExplorerModule.js 7.94 KB
16035364   Benjamin Renard   First commit
1
/** 
f792a3de   elena   catalog ihm
2
 * Project  : AMDA-NG
16035364   Benjamin Renard   First commit
3
4
5
6
7
 * Name     : ExplorerModule.js
 * @class   amdaDesktop.ExplorerModule 
 * @extends amdaDesktop.AmdaModule
 * @brief   Explorer Module controller definition
 * @author  CDA
16035364   Benjamin Renard   First commit
8
9
 */

3ab0bee9   Elena.Budnik   aprams with args ...
10
11
12
Ext.define('amdaDesktop.ExplorerModule', 
{
	extend: 'amdaDesktop.AmdaModule',
16035364   Benjamin Renard   First commit
13
    
3ab0bee9   Elena.Budnik   aprams with args ...
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
	requires : [
		'amdaUI.ExplorerUI',
		'amdaUI.AliasUI',
		// Node Models
		'amdaModel.BkgJobNode',
		'amdaModel.DerivedParamNode',
		'amdaModel.LocalParamNode',
		'amdaModel.RemoteParamNode',
		'amdaModel.RemoteSimuParamNode',
		'amdaModel.AliasNode',
		'amdaModel.TimeTableNode',
		'amdaModel.CatalogNode',
		'amdaModel.StatisticsNode',	// singleton; not shown in the tree
		'amdaModel.sharedTimeTableNode',
		'amdaModel.sharedCatalogNode',
		'amdaModel.MyDataParamNode',
		'amdaModel.MyDataNode',
		'amdaModel.PlotNode',
		'amdaModel.DownloadNode',  // singleton; not shown in the tree
		'amdaModel.SearchNode',
		// Object Models
		'amdaModel.Parameter',
		'amdaModel.Search',        
		'amdaModel.Download',
		'amdaModel.TimeTable',
		'amdaModel.Catalog',	
		'amdaModel.Statistics',
		'amdaModel.FileObject',
		'amdaModel.FileParamObject',
		'amdaModel.FilterInfo'
	],
16035364   Benjamin Renard   First commit
45
    
3ab0bee9   Elena.Budnik   aprams with args ...
46
	contentId : 'explorerUI',
16035364   Benjamin Renard   First commit
47
   
3ab0bee9   Elena.Budnik   aprams with args ...
48
49
	filter : null,
	filtersStore : null,
16035364   Benjamin Renard   First commit
50
    
3ab0bee9   Elena.Budnik   aprams with args ...
51
	paramInfoRegistry : {},
0314bd32   Benjamin Renard   Keep a registry o...
52
    
3ab0bee9   Elena.Budnik   aprams with args ...
53
54
55
56
57
58
59
60
61
62
63
64
	constructor : function(config)
	{
		this.callParent(arguments);
		if (!this.filtersStore) 
		{
			this.filtersStore = Ext.create('Ext.data.Store', {
					model: 'amdaModel.FilterList' 
			});                 
			this.filtersStore.load(); 
			//  amdaDesktop.ExplorerModule.filtersStore = this.filtersStore;
		}                
	},
16035364   Benjamin Renard   First commit
65
        
3ab0bee9   Elena.Budnik   aprams with args ...
66
67
68
	createWindow : function() 
	{
		var desktop = this.app.getDesktop();
16035364   Benjamin Renard   First commit
69
        
3ab0bee9   Elena.Budnik   aprams with args ...
70
71
72
73
74
75
76
77
78
79
		var win = desktop.getWindow(this.id);
		if (!win) {            
			win = desktop.createWindow( {
				id : this.id,
				title : this.title,
				width : 340,
				height : 500,
				iconCls : this.icon,
				animCollapse : false,
				border : false,
16035364   Benjamin Renard   First commit
80
       //         constrainHeader : true,
3ab0bee9   Elena.Budnik   aprams with args ...
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
				closable: false,
				stateful : true,
				stateId  : this.id,
				stateEvents: ['move','show','resize'],
				constrain: true,
				layout   :
				{
					type : 'border',
					align : 'stretch'
				},
				x : 5,
				y : 5,
				items : [
					{
						xtype: 'panelExplorer',
						id : this.contentId,
						region: 'center'
					},
					{
						xtype: 'panel', 
						id : 'LogPanel',
						region: 'south',
						height : 150,
						split : true,
						layout: {
							type: 'vbox',
							align : 'stretch',
							autoSize : true
						}, 
						autoScroll : true,
						stateful : true,
						stateId  : 'LogPanel',
						buttons : [{
							scope: this,
							text : 'Clear',
							handler: function(){	
								win.items.get('LogPanel').removeAll();  
								this.addLogMessage('<b>Log</b>');
							}
						}]
					}
				]
			});
		}
16035364   Benjamin Renard   First commit
125
        
3ab0bee9   Elena.Budnik   aprams with args ...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
		win.on({
			activate: {
				fn : function() 
				{
					myDesktopApp.getLoadedModule(this.id, true, function (module) {
					// on activation when there's a pinedModule 'null'
						if (module.pinedModule===null) {
							// get the ZIndex manager
							var manager = myDesktopApp.desktop.getDesktopZIndexManager();
							// ordering to send back this window
							manager.sendToBack(win);
						} 
					});
				},
				scope: this
			} 
		});
16035364   Benjamin Renard   First commit
143
        
3ab0bee9   Elena.Budnik   aprams with args ...
144
145
146
147
148
149
150
151
152
153
154
155
156
157
		win.on({
			show : 
			{
				fn : function(o)
				{
					//set current filter
					this.setCrtFilter();    				
					//resize the explorer in relation with the desktop size
					if (win.y + win.height > myDesktopApp.desktop.el.getHeight())
							win.setHeight(myDesktopApp.desktop.el.getHeight() - win.y);
				},
				scope : this
			}
		});
16035364   Benjamin Renard   First commit
158
        
3ab0bee9   Elena.Budnik   aprams with args ...
159
160
161
162
163
		win.addCls('window-active');
		win.show();
		this.addLogMessage('<b>Log</b>');
		return win;        
	},
16035364   Benjamin Renard   First commit
164
    
3ab0bee9   Elena.Budnik   aprams with args ...
165
	pinedModule : null,
16035364   Benjamin Renard   First commit
166
    
3ab0bee9   Elena.Budnik   aprams with args ...
167
168
169
170
171
172
173
174
175
	/**
	* Getter of pinedModule
	* @return {amdaDesktop.InteractiveModule} The pined module
	*/
	getPinedModule : function() 
	{
		// get the pined Module
		return this.pinedModule;
	},
16035364   Benjamin Renard   First commit
176

3ab0bee9   Elena.Budnik   aprams with args ...
177
178
179
180
181
182
183
184
185
	/**
	* Setter of pinedModule
	* @param {amdaDesktop.InteractiveModule} The pined module
	*/
	setPinedModule : function(amdaModule) 
	{
		// set the pined Module
		this.pinedModule = amdaModule;
	},
16035364   Benjamin Renard   First commit
186
    
3ab0bee9   Elena.Budnik   aprams with args ...
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
	/**
	* Module Attachment Method
	* @param {amdaDesktop.InteractiveModule} The module to attach
	*/
	pinMechanism : function(amdaModule) 
	{
		// if there is an old pined module
		if (this.getPinedModule()!=null) {
			// get old pined module :
			var oldPinedModule = this.getPinedModule();
			// call uncolor method on the old pined Module
			myDesktopApp.getLoadedModule(oldPinedModule).uncolorHeaderModule();
		}
		// set pined module
		this.setPinedModule(amdaModule);
		// call color method on pined Module
		myDesktopApp.getLoadedModule(amdaModule).colorHeaderModule();
	},
16035364   Benjamin Renard   First commit
205
206
    
    
3ab0bee9   Elena.Budnik   aprams with args ...
207
208
209
210
211
212
213
214
215
216
217
218
219
	addLogMessage : function(message)
	{
		var height = 40;
		var msg = Ext.create('Ext.Component', {
			height: height,
			html: message,
			style: { color : '#555555'}
		});
		var desktop = myDesktopApp.getDesktop();
		var win = desktop.getWindow(this.id);
		var panel = win.items.get('LogPanel');
		panel.add(msg);
	},
16035364   Benjamin Renard   First commit
220
     
3ab0bee9   Elena.Budnik   aprams with args ...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
	//
	setCrtFilter : function()
	{
		var me = this;
		//get current filter to apply
		AmdaAction.getCrtFilterResult(function (result, e)
			{
				var t = e.getTransaction();
				if (e.status) 
				{	
					if (result)
					{
						//apply current filter
						this.filter = result;
						// add saved filter to Explorer List
						if (!this.filtersStore.getById(this.filter.id)) 
							this.filtersStore.add({id : this.filter.id, name : this.filter.name});
						
						//apply filter to the tree
						var desktop = myDesktopApp.getDesktop();
						var win = desktop.getWindow(this.id);
						if (win)
						{
							var explorerUI = win.query('#'+this.contentId);
							explorerUI[0].updateFilter();
						}
					}
					else
						Ext.Msg.show( {
								title : 'Filter', 
								msg : 'Cannot apply filter',
								modal : true,
								icon : Ext.Msg.ERROR,
								buttons : Ext.Msg.OK
						});
				}
				else
				{
					// FAILURE
					Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
				} 
			},this);
	},
16035364   Benjamin Renard   First commit
264
     
3ab0bee9   Elena.Budnik   aprams with args ...
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
	resetFilter : function()
	{
		AmdaAction.resetFilter( function (result, e)
			{
				var t = e.getTransaction();
				if (e.status) 
				{	
					if (result)
					{
						this.setCrtFilter();						
						//update filter win
						var desktop = myDesktopApp.getDesktop();
						var win = desktop.getWindow(myDesktopApp.dynamicModules.filters.id);
						if (win)
						{
							var filterUI = win.query('panelFilters');
							filterUI[0].reloadFilter();
						}
					}
					else
						Ext.Msg.show( {
									title : 'Filter', 
									msg : 'Cannot reset filter',
									modal : true,
									icon : Ext.Msg.ERROR,
									buttons : Ext.Msg.OK
						});
				}
				else
				{
					// FAILURE
					Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
				} 
			},this);
	},
0314bd32   Benjamin Renard   Keep a registry o...
300
     
3ab0bee9   Elena.Budnik   aprams with args ...
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
	getParamInfo : function(paramId, onReady) 
	{
		if (this.paramInfoRegistry[paramId]) 
		{
			if (onReady)
				onReady(this.paramInfoRegistry[paramId]);
			return this.paramInfoRegistry[paramId];
		}
			
		var me = this;
		AmdaAction.getParamInfo({"paramId" : paramId}, function (result, e) 
		{
			var paramInfo = null;
			if (e.status === true)
			{
				if (!result.success)
				{
				//No available info for this parameter. Do not display an error message
					/*if (result.message && result.message != '')
						Ext.Msg.show({title:'Get parameter arguments error ', msg: result.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
					else
						Ext.Msg.show({title:'Get parameter arguments error', msg: 'Unknown error', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});*/
				}
				else
				{
					//Store parameter info in registry
					me.paramInfoRegistry[paramId] = result;
					paramInfo = result;
				}
			}
			else
			{
				Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
			}
bb6e93d9   Benjamin Renard   Implement templat...
335

3ab0bee9   Elena.Budnik   aprams with args ...
336
337
338
339
340
341
342
			if (onReady)
				onReady(paramInfo); 
		});
		
		return null;
	}
	
16035364   Benjamin Renard   First commit
343
});