]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Gestion de la sélection dans l'arbre d'étude
authorAndré Ribes <andre.ribes@edf.fr>
Wed, 23 Feb 2011 13:49:20 +0000 (14:49 +0100)
committerAndré Ribes <andre.ribes@edf.fr>
Wed, 23 Feb 2011 13:49:20 +0000 (14:49 +0100)
src/daSalome/daGUI/daEficasWrapper/adaoEficasWrapper.py
src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py

index 98ac5a9244faf3086c9cc68d64de50ca3e1df463..b64544c9250ad5eea6966f46d93796ccd744aaa4 100644 (file)
@@ -65,7 +65,10 @@ class AdaoEficasWrapper(eficasSalome.MyEficas):
 
     def tabChanged(self, index):
       debug("tabChanged " + str(index))
-      self.notifyObserver(EficasEvent.EVENT_TYPES.TABCHANGED, callbackId=self.viewmanager.dict_editors[index])
+      # This signal is also emit when a new case is created/added
+      # On regarde que le dictionnaire contient l'index
+      if index in self.viewmanager.dict_editors.keys():
+        self.notifyObserver(EficasEvent.EVENT_TYPES.TABCHANGED, callbackId=self.viewmanager.dict_editors[index])
 
     def addJdcInSalome(  self, jdcPath ):
       # On gere nous meme l'etude
@@ -147,18 +150,13 @@ class AdaoEficasWrapper(eficasSalome.MyEficas):
     def getOpenFileName(self):
       return str(self.__file_open_name)
 
-    def selectCase(self, callbackId):
+    def selectCase(self, editor):
       rtn = False
-      for editor, myCallbackId in self.__myCallbackId.iteritems():
-        if myCallbackId[0] == callbackId[0]:
-          if myCallbackId[1].GetID() == callbackId[1].GetID():
-            try:
-              for indexEditor in self.viewmanager.dict_editors.keys():
-                if editor is self.viewmanager.dict_editors[indexEditor]:
-                  self.viewmanager.myQtab.setCurrentIndex(indexEditor)
-                  rtn = True
-            except:
-              pass
+      for indexEditor in self.viewmanager.dict_editors.keys():
+        if editor is self.viewmanager.dict_editors[indexEditor]:
+          self.viewmanager.myQtab.setCurrentIndex(indexEditor)
+          rtn = True
+          break
       return rtn
 
     def fileClose(self):
index eafa6446b03dde81c55bf15e98e12ec603543bba..4fffb9c3aef1dbb4855e29f43ca4165bda7a64d6 100644 (file)
@@ -27,6 +27,7 @@ __author__ = "aribes/gboulant"
 
 import traceback
 from PyQt4.QtCore import QObject
+from PyQt4.QtCore import *        # Import from PyQT
 from PyQt4 import QtGui,QtCore
 import SalomePyQt
 sgPyQt = SalomePyQt.SalomePyQt()
@@ -83,7 +84,6 @@ class AdaoCaseManager(EficasObserver):
     # Value == objet AdaoCase()
     self.cases = {}
 
-
     # Création des deux managers
     self.salome_manager = AdaoGuiUiComponentBuilder()
     self.eficas_manager = AdaoEficasWrapper(parent=SalomePyQt.SalomePyQt().getDesktop())
@@ -108,11 +108,23 @@ class AdaoCaseManager(EficasObserver):
     # Cela simplifier grandement le code
     sgPyQt.setViewClosable(self.eficas_viewId, False)
 
+    # On s'abonne au gestionnaire de selection
+    self.selection_manager = sgPyQt.getSelection()
+    QtCore.QObject.connect(self.selection_manager, QtCore.SIGNAL('currentSelectionChanged()'), self.currentSelectionChanged)
+
   def activate(self):
-    self.__dlgEficasWrapper.setEnabled(True)
+    self.eficas_manager.setEnabled(True)
 
   def deactivate(self):
-    self.__dlgEficasWrapper.setEnabled(False)
+    self.eficas_manager.setEnabled(False)
+
+  def currentSelectionChanged(self):
+    adaoLogger.debug("currentSelectionChanged")
+    salomeStudyItem = adaoGuiHelper.getSelectedItem()
+    for case_name, adao_case in self.cases.iteritems():
+      if adao_case.salome_study_item.GetID() == salomeStudyItem.GetID():
+        self.eficas_manager.selectCase(adao_case.eficas_editor)
+        break
 
   def _processEficasTabChanged(self, eficasWrapper, eficasEvent):
     """