Blame view

js/app/views/PlotComponents/PlotTabContent.js 5.83 KB
437c4dbc   Benjamin Renard   First implementat...
1
2
3
4
5
6
7
8
9
10
11
/**
 * Project   : AMDA-NG
 * Name      : PlotTab.js
 * @class   amdaPlotComp.PlotTab
 * @extends Ext.form.Panel
 * @brief   Tab content to define a plot
 * @author  Benjamin Renard
 * @version $Id: PlotTab.js benjamin $
 */

Ext.define('amdaPlotComp.PlotTabContent', {
495fc7a3   Benjamin Renard   Adapt plot UI in ...
12
13
14
15
16
17
18
    extend: 'Ext.form.Panel',

    requires: [
        'amdaUI.TimeSelectorUI',
        'amdaPlotComp.PlotTree',
        'amdaPlotComp.PlotOutputForm',
        'amdaPlotComp.PlotElementPanel'
437c4dbc   Benjamin Renard   First implementat...
19
20
    ],
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
21
22
23
24
25
26
27
    //Link to the Plot Node
    plotNode: null,

    timeSelector: null,
    plotTree: null,
    plotElement: null,
    plotOutput: null,
437c4dbc   Benjamin Renard   First implementat...
28
29
30
31
    
    constructor: function(config) {
		this.init(config);	    
		this.callParent(arguments);
495fc7a3   Benjamin Renard   Adapt plot UI in ...
32
    },
57e15214   Benjamin Renard   Fix addParameter ...
33
34
35
36
37

    setTime : function(startDate, stopDate) {
        this.timeSelector.intervalSel.setInterval(startDate, stopDate);
        
    },
27b2a53e   Benjamin Renard   Link tab plot to ...
38
	
495fc7a3   Benjamin Renard   Adapt plot UI in ...
39
40
41
42
43
44
45
46
    updateTimeObject : function() {
        var timeSource = this.timeSelector.getActiveTimeSource();
        var tabForm = this.getForm();
        tabForm.updateRecord(this.plotNode.get('object'));
        this.plotNode.get('object').set('timesrc', timeSource);
        if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
            this.plotNode.get('object').set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
    },
57e15214   Benjamin Renard   Fix addParameter ...
47
48
49
50
51

    doPlot : function() {
        this.plotNode.execute();
    },

c9db9962   Benjamin Renard   WIP
52
53
54
55
56
57
58
59
60
61
62
63
    savePlot : function() {
        var object = this.plotNode.get('object');
        if (!object)
            return;

        if ((object.get('id') != '') && (this.plotNode.get('text') == object.get('name'))) {
            //update existing request
            this.plotNode.update();
            return;
        }

        //save new request
495fc7a3   Benjamin Renard   Adapt plot UI in ...
64
        var me = this;
c9db9962   Benjamin Renard   WIP
65
66
67
68
69
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
        this.plotNode.isValidName(object.get('name'), function (res) {
            if (!res) {
                myDesktopApp.errorMsg('Error during object validation');
                return;
            }
            if (!res.valid) {
                if (res.error) {
                    if (res.error.search('subtree') != -1) {
                        Ext.Msg.show( { title : 'Warning',
                            msg: res.error + '<br/>Do you want to overwrite it?',
                            width: 300,
                            buttons: Ext.Msg.OKCANCEL,
                            icon: Ext.Msg.WARNING,
                            fn :  me.overwritePlot,
                            scope : me
                        });
                    }
                    else {
                        myDesktopApp.errorMsg(res.error);
                    }
                }
                else {
                    myDesktopApp.errorMsg('Invalid object name');
                }
                return;
            }
            me.saveProcess(false);
        });
    },

    overwritePlot : function(btn) {
        if (btn == 'cancel') return;
        this.saveProcess(true);
    },

    saveProcess : function(toRename) {
        if (toRename) {
            this.plotNode.update();
        }
        else {
            if (this.plotNode.get('object').get('id') != '') {
                //Duplicate request
                var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
                if (!plotModule)
                    return;
                this.plotNode = plotModule.linkedNode.get('object').duplicatePlot(this.plotNode);
                this.updateUI();
            }
            this.plotNode.create();
        }
    },

    updateUI : function() {
        this.plotOutput.setObject(this.plotNode.get('object'));
        this.timeSelector.intervalSel.setInterval(this.plotNode.get('object').get('startDate'), this.plotNode.get('object').get('stopDate'));
        this.timeSelector.setTTTab(this.plotNode.get('object').get('timeTables'));
        this.treePlot.buildTree(this.plotNode.get('object'));
    },

    init : function(config) {
        this.plotNode = config.plotNode;
495fc7a3   Benjamin Renard   Adapt plot UI in ...
126

c9db9962   Benjamin Renard   WIP
127
        this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelectorTab' + this.plotNode.id, border : false, flex: 6, collapsible: true, collapseDirection : 'bottom'} );
495fc7a3   Benjamin Renard   Adapt plot UI in ...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
        this.plotElement = new amdaPlotComp.PlotElementPanel({flex: 11});
        this.treePlot = new amdaPlotComp.PlotTree({flex: 11, plotElementPanel: this.plotElement});
        this.plotOutput = new amdaPlotComp.PlotOutputForm({flex: 6, collapseDirection : 'bottom', collapsible : true });

        var treePanel = new Ext.form.Panel({
            flex: 1,
            layout: {
                type: 'vbox',
                pack: 'start',
                align: 'stretch'
            },
            bodyStyle: { background : '#dfe8f6' },
            defaults: {
                border: false
            },
            items: [
                this.treePlot,
                this.timeSelector
            ]
        });

        var optionsPanel = new Ext.form.Panel({
            flex: 1,
            layout: {
                type: 'vbox',
                pack: 'start',
                align: 'stretch'
            },
            bodyStyle: { background : '#dfe8f6' },
            defaults: {
                border: false
            },
            items: [
                this.plotElement,
                this.plotOutput
            ]
        });

437c4dbc   Benjamin Renard   First implementat...
166
		
495fc7a3   Benjamin Renard   Adapt plot UI in ...
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
        var myConf = {
            bodyStyle: { background : '#dfe8f6' },
            border : false,
            defaults: {
                border: false
            },
            layout: {
                type: 'hbox',
                pack: 'start',
                align: 'stretch'
            },
            items: [
                treePanel,
                optionsPanel
            ],
            listeners: {
                afterrender: function(comp, eOpts) {
c9db9962   Benjamin Renard   WIP
184
                    this.updateUI();
495fc7a3   Benjamin Renard   Adapt plot UI in ...
185
186
187
188
189
190
                },
                scope: this
            }
        };

        Ext.apply (this , Ext.apply (arguments, myConf));
437c4dbc   Benjamin Renard   First implementat...
191
192
		
		
495fc7a3   Benjamin Renard   Adapt plot UI in ...
193
194
    }
});