Blame view

js/app/views/ExplorerUI.js 41.4 KB
16035364   Benjamin Renard   First commit
1
2
3
4
Ext.Ms/**
 * Project      : AMDA-NG4
 * Name         : ExplorerUI.js
 * Description  : Explorer Module UI definition (View)
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
5
6
 * @class   amdaUI.ExplorerUI
 * @extends Ext.tab.Panel
16035364   Benjamin Renard   First commit
7
8
 * @brief   Explorer View
 * @author  CDA
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
9
 * @version $Id: ExplorerUI.js 2544 2014-10-03 10:21:56Z elena $
16035364   Benjamin Renard   First commit
10
11
12
13
14
15
 */


Ext.define('amdaUI.TreeToolColumn', {
    extend: 'Ext.tree.Column',
    alias: 'widget.treetoolcolumn',
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
16

16035364   Benjamin Renard   First commit
17
18
19
20
21
22
    /**
     * Add more tools here.  These will be on the prototype for all TreeToolColumns
     */
    tools: {
        'info': 'js/resources/images/16x16/info_mini.png'
    },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
23
24

    initComponent: function()
16035364   Benjamin Renard   First commit
25
26
27
28
29
30
    {
        var me = this;
        me.addEvents( 'toolclick' );
        me.callParent();
        me.on('toolclick', me.toolHandler, me);
    },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
31

16035364   Benjamin Renard   First commit
32
33
34
    renderer: function(value, metaData, record, rowIdx, colIdx, store, view)
    {
        var toolCol = view.getHeaderAtIndex(colIdx);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
35

16035364   Benjamin Renard   First commit
36
37
        if (!toolCol.toolIsVisible(record))
                return value;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
38

16035364   Benjamin Renard   First commit
39
40
41
42
43
44
45
46
47
        var toolId  = 'tool-' + rowIdx + '-' + colIdx,
            toolImg = toolCol.tools[toolCol.tool],
            imgHtml = Ext.DomHelper.markup({
                id      : toolId,
                tag     : 'img',
                tooltype: toolCol.tool,
                src     : toolImg,
                style   : 'cursor:hand;'
            });
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
48

16035364   Benjamin Renard   First commit
49
50
        return value + ' ' + imgHtml;
    },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
51
52

    processEvent: function(type, view, cell, recordIndex, cellIndex, e)
16035364   Benjamin Renard   First commit
53
    {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
54
        if(type === "click" && e.target.tagName === "IMG")
16035364   Benjamin Renard   First commit
55
56
57
58
59
60
61
        {
                var tooltype = e.target.getAttribute("tooltype");
            if(tooltype)
                return this.fireEvent("toolclick", view, cell, recordIndex, cellIndex, e);
        }
        return this.fireEvent.apply(this, arguments);
    },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
62

16035364   Benjamin Renard   First commit
63
64
65
66
67
68
    /**
     * Override this when you add columns to the tree... see example below
     */
//    toolHandler: function() {
//        alert("override this");
//    },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
69

16035364   Benjamin Renard   First commit
70
71
72
73
74
75
76
77
78
79
80
    toolIsVisible : function(record) {
    	return false;
    }
});


Ext.define('amdaUI.ExplorerUI', {

    extend: 'Ext.tab.Panel',
    alias : 'widget.panelExplorer',

a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
81
82
    statics:
    {
16035364   Benjamin Renard   First commit
83
84
85
86
87
88
89
90
91
92
93
94
        RESRC_TAB : {
            TREE_ID:'resourcesTree',
            TREE_TYPE:'resources'
        },
        OPE_TAB : {
            TREE_ID:'operationsTree',
            TREE_TYPE:'operations'
        },
        JOB_TAB : {
            TREE_ID:'jobsTree',
            TREE_TYPE:'jobs'
        },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
95

16035364   Benjamin Renard   First commit
96
97
98
99
100
101
102
103
104
105
106
        CAT_SUFFIX: '-treeBase',
        ROOT_SUFFIX: '-treeRootNode',
        SUB_ROOT_SUFFIX : 'RootNode',

        ITEM_KIND_ROOT : 'root',
        ITEM_KIND_LEAF : 'leaf',
        ITEM_KIND_DIRE : 'dire',
        ITEM_KIND_PARA : 'para',
    },

    initComponent : function (config) {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
107

16035364   Benjamin Renard   First commit
108
        var explorerModule =  myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
109

16035364   Benjamin Renard   First commit
110
111
112
113
114
115
116
117
118
119
        var myConf = {
            split	: true,
            width	: '100%',
            height      : '100%',
            autoScroll  : true,
            border      : true,
            header	: false,
            defaults	: {
                // applied to each contained panel
                containerScroll	: true
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
120
            },
16035364   Benjamin Renard   First commit
121
122
123
124
125
126
127
128
129
130
131
132
133
            stateful: true,
       //     stateId: 'tp1',
            stateEvents: ['tabchange'],
            getState: function() {
            return {
                activeTab: this.items.findIndex('id',this.getActiveTab().id)
            };
            },
            applyState: function(s) {
                this.setActiveTab(s.activeTab);
            },
       //     activeTab: 0,
            items: [
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
134
                this.initTree(amdaUI.ExplorerUI.RESRC_TAB.TREE_TYPE),
16035364   Benjamin Renard   First commit
135
                this.initTree(amdaUI.ExplorerUI.OPE_TAB.TREE_TYPE),
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
136
                this.initTree(amdaUI.ExplorerUI.JOB_TAB.TREE_TYPE)
16035364   Benjamin Renard   First commit
137
            ],
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
138
139
140
            tbar : [
                {
                    xtype : 'combo',
16035364   Benjamin Renard   First commit
141
142
143
144
145
146
147
148
149
                    fieldLabel: 'Filter',
                    labelWidth: 25,
                    width: 140,
                    store: explorerModule.filtersStore,
                    queryMode: 'local',
                    displayField: 'name',
                    valueField: 'id',
                    listeners : {
                        scope : this,
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
150
151
                        select: function(combo, records) {
                                AmdaAction.setCrtFilterId({id : records[0].get('id')},
16035364   Benjamin Renard   First commit
152
153
154
                                    function (result, e)
                                    {
                                            var t = e.getTransaction();
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
155
156
                                            if (e.status)
                                            {
16035364   Benjamin Renard   First commit
157
158
159
160
161
162
163
164
                                                    if (result)
                                                    {
                                                        var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id);
                                                        if (explorerModule)
                                                                    explorerModule.setCrtFilter();
                                                    }
                                                    else
                                                            Ext.Msg.show( {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
165
                                                                    title : 'Filter',
16035364   Benjamin Renard   First commit
166
167
168
169
170
171
172
173
174
175
                                                                    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...
176
177
178
179
                                            }
                                },this);
                            }
                        }
16035364   Benjamin Renard   First commit
180
181
182
183
184
185
186
187
188
189
                },
                {
                    text: '',
                    iconCls : 'icon-parameters',
                    tooltip: { text: 'Edit Filter', align: 'bl-tl' },
                    handler: function(t){
                    	myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.filters.id, true, function (module) {
                    		module.createWindow();
                    	});
                    }
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
190
                },
16035364   Benjamin Renard   First commit
191
192
193
194
195
196
197
198
199
200
201
202
                {
                    text: '',
                    iconCls : 'icon-remover',
                    tooltip: { text: 'Reset Filter', align: 'bl-tl' },
                    handler: function(t){
                            var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id);
                            explorerModule.resetFilter();
                    }
                }, '-',
                {
                    xtype: 'displayfield',
                    fieldLabel: 'SortBy',
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
203
                    width: 40
16035364   Benjamin Renard   First commit
204
205
                },
                {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
206
207
                    text: 'Name',
                    scope : this,
16035364   Benjamin Renard   First commit
208
209
                    tooltip: { text: 'Sort out Local Data by Mission name', align: 'bl-tl' },
                    pressed: true,
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
210
                    enableToggle : true,
16035364   Benjamin Renard   First commit
211
212
213
214
                    toggleGroup: 'sorting',
                    handler: function(){
                        var tree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
                        tree.getStore().sort([
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
215
                            {  sorterFn: function(o1, o2){
16035364   Benjamin Renard   First commit
216
                                if (o1.get('nodeType') !== 'localParam')
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
217
218
                                    return;

16035364   Benjamin Renard   First commit
219
                                return o1.get('text').toUpperCase()  < o2.get('text').toUpperCase() ? -1 : 1;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
220
221
                        } }  ]);
                        this.updateFilter();
16035364   Benjamin Renard   First commit
222
223
224
                    }
                },
                {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
225
226
227
228
                    text: 'Target',
                    scope : this,
                    tooltip: { text: 'Sort Out Local Data by Mission main target', align: 'bl-tl' },
                    enableToggle : true,
16035364   Benjamin Renard   First commit
229
                    toggleGroup: 'sorting',
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
230
                    handler: function(){
16035364   Benjamin Renard   First commit
231
                          var tree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
232
                          tree.getStore().sort([{ property : 'rank' }]);
16035364   Benjamin Renard   First commit
233
                          this.updateFilter();
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
234
235
                    }
                }
16035364   Benjamin Renard   First commit
236
237
238
239
240
241
242
            ]
        };
        Ext.apply (this , Ext.apply (arguments, myConf));
        this.callParent(arguments);
    },

    initTree : function(treeType){
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
243
244
245

        switch (treeType) {
            case amdaUI.ExplorerUI.RESRC_TAB.TREE_TYPE:
16035364   Benjamin Renard   First commit
246
247
                treeId = amdaUI.ExplorerUI.RESRC_TAB.TREE_ID;
                break;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
248
            case amdaUI.ExplorerUI.OPE_TAB.TREE_TYPE:
16035364   Benjamin Renard   First commit
249
250
                treeId = amdaUI.ExplorerUI.OPE_TAB.TREE_ID;
                break;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
251
            case amdaUI.ExplorerUI.JOB_TAB.TREE_TYPE:
16035364   Benjamin Renard   First commit
252
253
                treeId = amdaUI.ExplorerUI.JOB_TAB.TREE_ID;
                break;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
254
            default:
16035364   Benjamin Renard   First commit
255
256
                treeId = amdaUI.ExplorerUI.RESRC_TAB.TREE_ID;
                break;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
257
        }
16035364   Benjamin Renard   First commit
258
259
260
261

        var store = Ext.create('Ext.data.TreeStore', {
            root: {
                expanded: true,
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
262
                nodeType : treeType
16035364   Benjamin Renard   First commit
263
264
             },
            model: 'amdaModel.AmdaNode',
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
265
266
            sorters:[{ property:'leaf', direction: 'DES' },
                    {  sorterFn: function(o1, o2){
16035364   Benjamin Renard   First commit
267
                        if (o1.get('nodeType') !== 'localParam')
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
268
269
                            return;

16035364   Benjamin Renard   First commit
270
271
272
273
274
                        return o1.get('text').toUpperCase()  < o2.get('text').toUpperCase() ? -1 : 1;
                    } }],
             listeners: {
                 beforeload: function(store, operation){
                     store.proxy.extraParams = {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
275
                         nodeType: operation.node.get('nodeType')
16035364   Benjamin Renard   First commit
276
277
278
279
280
281
282
283
                     };
                 }
             }

        });

        var menu = new Ext.menu.Menu();

a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
284
        var tree = Ext.create('Ext.tree.Panel', {
16035364   Benjamin Renard   First commit
285
286
287
288
289
290
291
292
293
294
295
296
            id : treeId,
            title: treeType,
            store: store,
            rootVisible: false,
            animate: false,
            hideHeaders : true,
            //TODO deprecated
            //multiSelect: true,
            selModel: Ext.create('Ext.selection.TreeModel', {
            	ignoreRightMouseSelection: true,
            	mode: 'MULTI'
            }),
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
297
298

            viewConfig:
16035364   Benjamin Renard   First commit
299
            {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
300
301
                plugins:
                {
16035364   Benjamin Renard   First commit
302
303
304
305
306
307
                    ptype: 'treeviewdragdrop',
                    enableDrag:true,
                    enableDrop:true,
                    //TODO - BRE - Wait a fix for drag&drop issue
                    ddGroup:'explorerTree',
                    pluginId : 'ddplugin',
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
308
309
                    isValidDropPoint : function (node, position, dragZone, e, data)
                    {
16035364   Benjamin Renard   First commit
310
311
312
                        if (!node || !data.item) {
                                return false;
                        }
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
313

16035364   Benjamin Renard   First commit
314
315
316
317
318
319
                        var view = this.view,
                        targetNode = view.getRecord(node),
                        draggedRecords = data.records,
                        dataLength = draggedRecords.length,
                        ln = draggedRecords.length,
                        i, record;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
320

16035364   Benjamin Renard   First commit
321
322
323
324
                        // No drop position, or dragged records: invalid drop point
                        if (!(targetNode && position && dataLength)) {
                            return false;
                        }
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
325

16035364   Benjamin Renard   First commit
326
327
328
329
330
331
332
                        // If the targetNode is within the folder we are dragging
                        for (i = 0; i < ln; i++) {
                            record = draggedRecords[i];
                            if (record.isNode && record.contains(targetNode)) {
                                return false;
                            }
                        }
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
333

16035364   Benjamin Renard   First commit
334
335
336
337
338
339
340
                        // Respect the allowDrop field on Tree nodes
                        if (position === 'append' && targetNode.get('allowDrop') === false) {
                            return false;
                        }
                        else if (position != 'append' && targetNode.parentNode.get('allowDrop') === false) {
                            return false;
                        }
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
341

16035364   Benjamin Renard   First commit
342
343
344
345
                        // If the target record is in the dragged dataset, then invalid drop
                        if (Ext.Array.contains(draggedRecords, targetNode)) {
                            return false;
                        }
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
346
347

                        //
16035364   Benjamin Renard   First commit
348
349
350
351
                        if (dataLength > 1)
                                return false;
                        var draggedRecord = draggedRecords[0];

a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
352
                        //
16035364   Benjamin Renard   First commit
353
354
355
                        switch (targetNode.data.nodeType)
                        {
                        case 'localParam' :
d0a99d97   elena   interdit drag-dro...
356
			   case 'remoteParam' :
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
357
358
			   case 'remoteSimuParam' :
                        case 'myData' :
16035364   Benjamin Renard   First commit
359
360
361
362
363
364
                            return false;
                        default :
                                if (draggedRecord.data.id == targetNode.data.nodeType+'-treeRootNode')
                                    return false;
                                if ((position == 'before') && (targetNode.data.id == targetNode.data.nodeType+'-treeRootNode'))
                                    return false;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
365
                                return (draggedRecord.data.nodeType == targetNode.data.nodeType);
16035364   Benjamin Renard   First commit
366
367
368
                        }
                        return false;
                    },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
369
370
                    onViewRender : function(view)
                    {
16035364   Benjamin Renard   First commit
371
                        var me = this;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
372

16035364   Benjamin Renard   First commit
373
                        view.on('itemupdate', function(record,index,node,opts)
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
374
                        {
16035364   Benjamin Renard   First commit
375
376
377
378
379
380
                                var forceHide = false;
                                var crtRec = record.parentNode;
                                while (crtRec && !forceHide)
                                {
                                    if (crtRec.get('filtered'))
                                        forceHide = crtRec.get('filtered');
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
381
                                    crtRec = crtRec.parentNode;
16035364   Benjamin Renard   First commit
382
383
384
385
                                }
                                tree.setNodesVisibility(record,forceHide);
                                tree.applyDisableToNode(record);
                        });
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
386

16035364   Benjamin Renard   First commit
387
388
389
390
                        view.on('itemadd', function(records,index,node,opts)
                        {
                                Ext.each(records,function (rec)
                                {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
391
                                        tree.applyFilterToNode(rec);
16035364   Benjamin Renard   First commit
392
                                        tree.applyDisableToNode(rec);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
393
394
                                });

16035364   Benjamin Renard   First commit
395
                        });
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
396

16035364   Benjamin Renard   First commit
397
398
399
400
401
402
403
404
405
                        view.on('afteritemexpand', function(record,index,node,opts)
                        {
                                var forceHide = false;
                                var crtRec = record.parentNode;
                                while (crtRec && !forceHide)
                                {
                                    if (crtRec.get('filtered'))
                                            forceHide = crtRec.get('filtered');
                                    crtRec = crtRec.parentNode;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
406

16035364   Benjamin Renard   First commit
407
408
409
410
411
                                }
                                tree.setNodesVisibility(record,forceHide);
                                tree.applyDisableToNode(record);
                        });

a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
412
                        if (me.enableDrag)
16035364   Benjamin Renard   First commit
413
414
415
416
417
418
419
420
421
422
                        {
                                me.dragZone = Ext.create('Ext.tree.ViewDragZone', {
                                view: view,
                                ddGroup: me.dragGroup || me.ddGroup,
                                dragText: me.dragText,
                                repairHighlightColor: me.nodeHighlightColor,
                                repairHighlight: me.nodeHighlightOnRepair
                                });
                        }

a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
423
                        if (me.enableDrop)
16035364   Benjamin Renard   First commit
424
425
426
427
428
429
430
431
432
433
434
435
                        {
                                me.dropZone = Ext.create('Ext.tree.ViewDropZone', {
                                view: view,
                                ddGroup: me.dropGroup || me.ddGroup,
                                allowContainerDrops: me.allowContainerDrops,
                                appendOnly: me.appendOnly,
                                allowParentInserts: me.allowParentInserts,
                                expandDelay: me.expandDelay,
                                dropHighlightColor: me.nodeHighlightColor,
                                dropHighlight: me.nodeHighlightOnDrop,
                                isValidDropPoint : me.isValidDropPoint
                                });
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
436
437
                        }
                    }
16035364   Benjamin Renard   First commit
438
                },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
439
                listeners :
16035364   Benjamin Renard   First commit
440
441
442
443
444
445
446
447
448
449
450
                {
                        beforedrop : function(node, data, overModel, dropPosition)
                        {
                                var parentId;
                                switch(dropPosition)
                                {
                                        case 'append' :
                                                if (overModel.isLeaf())
                                                        parentId = overModel.parentNode.get('id');
                                                else
                                                        parentId = overModel.get('id');
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
451
452
453
454

                                                        if(!overModel.isExpanded() && overModel.isExpandable()) {
                                                                myDesktopApp.warningMsg('Please open the folder before node adding');
                                                                return false;
16035364   Benjamin Renard   First commit
455
456
457
458
459
460
461
                                                        }
                                                break;
                                        case 'before' :
                                        case 'after' :
                                                parentId = overModel.parentNode.get('id');
                                                break;
                                }
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
462

16035364   Benjamin Renard   First commit
463
464
465
466
467
468
469
470
471
472
473
474
475
476
                            Ext.each(data.records, function(rec)
                            {
                                    rec.renameDD(parentId,function(result)
                                    {
                                        if (result)
                                        {
                                                if (!result.id)
                                                {
                                                        Ext.Msg.show({
                                                                title : 'Drop is impossible',
                                                                msg : result.error,
                                                                buttons : Ext.Msg.OK,
                                                                icon : Ext.MessageBox.WARNING
                                                        });
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
477

16035364   Benjamin Renard   First commit
478
479
480
481
482
483
484
485
486
487
488
                                                        return false;
                                                }
                                        }
                                        else
                                        {
                                                Ext.Msg.show({
                                                                title : 'Drop is impossible',
                                                                msg : 'Cannot connect to the server',
                                                                buttons : Ext.Msg.OK,
                                                                icon : Ext.MessageBox.WARNING
                                                        });
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
489

16035364   Benjamin Renard   First commit
490
491
                                                return false;
                                        }
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
492

16035364   Benjamin Renard   First commit
493
494
                                        return true;
                                    });
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
495
                            });
16035364   Benjamin Renard   First commit
496
497
498
499
                        }
                    },
	    },
            listeners: {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
500
501
502

	        itemmouseenter: function(view, record, item){
		  if(record.get('isParameter')){
16035364   Benjamin Renard   First commit
503
504
		        var el = Ext.get(item),
                        td = el.down('td > div');
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
505
                        td.setStyle('cursor', 'crosshair');
16035364   Benjamin Renard   First commit
506
507
508
509
510
		  }
		  else
		  {
			  var el = Ext.get(item),
              td = el.down('td > div');
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
511
              td.setStyle('cursor', 'pointer');
16035364   Benjamin Renard   First commit
512
513
514
515
516
		  }
		},
                itemcontextmenu: function(view, rec, item, index, e){
                	 // block other events
                    e.stopEvent();
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
517

16035364   Benjamin Renard   First commit
518
519
                    // unlock selection
                    view.ownerCt.getSelectionModel().setLocked(false);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
520

16035364   Benjamin Renard   First commit
521
                    view.ownerCt.getSelectionModel().select(rec,true);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
522

16035364   Benjamin Renard   First commit
523
524
525
                    // clear menu items
                    menu.removeAll();
                    var menuItems;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
526

16035364   Benjamin Renard   First commit
527
528
529
530
                    // if it's a single selection
                    if (view.ownerCt.getSelectionModel().selected.length === 1) {
                    	// get items menu corresponding to right clicked record
                        menuItems = rec.getContextMenuItems(this);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
531

16035364   Benjamin Renard   First commit
532
533
534
                    } else if (view.ownerCt.getSelectionModel().selected.length > 1) {
                        // get items menu corresponding to right clicked record
                        menuItems = rec.getContextMenuMultiItems(this);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
535

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

16035364   Benjamin Renard   First commit
538
539
540
541
542
543
544
545
546
547
548
549
550
                    // if there's at least one item menu
                    if (menuItems && menuItems.length){
                        // add the items
                        menu.add(menuItems);
                        // add listener on right clicked record
                        var onRecordClick = function (menu, item, e, eOpts)
                			{
                				//Dispatch click event to the record
                				this.onMenuItemClick(menu,item,e);
                				//Remove old click listener
                				menu.removeListener('click',onRecordClick,this);
                			};
                        menu.addListener('click',onRecordClick,rec);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
551

16035364   Benjamin Renard   First commit
552
553
                        // then show menu
                        menu.showAt(e.getXY());
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
554
                    }
16035364   Benjamin Renard   First commit
555
                },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
556

16035364   Benjamin Renard   First commit
557
558
                itemdblclick: function(view, record, item, index, event){
                    event.stopEvent();
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
559
560
561
562

                    // first check if it is for SAVE-START-STOP plugin...
		    if (Ext.PluginManager.getCount() > 0 &&
		        record.get('nodeType') == amdaModel.TimeTableNode.nodeType && record.isLeaf()) {
16035364   Benjamin Renard   First commit
563
564
565
566
567
568
			var zmgr = myDesktopApp.desktop.getDesktopZIndexManager();
			var winActive = zmgr.getActive();
			var winId =  winActive.getId();
			if (winId == 'explorer-win') {
			  zmgr.eachTopDown(function(win) {
			      var id = win.getId();
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
569
			      if (id !==  'explorer-win') {
16035364   Benjamin Renard   First commit
570
571
				winId = id;
			        return false;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
572
573
574
575
576
			      }
			  });
			}
		      }

16035364   Benjamin Renard   First commit
577
//		    var targetModuleName = myDesktopApp.getModule('explorer-win').getPinedModule();
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
578
		    if (record.get('nodeType') == 'remoteParam' && !record.isLeaf()
16035364   Benjamin Renard   First commit
579
580
581
							&& !record.get('isParameter')) {
			myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) {
				module.createWindow(record.getBaseId());
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
582
583
			});

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

16035364   Benjamin Renard   First commit
586
		    if (record.isLeaf() || record.data.isParameter)
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
587
		      switch (record.get('nodeType'))
16035364   Benjamin Renard   First commit
588
589
590
		      {
			case 'myData' :
			case 'myDataParam' :
c5984b95   elena   dblclk catalog
591
592
593
			case 'derivedParam' :
			case 'timeTable' :
			case 'sharedtimeTable' :
169f14d2   Benjamin Renard   Add shared object...
594
			case 'sharedcatalog' :
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
595
			case 'catalog' :
c5984b95   elena   dblclk catalog
596
597
			case 'request' :
			case 'condition' :
16035364   Benjamin Renard   First commit
598
599
		    	    record.editLeaf();
		    	    break;
c5984b95   elena   dblclk catalog
600
			case 'localParam' :
16035364   Benjamin Renard   First commit
601
			case 'remoteParam':
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
602
603
			case 'remoteSimuParam':
		    	    record.createAlias(record);
16035364   Benjamin Renard   First commit
604
		    	    break;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
605
606
		        case 'bkgWorks' :
		        	if (!record.get('object')) {
16035364   Benjamin Renard   First commit
607
608
609
610
611
		        		AmdaAction.getObject(record.get('id'), record.get('nodeType'), record.getObjectCallback, record);
		        	}
		        	else {
                                    if (record.get('status') == 'done') {
                                        var isInteractive = false;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
612
                                        var isNewTab = true;
16035364   Benjamin Renard   First commit
613
614
615
616
617
618
619
620
                                        record.editNode(isNewTab, isInteractive);
                                    }
                                    else {
                                        myDesktopApp.infoMsg('Job Status: ' + record.get('status'));
                                    }
		        	}
		        	break;
		      }
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
621

16035364   Benjamin Renard   First commit
622
623
                },
                beforeselect: function(view,node,index,options){
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
624
625
                    // if there's at least one node already selected
                    if(view.selected.length
16035364   Benjamin Renard   First commit
626
627
628
                            //AND (the node which is beeing selected has a different nodeType than the first selected node OR the first selected node isn't a leaf
                            && ( node.get('nodeType')!== view.selected.items[0].get('nodeType') ||  !view.selected.items[0].isLeaf())
                            // OR the node which is beeing selected has no nodeType OR it isn't a leaf OR
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
629
                            || !node.get('nodeType') || !node.isLeaf()
16035364   Benjamin Renard   First commit
630
631
632
633
634
635
636
637
638
639
640
641
642
643
                    ){
                        // clear old selection
                        view.deselectAll();
                    }
                },
                itemmousedown: function(tree,rec,item,index,event,options){
                    if(event.button===2){
                        // if the right clicked item is already selected
                        if (tree.getSelectionModel().isSelected(rec)) {
                            // lock selection to prevent the selection modification by the right click
                            tree.getSelectionModel().setLocked(true);
                        }
                    }
                },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
644
645
		afterrender: function(comp){
		  	        var view = comp.getView();
16035364   Benjamin Renard   First commit
646
647
648
649
				view.tip = Ext.create('Ext.tip.ToolTip', {
				    // The overall target element.
				    target: view.el,
				    // Each grid row causes its own seperate show and hide.
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
650
				    delegate: view.itemSelector,
16035364   Benjamin Renard   First commit
651
652
653
654
				    dismissDelay : 0,
				   //    showDelay: 100,
				    //  anchor: 'left',
				    // Moving within the row should not hide the tip.
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
655
656
				    trackMouse: true,
	 			    autoRender: true,
16035364   Benjamin Renard   First commit
657
658
659
660
661
				    listeners: {
					// Change content dynamically depending on which element triggered the show.
					beforeshow: function updateTipBody(tip) {
                                          if (view.getRecord(tip.triggerElement)) {
                                            var info = view.getRecord(tip.triggerElement).get('info');
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
662
663
664
665
666
667
                                                if (!info || info == '') {
                                                    tip.addCls('hide');
                                                }
                                                else {
                                                    tip.removeCls('hide');
                                                    tip.update(info);
16035364   Benjamin Renard   First commit
668
                                                }
16035364   Benjamin Renard   First commit
669
670
671
672
673
674
                                          }
				    }
				}
				});
		},
		// if remote base is empty - open interoperability module
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
675
676
		itemexpand: function(node) {
				    if ( node.get('nodeType') == amdaModel.RemoteParamNode.nodeType
16035364   Benjamin Renard   First commit
677
					&& node.getDepth() == 3 && !node.hasChildNodes()) {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
678
					node.addData();
16035364   Benjamin Renard   First commit
679
680
681
682
683
684
				    }
		},
                scope: this
            },
            hideHeaders: true,
            // must define a column with a field to enable editor
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
685
            columns: [{
16035364   Benjamin Renard   First commit
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
                xtype    : 'treetoolcolumn',
                text     : 'Name',
                flex     : 1,
                dataIndex: 'text',
                tool: 'info', // this references the "tools" object on the prototype
                toolHandler: function(view, cell, recordIndex, cellIndex, e) {
            	    var tooltype = e.target.getAttribute("tooltype");
            	    var record = view.store.getAt(recordIndex);
            	    switch (tooltype)
            	    {
            	    	case 'info' :
            	    		myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function (module) {
            	    			module.createWindow(record.get('help'), record.get('info'));
            	    		});
            	    		break;
            	    }
                },
                toolIsVisible : function(record) {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
704

16035364   Benjamin Renard   First commit
705
706
707
708
709
                	switch (record.get('nodeType'))
                	{
                		case 'localParam' :
                                case 'remoteParam' :
                                case 'remoteSimuParam' :
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
710

16035364   Benjamin Renard   First commit
711
712
713
714
                			return record.get('help') != '';
                	}
                	return false;
                },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
715
                field: {
16035364   Benjamin Renard   First commit
716
717
718
719
720
721
                	validFlag: false,
    	            validator : function(value) {
    	            	// get explorerModule
                    	var explModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id);
                        var explUI = explModule.getUiContent();
                        var activeTreePanel = explUI.getActiveTab();
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
722

16035364   Benjamin Renard   First commit
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
                        var editedNode = activeTreePanel.getSelectionModel().selected.items[0];
                        if (editedNode) {
                            if (!editedNode.get('id') && value === amdaModel.AmdaNode.NEW_DIR_NAME){
                                return false;
                            } else {
                            	return this.validFlag;
                            }
                        } else {
                            return true;
                        }
    	            },
    	            listeners: {
    	            	change : function( field, newValue, oldValue, eOpts )
    	            	{
    	            		var explModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id);
                            var explUI = explModule.getUiContent();
                            var activeTreePanel = explUI.getActiveTab();
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
740

16035364   Benjamin Renard   First commit
741
742
743
744
745
746
747
748
749
                            var editedNode = activeTreePanel.getSelectionModel().selected.items[0];
                            if (editedNode) {
                            	editedNode.isValidName(newValue, function (res) {
                            		if (!res)
								  	{
                            			field.validFlag = 'Error during object validation';
                            			field.validate();
									  	return;
								  	}
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
750

16035364   Benjamin Renard   First commit
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
                            		if (!res.valid)
                            		{
                            			if (res.error)
									  	{
                            				field.validFlag = res.error;
                            				field.validate();
											return;
									  	}
                            			else
                            			{
                            				field.validFlag = 'Invalid object name';
                            				field.validate();
                            				return;
                            			}
								  	}
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
766

16035364   Benjamin Renard   First commit
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
                            		field.validFlag = true;
                            		field.validate();
								});
                            }
    	            	}
    	            },
		    scope: this
                }
            }],
            //add our custom editor plugin
            plugins:  [new MyTreeEditor({
            	pluginId: 'treeEditor',
            	listeners: {
            		'canceledit' : function(editor, context) {
            			if (editor && editor.startValue===amdaModel.AmdaNode.NEW_DIR_NAME) {
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
782
            	            context.record.remove(true);
16035364   Benjamin Renard   First commit
783
784
            			}
            		}
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
785

16035364   Benjamin Renard   First commit
786
            	}})],
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
787

16035364   Benjamin Renard   First commit
788
789
790
            setNodesVisibility : function(node,forceHide)
            {
              var isFiltered = node.get('filtered');
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
791

16035364   Benjamin Renard   First commit
792
793
              for (var i = 0; i < node.childNodes.length; i++)
                this.setNodesVisibility(node.childNodes[i],forceHide || isFiltered);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
794

16035364   Benjamin Renard   First commit
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
              this.setNodeVisibility(node,!(forceHide || isFiltered));
            },

            setNodeVisibility : function(node,isVisible)
            {
              var record = store.getNodeById(node.internalId);
              var viewNode = Ext.fly(tree.getView().getNode(record));
              if (viewNode)
              {
            	viewNode.setVisibilityMode(Ext.Element.DISPLAY);
                if (isVisible)
                {
                  viewNode.show();
                  this.applyDisableToNode(record);
                }
                else
                  viewNode.hide();
              }
            },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
814

16035364   Benjamin Renard   First commit
815
816
817
818
            applyFilterToNode : function(node)
            {
            	if (!node)
            		return;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
819

16035364   Benjamin Renard   First commit
820
            	var filter = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id).filter;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
821

16035364   Benjamin Renard   First commit
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
            	switch (node.get('nodeType'))
            	{
            		case 'localParam' :
            			if (!filter || !filter['param'])
            			{
            				//no filter applied
            				node.set('filtered',false);
                			return;
            			}
            			var pos = node.get('depth') - 3; //depth from local param root node
            			if (pos < 0 || pos > 2)
            			{
            				node.set('filtered',false);
            				return;
            			}
            			var isFiltered = true;
            			for (var i = 0; i < filter['param'].length; i++)
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
839
            			{
16035364   Benjamin Renard   First commit
840
841
842
843
844
845
846
847
848
849
            				s = filter['param'][i].split(';');
        					if (node.get('id') == s[pos])
        					{
        						isFiltered = false;
        						break;
        					}
        				}
            			node.set('filtered',isFiltered);
            			break;
            		case 'remoteSimuParam' :
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
850
851
852

            			if (!filter || !filter['simu'] )
            			{
16035364   Benjamin Renard   First commit
853
854
855
856
                                    //no filter applied
            				node.set('filtered',false);
                			return;
            			}
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
857

16035364   Benjamin Renard   First commit
858
            			var pos = node.get('depth') - 3; //depth from remote param root node
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
859

16035364   Benjamin Renard   First commit
860
861
862
863
864
            			if (pos < 0 || pos > 5)
            			{
            				 node.set('filtered',false);
            				 return;
            			}
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
865

16035364   Benjamin Renard   First commit
866
            			var isFiltered = true;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
867

16035364   Benjamin Renard   First commit
868
            			for (var i = 0; i < filter['simu'].length; i++)
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
869
            			{
16035364   Benjamin Renard   First commit
870
            				s = filter['simu'][i].split(';');
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
871

16035364   Benjamin Renard   First commit
872
        					if (node.get('id') == s[pos])
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
873
        					{
16035364   Benjamin Renard   First commit
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
        						isFiltered = false;
        						break;
        					}
        				}
            			node.set('filtered',isFiltered);
            			break;
            		/*case 'alias' :
            			if (!this.localParamFilter.result || this.localParamFilter.id == "" ||
            				!node.isLeaf())
            			{
            				//no filter applied
            				node.set('filtered',false);
                			return;
            			}
            			var crtParam = node.get('id');
            			crtParam = crtParam.replace('alias_','');
            			crtParam = crtParam.replace(/_/g,':');
            			var isFiltered = true;
            			for (var i = 0; i < this.localParamFilter.result.length; i++)
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
893
            			{
16035364   Benjamin Renard   First commit
894
895
896
897
898
899
900
901
902
903
904
905
906
907
            				s = this.localParamFilter.result[i].split(';');
            				console.log(s[2]);
        					if (crtParam == s[2])
        					{
        						isFiltered = false;
        						break;
        					}
            			}
            			node.set('filtered',isFiltered);
            			break;*/
            		default :
            			return;
            	}
            },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
908

16035364   Benjamin Renard   First commit
909
910
911
912
913
914
915
            applyFilterToNodes : function(node)
            {
            	node.eachChild(function (child){
            		tree.applyFilterToNodes(child);
            	});
            	tree.applyFilterToNode(node);
            },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
916

16035364   Benjamin Renard   First commit
917
918
919
920
            applyDisableToNode : function(node)
            {
            	var crtNode = node;
            	var disable = false;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
921

16035364   Benjamin Renard   First commit
922
923
924
925
926
927
928
929
930
            	do
            	{
            		if (crtNode.get('disable'))
            		{
            			disable = true;
            			break;
            		}
            		crtNode = crtNode.parentNode;
            	} while (crtNode);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
931
932


16035364   Benjamin Renard   First commit
933
934
935
936
937
938
939
940
                var viewNode = Ext.fly(tree.getView().getNode(node));
			    if (disable)
			    {
			      node.set('disable',true);
				  viewNode.setStyle('opacity',0.5);
			    }
            }
        });
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
941

16035364   Benjamin Renard   First commit
942
        tree.addEvents('edition');
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
943
944
945



16035364   Benjamin Renard   First commit
946
947
        return tree;
    },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
948

16035364   Benjamin Renard   First commit
949
    updateFilter : function()
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
950
    {
16035364   Benjamin Renard   First commit
951
    	var filter = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id).filter;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
952

16035364   Benjamin Renard   First commit
953
954
955
956
957
    	var keys = [];
        for (var f in filter) {
            if (hasOwnProperty.call(filter, f))
            	keys.push(f);
        }
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
958

16035364   Benjamin Renard   First commit
959
960
        var tree = this.query('#'+amdaUI.ExplorerUI.RESRC_TAB.TREE_ID)[0];
		tree.getView().refresh();
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
961

16035364   Benjamin Renard   First commit
962
963
964
965
        for (var i = 0; i < keys.length; i++)
		{
			if (keys[i] == "_empty_")
				continue;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
966

16035364   Benjamin Renard   First commit
967
968
969
			switch (keys[i])
			{
    			case 'param' :
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
970

16035364   Benjamin Renard   First commit
971
    				//apply filter to local datasets
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
972
973
    				var localNode = tree.getRootNode().findChild('id','myLocalData-treeRootNode',true);
    				tree.applyFilterToNodes(localNode);
16035364   Benjamin Renard   First commit
974
975
    				tree.setNodesVisibility(localNode,false);
    				tree.applyDisableToNode(localNode);
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
976

16035364   Benjamin Renard   First commit
977
    				//apply filter to aliases
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
978
979
    				var aliasNode = tree.getRootNode().findChild('id','alias-treeRootNode',true);
    				tree.applyFilterToNodes(aliasNode);
16035364   Benjamin Renard   First commit
980
981
982
    				tree.setNodesVisibility(aliasNode,false);
    				tree.applyDisableToNode(aliasNode);
    				break;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
983

16035364   Benjamin Renard   First commit
984
985
    			case 'simu' :
    				//apply filter to simulation datasets (in remote data)
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
986
987
    				var remoteNode = tree.getRootNode().findChild('id','myRemoteSimuData-treeRootNode',true);
    				tree.applyFilterToNodes(remoteNode);
16035364   Benjamin Renard   First commit
988
989
990
991
992
    				tree.setNodesVisibility(remoteNode,false);
    				tree.applyDisableToNode(remoteNode);
    				break;
			}
		}
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
993

16035364   Benjamin Renard   First commit
994
995
996
         this.dockedItems.getAt(1).items.items[0].select(filter['name']);
    }

a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
997
998
});

16035364   Benjamin Renard   First commit
999
1000
1001
1002
1003
Ext.define( 'MyTreeEditor', {
    extend: 'Ext.grid.plugin.CellEditing',
    alias: 'editing.treeeditor',

    // initialization method of plugin
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
1004
    init: function(cmp) {
16035364   Benjamin Renard   First commit
1005
1006
1007
1008
1009
        var me = this;
        me.hostCmp = cmp;
        // on parent event
        me.hostCmp.on({
            // on edition event
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
1010
            edition : {
16035364   Benjamin Renard   First commit
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
                delay: 50,
                fn : function(view, record, item, index, e){
                	view.getHeaderAtIndex(0).field.validFlag = 'Not modified';
                    // call the start edition method
                    me.startEdit(record, view.getHeaderAtIndex(0));
                },
                scope: me
            }
        });
        me.callParent(arguments);
    },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
1022

16035364   Benjamin Renard   First commit
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
    /**
     * Cancel any active editing.
     */
    cancelEdit: function() {
        var me = this,
        activeEd = me.getActiveEditor(),
        viewEl = me.grid.getView().getEl(me.getActiveColumn());

        me.setActiveEditor(null);
        me.setActiveColumn(null);
        me.setActiveRecord(null);
        if (activeEd) {
            activeEd.cancelEdit();
            viewEl.focus();
            this.fireEvent('canceledit', activeEd, me.context);
        }
    },
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
1040

16035364   Benjamin Renard   First commit
1041
1042
    /**
     * overwrite the initEditTriggers to disable edition on click/dblclick
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
1043
     * and to add custom
16035364   Benjamin Renard   First commit
1044
1045
1046
1047
1048
     */
    initEditTriggers: function() {

        var me = this,
        view = me.view;
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
1049

16035364   Benjamin Renard   First commit
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
        me.on({
            edit: function(editor,event){
                // if there is a modification
                if (event.originalValue !== event.value) {
                    // delegate rename action on model
                    event.record.rename(event.value,function(result){
                        // if a result has been returned : success
                        if(result) {
                            // delegate commit action to delete modification flag
                            event.record.commit();
                            var rec = event.record.data;
                            // in case of directory
                            if (!rec.leaf){
                                // set folder's ID returned by server
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
1064
                                rec.id = result.id;
16035364   Benjamin Renard   First commit
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
                            }
                        } else { // in case of transaction error
                            // reset originalValue
                            event.record.value = event.originalValue;
                            event.record.get('text') = event.originalValue;
                            event.record.commit();
                        }
                    });
                }

            }
        });

        // enable Enter key and Esc Key
        view.on('render', function() {
            me.keyNav = Ext.create('Ext.util.KeyNav', view.el, {
                enter: me.onEnterKey,
                esc: me.onEscKey,
                scope: me
            });
        }, me, { single: true });
    },

    //overwrite the getEditing context because we do not need the rowId
    getEditingContext: function(record, columnHeader) {
        var me = this,
        grid = me.grid,
        store = grid.store,
        colIdx,
        view = grid.getView(),
        value;

        // getting colIdx and real columnHeader
        if (Ext.isNumber(columnHeader)) {
            colIdx = columnHeader;
            columnHeader = grid.headerCt.getHeaderAtIndex(colIdx);
        } else {
            colIdx = columnHeader.getIndex();
        }
        // getting current value
        value = record.get(columnHeader.dataIndex);

        // return editing context
        return {
            grid: grid,
            record: record,
            field: columnHeader.dataIndex,
            value: value,
            column: columnHeader,
            colIdx: colIdx,
            view: columnHeader.getOwnerHeaderCt().view
        };
    }
} );