From ca0a847af7fa0984f05319776a8e7c53f2b22565 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Ribes?= Date: Thu, 23 Dec 2010 16:37:42 +0100 Subject: [PATCH] Correction de la fonction Remove --- .../daEficasWrapper/adaoEficasWrapper.py | 8 ++-- .../daGUI/daGuiImpl/adaoGuiManager.py | 39 +++++++++++-------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/daSalome/daGUI/daEficasWrapper/adaoEficasWrapper.py b/src/daSalome/daGUI/daEficasWrapper/adaoEficasWrapper.py index f9b4056..68cf220 100644 --- a/src/daSalome/daGUI/daEficasWrapper/adaoEficasWrapper.py +++ b/src/daSalome/daGUI/daEficasWrapper/adaoEficasWrapper.py @@ -60,14 +60,14 @@ class AdaoEficasWrapper(eficasSalome.MyEficas): # On gere nous meme l'etude pass - def fileNew(self): + def fileNew(self): """ @overload """ qtEficas.Appli.fileNew(self) self.notifyObserver(EficasEvent.EVENT_TYPES.NEW) - def openEmptyCase(self, callbackId): + def openEmptyCase(self, callbackId): qtEficas.Appli.fileNew(self) self.removeCallbackId(callbackId) self.setCallbackId(callbackId) @@ -190,10 +190,12 @@ class AdaoEficasWrapper(eficasSalome.MyEficas): def removeCallbackId(self, callbackId): key_to_remove = None + print callbackId for k, v in self.__myCallbackId.iteritems(): + print k, v if v[0] == callbackId[0] and v[1].GetID() == callbackId[1].GetID(): key_to_remove = k - if key_to_remove is not None: + if key_to_remove is not None: del self.__myCallbackId[key_to_remove] else: print "Oups - cannot find callbackId" diff --git a/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py b/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py index 272a81e..3c98d52 100644 --- a/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py +++ b/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py @@ -165,6 +165,8 @@ class AdaoGuiActionImpl(EficasObserver): def activate(self): self.showEficas() + # Actions from SALOME GUI + def newAdaoCase(self): self.showEficas() self.__dlgEficasWrapper.fileNew() @@ -227,40 +229,45 @@ class AdaoGuiActionImpl(EficasObserver): salomeStudyItem = adaoGuiHelper.getSelectedItem(salomeStudyId) callbackId = [salomeStudyId, salomeStudyItem] case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId) + # If case is in eficas close it ! if case_open_in_eficas: + # fileClose: remove the CallbackId + # fileClose: sends a destroy event self.__dlgEficasWrapper.fileClose() - - # Test if case exists - case_key = (salomeStudyId, salomeStudyItem.GetID()) - if __cases__.has_key(case_key): - __cases__.pop(case_key) - adaoStudyEditor.removeItem(salomeStudyId, salomeStudyItem) - adaoGuiHelper.refreshObjectBrowser() - - # Remove Callback in adaoEficasWrapper - self.__dlgEficasWrapper.removeCallbackId(callbackId) + else: + # Test if case exists + case_key = (salomeStudyId, salomeStudyItem.GetID()) + if __cases__.has_key(case_key): + __cases__.pop(case_key) + adaoStudyEditor.removeItem(salomeStudyId, salomeStudyItem) + adaoGuiHelper.refreshObjectBrowser() def exportCaseToYACS(self): global __cases__ + + # Get case from study salomeStudyId = adaoGuiHelper.getActiveStudyId() salomeStudyItem = adaoGuiHelper.getSelectedItem(salomeStudyId) case_key = (salomeStudyId, salomeStudyItem.GetID()) case = __cases__[case_key] + # Generates YACS schema and export it msg = case.exportCaseToYACS() + + # If msg is not empty -> error found if msg != "": adaoGuiHelper.gui_warning(self.__parent, msg) # ========================================================================== - # Processing notifications from eficas + # Processing notifications from adaoEficasWrapper # __processOptions={ - EficasEvent.EVENT_TYPES.CLOSE : "_processEficasCloseEvent", - EficasEvent.EVENT_TYPES.SAVE : "_processEficasSaveEvent", - EficasEvent.EVENT_TYPES.NEW : "_processEficasNewEvent", - EficasEvent.EVENT_TYPES.DESTROY : "_processEficasDestroyEvent", - EficasEvent.EVENT_TYPES.OPEN : "_processEficasOpenEvent", + EficasEvent.EVENT_TYPES.CLOSE : "_processEficasCloseEvent", + EficasEvent.EVENT_TYPES.SAVE : "_processEficasSaveEvent", + EficasEvent.EVENT_TYPES.NEW : "_processEficasNewEvent", + EficasEvent.EVENT_TYPES.DESTROY : "_processEficasDestroyEvent", + EficasEvent.EVENT_TYPES.OPEN : "_processEficasOpenEvent", EficasEvent.EVENT_TYPES.REOPEN : "_processEficasReOpenEvent" } def processEficasEvent(self, eficasWrapper, eficasEvent): -- 2.39.2