]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Edit popup
authorAndré <andre.ribes@edf.fr>
Wed, 28 Apr 2010 14:40:24 +0000 (16:40 +0200)
committerAndré <andre.ribes@edf.fr>
Wed, 28 Apr 2010 14:40:24 +0000 (16:40 +0200)
src/daSalome/daGUI/daEficasWrapper/datassimEficasWrapper.py
src/daSalome/daGUI/daGuiImpl/DATASSIMGUI_impl.py
src/daSalome/daGUI/daGuiImpl/datassimGuiManager.py

index 01a6f6468d9814cba83ce2d0992eaad58041f72b..eaba562c76f7563555cea8d524a89bb2296d1b7a 100644 (file)
@@ -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
index 883f6552872805a4e97b70fbdcea0a709e03f3f4..6423113010b1428bfb8fe4b0647f3d66affab486 100644 (file)
@@ -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) :
     """
index 231d7cbaee604cfc10c1a96ff0a90d48e24bc822..b49f4eb55b9d091b09c54c4547e355f60e59048c 100644 (file)
@@ -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()