Salome HOME
Updating date copyright information
[modules/adao.git] / src / daSalome / daGUI / daEficasWrapper / adaoEficasWrapper.py
index b724a933e02535566c80d39a429bf0e1cde542ca..c73948cd7fca2a2d34c4baf50aa50e89ad32fc58 100644 (file)
@@ -1,5 +1,5 @@
-# -*- coding: utf-8 -*-
-#  Copyright (C) 2010 EDF R&D
+#-*-coding:iso-8859-1-*-
+#  Copyright (C) 2010-2013 EDF R&D
 #
 #  This library is free software; you can redistribute it and/or
 #  modify it under the terms of the GNU Lesser General Public
@@ -25,10 +25,10 @@ import eficasSalome               # Import from EFICAS_SRC
 from InterfaceQT4 import qtEficas # Import from Eficas
 from PyQt4.QtGui  import *        # Import from PyQT
 from PyQt4.QtCore import *        # Import from PyQT
-from PyQt4.QtAssistant import *   # Import from PyQT
+from PyQt4.QtAssistant import *   # Import from PyQT
 
 from daUtils.adaoEficasEvent import *
-from daGuiImpl.adaoLogger import *
+from daUtils.adaoLogger import *
 
 #
 # ============================================
@@ -39,10 +39,10 @@ class AdaoEficasWrapper(eficasSalome.MyEficas):
 
     def __init__(self, parent):
         # Configuration de l'installation
-        # Permet à EFICAS de faire ses import correctement
+        # Permet à EFICAS de faire ses import correctement
         my_path = os.path.dirname(os.path.abspath(__file__))
         ADAO_INSTALL_DIR = my_path + "/../daEficas"
-        sys.path[:0]=[ADAO_INSTALL_DIR]
+        sys.path.insert(0,ADAO_INSTALL_DIR)
 
         self.__parent = parent
 
@@ -50,6 +50,8 @@ class AdaoEficasWrapper(eficasSalome.MyEficas):
 
       eficasSalome.MyEficas.__init__(self, self.__parent, code="ADAO", module="ADAO")
       self.connect(self.viewmanager.myQtab, SIGNAL('currentChanged(int)'), self.tabChanged)
+      self.menubar.hide()
+      self.toolBar.hide()
 
     def addJdcInSalome(self, jdcPath):
       debug("addJdcInSalome is called " + str(jdcPath))
@@ -58,7 +60,7 @@ class AdaoEficasWrapper(eficasSalome.MyEficas):
 
 #######
 #
-# Gestion des évènements provenant des widgets QT d'Eficas
+# Gestion des évènements provenant des widgets QT d'Eficas
 #
 #######
 
@@ -71,18 +73,18 @@ class AdaoEficasWrapper(eficasSalome.MyEficas):
 
 #######
 #
-# Méthodes gérant les boutons dans SALOME
+# Méthodes gérant les boutons dans SALOME
 #
 #######
 
-# Rq: Utilisation de la méthode str() pour passer d'un Qstring à un string
+# Rq: Utilisation de la méthode str() pour passer d'un Qstring à un string
 
     def adaofileNew(self, adao_case):
 
       qtEficas.Appli.fileNew(self)
       index = self.viewmanager.myQtab.currentIndex()
       adao_case.name          = str(self.viewmanager.myQtab.tabText(index))
-      adao_case.eficas_editor = self.viewmanager.dict_editors[index]
+      adao_case.setEditor(self.viewmanager.dict_editors[index])
       self.notifyObserver(EficasEvent.EVENT_TYPES.NEW, callbackId=adao_case)
 
     def adaoFileSave(self, adao_case):
@@ -92,7 +94,7 @@ class AdaoEficasWrapper(eficasSalome.MyEficas):
         index = self.viewmanager.myQtab.currentIndex()
         adao_case.name          = str(self.viewmanager.myQtab.tabText(index))
         adao_case.filename      = str(self.viewmanager.dict_editors[index].fichier)
-        adao_case.eficas_editor = self.viewmanager.dict_editors[index]
+        adao_case.setEditor(self.viewmanager.dict_editors[index])
         self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE, callbackId=adao_case)
 
     def adaoFileSaveAs(self, adao_case):
@@ -102,7 +104,7 @@ class AdaoEficasWrapper(eficasSalome.MyEficas):
         index = self.viewmanager.myQtab.currentIndex()
         adao_case.name          = str(self.viewmanager.myQtab.tabText(index))
         adao_case.filename      = str(self.viewmanager.dict_editors[index].fichier)
-        adao_case.eficas_editor = self.viewmanager.dict_editors[index]
+        adao_case.setEditor(self.viewmanager.dict_editors[index])
         self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE, callbackId=adao_case)
 
     def adaoFileOpen(self, adao_case):
@@ -115,7 +117,7 @@ class AdaoEficasWrapper(eficasSalome.MyEficas):
           index = self.viewmanager.myQtab.currentIndex()
           adao_case.name          = str(self.viewmanager.myQtab.tabText(index))
           adao_case.filename      = str(self.viewmanager.dict_editors[index].fichier)
-          adao_case.eficas_editor = self.viewmanager.dict_editors[index]
+          adao_case.setEditor(self.viewmanager.dict_editors[index])
           self.notifyObserver(EficasEvent.EVENT_TYPES.OPEN, callbackId=adao_case)
 
     def adaoFileClose(self, adao_case):
@@ -126,16 +128,14 @@ class AdaoEficasWrapper(eficasSalome.MyEficas):
         if res != 2: # l utilsateur a annule
           if close_editor.fichier is None:
             # Cas fichier vide
-            print "cas fichier vide"
             self.notifyObserver(EficasEvent.EVENT_TYPES.CLOSE, callbackId=close_editor)
           else:
             # Cas fichier existant
-            print "cas fichier existant"
             self.notifyObserver(EficasEvent.EVENT_TYPES.CLOSE, callbackId=close_editor)
 
 #######
 #
-# Méthodes auxiliares de gestion du GUI Eficas pour synchronisation
+# Méthodes auxiliares de gestion du GUI Eficas pour synchronisation
 # avec la partie GUI de SALOME
 #
 #######
@@ -149,12 +149,19 @@ class AdaoEficasWrapper(eficasSalome.MyEficas):
           break
       return rtn
 
+    def getCurrentEditor(self):
+      index = self.viewmanager.myQtab.currentIndex()
+      editor = None
+      if index >= 0:
+        editor = self.viewmanager.dict_editors[index]
+      return editor
+
 
 
 
 #######
 #
-# Méthodes secondaires permettant de gérer les observeurs du
+# Méthodes secondaires permettant de gérer les observeurs du
 # GUI d'Eficas
 #
 #######
@@ -172,82 +179,3 @@ class AdaoEficasWrapper(eficasSalome.MyEficas):
     def notifyObserver(self, eventType, callbackId=None):
       eficasEvent = EficasEvent(eventType, callbackId)
       self.__observer.processEficasEvent(self, eficasEvent)
-
-
-#######
-#
-# Deprecated code
-#
-#######
-
-    def openEmptyCase(self, callbackId):
-        qtEficas.Appli.fileNew(self)
-        self.removeCallbackId(callbackId)
-        self.setCallbackId(callbackId)
-
-    def getCaseName(self):
-      if self.__close_editor is None:
-        index = self.viewmanager.myQtab.currentIndex()
-        CaseName = self.viewmanager.myQtab.tabText(index)
-        return CaseName
-      else:
-        CaseName = str(self.__close_editor.fichier.split('/')[-1])
-        return CaseName
-
-    def getFileCaseName(self):
-      if self.__close_editor is None:
-        index = self.viewmanager.myQtab.currentIndex()
-        editor = self.viewmanager.dict_editors[index]
-        return editor.fichier
-      else:
-        return self.__close_editor.fichier
-
-    def Openfile(self, filename):
-      self.viewmanager.handleOpen(fichier=filename)
-
-    def handleOpenRecent(self):
-      """
-      @overload
-      """
-      idx = self.sender()
-      fichier = self.ficRecents[idx]
-      self.__file_open_name = fichier
-      self.notifyObserver(EficasEvent.EVENT_TYPES.OPEN)
-      self.__file_open_name = ""
-
-
-    def getOpenFileName(self):
-      return str(self.__file_open_name)
-
-
-    def fileClose(self):
-        """
-        @overload
-        """
-        index = self.viewmanager.myQtab.currentIndex()
-        self.__close_editor = self.viewmanager.dict_editors[index]
-        res = self.viewmanager.handleClose(self)
-        if res != 2: # l utilsateur a annule
-          if self.__close_editor.fichier is None:
-            # We have to destroy the case
-            self.notifyObserver(EficasEvent.EVENT_TYPES.DESTROY)
-            self.__myCallbackId.pop(self.__close_editor)
-          else:
-            # Il faudrait en faire plus -> Voir Edit dans SALOME !
-            self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
-            self.__myCallbackId.pop(self.__close_editor)
-        self.__close_editor = None
-        return res
-
-    def fileCloseAll(self):
-      """
-      @overload
-      """
-      while len(self.viewmanager.dict_editors) > 0:
-        self.viewmanager.myQtab.setCurrentIndex(0)
-        if self.viewmanager.myQtab.currentIndex() == 0:
-          res = self.fileClose()
-          if res==2 : return res   # l utilsateur a annule
-        else:
-          return 0
-