Salome HOME
Open and Edit case
[modules/adao.git] / src / daSalome / daGUI / daEficasWrapper / datassimEficasWrapper.py
index 5963037b1dd6a1a99747fdc7f10cd908fbeeab9a..8b83a7c52070111aca7b866f7f3111bf54196432 100644 (file)
@@ -19,6 +19,7 @@
 #
 
 from eficasWrapper import *
+from PyQt4 import QtGui,QtCore
 import sys
 
 # Configuration de l'installation
@@ -32,15 +33,34 @@ sys.path[:0]=[DATASSIM_INSTALL_DIR]
 # ================================================
 #
 class DatassimEficasWrapper(EficasWrapper):
+
+    __myCallbackId = {}
+    __close_editor = None
+    __file_open_name = ""
+
     def __init__(self, parent, code="DATASSIM"):
         EficasWrapper.__init__(self, parent, code)
 
+    # Association de l'objet editor avec le callbackId
+    def setCallbackId(self, callbackId):
+      index = self.viewmanager.myQtab.currentIndex()
+      self.__myCallbackId[self.viewmanager.dict_editors[index]] = callbackId
+
+    def getCallbackId(self):
+      if self.__close_editor is None:
+        index = self.viewmanager.myQtab.currentIndex()
+        return self.__myCallbackId[self.viewmanager.dict_editors[index]]
+      else:
+        return self.__myCallbackId[self.__close_editor]
+
     def fileSave(self):
         """
         @overload
         """
         qtEficas.Appli.fileSave(self)
-        self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
+        index = self.viewmanager.myQtab.currentIndex()
+        if index > -1 :
+          self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
 
     def fileSaveAs(self):
         """
@@ -49,10 +69,76 @@ class DatassimEficasWrapper(EficasWrapper):
         qtEficas.Appli.fileSaveAs(self)
         self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
 
-    def getCurrentFileName(self):
-       index = self.viewmanager.myQtab.currentIndex()
-       print index
-       rtn = ""
-       if index > 0 :
-         rtn  = self.viewmanager.myQtab.tabText(index)
-       return rtn
+    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 str(editor.fichier)
+      else:
+        return str(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 fileOpen(self):
+        """
+        @overload
+        """
+        fichier = QtGui.QFileDialog.getOpenFileName(self,
+                                                    self.trUtf8('Ouvrir Fichier'),
+                                                    self.CONFIGURATION.savedir,
+                                                    self.trUtf8('JDC Files (*.comm);;''All Files (*)'))
+        if fichier.isNull(): return
+        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)
+        res = self.fileClose()
+        if res==2 : return res   # l utilsateur a annule