Blame view

js/app/controllers/ExplorerModule.js 12.8 KB
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
1
/**
f792a3de   elena   catalog ihm
2
 * Project  : AMDA-NG
16035364   Benjamin Renard   First commit
3
 * Name     : ExplorerModule.js
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
4
 * @class   amdaDesktop.ExplorerModule
16035364   Benjamin Renard   First commit
5
6
7
 * @extends amdaDesktop.AmdaModule
 * @brief   Explorer Module controller definition
 * @author  CDA
16035364   Benjamin Renard   First commit
8
9
10
11
12
 */

Ext.define('amdaDesktop.ExplorerModule', {

    extend: 'amdaDesktop.AmdaModule',
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
13

16035364   Benjamin Renard   First commit
14
15
16
17
18
19
20
21
22
23
24
    requires : [
        'amdaUI.ExplorerUI',
        'amdaUI.AliasUI',
        // Node Models
        'amdaModel.BkgJobNode',
        'amdaModel.DerivedParamNode',
        'amdaModel.LocalParamNode',
        'amdaModel.RemoteParamNode',
        'amdaModel.RemoteSimuParamNode',
        'amdaModel.AliasNode',
        'amdaModel.TimeTableNode',
f792a3de   elena   catalog ihm
25
	'amdaModel.CatalogNode',
d18b535d   elena   catalog draft + c...
26
	'amdaModel.StatisticsNode',	// singleton; not shown in the tree
16035364   Benjamin Renard   First commit
27
        'amdaModel.sharedTimeTableNode',
169f14d2   Benjamin Renard   Add shared object...
28
        'amdaModel.sharedCatalogNode',
16035364   Benjamin Renard   First commit
29
30
31
32
33
34
35
36
        'amdaModel.MyDataParamNode',
        'amdaModel.MyDataNode',
        'amdaModel.PlotNode',
        'amdaModel.DownloadNode',       // singleton; not shown in the tree
        'amdaModel.SearchNode',
        // Object Models
        'amdaModel.Parameter',
        'amdaModel.Search',
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
37

16035364   Benjamin Renard   First commit
38
39
        'amdaModel.Download',
        'amdaModel.TimeTable',
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
40
	'amdaModel.Catalog',
d18b535d   elena   catalog draft + c...
41
	'amdaModel.Statistics',
16035364   Benjamin Renard   First commit
42
43
44
45
        'amdaModel.FileObject',
        'amdaModel.FileParamObject',
        'amdaModel.FilterInfo'
    ],
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
46

16035364   Benjamin Renard   First commit
47
    contentId : 'explorerUI',
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
48

16035364   Benjamin Renard   First commit
49
50
    filter : null,
    filtersStore : null,
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
51

0314bd32   Benjamin Renard   Keep a registry o...
52
    paramInfoRegistry : {},
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
53

16035364   Benjamin Renard   First commit
54
55
56
57
    constructor : function(config){
                this.callParent(arguments);
                if (!this.filtersStore) {
                  this.filtersStore = Ext.create('Ext.data.Store', {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
58
59
60
                        model: 'amdaModel.FilterList'
                });
               this.filtersStore.load();
16035364   Benjamin Renard   First commit
61
             //  amdaDesktop.ExplorerModule.filtersStore = this.filtersStore;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
62
            }
16035364   Benjamin Renard   First commit
63
        },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
64

16035364   Benjamin Renard   First commit
65
66
    createWindow : function() {
        var desktop = this.app.getDesktop();
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
67

16035364   Benjamin Renard   First commit
68
        var win = desktop.getWindow(this.id);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
69
        if (!win) {
16035364   Benjamin Renard   First commit
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    	win = desktop.createWindow( {
                id : this.id,
                title : this.title,
                width : 340,
                height : 500,
                iconCls : this.icon,
                animCollapse : false,
                border : false,
       //         constrainHeader : true,
                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'
                    },
                    {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
98
                        xtype: 'panel',
16035364   Benjamin Renard   First commit
99
100
101
102
103
104
105
106
                        id : 'LogPanel',
                        region: 'south',
                        height : 150,
                        split : true,
                        layout: {
                                type: 'vbox',
                                align : 'stretch',
                                autoSize : true
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
107
                        },
16035364   Benjamin Renard   First commit
108
109
110
111
112
113
                        autoScroll : true,
                        stateful : true,
                        stateId  : 'LogPanel',
                        buttons : [{
                                scope: this,
                                text : 'Clear',
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
114
115
                                handler: function(){
                                        win.items.get('LogPanel').removeAll();
16035364   Benjamin Renard   First commit
116
117
118
119
120
121
                                        this.addLogMessage('<b>Log</b>');
                                }
                        }]
                    }
                ]
            });
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
122
123


16035364   Benjamin Renard   First commit
124
        }
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
125

16035364   Benjamin Renard   First commit
126
127
        win.on({
                activate: {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
128
                        fn : function()
16035364   Benjamin Renard   First commit
129
130
131
132
133
134
135
136
                        {
                                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);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
137
                                    }
16035364   Benjamin Renard   First commit
138
                                });
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
139

16035364   Benjamin Renard   First commit
140
141
                        },
                        scope: this
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
142
                }
16035364   Benjamin Renard   First commit
143
        });
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
144

16035364   Benjamin Renard   First commit
145
        win.on({
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
146
                show :
16035364   Benjamin Renard   First commit
147
148
149
150
                {
                        fn : function(o)
                        {
                                //set current filter
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
151
                                this.setCrtFilter();
16035364   Benjamin Renard   First commit
152
153
154
155
156
157
158
                                //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
                }
        });
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
159

16035364   Benjamin Renard   First commit
160
161
162
163
        win.addCls('window-active');
        win.show();
        this.addLogMessage('<b>Log</b>');
        return win;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
164

16035364   Benjamin Renard   First commit
165
    },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
166

16035364   Benjamin Renard   First commit
167
    pinedModule : null,
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
168

16035364   Benjamin Renard   First commit
169
170
171
172
    /**
     * Getter of pinedModule
     * @return {amdaDesktop.InteractiveModule} The pined module
     */
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
173
    getPinedModule : function()
16035364   Benjamin Renard   First commit
174
175
176
177
178
179
180
181
182
    {
        // get the pined Module
        return this.pinedModule;
    },

    /**
     * Setter of pinedModule
     * @param {amdaDesktop.InteractiveModule} The pined module
     */
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
183
    setPinedModule : function(amdaModule)
16035364   Benjamin Renard   First commit
184
185
186
187
    {
        // set the pined Module
        this.pinedModule = amdaModule;
    },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
188

16035364   Benjamin Renard   First commit
189
190
191
192
    /**
     * Module Attachment Method
     * @param {amdaDesktop.InteractiveModule} The module to attach
     */
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
193
    pinMechanism : function(amdaModule)
16035364   Benjamin Renard   First commit
194
195
196
197
198
199
200
201
202
203
204
205
206
    {
        // 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();
    },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
207
208


16035364   Benjamin Renard   First commit
209
210
211
212
213
214
215
216
217
218
219
220
221
    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);
    },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
222

16035364   Benjamin Renard   First commit
223
224
225
226
227
228
229
230
     //
     setCrtFilter : function()
     {
            var me = this;
                //get current filter to apply
                AmdaAction.getCrtFilterResult(function (result, e)
                                {
                                    var t = e.getTransaction();
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
231
232
                                    if (e.status)
                                    {
16035364   Benjamin Renard   First commit
233
234
235
236
                                            if (result)
                                            {
                                                    //apply current filter
                                                    this.filter = result;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
237

16035364   Benjamin Renard   First commit
238
                                                    // add saved filter to Explorer List
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
239
                                                    if (!this.filtersStore.getById(this.filter.id))
16035364   Benjamin Renard   First commit
240
                                                        this.filtersStore.add({id : this.filter.id, name : this.filter.name});
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
241

16035364   Benjamin Renard   First commit
242
243
244
245
246
247
248
249
250
251
252
                                                    //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( {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
253
                                                            title : 'Filter',
16035364   Benjamin Renard   First commit
254
255
256
257
258
259
260
261
262
263
                                                            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});
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
264
                                    }
16035364   Benjamin Renard   First commit
265
266
                            },this);
     },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
267

16035364   Benjamin Renard   First commit
268
269
        resetFilter : function()
        {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
270
            AmdaAction.resetFilter(
16035364   Benjamin Renard   First commit
271
272
273
                                function (result, e)
                                {
                                        var t = e.getTransaction();
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
274
275
                                        if (e.status)
                                        {
16035364   Benjamin Renard   First commit
276
277
278
                                                if (result)
                                                {
                                                        this.setCrtFilter();
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
279

16035364   Benjamin Renard   First commit
280
281
282
283
284
285
286
287
288
289
290
                                                        //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( {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
291
                                                                title : 'Filter',
16035364   Benjamin Renard   First commit
292
293
294
295
296
297
298
299
300
301
                                                                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});
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
302
                                        }
16035364   Benjamin Renard   First commit
303
                        },this);
0314bd32   Benjamin Renard   Keep a registry o...
304
     },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
305

bb6e93d9   Benjamin Renard   Implement templat...
306
307
308
309
310
311
     getParamInfo : function(paramId, onReady) {
    	 if (this.paramInfoRegistry[paramId]) {
    		 if (onReady)
    			 onReady(this.paramInfoRegistry[paramId]);
    		 return this.paramInfoRegistry[paramId];
    	 }
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
312

bb6e93d9   Benjamin Renard   Implement templat...
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
    	 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});
    		 }

			 if (onReady)
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
339
				 onReady(paramInfo);
bb6e93d9   Benjamin Renard   Implement templat...
340
341
    	 });
    	 return null;
16035364   Benjamin Renard   First commit
342
343
     }
});