Blame view

js/app/views/PlotUI.js 7.38 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
/**
 * Project   : AMDA-NG
 * Name      : PlotUI.js
 * @class   amdaUI.PlotUI
 * @extends Ext.container.Container
18d4a11e   Benjamin Renard   Save and load plo...
6
7
8
 * @brief   New Plot Module UI definition (View)
 * @author  Benjamin Renard
 * @version $Id: PlotUI.js benjamin $
16035364   Benjamin Renard   First commit
9
10
11
12
 */


Ext.define('amdaUI.PlotUI', {
495fc7a3   Benjamin Renard   Adapt plot UI in ...
13
14
    extend: 'Ext.container.Container',
    alias: 'widget.newPanelPlot',
16035364   Benjamin Renard   First commit
15
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
16
17
18
19
    requires: [
        'amdaModel.DownloadNode',
        'amdaModel.Download',
        'amdaPlotComp.PlotTabPanel'
18d4a11e   Benjamin Renard   Save and load plo...
20
21
    ],
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
    formPanel: null,	
    plotTabs : null,

    constructor: function(config) {
        this.init(config);	    
        this.callParent(arguments);
        if (this.object)
            this.setObject(this.object);
    },

    setObject : function(object) {
        this.object = object;
        if (this.object.plots().count() == 0) {
            this.object.createNewPlot();
        }
        this.plotTabs.setMultiplotObject(this.object);
    },
e6065c11   Elena.Budnik   overwrite request...
39
	
acafe456   Benjamin Renard   Fix Get Data
40
41
42
43
44
45
46
47
48
49
    resetProcess : function(){
        var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);			
        plotModule.createLinkedNode();
        var obj = null;
        if ((arguments.length > 0) && (arguments[0] != null)) {
            obj = arguments[0];
        }
        plotModule.createObject(obj);					  
        this.setObject(plotModule.linkedNode.get('object'));
    },
16035364   Benjamin Renard   First commit
50
	
acafe456   Benjamin Renard   Fix Get Data
51
    getDataProcess : function(){
9c4e0454   Elena.Budnik   check if Stop > S...
52
53
54
55
        if ( this.updateObject() ) {
            var plotTab = this.plotTabs.getCurrentPlotTabContent();
            if (!plotTab || !plotTab.plotNode)
                return;
bab40211   Benjamin Renard   Test time selecti...
56
            plotTab.getDataProcess();
9c4e0454   Elena.Budnik   check if Stop > S...
57
        }
acafe456   Benjamin Renard   Fix Get Data
58
    },
18d4a11e   Benjamin Renard   Save and load plo...
59
    
57e15214   Benjamin Renard   Fix addParameter ...
60
61
62
63
64
65
66
67
68
69
70
    addParameter : function(node, updateTime){
        var crtTree = this.plotTabs.getTreeFromPlotTab(this.plotTabs.getActiveTab());
        if (crtTree) {
            crtTree.dropRecord(node,null,'append');
            if (updateTime) {
                if((node.get('globalStart') != null) && (node.get('globalStop') != null) && node.get('globalStart') != 'depending on mission' && node.get('isParameter')) {
                    this.setTimeFromData(node.getTimeFromNode(node));
                }
            }
        }
    },
2048f5bc   Benjamin Renard   Fix save & edit plot
71
72

    editPlot : function(plotNode) {
4efeb459   Benjamin Renard   First version for...
73
        this.plotTabs.addPlotNode(plotNode, true, true);
2048f5bc   Benjamin Renard   Fix save & edit plot
74
    },
8dddc557   Benjamin Renard   Fix plot reload
75
76
77
78

    reloadPlot : function(plotNode) {
        this.plotTabs.reloadPlot(plotNode);
    },
16035364   Benjamin Renard   First commit
79
    
acafe456   Benjamin Renard   Fix Get Data
80
    /**
16035364   Benjamin Renard   First commit
81
82
     * plot method called by 'Do Plot' button to launch the plot process
     */
57e15214   Benjamin Renard   Fix addParameter ...
83
    doPlot : function(){
4efeb459   Benjamin Renard   First version for...
84
        var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
bab40211   Benjamin Renard   Test time selecti...
85
        if ( this.updateObject(false) ) {
9c4e0454   Elena.Budnik   check if Stop > S...
86
            var plotTab = this.plotTabs.getCurrentPlotTabContent();
4efeb459   Benjamin Renard   First version for...
87
            if (plotTab) {
9c4e0454   Elena.Budnik   check if Stop > S...
88
                plotTab.doPlot();
4efeb459   Benjamin Renard   First version for...
89
            }
9c4e0454   Elena.Budnik   check if Stop > S...
90
        }
57e15214   Benjamin Renard   Fix addParameter ...
91
    },  
16035364   Benjamin Renard   First commit
92
	
fac46f96   Benjamin Renard   Cleanup
93
94
95
96
97
98
99
100
    /**
     * Check if changes were made before closing window 
     * @return false
     */	
    fclose : function() {
        var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
        if (module)
            module.closeInteractiveSession();
55fa3bbc   Benjamin Renard   Reset plot reques...
101
102

        return this.plotTabs.isDirty();
fac46f96   Benjamin Renard   Cleanup
103
    },
16035364   Benjamin Renard   First commit
104
	
acafe456   Benjamin Renard   Fix Get Data
105
106
107
    /**
     * update time selector of this.object from form
     */
bab40211   Benjamin Renard   Test time selecti...
108
109
110
111
112
    updateObject : function(acceptEmptyTTList = true){
        var plotTab = this.plotTabs.getCurrentPlotTabContent();
        if (plotTab)
            return plotTab.isValidRequest(acceptEmptyTTList);
        return false;
acafe456   Benjamin Renard   Fix Get Data
113
    },
84d442b4   Benjamin Renard   Synchronize plot ...
114
115
116
117

    updateTabs : function() {
        this.plotTabs.updatePlotTabs();
    },
5c744625   Benjamin Renard   Synchronize reque...
118
119
120
121

    updateRequestName : function(renamedNode) {
        this.plotTabs.updateRequestName(renamedNode);
    },
a971060f   Benjamin Renard   Fix some bugs
122
	
04084c4e   Benjamin Renard   Cleanup
123
    addTT : function(newTTName,newTTid,timeSelectorId) {
1b2281a1   Hacene SI HADJ MOHAND   ok for tt
124
125
126
127
128
129
130
131
132
133
134
        if(timeSelectorId){
            var crtTimeSelector = Ext.getCmp(timeSelectorId);
            if (crtTimeSelector)
                crtTimeSelector.addTT(newTTName,newTTid);
        }else{
            var plotTab = this.plotTabs.getCurrentPlotTabContent();
            if (plotTab)
                var crtTimeSelector = plotTab.getTimeSelector();
            if (crtTimeSelector)
                crtTimeSelector.addTT(newTTName,newTTid);
        }
04084c4e   Benjamin Renard   Cleanup
135
    },
e27eecbd   Benjamin Renard   Save and load TT ...
136
	
57e15214   Benjamin Renard   Fix addParameter ...
137
138
139
140
141
142
    /**
     * Set Start-Stop from parameter info (Local & MyData)
     */ 
    setTimeFromData : function(obj) {                                                               
        if (!obj.start || !obj.stop)
            return;
a54cfb3f   Benjamin Renard   Merge amdadev int...
143
144
145
        if (obj.interactiveId) {
            this.plotTabs.setActiveTabByInteractiveId(obj.interactiveId);
        }
57e15214   Benjamin Renard   Fix addParameter ...
146
147
        var plotTab = this.plotTabs.getCurrentPlotTabContent();
        if (plotTab)
b852834a   Hacene SI HADJ MOHAND   progress
148
            plotTab.setTime(obj.start, obj.stop);
57e15214   Benjamin Renard   Fix addParameter ...
149
    },
ebbb3638   Benjamin Renard   Edit plot tab on ...
150

c9db9962   Benjamin Renard   WIP
151
    savePlotRequest : function() {
bab40211   Benjamin Renard   Test time selecti...
152
153
154
155
156
        if (this.updateObject(true)) {
            var plotTab = this.plotTabs.getCurrentPlotTabContent();
            if (plotTab)
                plotTab.savePlot();
        }
c9db9962   Benjamin Renard   WIP
157
    },
d4a8d462   Benjamin Renard   Improve MultiPlot...
158
159
160
161
162

    enableSinglePlot : function(enable) {
        var plotButton = this.queryById('single-plot-button');
        plotButton.setDisabled(!enable);
        plotButton.setTooltip(enable ? 'Plot request' : 'Multiplot is enabled');
ae185f40   Benjamin Renard   Fix multiplot (#8...
163
164
165
        if (enable) {
            this.plotTabs.enableTimeSelection(true);
        }
d4a8d462   Benjamin Renard   Improve MultiPlot...
166
    },
27b2a53e   Benjamin Renard   Link tab plot to ...
167
    
fac46f96   Benjamin Renard   Cleanup
168
169
    init : function(config) {
        this.plotTabs = new amdaPlotComp.PlotTabPanel({plotUI : this});
6f513d3f   Benjamin Renard   WIP
170

fac46f96   Benjamin Renard   Cleanup
171
172
173
174
175
176
177
178
179
180
181
182
183
184
        this.formPanel = new Ext.form.Panel({
            region: 'center',
            layout: 'fit',
            bodyStyle: { background : '#dfe8f6' },
            defaults: {
                border: false
            },
            items: [
                this.plotTabs
            ],
            fbar: [
                {
                    xtype: 'button',
                    text: 'Plot',
d4a8d462   Benjamin Renard   Improve MultiPlot...
185
                    id: 'single-plot-button',
fac46f96   Benjamin Renard   Cleanup
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
                    scope: this,
                    handler: function(button) {
                        this.doPlot();
                    }
                },' ', {
                    xtype: 'button',
                    text: 'Get Data',
                    scope: this,
                    handler: function(button) {
                        this.getDataProcess();
                    }
                },' ', {
                    xtype: 'button',
                    text: 'Reset',
                    scope: this,
                    handler: function(button) {
                        this.resetProcess();
                    }
4efeb459   Benjamin Renard   First version for...
204
205
206
207
208
209
210
211
212
213
214
                },
		'-', {
			xtype: 'button',
			text: 'Multiplot',
			scope: this,
			handler: function(button) {
				var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
				plotModule.showMultiplotWin();
			}
		},
		'->', '-', {
fac46f96   Benjamin Renard   Cleanup
215
216
217
218
219
220
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
                    xtype: 'button',
                    text: 'Save',
                    scope: this,
                    handler: function(button) {
                        this.savePlotRequest();
                    }
                }
            ]
        });

        var myConf = {
            layout: 'border',
            items: [
                this.formPanel,
                {
                    xtype: 'panel', 
                    region: 'south',
                    title: 'Information',
                    collapsible: true,
                    collapseMode: 'header',
                    height: 100,
                    autoHide: false,
                    bodyStyle: 'padding:5px',
                    iconCls: 'icon-information',
                    loader: {
                        autoLoad: true,
                        url: helpDir+'plotHOWTO'
                    }
                }
            ]
        };
16035364   Benjamin Renard   First commit
246

fac46f96   Benjamin Renard   Cleanup
247
248
        Ext.apply(this, Ext.apply(arguments, myConf));
    }
8f85fbfa   Benjamin Renard   Remove deprecated...
249
});