From 74a22cb1272c6b4ac1bd6669e287dd1a6b532c6c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9?= Date: Wed, 28 Apr 2010 16:40:24 +0200 Subject: [PATCH] Edit popup --- .../daEficasWrapper/datassimEficasWrapper.py | 3 ++ .../daGUI/daGuiImpl/DATASSIMGUI_impl.py | 15 +++--- .../daGUI/daGuiImpl/datassimGuiManager.py | 53 +++++++++++++++++-- 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/src/daSalome/daGUI/daEficasWrapper/datassimEficasWrapper.py b/src/daSalome/daGUI/daEficasWrapper/datassimEficasWrapper.py index 01a6f64..eaba562 100644 --- a/src/daSalome/daGUI/daEficasWrapper/datassimEficasWrapper.py +++ b/src/daSalome/daGUI/daEficasWrapper/datassimEficasWrapper.py @@ -77,6 +77,9 @@ class DatassimEficasWrapper(EficasWrapper): CaseName = self.__close_editor.fichier.split('/')[-1] return CaseName + def Openfile(self, filename): + self.viewmanager.handleOpen(fichier=filename) + def fileOpen(self): """ @overload diff --git a/src/daSalome/daGUI/daGuiImpl/DATASSIMGUI_impl.py b/src/daSalome/daGUI/daGuiImpl/DATASSIMGUI_impl.py index 883f655..6423113 100644 --- a/src/daSalome/daGUI/daGuiImpl/DATASSIMGUI_impl.py +++ b/src/daSalome/daGUI/daGuiImpl/DATASSIMGUI_impl.py @@ -35,6 +35,7 @@ sgPyQt = SalomePyQt.SalomePyQt() # to be created for each study. It contains at least the ui component builder that # creates the menu and toolbar items (must be created for every study) +from daGuiImpl import datassimGuiHelper from daGuiImpl.datassimGuiManager import DatassimGuiUiComponentBuilder class GUIcontext: uiComponentBuilder = None @@ -105,14 +106,12 @@ def activeStudyChanged( studyID ): # called when popup menu is invoked # popup menu and menu context are passed as parameters def createPopupMenu( popup, context ): - pass -# activeStudyId = sgPyQt.getStudyId() -# if omaModuleHelper.verbose() : print "OMAGUI.createPopupMenu(): context = %s" % context -# ctx = _setContext( sgPyQt.getStudyId() ) -# selcount, selected = omaGuiHelper.getAllSelected(activeStudyId) -# if selcount == 1: -# selectedItem = omaGuiHelper.getSelectedItem(activeStudyId) -# popup = ctx.uiComponentBuilder.createPopupMenuOnItem(popup, activeStudyId, selectedItem) + activeStudyId = sgPyQt.getStudyId() + ctx = _setContext(sgPyQt.getStudyId()) + selcount, selected = datassimGuiHelper.getAllSelected(activeStudyId) + if selcount == 1: + selectedItem = datassimGuiHelper.getSelectedItem(activeStudyId) + popup = ctx.uiComponentBuilder.createPopupMenuOnItem(popup, activeStudyId, selectedItem) def OnGUIEvent(actionId) : """ diff --git a/src/daSalome/daGUI/daGuiImpl/datassimGuiManager.py b/src/daSalome/daGUI/daGuiImpl/datassimGuiManager.py index 231d7cb..b49f4eb 100644 --- a/src/daSalome/daGUI/daGuiImpl/datassimGuiManager.py +++ b/src/daSalome/daGUI/daGuiImpl/datassimGuiManager.py @@ -48,10 +48,14 @@ __cases__ = {} UI_ELT_IDS = Enumerate([ 'DATASSIM_MENU_ID', 'NEW_DATASSIMCASE_ID', + 'EDIT_DATASSIMCASE_POP_ID', + 'DELETE_DATASSIMCASE_POP_ID', + 'YACS_EXPORT_POP_ID', ],offset=950) ACTIONS_MAP={ UI_ELT_IDS.NEW_DATASSIMCASE_ID:"newDatassimCase", + UI_ELT_IDS.EDIT_DATASSIMCASE_POP_ID:"editDatassimCase", } class DatassimGuiUiComponentBuilder: @@ -76,6 +80,19 @@ class DatassimGuiUiComponentBuilder: sgPyQt.createMenu(a, mid) sgPyQt.createTool(a, tid) + # the following action are used in context popup + a = sgPyQt.createAction( UI_ELT_IDS.EDIT_DATASSIMCASE_POP_ID, "Edit case", "Edit case", "Edit the selected study case", "" ) + a = sgPyQt.createAction( UI_ELT_IDS.DELETE_DATASSIMCASE_POP_ID, "Delete case", "Delete case", "Delete the selected study case", "" ) + a = sgPyQt.createAction( UI_ELT_IDS.YACS_EXPORT_POP_ID, "Export to YACS", "Export to YACS", "Generate a YACS graph executing this case", "" ) + + def createPopupMenuOnItem(self,popup,salomeSudyId, item): + if datassimStudyEditor.isValidDatassimCaseItem(salomeSudyId, item): + popup.addAction( sgPyQt.action( UI_ELT_IDS.EDIT_DATASSIMCASE_POP_ID ) ) + popup.addAction( sgPyQt.action( UI_ELT_IDS.DELETE_DATASSIMCASE_POP_ID ) ) + popup.addAction( sgPyQt.action( UI_ELT_IDS.YACS_EXPORT_POP_ID ) ) + + return popup + class DatassimGuiActionImpl(EficasObserver): """ This class implements the ui actions concerning the management of oma study @@ -111,6 +128,22 @@ class DatassimGuiActionImpl(EficasObserver): def newDatassimCase(self): self.__dlgEficasWrapper.displayNew() + def editDatassimCase(self): + global __cases__ + salomeStudyId = datassimGuiHelper.getActiveStudyId() + salomeStudyItem = datassimGuiHelper.getSelectedItem(salomeStudyId) + case_key = (salomeStudyId, salomeStudyItem.GetName()) + try: + case = __cases__[case_key] + self.__dlgEficasWrapper.Openfile(case.get_name()) + callbackId = [salomeStudyId, salomeStudyItem] + self.__dlgEficasWrapper.setCallbackId(callbackId) + self.__dlgEficasWrapper.show() + except: + print "Oups - cannot edit case !" + traceback.print_exc() + + # ========================================================================== # Processing notifications from eficas # @@ -139,13 +172,14 @@ class DatassimGuiActionImpl(EficasObserver): new_case = DatassimCase() salomeStudyId = datassimGuiHelper.getActiveStudyId() salomeStudyItem = datassimStudyEditor.addInStudy(salomeStudyId, new_case) - case_key = (salomeStudyId, salomeStudyItem) + case_key = (salomeStudyId, salomeStudyItem.GetName()) __cases__[case_key] = new_case datassimGuiHelper.refreshObjectBrowser() callbackId = [salomeStudyId, salomeStudyItem] self.__dlgEficasWrapper.setCallbackId(callbackId) def _processEficasSaveEvent(self, eficasWrapper, eficasEvent): + global __cases__ callbackId = eficasEvent.callbackId if callbackId is None: raise DevelException("the callback data should not be None. Can't guess what are the study and case") @@ -156,13 +190,24 @@ class DatassimGuiActionImpl(EficasObserver): # Get Editor All infos we need ! file_name = eficasWrapper.getCaseName() if file_name != "" : - case_key = (targetSalomeStudyId, targetSalomeStudyItem) - case =__cases__[case_key] + # Get case + old_case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetName()) + case =__cases__[old_case_key] + + # Set new informations case.set_name(file_name) datassimStudyEditor.updateItem(targetSalomeStudyId, targetSalomeStudyItem, case) + + # Case key changed ! + new_case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetName()) + # A ne pas inverser !!! + __cases__.pop(old_case_key) + __cases__[new_case_key] = case + datassimGuiHelper.refreshObjectBrowser() def _processEficasDestroyEvent(self, eficasWrapper, eficasEvent): + global __cases__ callbackId = eficasEvent.callbackId if callbackId is None: raise DevelException("the callback data should not be None. Can't guess what are the study and case") @@ -170,7 +215,7 @@ class DatassimGuiActionImpl(EficasObserver): if ( targetSalomeStudyId is None ) or ( targetSalomeStudyItem is None ): raise DevelException("the parameters targetSalomeStudyId and targetSalomeStudyItem should not be None") - case_key = (targetSalomeStudyId, targetSalomeStudyItem) + case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetName()) __cases__.pop(case_key) datassimStudyEditor.removeItem(targetSalomeStudyId, targetSalomeStudyItem) datassimGuiHelper.refreshObjectBrowser() -- 2.39.2