From ebbb3638f39b8fc2076e5fb1de43ae72ffeda848 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 6 May 2019 10:27:27 +0200 Subject: [PATCH] Edit plot tab on double click --- js/app/controllers/AmdaModule.js | 9 +++++++-- js/app/controllers/InteractiveModule.js | 10 ++++++++-- js/app/controllers/PlotModule.js | 7 +++++++ js/app/models/PlotNode.js | 1 + js/app/models/PlotObjects/PlotRequestObject.js | 33 ++++++++++----------------------- js/app/models/PlotTabNode.js | 9 +++++++++ js/app/views/ExplorerUI.js | 7 +++++-- js/app/views/PlotComponents/PlotTabPanel.js | 14 +++++++++----- js/app/views/PlotUI.js | 12 ++++++++++-- 9 files changed, 66 insertions(+), 36 deletions(-) diff --git a/js/app/controllers/AmdaModule.js b/js/app/controllers/AmdaModule.js index 40cfcc4..cec714b 100644 --- a/js/app/controllers/AmdaModule.js +++ b/js/app/controllers/AmdaModule.js @@ -99,7 +99,12 @@ Ext.define('amdaDesktop.AmdaModule', { show : onshowfn, scope : this }); - } - win.show(); + } + if (!win.isVisible()) { + win.show(); + } + else if (onshowfn) { + onshowfn(); + } } }); diff --git a/js/app/controllers/InteractiveModule.js b/js/app/controllers/InteractiveModule.js index a8f9ccd..a39d17e 100644 --- a/js/app/controllers/InteractiveModule.js +++ b/js/app/controllers/InteractiveModule.js @@ -144,7 +144,13 @@ Ext.define('amdaDesktop.InteractiveModule', { // second arg 'true' is used in CatalogUI to mark if Grid Reconfiguration is needed this.getUiContent().setObject(this.linkedNode.get('object'), true); } - win.show(); + + if (!win.isVisible()) { + win.show(); + } + else if (onShowEvent) { + onShowEvent(); + } }, /** * Mechanism to attach a Module to the Workspace Explorer to enable interactions @@ -256,4 +262,4 @@ Ext.define('amdaDesktop.InteractiveModule', { return null; } -}); \ No newline at end of file +}); diff --git a/js/app/controllers/PlotModule.js b/js/app/controllers/PlotModule.js index d30a0e1..54a9d9e 100644 --- a/js/app/controllers/PlotModule.js +++ b/js/app/controllers/PlotModule.js @@ -208,5 +208,12 @@ Ext.define('amdaDesktop.PlotModule', { getWindowResult: function(winResultId){ if (!this.plotResultWindowsManager.get(winResultId)) return null; return this.plotResultWindowsManager.get(winResultId); + }, + + forceTabSelection: function(tabId) { + var uiContent = this.getUiContent(); + if (uiContent != null) { + uiContent.forceActiveTab(tabId); } + } }); diff --git a/js/app/models/PlotNode.js b/js/app/models/PlotNode.js index ec52b4f..7d0e71c 100644 --- a/js/app/models/PlotNode.js +++ b/js/app/models/PlotNode.js @@ -43,6 +43,7 @@ Ext.define('amdaModel.PlotNode', { me.appendChild(tabNode); }); } + this.set('tabs', tabs); } }, diff --git a/js/app/models/PlotObjects/PlotRequestObject.js b/js/app/models/PlotObjects/PlotRequestObject.js index cc56acb..3f91cde 100644 --- a/js/app/models/PlotObjects/PlotRequestObject.js +++ b/js/app/models/PlotObjects/PlotRequestObject.js @@ -30,8 +30,7 @@ Ext.define('amdaPlotObj.PlotRequestObject', { {name: 'one-file-per-interval', type: 'boolean'}, {name: 'last-plotted-tab', type: 'int', defaultValue: 0}, {name: 'last-tab-id', type: 'int', defaultValue: 0}, - {name: 'active-tab-id', type: 'int', defaultValue: 1}, - {name: 'all-in-one', type: 'boolean', defaultValue: false} + {name: 'active-tab-id', type: 'int', defaultValue: 1} ], hasMany: { @@ -77,7 +76,7 @@ Ext.define('amdaPlotObj.PlotRequestObject', { var recs = this.tabs().add({id : this.get('last-tab-id')}); recs[0].setDefaultValues(); this.dirty = true; - return recs[0]; + return recs[0]; }, removeTabById: function(tabId) { @@ -124,7 +123,6 @@ Ext.define('amdaPlotObj.PlotRequestObject', { requestValues['one-file-per-interval'] = this.get('one-file-per-interval'); requestValues['last-plotted-tab'] = this.get('last-plotted-tab'); requestValues['name'] = this.get('name'); - requestValues['all-in-one'] = this.get('all-in-one'); requestValues['timesrc'] = this.get('timesrc'); @@ -153,26 +151,15 @@ Ext.define('amdaPlotObj.PlotRequestObject', { requestValues['durationSec'] = this.get('durationSec'); } - requestValues['tabs'] = []; + requestValues['tabs'] = []; - if (this.get('all-in-one')) { - this.tabs().each(function (tab, index) { - requestValues['tabs'][index] = tab.getJsonValues(); - }); + this.tabs().each(function (tab, index) { + requestValues['tabs'][index] = tab.getJsonValues(); + }); - requestValues['active-tab-id'] = this.get('active-tab-id'); - requestValues['last-tab-id'] = this.get('last-tab-id'); - } - else { - var tab = this.tabs().getAt(this.get('active-tab-id')-1); - requestValues['tabs'][0] = tab.getJsonValues(); - - requestValues['tabs'][0]['id'] = "1"; - requestValues['active-tab-id'] = "1"; - requestValues['last-tab-id'] = "1"; - requestValues['last-plotted-tab'] = "0"; - } + requestValues['active-tab-id'] = this.get('active-tab-id'); + requestValues['last-tab-id'] = this.get('last-tab-id'); - return requestValues; + return requestValues; } -}); \ No newline at end of file +}); diff --git a/js/app/models/PlotTabNode.js b/js/app/models/PlotTabNode.js index c7321f3..f18b655 100644 --- a/js/app/models/PlotTabNode.js +++ b/js/app/models/PlotTabNode.js @@ -78,6 +78,15 @@ Ext.define('amdaModel.PlotTabNode', { default: break; } + }, + + editPlotTab : function() { + var me = this; + this.parentNode.editLeaf(function () { + myDesktopApp.getLoadedModule(me.get('moduleId'), true, function (module) { + module.forceTabSelection(me.get('tabid')); + }); + }); } }); diff --git a/js/app/views/ExplorerUI.js b/js/app/views/ExplorerUI.js index 31648d8..6165d0e 100644 --- a/js/app/views/ExplorerUI.js +++ b/js/app/views/ExplorerUI.js @@ -576,13 +576,13 @@ Ext.define('amdaUI.ExplorerUI', { }); } - if (record.isLeaf() || record.data.isParameter) + if (record.isLeaf() || record.data.isParameter || (record.data.tabs && (record.data.tabs.length > 0))) switch (record.get('nodeType')) { case 'myData' : case 'myDataParam' : case 'derivedParam' : - case 'timeTable' : + case 'timeTable' : case 'sharedtimeTable' : case 'sharedcatalog' : case 'catalog' : @@ -590,6 +590,9 @@ Ext.define('amdaUI.ExplorerUI', { case 'condition' : record.editLeaf(); break; + case 'plottab' : + record.editPlotTab(); + break; case 'localParam' : case 'remoteParam': case 'remoteSimuParam': diff --git a/js/app/views/PlotComponents/PlotTabPanel.js b/js/app/views/PlotComponents/PlotTabPanel.js index 3fec029..60ccac9 100644 --- a/js/app/views/PlotComponents/PlotTabPanel.js +++ b/js/app/views/PlotComponents/PlotTabPanel.js @@ -31,16 +31,20 @@ Ext.define('amdaPlotComp.PlotTabPanel', { setRequestObject: function(object) { + var me = this; this.removeAll(); this.object = object; - var selectedTab = this.object.get('active-tab-id'); + var haveSelectedTab = false; this.object.tabs().each(function (rec, index) { - var isSelected = false; - if (index+1 == selectedTab) - isSelected = true; + if (rec.get('id') == me.object.get('active-tab-id')) { + haveSelectedTab = true; + } + }); - this.addPlotTab(rec, isSelected); + this.object.tabs().each(function (rec, index) { + var isSelectedTab = haveSelectedTab ? (rec.get('id') == me.object.get('active-tab-id')) : (index == 0); + this.addPlotTab(rec, isSelectedTab); }, this); }, diff --git a/js/app/views/PlotUI.js b/js/app/views/PlotUI.js index f872777..add5bcc 100644 --- a/js/app/views/PlotUI.js +++ b/js/app/views/PlotUI.js @@ -111,7 +111,6 @@ Ext.define('amdaUI.PlotUI', { doPlot : function(){ this.updateObject(); - this.object.set('all-in-one', true); this.object.set('last-plotted-tab', this.plotTabs.getSelectedTabId()); var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); if (plotModule) @@ -172,6 +171,16 @@ Ext.define('amdaUI.PlotUI', { this.timeSelector.intervalSel.setInterval(dateStart, dateStop); }, + + forceActiveTab : function(tabId) { + for (var i = 0; i < this.plotTabs.items.getCount(); ++i) { + var plotTab = this.plotTabs.items.getAt(i).items.getAt(0); + if (plotTab.tabId == tabId) { + this.plotTabs.setActiveTab(i); + return; + } + } + }, updateLinkedToMultiPlotMode : function(isLinkedToMultiPlotMode) { this.timeSelector.setVisible(isLinkedToMultiPlotMode); @@ -183,7 +192,6 @@ Ext.define('amdaUI.PlotUI', { return; this.updateObject(); this.object.set('active-tab-id', this.plotTabs.getSelectedTabId()); - this.object.set('all-in-one', allTabs); if ((this.object.get('id') != '') && (plotModule.linkedNode.get('text') == this.object.get('name'))) { //update existing request -- libgit2 0.21.2