Commit b2481b883b8cdd61db2d6919c9b631c1c7e2419f
1 parent
3a1fa4bd
Exists in
master
and in
110 other branches
fix indent
Showing
1 changed file
with
396 additions
and
403 deletions
Show diff stats
js/app/views/PlotComponents/PlotZoomPlug.js
1 | 1 | /** |
2 | - * Project : AMDA-NG | |
3 | - * Name : PlotZoomPlug.js | |
4 | - * @plugin amdaPlotComp.PlotZoomPlug | |
5 | - * @extends Ext.util.Observable | |
6 | - * @ptype plotZoomPlugin | |
7 | - * @brief Plot Zoom UI (View) | |
8 | - * @author Benjamin | |
9 | - * @version $Id: PlotZoomPlug.js | |
10 | - ******************************************************************************** | |
11 | - * FT Id : Date : Name - Description | |
12 | - ******************************************************************************* | |
13 | - * : | |
14 | - */ | |
2 | + * Project : AMDA-NG | |
3 | + * Name : PlotZoomPlug.js | |
4 | + * @plugin amdaPlotComp.PlotZoomPlug | |
5 | + * @extends Ext.util.Observable | |
6 | + * @ptype plotZoomPlugin | |
7 | + * @brief Plot Zoom UI (View) | |
8 | + * @author Benjamin | |
9 | + * @version $Id: PlotZoomPlug.js | |
10 | + ******************************************************************************** | |
11 | + * FT Id : Date : Name - Description | |
12 | + ******************************************************************************* | |
13 | + * : | |
14 | + */ | |
15 | 15 | |
16 | 16 | |
17 | 17 | Ext.define('amdaPlotComp.PlotZoomPlug', { |
18 | - extend: 'Ext.util.Observable', | |
19 | - alias: 'plugin.plotZoomPlugin', | |
20 | - | |
21 | - id: 'plot-zoom-plug', | |
22 | - | |
23 | - ttModuleId : 'timetab-win', | |
24 | - | |
25 | - win : null, | |
26 | - form : null, | |
27 | - zoomType : '', | |
28 | - tabId : '', | |
29 | - panelId : -1, | |
30 | - | |
31 | - linkedTTNode : null, | |
32 | - | |
33 | - constructor: function(config) { | |
34 | - Ext.apply(this, config); | |
35 | - this.callParent(arguments); | |
36 | - }, | |
37 | - | |
38 | - onDestroy : function() { | |
39 | - this.win = null; | |
40 | - }, | |
41 | - | |
42 | - init: function(cmp) { | |
43 | - this.hostCmp = cmp; | |
44 | - }, | |
45 | - | |
46 | - setMinValue : function(min) { | |
47 | - if (!this.form) | |
48 | - return; | |
49 | - | |
50 | - if (this.zoomType == 'timeAxis') | |
51 | - this.form.getForm().findField('zoom-min-time').setValue(min); | |
52 | - else | |
53 | - this.form.getForm().findField('zoom-min-float').setValue(min); | |
54 | - }, | |
55 | - | |
56 | - setMaxValue : function(max) { | |
57 | - if (!this.form) | |
58 | - return; | |
59 | - | |
60 | - if (this.zoomType == 'timeAxis') | |
61 | - { | |
62 | - var minValue = this.form.getForm().findField('zoom-min-time').getValue(); | |
63 | - if (minValue <= max) | |
64 | - this.form.getForm().findField('zoom-max-time').setValue(max); | |
65 | - else | |
66 | - { | |
67 | - this.form.getForm().findField('zoom-min-time').setValue(max); | |
68 | - this.form.getForm().findField('zoom-max-time').setValue(minValue); | |
69 | - } | |
70 | - } | |
71 | - else | |
72 | - { | |
73 | - var minValue = this.form.getForm().findField('zoom-min-float').getValue(); | |
74 | - if (minValue <= max) | |
75 | - this.form.getForm().findField('zoom-max-float').setValue(max); | |
76 | - else | |
77 | - { | |
78 | - this.form.getForm().findField('zoom-min-float').setValue(max); | |
79 | - this.form.getForm().findField('zoom-max-float').setValue(minValue); | |
80 | - } | |
81 | - } | |
82 | - }, | |
83 | - | |
84 | -/** | |
85 | - * add Interval to Time table | |
86 | - **/ | |
87 | - insertInterval: function() { | |
88 | - if (this.zoomType != 'timeAxis') | |
89 | - return; | |
90 | - | |
91 | - var start = this.form.getForm().findField('zoom-min-time').getValue(); | |
92 | - var stop = this.form.getForm().findField('zoom-max-time').getValue(); | |
93 | - | |
94 | - myDesktopApp.getLoadedModule(this.ttModuleId, true, function(module){ | |
95 | - var targetModuleUI = module.getUiContent(); | |
96 | - if (targetModuleUI) | |
97 | - targetModuleUI.addInterval(start,stop); | |
98 | - }); | |
99 | - }, | |
18 | + extend: 'Ext.util.Observable', | |
19 | + alias: 'plugin.plotZoomPlugin', | |
100 | 20 | |
101 | -/** | |
102 | - * creation of the window | |
103 | - */ | |
104 | - show : function(tabId, zoomType, panelId) { | |
105 | - if (!this.win) | |
106 | - { | |
107 | - this.win = new Ext.Window({ | |
108 | - id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(), // Plot window ID | |
109 | - width: 250, | |
110 | - height: 250, | |
111 | - x: 0, y: 0, | |
112 | - baseCls:'x-panel', | |
113 | - title: 'Zoom', | |
114 | - layout: 'fit', | |
115 | - constrain: true, | |
116 | - collapsible: true, | |
117 | - resizable: false, | |
118 | - ghost: false, | |
119 | - renderTo: this.hostCmp.ownerCt.body, | |
120 | - items: this.getFormConfig(), | |
121 | - listeners: { | |
122 | - scope: this, | |
123 | - beforeclose: function() { | |
124 | - this.hostCmp.panelImage.stopZoom(); | |
125 | - Ext.PluginManager.unregister(this); | |
126 | - } | |
127 | - }, | |
128 | - getConstrainVector: function(constrainTo){ | |
129 | - var me = this; | |
130 | - if (me.constrain || me.constrainHeader) { | |
131 | - constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent(); | |
132 | - return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo); | |
133 | - } | |
134 | - } | |
135 | - }); | |
136 | - | |
137 | - this.win.on('destroy', this.onDestroy, this); | |
138 | - | |
139 | - Ext.PluginManager.register(this); | |
140 | - } | |
141 | - | |
142 | - this.tabId = tabId; | |
143 | - this.updateWinByType(zoomType, panelId); | |
144 | - this.win.show(); | |
145 | - this.win.setPosition(0,0); | |
146 | - }, | |
147 | - | |
148 | - close : function() { | |
149 | - if (this.win == null) | |
150 | - return; | |
151 | - this.win.close(); | |
152 | - }, | |
153 | - | |
154 | - updateWinByType : function(zoomType, panelId) { | |
155 | - if (this.win == null) | |
156 | - return; | |
157 | - | |
158 | - this.zoomType = zoomType; | |
159 | - this.panelId = panelId; | |
160 | - | |
161 | - switch (zoomType) | |
162 | - { | |
163 | - case 'timeAxis': | |
164 | - this.win.setTitle('Zoom on time axis & Interval selection - Panel Id : '+panelId); | |
165 | - break; | |
166 | - case 'y-left' : | |
167 | - this.win.setTitle('Zoom on Y Left axis - Panel Id : '+panelId); | |
168 | - break; | |
169 | - case 'y-right' : | |
170 | - this.win.setTitle('Zoom on Y Right axis - Panel Id : '+panelId); | |
171 | - break; | |
172 | - case 'xaxis_id' : | |
173 | - this.win.setTitle('Zoom on X axis - Panel Id : '+panelId); | |
174 | - break; | |
175 | - } | |
176 | - | |
177 | - this.form.getForm().findField('zoom-min-time').setVisible(this.zoomType == 'timeAxis'); | |
178 | - this.form.getForm().findField('zoom-max-time').setVisible(this.zoomType == 'timeAxis'); | |
179 | - | |
180 | - this.form.getForm().findField('zoom-min-float').setVisible(this.zoomType != 'timeAxis'); | |
181 | - this.form.getForm().findField('zoom-max-float').setVisible(this.zoomType != 'timeAxis'); | |
182 | - | |
183 | - var ttNameField = this.form.getForm().findField('tt-name'); | |
184 | - if (ttNameField) | |
185 | - ttNameField.findParentByType('fieldset').setVisible(this.zoomType == 'timeAxis'); | |
186 | - | |
187 | - this.win.setHeight((this.zoomType == 'timeAxis') ? 250 : 160); | |
188 | - }, | |
189 | - | |
190 | - resetMinMaxValue: function() { | |
191 | - if (this.zoomType == 'timeAxis') | |
192 | - { | |
193 | - this.form.getForm().findField('zoom-min-time').setValue(''); | |
194 | - this.form.getForm().findField('zoom-max-time').setValue(''); | |
195 | - } | |
196 | - else | |
197 | - { | |
198 | - this.form.getForm().findField('zoom-min-float').setValue(null); | |
199 | - this.form.getForm().findField('zoom-max-float').setValue(null); | |
200 | - } | |
201 | - | |
202 | - this.hostCmp.panelImage.resetZoom(); | |
203 | - }, | |
21 | + id: 'plot-zoom-plug', | |
204 | 22 | |
205 | -/** | |
206 | - * Main form | |
207 | - */ | |
208 | - getFormConfig: function(){ | |
209 | - | |
210 | - var intervalFieldSet = { | |
211 | - xtype: 'fieldset', | |
212 | - title: 'Interval Selection', | |
213 | - name: 'interval-selection-fieldset', | |
214 | - collapsible: false, | |
215 | - layout: { | |
216 | - type: 'vbox', | |
217 | - pack: 'start', | |
218 | - align: 'stretch' | |
219 | - }, | |
220 | - items : [ | |
221 | - { | |
222 | - xtype:'datefield', name:'zoom-min-time', fieldLabel: 'Start Time', | |
223 | - format : 'Y-m-d\\TH:i:s' | |
224 | - }, | |
225 | - { | |
226 | - xtype:'datefield', name:'zoom-max-time', fieldLabel: 'Stop Time', | |
227 | - format : 'Y-m-d\\TH:i:s' | |
228 | - }, | |
229 | - { | |
230 | - xtype:'numberfield', name:'zoom-min-float', fieldLabel: 'Min Value' | |
231 | - }, | |
232 | - { | |
233 | - xtype:'numberfield', name:'zoom-max-float', fieldLabel: 'Max Value' | |
234 | - }, | |
235 | - { | |
236 | - xtype: 'button', | |
237 | - width: 100, | |
238 | - text: 'Reset interval', | |
239 | - scope: this, | |
240 | - handler: function() { | |
241 | - this.resetMinMaxValue(); | |
242 | - } | |
243 | - } | |
244 | - ] | |
245 | - }; | |
246 | - | |
247 | - var insertTTFieldSet = { | |
248 | - xtype: 'fieldset', | |
249 | - title: 'TimeTable Insertion', | |
250 | - name: 'tt-insertion-fieldset', | |
251 | - collapsible: false, | |
252 | - layout: { | |
253 | - type: 'vbox', | |
254 | - pack: 'start', | |
255 | - align: 'stretch' | |
256 | - }, | |
257 | - items : [ | |
258 | - { | |
259 | - xtype: 'textfield', | |
260 | - fieldLabel: 'TimeTable Name', | |
261 | - name: 'tt-name', | |
262 | - listeners : | |
263 | - { | |
264 | - render : function(o,op) | |
265 | - { | |
266 | - var me = this; | |
267 | - var el = me.el; | |
268 | - var dropTarget = Ext.create('Ext.dd.DropTarget', el, { | |
269 | - ddGroup: 'explorerTree', | |
270 | - notifyOver : function(ddSource, e, data) | |
271 | - { | |
272 | - if ((data.records[0].data.nodeType == 'timeTable') && (data.records[0].data.leaf)) | |
273 | - { | |
274 | - this.valid = true; | |
275 | - return this.dropAllowed; | |
276 | - } | |
277 | - this.valid = false; | |
278 | - return this.dropNotAllowed; | |
279 | - }, | |
280 | - notifyDrop : function(ddSource, e, data) | |
281 | - { | |
282 | - if (!this.valid) | |
283 | - return false; | |
284 | - me.setValue(data.records[0].get('text')); | |
285 | - return true; | |
286 | - } | |
287 | - }); | |
288 | - } | |
289 | - } | |
290 | - }, | |
291 | - { | |
292 | - xtype: 'button', | |
293 | - width: 100, | |
294 | - text: 'Insert Interval', | |
295 | - scope: this, | |
296 | - handler: function(){ | |
297 | - var me = this; | |
298 | - | |
299 | - var TTname = this.form.getForm().findField('tt-name').getValue(); | |
300 | - | |
301 | - myDesktopApp.getLoadedModule(this.ttModuleId, true, function(module){ | |
302 | - var targetModuleUI = module.getUiContent(); | |
303 | - if (me.linkedTTNode && (me.linkedTTNode.get('text') == TTname)) | |
304 | - { | |
305 | - if (targetModuleUI) | |
306 | - me.insertInterval(); | |
307 | - else | |
308 | - { | |
309 | - me.linkedTTNode.editLeaf(function () { | |
310 | - me.insertInterval(); | |
311 | - }); | |
312 | - } | |
313 | - } | |
314 | - else | |
315 | - { | |
316 | - if (TTname == '') | |
317 | - { | |
318 | - me.linkedTTNode.editLeaf(function () { | |
319 | - me.insertInterval(); | |
320 | - }); | |
321 | - } | |
322 | - | |
323 | - var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
324 | - var ttRootNode = explorerTree.getRootNode().findChild('id','timeTable-treeRootNode',true); | |
325 | - amdaModel.InteractiveNode.preloadNodes(ttRootNode, function() { | |
326 | - var nodeWithSameName = null; | |
327 | - | |
328 | - if (TTname != '') | |
329 | - nodeWithSameName = ttRootNode.findChild('text', TTname, true); | |
330 | - | |
331 | - if (nodeWithSameName !== null) | |
332 | - me.linkedTTNode = nodeWithSameName; | |
333 | - else | |
334 | - { | |
335 | - var obj = Ext.create('amdaModel.TimeTable', {name : TTname, fromPlugin : true}); | |
336 | - me.linkedTTNode = Ext.create('amdaModel.TimeTableNode', { | |
337 | - leaf : true, | |
338 | - text : TTname, | |
339 | - nodeType : 'timeTable', | |
340 | - object : obj | |
341 | - }); | |
342 | - } | |
343 | - | |
344 | - me.linkedTTNode.editLeaf(function () { | |
345 | - me.insertInterval(); | |
346 | - }); | |
347 | - }); | |
348 | - } | |
349 | - }); | |
350 | - } | |
351 | - } | |
352 | - ] | |
353 | - }; | |
354 | - | |
355 | - this.form = new Ext.form.FormPanel( { | |
356 | - frame: true, | |
357 | - width: 250, | |
358 | - height: 250, | |
359 | - layout: { | |
360 | - type: 'vbox', | |
361 | - pack: 'start', | |
362 | - align: 'stretch' | |
363 | - }, | |
364 | - fieldDefaults: { | |
365 | - labelWidth: 60 | |
366 | - }, | |
367 | - items: [ | |
368 | - intervalFieldSet, | |
369 | - insertTTFieldSet | |
370 | - ], | |
371 | - fbar : [ | |
372 | - { | |
373 | - text: 'Apply Zoom', | |
374 | - width: 100, | |
375 | - scope: this, | |
376 | - handler: function(){ | |
377 | - if (this.zoomType == 'timeAxis') | |
378 | - { | |
379 | - var minZoom = this.form.getForm().findField('zoom-min-time').getValue(); | |
380 | - var maxZoom = this.form.getForm().findField('zoom-max-time').getValue(); | |
381 | - } | |
382 | - else | |
383 | - { | |
384 | - var minZoom = this.form.getForm().findField('zoom-min-float').getValue(); | |
385 | - var maxZoom = this.form.getForm().findField('zoom-max-float').getValue(); | |
386 | - } | |
387 | - | |
388 | - if(!maxZoom || !minZoom || !this.form.getForm().isValid()) { | |
389 | - myDesktopApp.warningMsg('Error in values definition'); | |
390 | - return; | |
391 | - } | |
392 | - | |
393 | - this.hostCmp.callInteractivePlot({'action' : 'zoom', 'tabId' : this.tabId, 'panelId' : this.panelId, 'axeId' : this.zoomType, 'min' : minZoom, 'max' : maxZoom}); | |
394 | - this.hostCmp.panelImage.resetZoom(); | |
395 | - } | |
396 | - }, | |
397 | - { | |
398 | - text: 'Undo Zoom', | |
399 | - width: 100, | |
400 | - scope : this, | |
401 | - handler: function(){ | |
402 | - this.hostCmp.callInteractivePlot({'action' : 'undozoom', 'tabId' : this.tabId, 'panelId' : this.panelId, 'axeId' : this.zoomType}); | |
403 | - this.hostCmp.panelImage.resetZoom(); | |
404 | - } | |
405 | - } | |
406 | - ] | |
407 | - }); | |
408 | - return this.form; | |
409 | - } | |
23 | + ttModuleId: 'timetab-win', | |
24 | + | |
25 | + win: null, | |
26 | + form: null, | |
27 | + zoomType: '', | |
28 | + tabId: '', | |
29 | + panelId: -1, | |
30 | + | |
31 | + linkedTTNode: null, | |
32 | + | |
33 | + constructor: function (config) { | |
34 | + Ext.apply(this, config); | |
35 | + this.callParent(arguments); | |
36 | + }, | |
37 | + | |
38 | + onDestroy: function () { | |
39 | + this.win = null; | |
40 | + }, | |
41 | + | |
42 | + init: function (cmp) { | |
43 | + this.hostCmp = cmp; | |
44 | + }, | |
45 | + | |
46 | + setMinValue: function (min) { | |
47 | + if (!this.form) | |
48 | + return; | |
49 | + | |
50 | + if (this.zoomType == 'timeAxis') | |
51 | + this.form.getForm().findField('zoom-min-time').setValue(min); | |
52 | + else | |
53 | + this.form.getForm().findField('zoom-min-float').setValue(min); | |
54 | + }, | |
55 | + | |
56 | + setMaxValue: function (max) { | |
57 | + if (!this.form) | |
58 | + return; | |
59 | + | |
60 | + if (this.zoomType == 'timeAxis') { | |
61 | + var minValue = this.form.getForm().findField('zoom-min-time').getValue(); | |
62 | + if (minValue <= max) | |
63 | + this.form.getForm().findField('zoom-max-time').setValue(max); | |
64 | + else { | |
65 | + this.form.getForm().findField('zoom-min-time').setValue(max); | |
66 | + this.form.getForm().findField('zoom-max-time').setValue(minValue); | |
67 | + } | |
68 | + } | |
69 | + else { | |
70 | + var minValue = this.form.getForm().findField('zoom-min-float').getValue(); | |
71 | + if (minValue <= max) | |
72 | + this.form.getForm().findField('zoom-max-float').setValue(max); | |
73 | + else { | |
74 | + this.form.getForm().findField('zoom-min-float').setValue(max); | |
75 | + this.form.getForm().findField('zoom-max-float').setValue(minValue); | |
76 | + } | |
77 | + } | |
78 | + }, | |
79 | + | |
80 | + /** | |
81 | + * add Interval to Time table | |
82 | + **/ | |
83 | + insertInterval: function () { | |
84 | + if (this.zoomType != 'timeAxis') | |
85 | + return; | |
86 | + | |
87 | + var start = this.form.getForm().findField('zoom-min-time').getValue(); | |
88 | + var stop = this.form.getForm().findField('zoom-max-time').getValue(); | |
89 | + | |
90 | + myDesktopApp.getLoadedModule(this.ttModuleId, true, function (module) { | |
91 | + var targetModuleUI = module.getUiContent(); | |
92 | + if (targetModuleUI) | |
93 | + targetModuleUI.addInterval(start, stop); | |
94 | + }); | |
95 | + }, | |
96 | + | |
97 | + /** | |
98 | + * creation of the window | |
99 | + */ | |
100 | + show: function (tabId, zoomType, panelId) { | |
101 | + if (!this.win) { | |
102 | + this.win = new Ext.Window({ | |
103 | + id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(), // Plot window ID | |
104 | + width: 250, | |
105 | + height: 250, | |
106 | + x: 0, y: 0, | |
107 | + baseCls: 'x-panel', | |
108 | + title: 'Zoom', | |
109 | + layout: 'fit', | |
110 | + constrain: true, | |
111 | + collapsible: true, | |
112 | + resizable: false, | |
113 | + ghost: false, | |
114 | + renderTo: this.hostCmp.ownerCt.body, | |
115 | + items: this.getFormConfig(), | |
116 | + listeners: { | |
117 | + scope: this, | |
118 | + beforeclose: function () { | |
119 | + this.hostCmp.panelImage.stopZoom(); | |
120 | + Ext.PluginManager.unregister(this); | |
121 | + } | |
122 | + }, | |
123 | + getConstrainVector: function (constrainTo) { | |
124 | + var me = this; | |
125 | + if (me.constrain || me.constrainHeader) { | |
126 | + constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent(); | |
127 | + return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo); | |
128 | + } | |
129 | + } | |
130 | + }); | |
131 | + | |
132 | + this.win.on('destroy', this.onDestroy, this); | |
133 | + | |
134 | + Ext.PluginManager.register(this); | |
135 | + } | |
136 | + | |
137 | + this.tabId = tabId; | |
138 | + this.updateWinByType(zoomType, panelId); | |
139 | + this.win.show(); | |
140 | + this.win.setPosition(0, 0); | |
141 | + }, | |
142 | + | |
143 | + close: function () { | |
144 | + if (this.win == null) | |
145 | + return; | |
146 | + this.win.close(); | |
147 | + }, | |
148 | + | |
149 | + updateWinByType: function (zoomType, panelId) { | |
150 | + if (this.win == null) | |
151 | + return; | |
152 | + | |
153 | + this.zoomType = zoomType; | |
154 | + this.panelId = panelId; | |
155 | + | |
156 | + switch (zoomType) { | |
157 | + case 'timeAxis': | |
158 | + this.win.setTitle('Zoom on time axis & Interval selection - Panel Id : ' + panelId); | |
159 | + break; | |
160 | + case 'y-left' : | |
161 | + this.win.setTitle('Zoom on Y Left axis - Panel Id : ' + panelId); | |
162 | + break; | |
163 | + case 'y-right' : | |
164 | + this.win.setTitle('Zoom on Y Right axis - Panel Id : ' + panelId); | |
165 | + break; | |
166 | + case 'xaxis_id' : | |
167 | + this.win.setTitle('Zoom on X axis - Panel Id : ' + panelId); | |
168 | + break; | |
169 | + } | |
170 | + | |
171 | + this.form.getForm().findField('zoom-min-time').setVisible(this.zoomType == 'timeAxis'); | |
172 | + this.form.getForm().findField('zoom-max-time').setVisible(this.zoomType == 'timeAxis'); | |
173 | + | |
174 | + this.form.getForm().findField('zoom-min-float').setVisible(this.zoomType != 'timeAxis'); | |
175 | + this.form.getForm().findField('zoom-max-float').setVisible(this.zoomType != 'timeAxis'); | |
176 | + | |
177 | + var ttNameField = this.form.getForm().findField('tt-name'); | |
178 | + if (ttNameField) | |
179 | + ttNameField.findParentByType('fieldset').setVisible(this.zoomType == 'timeAxis'); | |
180 | + | |
181 | + this.win.setHeight((this.zoomType == 'timeAxis') ? 250 : 160); | |
182 | + }, | |
183 | + | |
184 | + resetMinMaxValue: function () { | |
185 | + if (this.zoomType == 'timeAxis') { | |
186 | + this.form.getForm().findField('zoom-min-time').setValue(''); | |
187 | + this.form.getForm().findField('zoom-max-time').setValue(''); | |
188 | + } | |
189 | + else { | |
190 | + this.form.getForm().findField('zoom-min-float').setValue(null); | |
191 | + this.form.getForm().findField('zoom-max-float').setValue(null); | |
192 | + } | |
193 | + | |
194 | + this.hostCmp.panelImage.resetZoom(); | |
195 | + }, | |
196 | + | |
197 | + /** | |
198 | + * Main form | |
199 | + */ | |
200 | + getFormConfig: function () { | |
201 | + | |
202 | + var intervalFieldSet = { | |
203 | + xtype: 'fieldset', | |
204 | + title: 'Interval Selection', | |
205 | + name: 'interval-selection-fieldset', | |
206 | + collapsible: false, | |
207 | + layout: { | |
208 | + type: 'vbox', | |
209 | + pack: 'start', | |
210 | + align: 'stretch' | |
211 | + }, | |
212 | + items: [ | |
213 | + { | |
214 | + xtype: 'datefield', name: 'zoom-min-time', fieldLabel: 'Start Time', | |
215 | + format: 'Y-m-d\\TH:i:s' | |
216 | + }, | |
217 | + { | |
218 | + xtype: 'datefield', name: 'zoom-max-time', fieldLabel: 'Stop Time', | |
219 | + format: 'Y-m-d\\TH:i:s' | |
220 | + }, | |
221 | + { | |
222 | + xtype: 'numberfield', name: 'zoom-min-float', fieldLabel: 'Min Value' | |
223 | + }, | |
224 | + { | |
225 | + xtype: 'numberfield', name: 'zoom-max-float', fieldLabel: 'Max Value' | |
226 | + }, | |
227 | + { | |
228 | + xtype: 'button', | |
229 | + width: 100, | |
230 | + text: 'Reset interval', | |
231 | + scope: this, | |
232 | + handler: function () { | |
233 | + this.resetMinMaxValue(); | |
234 | + } | |
235 | + } | |
236 | + ] | |
237 | + }; | |
238 | + | |
239 | + var insertTTFieldSet = { | |
240 | + xtype: 'fieldset', | |
241 | + title: 'TimeTable Insertion', | |
242 | + name: 'tt-insertion-fieldset', | |
243 | + collapsible: false, | |
244 | + layout: { | |
245 | + type: 'vbox', | |
246 | + pack: 'start', | |
247 | + align: 'stretch' | |
248 | + }, | |
249 | + items: [ | |
250 | + { | |
251 | + xtype: 'textfield', | |
252 | + fieldLabel: 'TimeTable Name', | |
253 | + name: 'tt-name', | |
254 | + listeners: | |
255 | + { | |
256 | + render: function (o, op) { | |
257 | + var me = this; | |
258 | + var el = me.el; | |
259 | + var dropTarget = Ext.create('Ext.dd.DropTarget', el, { | |
260 | + ddGroup: 'explorerTree', | |
261 | + notifyOver: function (ddSource, e, data) { | |
262 | + if ((data.records[0].data.nodeType == 'timeTable') && (data.records[0].data.leaf)) { | |
263 | + this.valid = true; | |
264 | + return this.dropAllowed; | |
265 | + } | |
266 | + this.valid = false; | |
267 | + return this.dropNotAllowed; | |
268 | + }, | |
269 | + notifyDrop: function (ddSource, e, data) { | |
270 | + if (!this.valid) | |
271 | + return false; | |
272 | + me.setValue(data.records[0].get('text')); | |
273 | + return true; | |
274 | + } | |
275 | + }); | |
276 | + } | |
277 | + } | |
278 | + }, | |
279 | + { | |
280 | + xtype: 'button', | |
281 | + width: 100, | |
282 | + text: 'Insert Interval', | |
283 | + scope: this, | |
284 | + handler: function () { | |
285 | + var me = this; | |
286 | + | |
287 | + var TTname = this.form.getForm().findField('tt-name').getValue(); | |
288 | + | |
289 | + myDesktopApp.getLoadedModule(this.ttModuleId, true, function (module) { | |
290 | + var targetModuleUI = module.getUiContent(); | |
291 | + if (me.linkedTTNode && (me.linkedTTNode.get('text') == TTname)) { | |
292 | + if (targetModuleUI) | |
293 | + me.insertInterval(); | |
294 | + else { | |
295 | + me.linkedTTNode.editLeaf(function () { | |
296 | + me.insertInterval(); | |
297 | + }); | |
298 | + } | |
299 | + } | |
300 | + else { | |
301 | + if (TTname == '') { | |
302 | + me.linkedTTNode.editLeaf(function () { | |
303 | + me.insertInterval(); | |
304 | + }); | |
305 | + } | |
306 | + | |
307 | + var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
308 | + var ttRootNode = explorerTree.getRootNode().findChild('id', 'timeTable-treeRootNode', true); | |
309 | + amdaModel.InteractiveNode.preloadNodes(ttRootNode, function () { | |
310 | + var nodeWithSameName = null; | |
311 | + | |
312 | + if (TTname != '') | |
313 | + nodeWithSameName = ttRootNode.findChild('text', TTname, true); | |
314 | + | |
315 | + if (nodeWithSameName !== null) | |
316 | + me.linkedTTNode = nodeWithSameName; | |
317 | + else { | |
318 | + var obj = Ext.create('amdaModel.TimeTable', {name: TTname, fromPlugin: true}); | |
319 | + me.linkedTTNode = Ext.create('amdaModel.TimeTableNode', { | |
320 | + leaf: true, | |
321 | + text: TTname, | |
322 | + nodeType: 'timeTable', | |
323 | + object: obj | |
324 | + }); | |
325 | + } | |
326 | + | |
327 | + me.linkedTTNode.editLeaf(function () { | |
328 | + me.insertInterval(); | |
329 | + }); | |
330 | + }); | |
331 | + } | |
332 | + }); | |
333 | + } | |
334 | + } | |
335 | + ] | |
336 | + }; | |
337 | + | |
338 | + this.form = new Ext.form.FormPanel({ | |
339 | + frame: true, | |
340 | + width: 250, | |
341 | + height: 250, | |
342 | + layout: { | |
343 | + type: 'vbox', | |
344 | + pack: 'start', | |
345 | + align: 'stretch' | |
346 | + }, | |
347 | + fieldDefaults: { | |
348 | + labelWidth: 60 | |
349 | + }, | |
350 | + items: [ | |
351 | + intervalFieldSet, | |
352 | + insertTTFieldSet | |
353 | + ], | |
354 | + fbar: [ | |
355 | + { | |
356 | + text: 'Apply Zoom', | |
357 | + width: 100, | |
358 | + scope: this, | |
359 | + handler: function () { | |
360 | + if (this.zoomType == 'timeAxis') { | |
361 | + var minZoom = this.form.getForm().findField('zoom-min-time').getValue(); | |
362 | + var maxZoom = this.form.getForm().findField('zoom-max-time').getValue(); | |
363 | + } | |
364 | + else { | |
365 | + var minZoom = this.form.getForm().findField('zoom-min-float').getValue(); | |
366 | + var maxZoom = this.form.getForm().findField('zoom-max-float').getValue(); | |
367 | + } | |
368 | + | |
369 | + if (!maxZoom || !minZoom || !this.form.getForm().isValid()) { | |
370 | + myDesktopApp.warningMsg('Error in values definition'); | |
371 | + return; | |
372 | + } | |
373 | + | |
374 | + this.hostCmp.callInteractivePlot({ | |
375 | + 'action': 'zoom', | |
376 | + 'tabId': this.tabId, | |
377 | + 'panelId': this.panelId, | |
378 | + 'axeId': this.zoomType, | |
379 | + 'min': minZoom, | |
380 | + 'max': maxZoom | |
381 | + }); | |
382 | + this.hostCmp.panelImage.resetZoom(); | |
383 | + } | |
384 | + }, | |
385 | + { | |
386 | + text: 'Undo Zoom', | |
387 | + width: 100, | |
388 | + scope: this, | |
389 | + handler: function () { | |
390 | + this.hostCmp.callInteractivePlot({ | |
391 | + 'action': 'undozoom', | |
392 | + 'tabId': this.tabId, | |
393 | + 'panelId': this.panelId, | |
394 | + 'axeId': this.zoomType | |
395 | + }); | |
396 | + this.hostCmp.panelImage.resetZoom(); | |
397 | + } | |
398 | + } | |
399 | + ] | |
400 | + }); | |
401 | + return this.form; | |
402 | + } | |
410 | 403 | }); |
411 | 404 | \ No newline at end of file | ... | ... |