From 8b11b1afde966da0a1028fa67671f3409636fb9f Mon Sep 17 00:00:00 2001 From: Benjamin Renard <benjamin.renard@akka.eu> Date: Thu, 11 Jul 2019 07:56:21 +0200 Subject: [PATCH] Insert intervals in catalog from plot (#5118) --- js/app/models/Catalog.js | 5 +++-- js/app/models/InteractiveNode.js | 1 + js/app/views/CatalogUI.js | 25 ++++++++++++++++++++++--- js/app/views/PlotComponents/PlotZoomPlug.js | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------- js/app/views/PlotTabResultUI.js | 17 ++++++++++++++++- 5 files changed, 119 insertions(+), 44 deletions(-) diff --git a/js/app/models/Catalog.js b/js/app/models/Catalog.js index afc1c31..d410384 100644 --- a/js/app/models/Catalog.js +++ b/js/app/models/Catalog.js @@ -14,7 +14,8 @@ Ext.define('amdaModel.Catalog', { extend: 'amdaModel.TimeTable', fields : [ - { name: 'parameters' } + { name: 'parameters' }, + { name: 'nbParameters', type: 'int', defaultValue: 1} ], getJsonValues : function (hasId) { @@ -46,4 +47,4 @@ Ext.define('amdaModel.Catalog', { -}); \ No newline at end of file +}); diff --git a/js/app/models/InteractiveNode.js b/js/app/models/InteractiveNode.js index b40ced8..da9554e 100644 --- a/js/app/models/InteractiveNode.js +++ b/js/app/models/InteractiveNode.js @@ -778,6 +778,7 @@ Ext.define('amdaModel.InteractiveNode', { this.set('object',paramObj); // Edition of parameter into parameter Module this.editInModule(null, this.onReady); + this.onReady = null; } else { // EXCEPTION : parameter not found !? diff --git a/js/app/views/CatalogUI.js b/js/app/views/CatalogUI.js index 1f3345b..42ab5ed 100644 --- a/js/app/views/CatalogUI.js +++ b/js/app/views/CatalogUI.js @@ -63,7 +63,8 @@ Ext.define('amdaUI.CatalogUI', { params[index] = item; }, this); - this.object.set('parameters', params); + this.object.set('parameters', params); + this.object.set('nbParameters', params.length); }, /** @@ -92,6 +93,24 @@ Ext.define('amdaUI.CatalogUI', { // return the update status return updateStatus; }, + + addInterval : function(start, stop) { + var row = this.TTGrid.getStore().getTotalCount(); + var me = this; + this.TTGrid.getSelectionModel().deselectAll(); + AmdaAction.addTTCacheInterval({'start' : start, 'stop' : stop, 'index' : row, 'isCatalog' : true},function (result, e) { + this.status = result.status; + if (!this.TTGrid.getStore().loading) { + this.TTGrid.getStore().reload({ + callback : function(records, options, success) { + me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() { + me.TTGrid.getView().select(row); + }, me); + } + }); + } + }, this); + }, updateCount : function() { this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount()); @@ -367,7 +386,7 @@ Ext.define('amdaUI.CatalogUI', { this.status = null; - if (this.object.get('fromPlugin')){ + if (this.object.get('fromPlugin') && (this.object.get('objName') != '')){ if (this.object.get('objFormat') && this.object.get('objFormat') != ''){ //From uploaded file AmdaAction.initTTCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), this.isCatalog, this.onAfterInit, this); @@ -381,7 +400,7 @@ Ext.define('amdaUI.CatalogUI', { var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id).linkedNode.data.nodeType; if (this.object.get('id') == '') { - AmdaAction.initTTCache(this.isCatalog, 1, this.onAfterInit,this); + AmdaAction.initTTCache(this.isCatalog, this.object.get('nbParameters'), this.onAfterInit,this); } else { //From existing TT file diff --git a/js/app/views/PlotComponents/PlotZoomPlug.js b/js/app/views/PlotComponents/PlotZoomPlug.js index 9ca6e28..68579d7 100644 --- a/js/app/views/PlotComponents/PlotZoomPlug.js +++ b/js/app/views/PlotComponents/PlotZoomPlug.js @@ -21,6 +21,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { id: 'plot-zoom-plug', ttModuleId: 'timetab-win', + catModuleId: 'catalog-win', win: null, form: null, @@ -28,7 +29,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { tabId: '', panelId: -1, - linkedTTNode: null, + linkedTTCatNode: null, constructor: function (config) { Ext.apply(this, config); @@ -87,7 +88,10 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { var start = this.form.getForm().findField('zoom-min-time').getValue(); var stop = this.form.getForm().findField('zoom-max-time').getValue(); - myDesktopApp.getLoadedModule(this.ttModuleId, true, function (module) { + var TTCatType = this.form.getForm().findField('ttcat-type').getValue(); + var isCatalog = (TTCatType == 'catalog'); + + myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { var targetModuleUI = module.getUiContent(); if (targetModuleUI) targetModuleUI.addInterval(start, stop); @@ -172,9 +176,9 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { this.form.getForm().findField('zoom-min-float').setVisible(this.zoomType != 'timeAxis'); this.form.getForm().findField('zoom-max-float').setVisible(this.zoomType != 'timeAxis'); - var ttNameField = this.form.getForm().findField('tt-name'); - if (ttNameField) - ttNameField.findParentByType('fieldset').setVisible(this.zoomType == 'timeAxis'); + var ttCatNameField = this.form.getForm().findField('ttcat-name'); + if (ttCatNameField) + ttCatNameField.findParentByType('fieldset').setVisible(this.zoomType == 'timeAxis'); }, resetMinMaxValue: function () { @@ -232,9 +236,18 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { ] }; + var insertTypeStore = Ext.create('Ext.data.Store', { + fields: ['key', 'name'], + data : [ + {"key":"timeTable", "name":"TimeTable"}, + {"key":"catalog", "name":"Catalog"} + ] + }); + + var me = this; var insertTTFieldSet = { xtype: 'fieldset', - title: 'TimeTable Insertion', + title: 'Intervals Insertion', name: 'tt-insertion-fieldset', collapsible: false, layout: { @@ -244,20 +257,32 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { }, items: [ { + xtype: 'combo', + fieldLabel: 'Insert In', + store: insertTypeStore, + queryMode: 'local', + displayField: 'name', + valueField: 'key', + editable: false, + value: 'timeTable', + name: 'ttcat-type' + }, + { xtype: 'textfield', - fieldLabel: 'TimeTable Name', - name: 'tt-name', + fieldLabel: 'Name', + name: 'ttcat-name', listeners: { render: function (o, op) { - var me = this; - var el = me.el; + var field = this; + var el = this.el; var dropTarget = Ext.create('Ext.dd.DropTarget', el, { ddGroup: 'explorerTree', notifyOver: function (ddSource, e, data) { - if ((data.records[0].data.nodeType == 'timeTable') && (data.records[0].data.leaf)) { - this.valid = true; - return this.dropAllowed; + var TTCatType = me.form.getForm().findField('ttcat-type').getValue(); + if (data.records[0].data.leaf && (data.records[0].data.nodeType == TTCatType)) { + this.valid = true; + return this.dropAllowed; } this.valid = false; return this.dropNotAllowed; @@ -265,7 +290,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { notifyDrop: function (ddSource, e, data) { if (!this.valid) return false; - me.setValue(data.records[0].get('text')); + field.setValue(data.records[0].get('text')); return true; } }); @@ -280,47 +305,61 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { handler: function () { var me = this; - var TTname = this.form.getForm().findField('tt-name').getValue(); + var TTCatType = this.form.getForm().findField('ttcat-type').getValue(); + var TTCatName = this.form.getForm().findField('ttcat-name').getValue(); - myDesktopApp.getLoadedModule(this.ttModuleId, true, function (module) { + var isCatalog = (TTCatType == 'catalog'); + myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { var targetModuleUI = module.getUiContent(); - if (me.linkedTTNode && (me.linkedTTNode.get('text') == TTname)) { + if (me.linkedTTCatNode && (me.linkedTTCatNode.get('text') == TTCatName) && (me.linkedTTCatNode.get('nodeType') == TTCatType)) { if (targetModuleUI) me.insertInterval(); else { - me.linkedTTNode.editLeaf(function () { + me.linkedTTCatNode.editLeaf(function () { me.insertInterval(); }); } } else { - if (TTname == '') { - me.linkedTTNode.editLeaf(function () { - me.insertInterval(); - }); - } - var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); - var ttRootNode = explorerTree.getRootNode().findChild('id', 'timeTable-treeRootNode', true); - amdaModel.InteractiveNode.preloadNodes(ttRootNode, function () { + var ttCatRootNode = explorerTree.getRootNode().findChild('id', isCatalog ? 'catalog-treeRootNode' : 'timeTable-treeRootNode', true); + amdaModel.InteractiveNode.preloadNodes(ttCatRootNode, function () { var nodeWithSameName = null; - if (TTname != '') - nodeWithSameName = ttRootNode.findChild('text', TTname, true); + if (TTCatName != '') + nodeWithSameName = ttCatRootNode.findChild('text', TTCatName, true); if (nodeWithSameName !== null) - me.linkedTTNode = nodeWithSameName; + me.linkedTTCatNode = nodeWithSameName; else { - var obj = Ext.create('amdaModel.TimeTable', {name: TTname, fromPlugin: true}); - me.linkedTTNode = Ext.create('amdaModel.TimeTableNode', { - leaf: true, - text: TTname, - nodeType: 'timeTable', - object: obj - }); + module.createLinkedNode(); + module.getLinkedNode().set('text', TTCatName); + me.linkedTTCatNode = module.getLinkedNode(); + var obj = { + name: TTCatName, + fromPlugin: true + }; + if (isCatalog) { + Ext.Msg.prompt('Define Parameters', 'Please enter parameters number for the new xatalog:', function(btn, text){ + if (btn == 'ok'){ + obj.nbParameters = parseInt(text,10); + if (isNaN(obj.nbParameters)) { + obj.nbParameters = 1; + } + module.createObject(obj); + me.linkedTTCatNode.editLeaf(function () { + me.insertInterval(); + }); + } + }); + return; + } + else { + module.createObject(obj); + } } - me.linkedTTNode.editLeaf(function () { + me.linkedTTCatNode.editLeaf(function () { me.insertInterval(); }); }); @@ -395,4 +434,4 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { }); return this.form; } -}); \ No newline at end of file +}); diff --git a/js/app/views/PlotTabResultUI.js b/js/app/views/PlotTabResultUI.js index 01fc6ca..0927dcd 100644 --- a/js/app/views/PlotTabResultUI.js +++ b/js/app/views/PlotTabResultUI.js @@ -78,6 +78,7 @@ Ext.define('amdaUI.PlotTabResultUI', { var size = this.getImageSize(); var me = this; + var insertIntervalItem = null; Ext.each(panelContext.plotArea.axes, function (axis) { //Events for zoom on a time axis var onMinTimeSelection = function (posX) { @@ -152,6 +153,15 @@ Ext.define('amdaUI.PlotTabResultUI', { }, scope: this }); + insertIntervalItem = { + text:'Insert Interval in TimeTable or Catalog', + handler : function(item, e) { + zoomPlugin.show(me.tabId, axis.id, panelContext.id); + zoomPlugin.resetMinMaxValue(); + me.panelImage.startZoom(true, 0/*me.toPixelOnResultImage(panelContext.y)*/, size.height /*me.toPixelOnResultImage(panelContext.height)*/, onMinTimeSelection, onMaxTimeSelection); + }, + scope: this + }; break; case 'y-left' : me.contextualMenu.add({ @@ -189,6 +199,11 @@ Ext.define('amdaUI.PlotTabResultUI', { } }); + + if (insertIntervalItem != null) { + me.contextualMenu.add('-'); + me.contextualMenu.add(insertIntervalItem); + } }, createPlotImage: function(resultFolder, plotFile) { @@ -307,7 +322,7 @@ Ext.define('amdaUI.PlotTabResultUI', { if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos)) me.createZoomItemsForPanel(panel.id); } - + if (me.contextualMenu.items.getCount() > 0) me.contextualMenu.add('-'); -- libgit2 0.21.2