Salome HOME
CCAR: creation V1_13a1 a partir de la branche Liv-V1_12
[tools/eficas.git] / Editeur / bureau.py
index ca57be47117bb5f3e96c7fa78a014f7c41d64a21..b1a408d561db988a8bf760b681008042c17ea377 100644 (file)
@@ -1,55 +1,90 @@
+# -*- coding: utf-8 -*-
+#            CONFIGURATION MANAGEMENT OF EDF VERSION
+# ======================================================================
+# COPYRIGHT (C) 1991 - 2002  EDF R&D                  WWW.CODE-ASTER.ORG
+# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
+# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
+# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
+# (AT YOUR OPTION) ANY LATER VERSION.
+#
+# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
+# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
+# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
+# GENERAL PUBLIC LICENSE FOR MORE DETAILS.
+#
+# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
+# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
+#    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
+#
+#
+# ======================================================================
 """
    Ce module contient la classe BUREAU qui gere les JDC ouverts
 """
 # Modules Python
-import os,string
+import os,string,sys
 import traceback
 import Pmw
-from tkFileDialog import askopenfilename,asksaveasfilename
-from tkMessageBox import showinfo,askyesno,showerror
+from widgets import askopenfilename,asksaveasfilename
+from widgets import showinfo,askyesno,showerror
 
 # Modules Eficas
 import splash
 import prefs
 import convert
 import generator
+import AIDE
+import os
 from jdcdisplay import JDCDISPLAY
-from utils import extension,stripPath,save_in_file
-from widgets import Fenetre,Ask_Format_Fichier
+from utils import extension_fichier,stripPath,save_in_file
+from widgets import Fenetre,Ask_Format_Fichier,FenetreSurLigneWarning
 from fenetre_mc_inconnus import fenetre_mc_inconnus
+from Ihm import CONNECTOR
+from Traducteur import traduitV7V8 
+
+import comploader
 
 class BUREAU:
    menu_defs=[
               ('Fichier',[
-                           ('Nouveau','newJDC'),
-                           ('Ouvrir','openJDC'),
-                           ('Enregistrer','saveJDC'),
-                           ('Enregistrer sous','saveasJDC'),
+                           ('Nouveau','newJDC','<Control-n>'),
+                           ('Ouvrir','openJDC','<Control-o>'),
+                           ('Enregistrer','saveJDC','<Control-e>'),
+                           ('Enregistrer sous','saveasJDC','<Control-s>'),
                            None,
-                           ('Fermer','closeJDC'),
-                           ('Quitter','exitEFICAS'),
+                           ('Fermer','closeJDC','<Control-f>'),
+                           ('Quitter','exitEFICAS','<Control-q>'),
                          ]
               ),
               ('Edition',[
-                           ('Copier','copy'),
-                           ('Couper','cut'),
-                           ('Coller','paste'),
+                           ('Copier','copy','<Control-c>'),
+                           ('Couper','cut','<Control-x>'),
+                           ('Coller','paste','<Control-v>'),
                          ]
               ),
               ('Jeu de commandes',[
-                                   ('Rapport de validation','visuCRJDC'),
-                                   ('Fichier à plat','visu_a_plat'),
+                                   ('Rapport de validation','visuCRJDC','<Control-r>'),
+                                   ('Fichier à plat','visu_a_plat','<Control-p>'),
                                    ('Fichier .py','visuJDC_py'),
-                                   ('Fichier source','visu_txt_brut_JDC'),
+                                   ('Fichier source','visu_txt_brut_JDC','<Control-b>'),
                                    ('Paramètres Eficas','affichage_fichier_ini'),
                                    ('Mots-clés inconnus','mc_inconnus'),
                                   ]
               ),
+              ('Traduction',[
+                             ('Traduction v7 en v8','TraduitFichier','<Control-t>','Ctrl+T')
+                            ]
+              ),
+              ('Aide',[
+                        ('Aide EFICAS','aideEFICAS'),
+                      ]
+              ),
              ]
 
    button_defs  =      (('New24',"newJDC","Création d'un nouveau fichier",'always'),
                         ('Open24',"openJDC","Ouverture d'un fichier existant",'always'),
                         ('Save24',"saveJDC","Sauvegarde du fichier courant",'always'),
+                        ('Fermer24',"closeJDC","Fermeture du fichier courant",'always'),
                         ('Zoom24',"visuJDC","Visualisation du fichier de commandes",'always'),
                         None,
                         ('Copy24',"copy","Copie l'objet courant",'jdc'),
@@ -71,17 +106,21 @@ class BUREAU:
    def __init__(self,appli,parent):
       self.parent=parent
       self.appli=appli
-      splash._splash.configure(text = "Création du bureau")
+      if self.appli.test == 0 :
+         splash._splash.configure(text = "Création du bureau")
       self.nb = Pmw.NoteBook(self.parent,raisecommand=self.selectJDC)
       self.nb.pack(fill='both',expand=1)
       self.JDCDisplay_courant=None
       self.fileName=None
       self.liste_JDCDisplay=[]
+      comploader.charger_composants()
       self.cree_cataitem()
+      self.text_reel=""
+      self.initialdir = self.appli.CONFIGURATION.initialdir
 
    def cree_cataitem(self):
       """
-          On récupère dans l'extension readercata les variables 
+          On récupère dans l'appli_composant readercata les variables 
           qui servent par la suite pour la création des JDC
       """
       self.cataitem=self.appli.readercata.cataitem
@@ -101,27 +140,61 @@ class BUREAU:
       if len(self.liste_JDCDisplay) == 0 : return
       #if self.JDCDisplay_courant : self.JDCDisplay_courant.jdc.unset_context()
       numero_jdc = self.nb.index(self.nb.getcurselection())
+      self.JDCDisplay_courant.unselect()
       self.JDCDisplay_courant = self.liste_JDCDisplay[numero_jdc]
       self.JDC = self.JDCDisplay_courant.jdc
-      #self.JDC.set_context()
       self.JDCName = self.JDC.nom
+      self.JDCDisplay_courant.select()
+      #print "selectJDC",numero_jdc,self.JDCDisplay_courant,self.JDCName
+
 
-   def newJDC(self):
+   def newJDC_include(self,event=None):
+      """
+          Initialise un nouveau JDC include vierge
+      """
+      import Extensions.jdc_include
+      JdC_aux=Extensions.jdc_include.JdC_include
+
+      self.appli.statusbar.reset_affichage_infos()
+
+      CONTEXT.unset_current_step()
+      jaux=self.cata[0].JdC(procedure="",appli=self.appli,
+                         cata=self.cata,cata_ord_dico=self.cata_ordonne_dico,
+                         rep_mat=self.appli.CONFIGURATION.rep_mat,
+                         )
+      jaux.analyse()
+
+      J=JdC_aux(procedure="",appli=self.appli,
+                         cata=self.cata,cata_ord_dico=self.cata_ordonne_dico,
+                         jdc_pere=jaux,
+                         rep_mat=self.appli.CONFIGURATION.rep_mat,
+                         )
+      J.analyse()
+      self.JDCName=J.nom
+      self.fileName=None
+      self.ShowJDC(J,self.JDCName)
+      self.appli.toolbar.active_boutons()
+      return J
+
+   def newJDC(self,event=None):
       """
           Initialise un nouveau JDC vierge
       """
       self.appli.statusbar.reset_affichage_infos()
 
       CONTEXT.unset_current_step()
-      J=self.cata[0].JdC(cata=self.cata,
-                         cata_ord_dico=self.cata_ordonne_dico,
-                         appli=self.appli)
+      J=self.cata[0].JdC(procedure="",appli=self.appli,
+                         cata=self.cata,cata_ord_dico=self.cata_ordonne_dico,
+                         rep_mat=self.appli.CONFIGURATION.rep_mat,
+                         )
+      J.analyse()
       self.JDCName=J.nom
       self.fileName=None
       self.ShowJDC(J,self.JDCName)
       self.appli.toolbar.active_boutons()
+      return J
 
-   def ShowJDC(self,JDC,nom,label_onglet=None):
+   def ShowJDC(self,JDC,nom,label_onglet=None,JDCDISPLAY=JDCDISPLAY,enregistre="non"):
       """
           Lance l'affichage du JDC cad création du JDCDisplay
           Rajoute le JDCDisplay à la liste des JDCDisplay si label_onglet == None cad si on crée
@@ -129,9 +202,8 @@ class BUREAU:
       """
       self.JDC=JDC
       self.JDCName = self.JDC.nom = nom
-      #XXX CCAR: pour le moment mis en commentaire
-      #self.JDC.set_context()
       if label_onglet == None :
+          # On veut un nouvel onglet
           label_onglet = self.GetLabelJDC()
           self.nb.add(label_onglet,tab_text = nom,tab_width=20)
           new = 'oui'
@@ -141,13 +213,54 @@ class BUREAU:
       if new == 'oui':
           self.liste_JDCDisplay.append(self.JDCDisplay_courant)
       self.JDCDisplay_courant.modified='n'
-      self.JDCDisplay_courant.fichier=self.fileName
+      if enregistre != "non" :
+         self.JDCDisplay_courant.fichier=self.fileName
+      else :
+         self.initialdir = self.appli.CONFIGURATION.rep_user
       self.nb.selectpage(label_onglet)
       self.nb.setnaturalsize()
+      self.nb.bind_all("<Key-Next>",lambda e,s=self:s.selectArbreDown())
+      self.nb.bind_all("<Key-Prior>",lambda e,s=self:s.selectArbreUp())
+      self.nb.bind_all("<Insert>",lambda e,s=self:s.deplieReplieNode())
       texte = "Jeu de commandes :" + self.JDCName+" ouvert"
+      CONNECTOR.Connect(JDC,"close",self.onClose,(self.JDCDisplay_courant,))
       self.appli.affiche_infos(texte)
 
-   def closeJDC (self) :
+   def onClose(self,jdcdisplay):
+      #print "onClose",jdcdisplay
+      self.closeJDCDISPLAY(jdcdisplay)
+
+   def closeJDCDISPLAY(self,jdc):
+      """
+        Ferme le jdcdisplay spécifié par l'argument jdc
+      """
+      if jdc is self.JDCDisplay_courant:
+         # on ferme le jdcdisplay courant
+         self.closeSelectedJDC()
+      else:
+         # on ferme un autre jdcdisplay que le courant
+         old_JDCDisplay=self.JDCDisplay_courant
+         old_page=self.nb.getcurselection()
+
+         self.JDCDisplay_courant=jdc
+         self.JDC=jdc.jdc
+         numero_jdc=self.liste_JDCDisplay.index(jdc)
+         self.nb.selectpage(numero_jdc)
+         #print numero_jdc
+      
+         self.closeSelectedJDC()
+         self.JDCDisplay_courant=old_JDCDisplay
+         self.JDC=old_JDCDisplay.jdc
+         self.nb.selectpage(old_page)
+
+   def closeJDC (self,event=None) :
+      """
+          Ferme le JDC associé au JDCDISPLAY selectionné
+      """
+      if self.JDCDisplay_courant :
+         self.JDCDisplay_courant.jdc.close()
+
+   def closeSelectedJDC (self) :
       """
       Ferme le JDC courant et détruit l'onglet associé dans le notebook self.nb
       """
@@ -160,21 +273,24 @@ class BUREAU:
               if test == 0 :
                   self.appli.affiche_infos("Sauvegarde impossible")
                   return
+
+      CONNECTOR.Disconnect(self.JDCDisplay_courant.jdc,"close",self.onClose,(self.JDCDisplay_courant,))
+      self.JDCDisplay_courant.supprime()
       self.JDCDisplay_courant.jdc.supprime()
       self.liste_JDCDisplay.remove(self.JDCDisplay_courant)
+      # Active le mecanisme de selection du notebook (selectJDC)
       self.nb.delete(self.nb.getcurselection())
-      #XXX CCAR: pour le moment mis en commentaire
-      #self.JDC.unset_context()
-      self.JDC = None
+
       try:
           index = self.nb.index(self.nb.getcurselection())
           self.JDCDisplay_courant = self.liste_JDCDisplay[index]
           self.JDC = self.JDCDisplay_courant.jdc
       except:
+          self.JDC = None
           self.JDCDisplay_courant = None
           self.appli.toolbar.inactive_boutons()
 
-   def visuCRJDC(self):
+   def visuCRJDC(self,event=None):
       return self.visuCR(mode='JDC')
 
    def visuCR(self,mode):
@@ -183,8 +299,10 @@ class BUREAU:
       """
       if mode == 'JDC':
           if not hasattr(self,'JDC') : return
+          if self.JDC == None : return
           titre="rapport de validation du jeu de commandes courant"
           cr = self.JDC.report()
+          #self.update_jdc_courant()
       elif mode == 'CATA':
           from Noyau.N_CR import CR
           cr = CR()
@@ -201,30 +319,31 @@ class BUREAU:
       texte_cr = str(cr)
       self.visu_texte_cr = Fenetre(self.appli,titre=titre,texte=texte_cr)
 
-   def openJDC(self,file=None):
+   def openJDC(self,event=None,file=None,units=None,enregistre="oui"):
       """
           Demande à l'utilisateur quel JDC existant il veut ouvrir
       """
       if self.code == 'ASTER':
-          filetypes = ( ("format "+self.appli.format_fichier.get(), ".comm"),)
+          filetypes = ( ("format "+self.appli.format_fichier.get(), ".com*"),("Tous",'*'))
+      elif self.code == 'HOMARD' :
+          filetypes = ( ("format "+self.appli.format_fichier.get(), ".py"),("Tous",'*'))
       else:
           filetypes = ( ("format "+self.appli.format_fichier.get(), ".py"),)
       if not hasattr(self,'initialdir'):
-         self.initialdir = self.appli.CONFIGURATION.rep_user
+         self.initialdir = self.appli.CONFIGURATION.initialdir
+
       if not file :
           file = askopenfilename(title="Ouverture d'un fichier de commandes Aster",
                                  defaultextension=".comm",
                                  filetypes = filetypes,
                                  initialdir = self.initialdir)
-      if file != '':
+      if file :
           self.fileName = file
-          e=extension(file)
+          e=extension_fichier(file)
           self.JDCName=stripPath(file)
-          self.initialdir = os.path.dirname(file)
+          self.initialdir = os.path.dirname(os.path.abspath(file))
       else :
           return
-      #XXX CCAR: pour le moment mis en commentaire
-      #if self.JDCDisplay_courant:self.JDCDisplay_courant.jdc.unset_context()
 
       format=self.appli.format_fichier.get()
       # Il faut convertir le contenu du fichier en fonction du format
@@ -232,13 +351,15 @@ class BUREAU:
          # Le convertisseur existe on l'utilise
          p=convert.plugins[format]()
          p.readfile(file)
-         text=p.convert('exec')
+         text=p.convert('exec',self.appli)
          if not p.cr.estvide(): 
             self.appli.affiche_infos("Erreur à la conversion")
             Fenetre(self.appli,
                     titre="compte-rendu d'erreurs, EFICAS ne sait pas convertir ce fichier",
                     texte = str(p.cr)).wait()
             return
+         if enregistre == "oui" :
+            self.appli.listeFichiers.aOuvert(file)
       else:
          # Il n'existe pas c'est une erreur
          self.appli.affiche_infos("Type de fichier non reconnu")
@@ -252,25 +373,43 @@ class BUREAU:
       CONTEXT.unset_current_step()
       J=self.cata[0].JdC(procedure=text,appli=self.appli,
                          cata=self.cata,cata_ord_dico=self.cata_ordonne_dico,
-                         nom = self.JDCName)
+                         nom = self.JDCName,
+                         rep_mat=self.appli.CONFIGURATION.rep_mat,
+                         )
+      if units is not None:
+         J.recorded_units=units
+         J.old_recorded_units=units
+
       J.analyse()
       txt_exception = J.cr.get_mess_exception()
       if txt_exception :
           # des exceptions ont été levées à la création du JDC 
           # --> on affiche les erreurs mais pas le JDC
+          self.JDC=J
           self.appli.affiche_infos("Erreur fatale au chargement de %s" %file)
-          showerror("Erreur fatale au chargement d'un fichier",txt_exception)
+          if self.appli.test == 0 :
+             showerror("Erreur fatale au chargement d'un fichier",txt_exception)
       else:
-          self.ShowJDC(J,self.JDCName)
+          self.ShowJDC(J,self.JDCName,enregistre=enregistre)
           self.appli.toolbar.active_boutons()
-         # si le JDC ne contient rien (vide), on retourne ici
-         if len(self.JDC.etapes) == 0 : return
-         # dans le cas où le JDC est invalide, on affiche son CR
-         cr = self.JDC.report()
-         if not cr.estvide() : 
-            self.appli.top.update()
-            self.visuCR(mode='JDC')
+          # si le JDC ne contient rien (vide), on retourne ici
+          if len(self.JDC.etapes) == 0 : return
+          # dans le cas où le JDC est invalide, on affiche son CR
+          if not self.JDC.isvalid():
+             self.appli.top.update()
+             self.visuCR(mode='JDC')
+      return J
+
+   def deplieReplieNode(self):
+       self.JDCDisplay_courant.tree.tree.deplieReplieNode()
 
+   def selectArbreDown(self):
+       self.JDCDisplay_courant.tree.tree.canvas.focus_set()
+       self.JDCDisplay_courant.tree.tree.mot_down_force()
+
+   def selectArbreUp(self):
+       self.JDCDisplay_courant.tree.tree.canvas.focus_set()
+       self.JDCDisplay_courant.tree.tree.mot_up_force()
 
    def GetLabelJDC(self,nb_jdc = 'absent'):
       """
@@ -285,7 +424,7 @@ class BUREAU:
       else :
           return self.GetLabelJDC(nb_jdc)
 
-   def saveasJDC(self):
+   def saveasJDC(self,event=None):
       """ 
            Sauvegarde le JDC courant en demandant impérativement à l'utilisateur de
            donner le nom du fichier de sauvegarde 
@@ -296,18 +435,21 @@ class BUREAU:
       """ 
           Sauvegarde le JDC courant.
           Retourne 1 si la sauvegarde s'est bien faite, 0 sinon.
-          Si echo = 'oui' : interactif (l'utilisateur donne le nom sous lequel il 
+
+            - Si echo = 'oui' : interactif (l'utilisateur donne le nom sous lequel il 
                             veut sauver le JDC
-          Si echo = 'non' : muet (sauvegarde le JDC dans JDC.procedure)
+            - Si echo = 'non' : muet (sauvegarde le JDC dans JDC.procedure)
       """
+      ok = 0
       if not hasattr(self,'JDC') : return 0
       format=self.appli.format_fichier.get()
       if generator.plugins.has_key(format):
          # Le generateur existe on l'utilise
          g=generator.plugins[format]()
          jdc_formate=g.gener(self.JDC,format='beautifie')
+         if format == 'homard':
+            self.jdc_homard=g.get_homard()
          if not g.cr.estvide():
-            print g.cr
             self.appli.affiche_infos("Erreur à la generation")
             showerror("Erreur à la generation","EFICAS ne sait pas convertir ce JDC")
             return
@@ -319,17 +461,35 @@ class BUREAU:
       self.jdc_fini = string.replace(jdc_formate,'\r\n','\n')
 
       if echo =='oui' or self.JDCDisplay_courant.fichier == None:
-          return self.asknomsauvegardeJDC()
+         ok = self.asknomsauvegardeJDC()
       elif self.JDCDisplay_courant.fichier != None :
-          # le JDC a déjà un nom : on sauvegarde directement sans demander
-          # un autre nom au développeur
-          if not save_in_file(self.JDCDisplay_courant.fichier,self.jdc_fini) :
+         # le JDC a déjà un nom : on sauvegarde directement sans demander
+         # un autre nom au développeur
+         if not save_in_file(self.JDCDisplay_courant.fichier,self.jdc_fini,self.appli.dir) :
               showinfo("Erreur","Problème à la sauvegarde du fichier :" + `self.JDCDisplay_courant.fichier`)
-              return 0
-          else :
+              #return 0
+              ok = 0
+         else :
+              if self.appli.format_fichier.get() == 'homard':
+                  self.save_homard(self.JDCDisplay_courant.fichier,self.jdc_homard)
               self.JDCDisplay_courant.stop_modif()
               self.appli.affiche_infos("sauvegarde de "+`self.JDCDisplay_courant.fichier`+" effectuée")
-              return 1
+              ok = 1
+
+      if ok and hasattr( self.appli, 'salome'):
+         # eficas a été lancé à partir deSalome
+         #1)ajout dans l'arbre d'étude du nom du jdc
+         ok, msg = self.appli.addJdcInSalome( self.JDCDisplay_courant.fichier )
+
+         #2)CS_pbruno ??
+         from panelsSalome import SALOME_UNIQUE_BASE_Panel
+         if len(SALOME_UNIQUE_BASE_Panel.dict_fichier_unite) > 0 :
+            print 'CS_pbruno if len(SALOMchier_unite) > 0 :???????'
+            self.appli.creeConfigTxt( self.appli.CONFIGURATION.initialdir, SALOME_UNIQUE_BASE_Panel.dict_fichier_unite )
+
+         #3)création/mise à jours d'un maillage dans Salome
+         self.appli.createOrUpdateMesh()
+      return ok
 
    def asknomsauvegardeJDC(self):
       """ Demande à l'utilsateur le nom sous lequel il veut sauvegarder le JDC courant """
@@ -343,18 +503,23 @@ class BUREAU:
       sauvegarde = asksaveasfilename(title=titre,
                                      defaultextension=defext,
                                      filetypes = filtyp,
-                                     initialdir = self.appli.CONFIGURATION.rep_user)
-      if sauvegarde != '':
-          if not save_in_file(sauvegarde,self.jdc_fini) :
+                                     initialdir = self.initialdir)
+                            #initialdir = self.appli.CONFIGURATION.initialdir)
+                            #initialdir = self.appli.CONFIGURATION.rep_user)
+      if sauvegarde :
+          if not save_in_file(sauvegarde,self.jdc_fini,None) :
               showinfo("Erreur","Problème à la sauvegarde du fichier "+`sauvegarde`)
               return 0
           else :
+              if self.appli.format_fichier.get() == 'homard':
+                  self.save_homard(sauvegarde,self.jdc_homard)
               self.JDCDisplay_courant.stop_modif()
               self.appli.affiche_infos("Sauvegarde effectuée")
               if sauvegarde != self.JDCDisplay_courant.fichier :
                   # l'utilisateur a sauvegardé le JDC sous un autre nom
                   self.JDCDisplay_courant.fichier = sauvegarde
                   self.JDCName = self.JDC.nom = stripPath(sauvegarde)
+                  self.JDC.changefichier(sauvegarde)
                   self.changeNomPage()
               return 1
       else :
@@ -371,7 +536,7 @@ class BUREAU:
       tab = self.nb.tab(num_page)
       tab.configure(text = nom)
 
-   def exitEFICAS(self):
+   def exitEFICAS(self,event=None):
       """
           Permet de sortir d'EFICAS en demandant à l'utilisateur
           s'il veut sauvegarder les modifications en cours
@@ -379,7 +544,7 @@ class BUREAU:
       liste = self.GetListeJDCaSauvegarder()
       if liste != [] :
           # Certains fichiers n'ont pas été sauvegardés ...
-          if askyesno("Enregistrer modifications","Enregister les modifications ?") :
+          if askyesno("Enregistrer modifications","Enregistrer les modifications ?") :
               test = self.saveall(liste)
               if test != 1 :
                   return
@@ -399,19 +564,19 @@ class BUREAU:
               l.append(JDCDisplay)
       return l
 
-   def copy(self):
+   def copy(self,event=None):
       """
           Lance la copie sur le JDC courant
       """
       if self.JDCDisplay_courant : self.JDCDisplay_courant.doCopy()
 
-   def paste(self):
+   def paste(self,event=None):
       """
            Lance le collage sur le JDC courant
       """
       if self.JDCDisplay_courant : self.JDCDisplay_courant.doPaste()
 
-   def cut(self):
+   def cut(self,event=None):
       """
          Lance le cut sur le JDC courant
       """
@@ -422,19 +587,13 @@ class BUREAU:
           Lance la suppression du noeud courant
       """
       if not self.JDCDisplay_courant : return
-      try:
-          if self.JDCDisplay_courant.modified == 'n' : 
-             self.JDCDisplay_courant.init_modif()
-          pere = self.JDCDisplay_courant.node_selected.parent
-          self.JDCDisplay_courant.node_selected.delete()
-          pere.select()
-      except AttributeError:
-          pass
+      self.JDCDisplay_courant.init_modif()
+      self.JDCDisplay_courant.node_selected.delete()
 
-   def visuJDC_py(self):
+   def visuJDC_py(self,event=None):
       """ 
           Méthode permettant d'afficher dans une fenêtre à part l'écho au 
-            format python du jdc courant 
+          format python du jdc courant 
       """
       if not hasattr(self,'JDC') : return
       jdc_fini = self.get_text_JDC('python')
@@ -446,7 +605,7 @@ class BUREAU:
    def visuJDC(self):
       """ 
           Méthode permettant d'afficher dans une fenêtre à part l'écho au 
-            format .comm ou .py du jdc courant 
+          format .comm ou .py du jdc courant 
       """
       if not hasattr(self,'JDC') : return
       titre = 'fichier '+ self.JDCName + ' à la syntaxe '+ self.code
@@ -461,7 +620,6 @@ class BUREAU:
          g=generator.plugins[format]()
          jdc_formate=g.gener(self.JDC,format='beautifie')
          if not g.cr.estvide():
-            print g.cr
             self.appli.affiche_infos("Erreur à la generation")
             showerror("Erreur à la generation","EFICAS ne sait pas convertir ce JDC")
             return
@@ -487,8 +645,7 @@ class BUREAU:
           cle_doc = string.replace(cle_doc,'-','')
           commande = self.appli.CONFIGURATION.exec_acrobat
           nom_fichier = cle_doc+".pdf"
-          rep_fichier = cle_doc[0:2]
-          fichier = os.path.abspath(os.path.join(self.appli.CONFIGURATION.path_doc,rep_fichier,nom_fichier))
+          fichier = os.path.abspath(os.path.join(self.appli.CONFIGURATION.path_doc,nom_fichier))
           if os.name == 'nt':
               os.spawnv(os.P_NOWAIT,commande,(commande,fichier,))
           elif os.name == 'posix':
@@ -498,7 +655,7 @@ class BUREAU:
           traceback.print_exc()
           pass
 
-   def visu_a_plat(self):
+   def visu_a_plat(self,event=None):
       """ 
           Méthode permettant d'afficher dans une fenêtre à part l'écho 'à plat' du jdc courant 
       """
@@ -508,7 +665,7 @@ class BUREAU:
       if self.jdc_fini == None : return
       self.visu_fichier_cmd = Fenetre(self.appli,titre=titre,texte = self.jdc_fini)
 
-   def visu_txt_brut_JDC(self):
+   def visu_txt_brut_JDC(self,event=None):
       """
            Méthode permettant d'afficher le jeu de commandes tel qu'il a été passé au JDC
       """
@@ -521,6 +678,7 @@ class BUREAU:
             showerror("Impossible de visualiser le fichier initial",
                       "EFICAS ne peut visualiser le fichier initial.\nIl s'agit d'un nouveau JDC")
             return
+      os.chdir(self.appli.dir)
       f=open(self.JDCDisplay_courant.fichier,'r')
       texte=f.read()
       f.close()
@@ -538,17 +696,73 @@ class BUREAU:
       """
       test = 1
       for JDCDisplay in liste :
+          self.JDCDisplay_courant=JDCDisplay
           self.JDC = JDCDisplay.jdc
           test = test * self.saveJDC(echo = 'non')
       return test
 
+   def save_homard(self,nom,texte):
+       file_homard=nom+'.conf_homard'
+       try:
+           f=open(file_homard,'w')
+           for ligne in texte:
+               f.write(ligne)
+               f.write('\n')
+           f.close()
+       except:
+           print "Pb a la sauvegarde sous le format homard"
+       if hasattr( self.appli, 'salome'):
+           import eficasEtude
+           self.appli.salome.rangeInStudy(file_homard,"_CONF")
 
 # ---------------------------------------------------------------------------
-#                      Méthodes liées aux mots-clés inconnus
+#                             Méthodes liées aux mots-clés inconnus
 # ---------------------------------------------------------------------------
 
    def mc_inconnus(self):
       l_mc = self.JDCDisplay_courant.jdc.get_liste_mc_inconnus()
       o = fenetre_mc_inconnus(l_mc)
       l = o.wait_new_list()
+      #print "mc_inconnus_new_list: ",l
+      #CCAR: Il n' y a pas de retour vers le JDC
+
+   def aideEFICAS(self,event=None):
+      AIDE.go(master=self.parent)
+
+   def update_jdc_courant(self):
+      self.JDCDisplay_courant.update()
+
+   def TraduitFichier(self):
+      directory = self.appli.CONFIGURATION.rep_user
+      FichieraTraduire = askopenfilename(title="Nom du  Fichier à Traduire",
+                                 defaultextension=".comm",
+                                 initialdir = directory 
+                                 )
+      if (FichieraTraduire == "" or FichieraTraduire == () ) : return
+      i=FichieraTraduire.rfind(".")
+      Feuille=FichieraTraduire[0:i]
+      FichierTraduit=Feuille+"v8.comm"
+      log=self.initialdir+"/convert.log"
+      os.system("rm -rf "+log)
+      os.system("rm -rf "+FichierTraduit)
+      Pmw.showbusycursor()
+      traduitV7V8.traduc(FichieraTraduire,FichierTraduit,log)
+      Pmw.hidebusycursor()
+      Entete="Fichier Traduit : "+FichierTraduit +"\n\n"
+      titre = "conversion de "+ FichieraTraduire
+
+      if  os.stat(log)[6] != 0L :
+          f=open(log)
+          texte_cr= f.read()
+          f.close()
+      else :
+          texte_cr = Entete  
+          commande="diff "+FichieraTraduire+" "+FichierTraduit+" >/dev/null"
+          try :
+            if os.system(commande) == 0 :
+               texte_cr = texte_cr + "Pas de difference entre le fichier V7 et le fichier traduit"
+          except :
+               pass
+
+      cptrendu = FenetreSurLigneWarning(self.appli,titre=titre,texte=texte_cr)