Blame view

js/app/views/PlotComponents/PlotTabPanel.js 4.06 KB
437c4dbc   Benjamin Renard   First implementat...
1
2
3
4
5
6
7
8
9
10
11
/**
 * Project   : AMDA-NG
 * Name      : PlotTabPanel.js
 * @class   amdaPlotComp.PlotTabPanel
 * @extends Ext.tab.Panel
 * @brief   Component use to show Plot tabs definition
 * @author  Benjamin Renard
 * @version $Id: PlotTabPanel.js benjamin $
 */

Ext.define('amdaPlotComp.PlotTabPanel', {
495fc7a3   Benjamin Renard   Adapt plot UI in ...
12
    extend: 'Ext.tab.Panel',
437c4dbc   Benjamin Renard   First implementat...
13
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
14
15
16
    requires: [
        'amdaPlotComp.PlotTabContent'
    ],
437c4dbc   Benjamin Renard   First implementat...
17
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
18
19
    //Link to the Plot UI
    plotUI : null,
437c4dbc   Benjamin Renard   First implementat...
20
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
21
22
    //Multiplot object
    multiplot_object: null,
437c4dbc   Benjamin Renard   First implementat...
23
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
24
25
26
27
    constructor: function(config) {
        this.init(config);	    
        this.callParent(arguments);
    },
437c4dbc   Benjamin Renard   First implementat...
28
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
29
30
31
32
    setMultiplotObject: function(multiplot_object) {
        var me = this;
        this.removeAll();
        this.multiplot_object = multiplot_object;
b9249413   Elena.Budnik   correct init value
33

495fc7a3   Benjamin Renard   Adapt plot UI in ...
34
35
36
37
        this.multiplot_object.plots().each(function (rec, index) {
            this.addPlotNode(rec, index == 0);
        }, this);
    },
437c4dbc   Benjamin Renard   First implementat...
38
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
39
40
41
42
43
44
45
    addPlotNode: function(plotNode, selectTab)
    {
        var tabNumber = this.getTabBar().items.getCount();
        var tabContent = new amdaPlotComp.PlotTabContent({plotNode: plotNode});
        var me = this;
        var tabComp = this.add({
            title: (plotNode.get('text') != '') ? plotNode.get('text') : 'Plot '+tabNumber,
495fc7a3   Benjamin Renard   Adapt plot UI in ...
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
            closable: true,
            layout: 'fit',
            bodyStyle: 'background: none',
            defaults: {
                border: false
            },
            items: [
                tabContent
            ],
            listeners : {
                scope : this,
                beforeclose: function( tab, eOpts ) {
                    if (this.items.getCount() == 1)
                    {
                        myDesktopApp.warningMsg('You need to keep at least one plot definition');
                        return false;
                    }
                    return true;
                },
                close: function( tab, eOpts ) {
57e15214   Benjamin Renard   Fix addParameter ...
66
67
                    if (tab.items.getAt(0).plotNode)
                        this.multiplot_object.removePlotByInternalId(tab.items.getAt(0).plotNode.internalId);
495fc7a3   Benjamin Renard   Adapt plot UI in ...
68
69
70
71
72
73
                },
                destroy: function(tab, eOpts) {	
                    this.updatePlotTabs();
                }
            }
        });
27b2a53e   Benjamin Renard   Link tab plot to ...
74
    	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
75
76
        if (selectTab)
            this.setActiveTab(tabComp);
437c4dbc   Benjamin Renard   First implementat...
77
    	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
78
79
        return tabContent;
    },
437c4dbc   Benjamin Renard   First implementat...
80
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
81
82
    updatePlotTabs: function()
    {
57e15214   Benjamin Renard   Fix addParameter ...
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
        for (i = 0; i < this.items.getCount(); ++i)
        {
            var tabItem = this.items.getAt(i);
            var tabContent = tabItem.items.getAt(0);
            var plotNode = tabContent.plotNode;
            var title = (plotNode.get('text') != '') ? plotNode.get('text') : 'Plot '+(i + 1);
            tabItem.setTitle(title);
            if (!this.getActiveTab())
                this.setActiveTab(tabItem);
        }
    },

    getCurrentPlotTabContent : function() {
        if (this.getActiveTab())
            return this.getActiveTab().child();
        return null;
495fc7a3   Benjamin Renard   Adapt plot UI in ...
99
    },
27b2a53e   Benjamin Renard   Link tab plot to ...
100
	
acafe456   Benjamin Renard   Fix Get Data
101
    updateTimeObjects : function() {
495fc7a3   Benjamin Renard   Adapt plot UI in ...
102
103
104
105
106
        for (i = 0; i < this.items.getCount(); ++i)
        {
            this.items.getAt(i).items.getAt(0).updateTimeObject();
        }
    },
27b2a53e   Benjamin Renard   Link tab plot to ...
107
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
108
109
110
111
    getTreeFromPlotTab: function(plotTab)
    {
        return plotTab.child().treePlot;
    },
437c4dbc   Benjamin Renard   First implementat...
112
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
113
114
115
116
117
118
    getSelectedTabId: function()
    {
        if (this.getActiveTab())
            return this.getActiveTab().child().tabId;
        return 0;
    },
87658ba0   Benjamin Renard   TT Navigation in ...
119
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
    init : function(config) {
        var me = this;

        this.plotUI = config.plotUI;

        var myConf = {
            plain: true,
            bodyStyle: { background : '#dfe8f6' },
            border : false,
            defaults: {
                border: false
            },	
            tabBar:{
                items:[
                    {
                        text:'+',
                        closable: false,
                        handler:function(btn,e){
                            var tabContent = me.addPlotNode(me.multiplot_object.createNewPlot(), true);
                        }
                    }
                ]
            }
        };

        Ext.apply (this , Ext.apply (arguments, myConf));
    }
0b0c7bc6   Benjamin Renard   Fix bug #6488
147
});