MultiPlotUI.js
4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
126
127
128
129
130
131
/**
* Project : AMDA-NG
* Name : MultiPlotUI.js
* @class amdaUI.MultiPlotUI
* @extends Ext. panel.Panel
* @brief MultiPlot UI definition (View)
* @author
* @version $Id: MultiPlotUI.js benjamin
*/
Ext.define('amdaUI.MultiPlotUI', {
extend: 'Ext.form.Panel',
plotWin: null,
timeSelector: null,
plotSelector: null,
constructor: function(config) {
this.init(config);
this.callParent(arguments);
},
refreshMultiPlot: function() {
var me = this;
var tabsInfo = this.plotWin.plotTabs.getTabsInfo();
this.plotSelector.removeAll();
Ext.Array.each(tabsInfo, function(tabInfo) {
me.plotSelector.add(
{
boxLabel: tabInfo.name,
checked: tabInfo.object.get('multi-selected'),
listeners: {
change: function(field, newValue, oldValue, eOpts) {
tabInfo.object.set('multi-selected', newValue);
tabInfo.tabContent.enableTimeSelection(!newValue);
}
}
}
);
tabInfo.tabContent.enableTimeSelection(!tabInfo.object.get('multi-selected'));
});
},
doMultiPlot: function() {
if (!this.isValidRequest()) {
return false;
}
// At least one plot must be selected
var nbSelected = 0;
this.plotSelector.items.each(function(item) {
if (item.checked)
++nbSelected;
});
if (nbSelected == 0) {
myDesktopApp.errorMsg('At least one Plot must be selected');
return false;
}
this.plotWin.plotTabs.updatePlotTabs()
// Execute multiplot request
var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
plotModule.linkedNode.execute();
},
updateTimeObject : function() {
var timeSource = this.timeSelector.getActiveTimeSource();
this.getForm().updateRecord(this.plotWin.object);
this.plotWin.object.set('timesrc', timeSource);
if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
this.plotWin.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
},
isValidRequest : function() {
this.updateTimeObject();
if (!this.timeSelector.isValid(false)) {
myDesktopApp.errorMsg('Error in Time definition');
return false;
}
return true;
},
init : function(config) {
var me = this;
this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'multiplot-time-selector', border : false, collapsible: false, height: 180} );
this.plotSelector = Ext.create('Ext.form.CheckboxGroup', {
xtype: 'checkboxgroup',
flex: 1,
columns: 3,
minHeight: 40,
autoScroll: true,
fieldLabel: 'Select plots to synchronize',
labelAlign: 'top'
});
var myConf = {
layout: {
type: 'vbox',
pack: 'start',
align: 'stretch'
},
items: [
this.plotSelector,
this.timeSelector
],
listeners: {
afterrender: function() {
me.refreshMultiPlot();
me.timeSelector.intervalSel.setInterval(me.plotWin.object.get('startDate'), me.plotWin.object.get('stopDate'));
me.timeSelector.intervalSel.updateStop();
me.timeSelector.setTTTab(me.plotWin.object.get('timeTables'));
me.timeSelector.timeSrc.setActiveTab(me.plotWin.object.get('timesrc'));
}
},
fbar: [
'->',
{
xtype: 'button',
text: 'Plot',
scope: this,
handler: function(button) {
this.doMultiPlot();
}
}
]
};
Ext.apply(this, Ext.apply(arguments, myConf));
}
});