diff --git a/js/app/controllers/InteractiveModule.js b/js/app/controllers/InteractiveModule.js index a39d17e..866ecdf 100644 --- a/js/app/controllers/InteractiveModule.js +++ b/js/app/controllers/InteractiveModule.js @@ -37,12 +37,15 @@ Ext.define('amdaDesktop.InteractiveModule', { /** * Window Creation method of the Module */ - createWindow : function (onShowEvent) { + createWindow : function (onShowEvent, onAfterCreateObject) { if (this.linkedNode === null){ this.createLinkedNode(); } - this.createObject(); + this.createObject(); + if (onAfterCreateObject) { + onAfterCreateObject(); + } var desktop = this.app.getDesktop(); var win = desktop.getWindow(this.id); var me = this; diff --git a/js/app/controllers/PlotModule.js b/js/app/controllers/PlotModule.js index b99b995..414d02a 100644 --- a/js/app/controllers/PlotModule.js +++ b/js/app/controllers/PlotModule.js @@ -212,5 +212,25 @@ Ext.define('amdaDesktop.PlotModule', { me.getUiContent().addParameter(paramNode, true); }); } + }, + + editPlot : function(plotNode) { + var me = this; + var desktop = this.app.getDesktop(); + var win = desktop.getWindow(this.id); + if (win) { + // Plot UI is opened => add plot in a new tab + me.getUiContent().editPlot(plotNode); + win.show(); + } + else { + // Plot UI is closed + this.createWindow(null, function() { + //This is the onAfterCreateObject callback + //Add plot node to the multiplot object + me.linkedNode.get('object').plots().removeAll(); + me.linkedNode.get('object').plots().add(plotNode); + }); + } } }); diff --git a/js/app/models/PlotNode.js b/js/app/models/PlotNode.js index b190dcf..2b1cd0d 100644 --- a/js/app/models/PlotNode.js +++ b/js/app/models/PlotNode.js @@ -95,5 +95,17 @@ Ext.define('amdaModel.PlotNode', { default: break; } + }, + + //Override editInModule + editInModule : function (contextNode, onReady) + { + // set the contextNode of this node + this.set('contextNode',contextNode); + + var me = this; + myDesktopApp.getLoadedModule(this.get('moduleId'),true, function (module) { + module.editPlot(me); + }); } }); diff --git a/js/app/models/PlotObjects/MultiplotRequestObject.js b/js/app/models/PlotObjects/MultiplotRequestObject.js index 6fcad09..1d10dbd 100644 --- a/js/app/models/PlotObjects/MultiplotRequestObject.js +++ b/js/app/models/PlotObjects/MultiplotRequestObject.js @@ -62,7 +62,6 @@ Ext.define('amdaPlotObj.MultiplotRequestObject', { createNewPlotFromObject: function(plotObject) { var plotNode = Ext.create('amdaModel.PlotNode', { leaf : true, - contextNode : this }); plotNode.set('object',plotObject); this.plots().add(plotNode); diff --git a/js/app/views/PlotComponents/PlotTabContent.js b/js/app/views/PlotComponents/PlotTabContent.js index c5f6128..b681b6f 100644 --- a/js/app/views/PlotComponents/PlotTabContent.js +++ b/js/app/views/PlotComponents/PlotTabContent.js @@ -83,7 +83,10 @@ Ext.define('amdaPlotComp.PlotTabContent', { width: 300, buttons: Ext.Msg.OKCANCEL, icon: Ext.Msg.WARNING, - fn : me.overwritePlot, + fn : function(btn) { + if (btn == 'cancel') return; + me.saveProcess(true); + }, scope : me }); } @@ -100,11 +103,6 @@ Ext.define('amdaPlotComp.PlotTabContent', { }); }, - overwritePlot : function(btn) { - if (btn == 'cancel') return; - this.saveProcess(true); - }, - saveProcess : function(toRename) { if (toRename) { this.plotNode.update(); diff --git a/js/app/views/PlotComponents/PlotTabPanel.js b/js/app/views/PlotComponents/PlotTabPanel.js index 6e37018..f280965 100644 --- a/js/app/views/PlotComponents/PlotTabPanel.js +++ b/js/app/views/PlotComponents/PlotTabPanel.js @@ -38,6 +38,17 @@ Ext.define('amdaPlotComp.PlotTabPanel', { addPlotNode: function(plotNode, selectTab) { + for (i = 0; i < this.items.getCount(); ++i) + { + var tabItem = this.items.getAt(i); + var tabContent = tabItem.items.getAt(0); + if (plotNode == tabContent.plotNode) { + //Already opened => select tab + this.setActiveTab(tabItem); + return; + } + } + var tabNumber = this.getTabBar().items.getCount(); var tabContent = new amdaPlotComp.PlotTabContent({plotNode: plotNode, tabIndex: tabNumber-1}); var me = this; diff --git a/js/app/views/PlotUI.js b/js/app/views/PlotUI.js index ba2c0c0..68c5734 100644 --- a/js/app/views/PlotUI.js +++ b/js/app/views/PlotUI.js @@ -69,6 +69,10 @@ Ext.define('amdaUI.PlotUI', { } } }, + + editPlot : function(plotNode) { + this.plotTabs.addPlotNode(plotNode, true); + }, /** * plot method called by 'Do Plot' button to launch the plot process diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index 68b972f..3f87a31 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -151,7 +151,6 @@ class AmdaAction $isParameter = false; $isAddable = false; $isSimulation = false; - $plotTabs = FALSE; $rank = null; $skip = FALSE; @@ -185,19 +184,6 @@ class AmdaAction else { $info = $id; } - - $isLeaf = isset($objplot->tabs); - if ($isLeaf) { - $plotTabs = array(); - foreach ($objplot->tabs as $index => $tab) { - $plotTabs[$index] = array( - "name" => (!empty($tab->{'tab-name'})) ? $tab->{'tab-name'} : "Plot ".($index+1), - "id" => $tab->id, - ); - } - } - else - $plotTabs = FALSE; break; // case 'alias': @@ -597,7 +583,7 @@ class AmdaAction } $childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info, - 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter, 'dim_1' => $dim_1, 'dim_2' => $dim_2, 'tabs' => $plotTabs, + 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter, 'dim_1' => $dim_1, 'dim_2' => $dim_2, 'component_info' => isset($component_info) ? $component_info : NULL, 'iconCls' => isset($iconCls) ? $iconCls : NULL ); } @@ -826,7 +812,6 @@ class AmdaAction break; case 'condition' : case 'request' : - case 'plottab' : $objectMgr = new RequestMgr($obj->nodeType); break; case 'alias' : @@ -916,7 +901,6 @@ class AmdaAction break; case 'condition' : case 'request' : - case 'plottab' : $objectMgr = new RequestMgr($obj->nodeType); break; default: diff --git a/php/classes/RequestMgr.php b/php/classes/RequestMgr.php index c8c5bde..b03af5d 100644 --- a/php/classes/RequestMgr.php +++ b/php/classes/RequestMgr.php @@ -30,7 +30,7 @@ class RequestMgr extends AmdaObjectMgr $this->attributes = array('name' => ''); $this->optionalAttributes = array(); - if ($type == 'request' || $type == 'plottab') + if ($type == 'request' ) { $this->id_prefix = 'req_'; } @@ -73,47 +73,11 @@ class RequestMgr extends AmdaObjectMgr public function validNameObject($p) { - if ($this->type == 'plottab') { - if (empty($p->name)) { - return array('valid' => false, 'error' => 'Name is required'); - } - return array('valid' => true); - } return parent::validNameObject($p); } public function renameObject($p) { - if ($this->type == 'plottab') { - //Rename a plot tab - if (!isset($p->parent) || empty($p->parent)) { - return array('error' => 'Missing parent definition'); - } - $plotObj = $this->getObject($p->parent); - if (is_array($plotObj) && isset($plotObj['error'])) { - return array('error' => $plotObj['error']); - } - if (!isset($plotObj->tabs)) { - return array('error' => 'Cannot retrieve tab in plot request'); - } - $renameOK = FALSE; - foreach ($plotObj->tabs as &$tab) { - if ($tab->id == $p->id) { - $tab->{'tab-name'} = $p->name; - $renameOK = TRUE; - break; - } - } - if (!$renameOK) { - return array('error' => 'Cannot retrieve tab in plot request 2'); - } - //Save modification - $file = fopen(USERREQDIR.$p->parent, 'w'); - fwrite($file, json_encode($plotObj)); - fclose($file); - - return array('id' => $p->id); - } return parent::renameObject($p); } @@ -225,17 +189,6 @@ class RequestMgr extends AmdaObjectMgr } $additional = array(); - if ($this->type == 'request') { - $additional['tabs'] = array(); - if (isset($p->tabs)) { - foreach ($p->tabs as $index => $tab) { - $additional['tabs'][$index] = array( - "name" => (!empty($tab->{'tab-name'})) ? $tab->{'tab-name'} : "Plot ".($index+1), - "id" => $tab->id, - ); - } - } - } $this->descFileName = USERREQDIR.$this->id; $p->id = $this->id; -- libgit2 0.21.2