]> SALOME platform Git repositories - tools/eficas.git/blob - Editeur/bureau.py
Salome HOME
PN : bug
[tools/eficas.git] / Editeur / bureau.py
1 # -*- coding: utf-8 -*-
2 #            CONFIGURATION MANAGEMENT OF EDF VERSION
3 # ======================================================================
4 # COPYRIGHT (C) 1991 - 2002  EDF R&D                  WWW.CODE-ASTER.ORG
5 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
6 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
7 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
8 # (AT YOUR OPTION) ANY LATER VERSION.
9 #
10 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
11 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
12 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
13 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.
14 #
15 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
16 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
17 #    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
18 #
19 #
20 # ======================================================================
21 """
22    Ce module contient la classe BUREAU qui gere les JDC ouverts
23 """
24 # Modules Python
25 import os,string,sys
26 import traceback
27 import Pmw
28 from widgets import askopenfilename,asksaveasfilename
29 from widgets import showinfo,askyesno,showerror
30
31 # Modules Eficas
32 import splash
33 import prefs
34 import convert
35 import generator
36 import AIDE
37 from jdcdisplay import JDCDISPLAY
38 from utils import extension_fichier,stripPath,save_in_file
39 from widgets import Fenetre,Ask_Format_Fichier
40 from fenetre_mc_inconnus import fenetre_mc_inconnus
41 from Ihm import CONNECTOR
42
43 import comploader
44
45 class BUREAU:
46    menu_defs=[
47               ('Fichier',[
48                            ('Nouveau','newJDC','<Control-n>'),
49                            ('Ouvrir','openJDC','<Control-o>'),
50                            ('Enregistrer','saveJDC','<Control-e>'),
51                            ('Enregistrer sous','saveasJDC','<Control-s>'),
52                            None,
53                            ('Fermer','closeJDC','<Control-f>'),
54                            ('Quitter','exitEFICAS','<Control-q>'),
55                          ]
56               ),
57               ('Edition',[
58                            ('Copier','copy','<Control-c>'),
59                            ('Couper','cut','<Control-x>'),
60                            ('Coller','paste','<Control-v>'),
61                          ]
62               ),
63               ('Jeu de commandes',[
64                                    ('Rapport de validation','visuCRJDC','<Control-r>'),
65                                    ('Fichier à plat','visu_a_plat','<Control-p>'),
66                                    ('Fichier .py','visuJDC_py'),
67                                    ('Fichier source','visu_txt_brut_JDC','<Control-b>'),
68                                    ('Paramètres Eficas','affichage_fichier_ini'),
69                                    ('Mots-clés inconnus','mc_inconnus'),
70                                   ]
71               ),
72               ('Aide',[
73                         ('Aide EFICAS','aideEFICAS'),
74                       ]
75               ),
76              ]
77
78    button_defs  =      (('New24',"newJDC","Création d'un nouveau fichier",'always'),
79                         ('Open24',"openJDC","Ouverture d'un fichier existant",'always'),
80                         ('Save24',"saveJDC","Sauvegarde du fichier courant",'always'),
81                         ('Fermer24',"closeJDC","Fermeture du fichier courant",'always'),
82                         ('Zoom24',"visuJDC","Visualisation du fichier de commandes",'always'),
83                         None,
84                         ('Copy24',"copy","Copie l'objet courant",'jdc'),
85                         ('Cut24',"cut","Coupe l'objet courant",'jdc'),
86                         ('Paste24',"paste","Colle l'objet copié après l'objet courant",'jdc'),
87                         None,
88                         ('Delete24',"delete","Supprime l'objet courant",'jdc'),
89                         ('Help24',"view_doc","Documentation de l'objet courant",'jdc')
90                        )
91    try:
92       menu_defs=prefs.menu_defs['bureau']
93    except:
94       pass
95    try:
96       button_defs=prefs.button_defs['bureau']
97    except:
98       pass
99
100    def __init__(self,appli,parent):
101       self.parent=parent
102       self.appli=appli
103       if self.appli.test == 0 :
104          splash._splash.configure(text = "Création du bureau")
105       self.nb = Pmw.NoteBook(self.parent,raisecommand=self.selectJDC)
106       self.nb.pack(fill='both',expand=1)
107       self.JDCDisplay_courant=None
108       self.fileName=None
109       self.liste_JDCDisplay=[]
110       comploader.charger_composants()
111       self.cree_cataitem()
112       self.text_reel=""
113       self.initialdir = self.appli.CONFIGURATION.initialdir
114
115    def cree_cataitem(self):
116       """
117           On récupère dans l'appli_composant readercata les variables 
118           qui servent par la suite pour la création des JDC
119       """
120       self.cataitem=self.appli.readercata.cataitem
121       self.cata=self.appli.readercata.cata
122       self.cata_ordonne_dico=self.appli.readercata.cata_ordonne_dico
123       self.code=self.appli.readercata.code
124       self.version_code=self.appli.readercata.version_code
125       self.fic_cata=self.appli.readercata.fic_cata
126
127    def selectJDC(self,event=None):
128       """
129           Cette méthode est appelée chaque fois que l'on sélectionne 
130           l'onglet d'un JDC dans le NoteBook des JDC.
131           Elle permet de stocker dans les variable self.JDC et 
132           self.JDCDisplay_courant les valeurs concernant le JDC courant
133       """
134       if len(self.liste_JDCDisplay) == 0 : return
135       #if self.JDCDisplay_courant : self.JDCDisplay_courant.jdc.unset_context()
136       numero_jdc = self.nb.index(self.nb.getcurselection())
137       self.JDCDisplay_courant.unselect()
138       self.JDCDisplay_courant = self.liste_JDCDisplay[numero_jdc]
139       self.JDC = self.JDCDisplay_courant.jdc
140       self.JDCName = self.JDC.nom
141       self.JDCDisplay_courant.select()
142       #print "selectJDC",numero_jdc,self.JDCDisplay_courant,self.JDCName
143
144
145    def newJDC_include(self,event=None):
146       """
147           Initialise un nouveau JDC vierge
148       """
149       import Extensions.jdc_include
150       JdC_aux=Extensions.jdc_include.JdC_include
151
152       self.appli.statusbar.reset_affichage_infos()
153
154       CONTEXT.unset_current_step()
155       jaux=self.cata[0].JdC(procedure="",appli=self.appli,
156                          cata=self.cata,cata_ord_dico=self.cata_ordonne_dico,
157                          rep_mat=self.appli.CONFIGURATION.rep_mat,
158                          )
159       jaux.analyse()
160
161       J=JdC_aux(procedure="",appli=self.appli,
162                          cata=self.cata,cata_ord_dico=self.cata_ordonne_dico,
163                          jdc_pere=jaux,
164                          rep_mat=self.appli.CONFIGURATION.rep_mat,
165                          )
166       J.analyse()
167       self.JDCName=J.nom
168       self.fileName=None
169       self.ShowJDC(J,self.JDCName)
170       self.appli.toolbar.active_boutons()
171
172    def newJDC(self,event=None):
173       """
174           Initialise un nouveau JDC include vierge
175       """
176       self.appli.statusbar.reset_affichage_infos()
177
178       CONTEXT.unset_current_step()
179       J=self.cata[0].JdC(procedure="",appli=self.appli,
180                          cata=self.cata,cata_ord_dico=self.cata_ordonne_dico,
181                          rep_mat=self.appli.CONFIGURATION.rep_mat,
182                          )
183       J.analyse()
184       self.JDCName=J.nom
185       self.fileName=None
186       self.ShowJDC(J,self.JDCName)
187       self.appli.toolbar.active_boutons()
188
189    def ShowJDC(self,JDC,nom,label_onglet=None,JDCDISPLAY=JDCDISPLAY,enregistre="non"):
190       """
191           Lance l'affichage du JDC cad création du JDCDisplay
192           Rajoute le JDCDisplay à la liste des JDCDisplay si label_onglet == None cad si on crée
193           bien un nouveau JDCDisplay et non si on remplace (renommage de l'onglet)
194       """
195       self.JDC=JDC
196       self.JDCName = self.JDC.nom = nom
197       if label_onglet == None :
198           # On veut un nouvel onglet
199           label_onglet = self.GetLabelJDC()
200           self.nb.add(label_onglet,tab_text = nom,tab_width=20)
201           new = 'oui'
202       else :
203           new = 'non'
204       self.JDCDisplay_courant=JDCDISPLAY(self.JDC,nom,appli=self.appli,parent=self.nb.page(label_onglet))
205       if new == 'oui':
206           self.liste_JDCDisplay.append(self.JDCDisplay_courant)
207       self.JDCDisplay_courant.modified='n'
208       if enregistre != "non" :
209          self.JDCDisplay_courant.fichier=self.fileName
210       else :
211          self.initialdir = self.appli.CONFIGURATION.rep_user
212       self.nb.selectpage(label_onglet)
213       self.nb.setnaturalsize()
214       self.nb.bind_all("<Key-Next>",lambda e,s=self:s.selectArbreDown())
215       self.nb.bind_all("<Key-Prior>",lambda e,s=self:s.selectArbreUp())
216       self.nb.bind_all("<Insert>",lambda e,s=self:s.deplieReplieNode())
217       texte = "Jeu de commandes :" + self.JDCName+" ouvert"
218       CONNECTOR.Connect(JDC,"close",self.onClose,(self.JDCDisplay_courant,))
219       self.appli.affiche_infos(texte)
220
221    def onClose(self,jdcdisplay):
222       #print "onClose",jdcdisplay
223       self.closeJDCDISPLAY(jdcdisplay)
224
225    def closeJDCDISPLAY(self,jdc):
226       """
227         Ferme le jdcdisplay spécifié par l'argument jdc
228       """
229       if jdc is self.JDCDisplay_courant:
230          # on ferme le jdcdisplay courant
231          self.closeSelectedJDC()
232       else:
233          # on ferme un autre jdcdisplay que le courant
234          old_JDCDisplay=self.JDCDisplay_courant
235          old_page=self.nb.getcurselection()
236
237          self.JDCDisplay_courant=jdc
238          self.JDC=jdc.jdc
239          numero_jdc=self.liste_JDCDisplay.index(jdc)
240          self.nb.selectpage(numero_jdc)
241          #print numero_jdc
242       
243          self.closeSelectedJDC()
244          self.JDCDisplay_courant=old_JDCDisplay
245          self.JDC=old_JDCDisplay.jdc
246          self.nb.selectpage(old_page)
247
248    def closeJDC (self,event=None) :
249       """
250           Ferme le JDC associé au JDCDISPLAY selectionné
251       """
252       if self.JDCDisplay_courant :
253          self.JDCDisplay_courant.jdc.close()
254
255    def closeSelectedJDC (self) :
256       """
257       Ferme le JDC courant et détruit l'onglet associé dans le notebook self.nb
258       """
259       if self.JDCDisplay_courant.modified == 'o' :
260           message = "Voulez-vous sauvegarder le jeu de commandes "+self.JDC.nom+" courant ?"
261           reponse = askyesno(title="Sauvegarde du jdc courant",
262                              message=message)
263           if reponse :
264               test = self.saveJDC()
265               if test == 0 :
266                   self.appli.affiche_infos("Sauvegarde impossible")
267                   return
268
269       CONNECTOR.Disconnect(self.JDCDisplay_courant.jdc,"close",self.onClose,(self.JDCDisplay_courant,))
270       self.JDCDisplay_courant.supprime()
271       self.JDCDisplay_courant.jdc.supprime()
272       self.liste_JDCDisplay.remove(self.JDCDisplay_courant)
273       # Active le mecanisme de selection du notebook (selectJDC)
274       self.nb.delete(self.nb.getcurselection())
275
276       try:
277           index = self.nb.index(self.nb.getcurselection())
278           self.JDCDisplay_courant = self.liste_JDCDisplay[index]
279           self.JDC = self.JDCDisplay_courant.jdc
280       except:
281           self.JDC = None
282           self.JDCDisplay_courant = None
283           self.appli.toolbar.inactive_boutons()
284
285    def visuCRJDC(self,event=None):
286       return self.visuCR(mode='JDC')
287
288    def visuCR(self,mode):
289       """
290       Méthode permettant l'affichage du rapport de validation
291       """
292       if mode == 'JDC':
293           if not hasattr(self,'JDC') : return
294           titre="rapport de validation du jeu de commandes courant"
295           cr = self.JDC.report()
296           #self.update_jdc_courant()
297       elif mode == 'CATA':
298           from Noyau.N_CR import CR
299           cr = CR()
300           cr.debut = "Début rapport de validation du catalogue"
301           cr.fin = "Fin rapport de validation du catalogue"
302           titre="rapport de validation du catalogue"
303           if hasattr(self,'cata_ordonne_cr') :
304               cr.add(self.cata_ordonne_cr)
305           if hasattr(self,'cata_dev_ordonne_cr') :
306               cr.add(self.cata_dev_ordonne_cr)
307           for cata in self.cata:
308               if hasattr(cata,'JdC'):
309                   cr.add(cata.JdC.report())
310       texte_cr = str(cr)
311       self.visu_texte_cr = Fenetre(self.appli,titre=titre,texte=texte_cr)
312
313    def openJDC(self,event=None,file=None,units=None,enregistre="oui"):
314       """
315           Demande à l'utilisateur quel JDC existant il veut ouvrir
316       """
317       if self.code == 'ASTER':
318           filetypes = ( ("format "+self.appli.format_fichier.get(), ".com*"),("Tous",'*'))
319       elif self.code == 'HOMARD' :
320           filetypes = ( ("format "+self.appli.format_fichier.get(), ".py"),("Tous",'*'))
321       else:
322           filetypes = ( ("format "+self.appli.format_fichier.get(), ".py"),)
323       if not hasattr(self,'initialdir'):
324          self.initialdir = self.appli.CONFIGURATION.initialdir
325
326       if not file :
327           file = askopenfilename(title="Ouverture d'un fichier de commandes Aster",
328                                  defaultextension=".comm",
329                                  filetypes = filetypes,
330                                  initialdir = self.initialdir)
331       if file :
332           self.fileName = file
333           e=extension_fichier(file)
334           self.JDCName=stripPath(file)
335           self.initialdir = os.path.dirname(os.path.abspath(file))
336       else :
337           return
338
339       format=self.appli.format_fichier.get()
340       # Il faut convertir le contenu du fichier en fonction du format
341       if convert.plugins.has_key(format):
342          # Le convertisseur existe on l'utilise
343          p=convert.plugins[format]()
344          p.readfile(file)
345          text=p.convert('exec',self.appli)
346          if not p.cr.estvide(): 
347             self.appli.affiche_infos("Erreur à la conversion")
348             Fenetre(self.appli,
349                     titre="compte-rendu d'erreurs, EFICAS ne sait pas convertir ce fichier",
350                     texte = str(p.cr)).wait()
351             return
352          if enregistre == "oui" :
353             self.appli.listeFichiers.aOuvert(file)
354       else:
355          # Il n'existe pas c'est une erreur
356          self.appli.affiche_infos("Type de fichier non reconnu")
357          showerror("Type de fichier non reconnu","EFICAS ne sait pas ouvrir ce type de fichier")
358          return
359
360       # On se met dans le repertoire ou se trouve le fichier de commandes
361       # pour trouver les eventuels fichiers include ou autres
362       # localises a cote du fichier de commandes
363       os.chdir(self.initialdir)
364       CONTEXT.unset_current_step()
365       J=self.cata[0].JdC(procedure=text,appli=self.appli,
366                          cata=self.cata,cata_ord_dico=self.cata_ordonne_dico,
367                          nom = self.JDCName,
368                          rep_mat=self.appli.CONFIGURATION.rep_mat,
369                          )
370       if units is not None:
371          J.recorded_units=units
372          J.old_recorded_units=units
373
374       J.analyse()
375       txt_exception = J.cr.get_mess_exception()
376       if txt_exception :
377           # des exceptions ont été levées à la création du JDC 
378           # --> on affiche les erreurs mais pas le JDC
379           self.JDC=J
380           self.appli.affiche_infos("Erreur fatale au chargement de %s" %file)
381           if self.appli.test == 0 :
382              showerror("Erreur fatale au chargement d'un fichier",txt_exception)
383       else:
384           self.ShowJDC(J,self.JDCName,enregistre=enregistre)
385           self.appli.toolbar.active_boutons()
386           # si le JDC ne contient rien (vide), on retourne ici
387           if len(self.JDC.etapes) == 0 : return
388           # dans le cas où le JDC est invalide, on affiche son CR
389           if not self.JDC.isvalid():
390              self.appli.top.update()
391              self.visuCR(mode='JDC')
392
393    def deplieReplieNode(self):
394        self.JDCDisplay_courant.tree.tree.deplieReplieNode()
395
396    def selectArbreDown(self):
397        self.JDCDisplay_courant.tree.tree.canvas.focus_set()
398        self.JDCDisplay_courant.tree.tree.mot_down_force()
399
400    def selectArbreUp(self):
401        self.JDCDisplay_courant.tree.tree.canvas.focus_set()
402        self.JDCDisplay_courant.tree.tree.mot_up_force()
403
404    def GetLabelJDC(self,nb_jdc = 'absent'):
405       """
406       Retourne le label de l'onglet du NoteBook associé au JDC à afficher
407       """
408       if nb_jdc == 'absent':
409           nb_jdc = len(self.nb.pagenames())
410       nb_jdc = nb_jdc+1
411       label_onglet = 'JDC'+`nb_jdc`
412       if label_onglet not in self.nb.pagenames() :
413           return label_onglet
414       else :
415           return self.GetLabelJDC(nb_jdc)
416
417    def saveasJDC(self,event=None):
418       """ 
419            Sauvegarde le JDC courant en demandant impérativement à l'utilisateur de
420            donner le nom du fichier de sauvegarde 
421       """
422       self.saveJDC(echo='oui')
423
424    def saveJDC(self,echo='non'):
425       """ 
426           Sauvegarde le JDC courant.
427           Retourne 1 si la sauvegarde s'est bien faite, 0 sinon.
428           Si echo = 'oui' : interactif (l'utilisateur donne le nom sous lequel il 
429                             veut sauver le JDC
430           Si echo = 'non' : muet (sauvegarde le JDC dans JDC.procedure)
431       """
432       ok = 0
433       if not hasattr(self,'JDC') : return 0
434       format=self.appli.format_fichier.get()
435       if generator.plugins.has_key(format):
436          # Le generateur existe on l'utilise
437          g=generator.plugins[format]()
438          jdc_formate=g.gener(self.JDC,format='beautifie')
439          if format == 'homard':
440             self.jdc_homard=g.get_homard()
441          if not g.cr.estvide():
442             self.appli.affiche_infos("Erreur à la generation")
443             showerror("Erreur à la generation","EFICAS ne sait pas convertir ce JDC")
444             return
445       else:
446          # Il n'existe pas c'est une erreur
447          self.appli.affiche_infos("Format %s non reconnu" % format)
448          showerror("Format %s non reconnu" % format,"EFICAS ne sait pas convertir le JDC")
449          return
450       self.jdc_fini = string.replace(jdc_formate,'\r\n','\n')
451
452       if echo =='oui' or self.JDCDisplay_courant.fichier == None:
453          ok = self.asknomsauvegardeJDC()
454       elif self.JDCDisplay_courant.fichier != None :
455          # le JDC a déjà un nom : on sauvegarde directement sans demander
456          # un autre nom au développeur
457          if not save_in_file(self.JDCDisplay_courant.fichier,self.jdc_fini,self.appli.dir) :
458               showinfo("Erreur","Problème à la sauvegarde du fichier :" + `self.JDCDisplay_courant.fichier`)
459               #return 0
460               ok = 0
461          else :
462               if self.appli.format_fichier.get() == 'homard':
463                   self.save_homard(self.JDCDisplay_courant.fichier,self.jdc_homard)
464               self.JDCDisplay_courant.stop_modif()
465               self.appli.affiche_infos("sauvegarde de "+`self.JDCDisplay_courant.fichier`+" effectuée")
466               ok = 1
467
468       if ok and hasattr( self.appli, 'salome'):
469          # eficas a été lancé à partir deSalome
470          #1)ajout dans l'arbre d'étude du nom du jdc
471          ok, msg = self.appli.addJdcInSalome( self.JDCDisplay_courant.fichier )
472
473          #2)CS_pbruno ??
474          from panelsSalome import SALOME_UNIQUE_BASE_Panel
475          if len(SALOME_UNIQUE_BASE_Panel.dict_fichier_unite) > 0 :
476             print 'CS_pbruno if len(SALOMchier_unite) > 0 :???????'
477             self.appli.creeConfigTxt( self.appli.CONFIGURATION.initialdir, SALOME_UNIQUE_BASE_Panel.dict_fichier_unite )
478
479          #3)création/mise à jours d'un maillage dans Salome
480          self.appli.createOrUpdateMesh()
481       return ok
482
483    def asknomsauvegardeJDC(self):
484       """ Demande à l'utilsateur le nom sous lequel il veut sauvegarder le JDC courant """
485       titre = "Sauvegarde d'un fichier de commandes "+self.code
486       if self.code == 'ASTER':
487           defext = ".comm"
488           filtyp = ( ("ASTER", ".comm"),)
489       else :
490           defext = ".py"
491           filtyp = ( (self.code, ".py"),)
492       sauvegarde = asksaveasfilename(title=titre,
493                                      defaultextension=defext,
494                                      filetypes = filtyp,
495                                      initialdir = self.initialdir)
496                             #initialdir = self.appli.CONFIGURATION.initialdir)
497                             #initialdir = self.appli.CONFIGURATION.rep_user)
498       if sauvegarde :
499           if not save_in_file(sauvegarde,self.jdc_fini,None) :
500               showinfo("Erreur","Problème à la sauvegarde du fichier "+`sauvegarde`)
501               return 0
502           else :
503               if self.appli.format_fichier.get() == 'homard':
504                   self.save_homard(sauvegarde,self.jdc_homard)
505               self.JDCDisplay_courant.stop_modif()
506               self.appli.affiche_infos("Sauvegarde effectuée")
507               if sauvegarde != self.JDCDisplay_courant.fichier :
508                   # l'utilisateur a sauvegardé le JDC sous un autre nom
509                   self.JDCDisplay_courant.fichier = sauvegarde
510                   self.JDCName = self.JDC.nom = stripPath(sauvegarde)
511                   self.JDC.changefichier(sauvegarde)
512                   self.changeNomPage()
513               return 1
514       else :
515           return 0
516
517    def changeNomPage(self):
518       """ Change le nom de l'onglet contenant le JDC courant : en fait détruit l'actuel
519           et recrée un autre onglet à la même place avec le bon nom 
520       """
521       nom = self.JDCName
522       self.JDCDisplay_courant.jdc.nom = nom
523       nom_page = self.nb.getcurselection()
524       num_page = self.nb.index(nom_page)
525       tab = self.nb.tab(num_page)
526       tab.configure(text = nom)
527
528    def exitEFICAS(self,event=None):
529       """
530           Permet de sortir d'EFICAS en demandant à l'utilisateur
531           s'il veut sauvegarder les modifications en cours
532       """
533       liste = self.GetListeJDCaSauvegarder()
534       if liste != [] :
535           # Certains fichiers n'ont pas été sauvegardés ...
536           if askyesno("Enregistrer modifications","Enregistrer les modifications ?") :
537               test = self.saveall(liste)
538               if test != 1 :
539                   return
540       if askyesno ("Quitter","Voulez-vous vraiment quitter l'application ?") :
541           for JDCDisplay in self.liste_JDCDisplay:
542               JDCDisplay.jdc.supprime()
543           self.appli.quit()
544           return
545
546    def GetListeJDCaSauvegarder(self) :
547       """ Retourne parmi la liste de tous les JDC ouverts la liste de ceux qui ont été modifiés """
548       if not self.JDCDisplay_courant : return []
549       if len(self.liste_JDCDisplay) == 0 : return l
550       l = []
551       for JDCDisplay in self.liste_JDCDisplay:
552           if JDCDisplay.modified == 'o' :
553               l.append(JDCDisplay)
554       return l
555
556    def copy(self,event=None):
557       """
558           Lance la copie sur le JDC courant
559       """
560       if self.JDCDisplay_courant : self.JDCDisplay_courant.doCopy()
561
562    def paste(self,event=None):
563       """
564            Lance le collage sur le JDC courant
565       """
566       if self.JDCDisplay_courant : self.JDCDisplay_courant.doPaste()
567
568    def cut(self,event=None):
569       """
570          Lance le cut sur le JDC courant
571       """
572       if self.JDCDisplay_courant: self.JDCDisplay_courant.doCut()
573
574    def delete(self):
575       """
576           Lance la suppression du noeud courant
577       """
578       if not self.JDCDisplay_courant : return
579       self.JDCDisplay_courant.init_modif()
580       self.JDCDisplay_courant.node_selected.delete()
581
582    def visuJDC_py(self,event=None):
583       """ 
584           Méthode permettant d'afficher dans une fenêtre à part l'écho au 
585             format python du jdc courant 
586       """
587       if not hasattr(self,'JDC') : return
588       jdc_fini = self.get_text_JDC('python')
589       if jdc_fini == None : return
590       Fenetre(self.appli,
591               titre = 'fichier '+ self.JDCName + ' à la syntaxe Python',
592               texte = jdc_fini)
593
594    def visuJDC(self):
595       """ 
596           Méthode permettant d'afficher dans une fenêtre à part l'écho au 
597             format .comm ou .py du jdc courant 
598       """
599       if not hasattr(self,'JDC') : return
600       titre = 'fichier '+ self.JDCName + ' à la syntaxe '+ self.code
601       format=self.appli.format_fichier.get()
602       self.jdc_fini = self.get_text_JDC(format)
603       if self.jdc_fini == None : return
604       self.visu_fichier_cmd = Fenetre(self.appli,titre=titre,texte = self.jdc_fini)
605
606    def get_text_JDC(self,format):
607       if generator.plugins.has_key(format):
608          # Le generateur existe on l'utilise
609          g=generator.plugins[format]()
610          jdc_formate=g.gener(self.JDC,format='beautifie')
611          if not g.cr.estvide():
612             self.appli.affiche_infos("Erreur à la generation")
613             showerror("Erreur à la generation","EFICAS ne sait pas convertir ce JDC")
614             return
615          else:
616             return jdc_formate
617       else:
618          # Il n'existe pas c'est une erreur
619          self.appli.affiche_infos("Format %s non reconnu" % format)
620          showerror("Format %s non reconnu" % format,"EFICAS ne sait pas convertir le JDC en format %s "% format)
621          return
622
623    def view_doc(self):
624       """
625           Permet d'ouvrir le fichier doc U de la commande au format pdf avec Acrobat Reader
626           - Ne fonctionne pas sous UNIX (chemin d'accès Acrobat Reader)
627           - indication du chemin d'accès aux fichiers pdf à revoir : trop statique
628       """
629       if not self.JDCDisplay_courant : return
630       try:
631           cle_doc = self.JDCDisplay_courant.node_selected.item.get_docu()
632           if cle_doc == None : return
633           cle_doc = string.replace(cle_doc,'.','')
634           cle_doc = string.replace(cle_doc,'-','')
635           commande = self.appli.CONFIGURATION.exec_acrobat
636           nom_fichier = cle_doc+".pdf"
637           fichier = os.path.abspath(os.path.join(self.appli.CONFIGURATION.path_doc,nom_fichier))
638           if os.name == 'nt':
639               os.spawnv(os.P_NOWAIT,commande,(commande,fichier,))
640           elif os.name == 'posix':
641               script ="#!/usr/bin/sh \n%s %s&" %(commande,fichier)
642               pid = os.system(script)
643       except AttributeError:
644           traceback.print_exc()
645           pass
646
647    def visu_a_plat(self,event=None):
648       """ 
649           Méthode permettant d'afficher dans une fenêtre à part l'écho 'à plat' du jdc courant 
650       """
651       if not hasattr(self,'JDC') : return
652       titre = 'fichier '+ self.JDCName + ' à plat '
653       self.jdc_fini = self.get_text_JDC('aplat')
654       if self.jdc_fini == None : return
655       self.visu_fichier_cmd = Fenetre(self.appli,titre=titre,texte = self.jdc_fini)
656
657    def visu_txt_brut_JDC(self,event=None):
658       """
659            Méthode permettant d'afficher le jeu de commandes tel qu'il a été passé au JDC
660       """
661       if not hasattr(self,'JDC') : return
662       titre = "fichier de commandes utilisateur"
663       #texte = self.JDC.procedure
664       #if texte == None:
665       if self.JDCDisplay_courant.fichier == None:
666             self.appli.affiche_infos("Pas de fichier initial")
667             showerror("Impossible de visualiser le fichier initial",
668                       "EFICAS ne peut visualiser le fichier initial.\nIl s'agit d'un nouveau JDC")
669             return
670       os.chdir(self.appli.dir)
671       f=open(self.JDCDisplay_courant.fichier,'r')
672       texte=f.read()
673       f.close()
674       self.visu_texte_JDC = Fenetre(self.appli,titre=titre,texte=texte)
675
676    def affichage_fichier_ini(self):
677       """
678            Affichage des valeurs des paramètres relus par Eficas
679       """
680       self.appli.CONFIGURATION.affichage_fichier_ini()
681
682    def saveall(self,liste):
683       """ 
684            Sauvegarde tous les JDC contenus dans liste 
685       """
686       test = 1
687       for JDCDisplay in liste :
688           self.JDCDisplay_courant=JDCDisplay
689           self.JDC = JDCDisplay.jdc
690           test = test * self.saveJDC(echo = 'non')
691       return test
692
693    def save_homard(self,nom,texte):
694        file_homard=nom+'.conf_homard'
695        try:
696            f=open(file_homard,'w')
697            for ligne in texte:
698                f.write(ligne)
699                f.write('\n')
700            f.close()
701        except:
702            print "Pb a la sauvegarde sous le format homard"
703        if hasattr( self.appli, 'salome'):
704            import eficasEtude
705            self.appli.salome.rangeInStudy(file_homard,"_CONF")
706
707 # ---------------------------------------------------------------------------
708 #                       Méthodes liées aux mots-clés inconnus
709 # ---------------------------------------------------------------------------
710
711    def mc_inconnus(self):
712       l_mc = self.JDCDisplay_courant.jdc.get_liste_mc_inconnus()
713       o = fenetre_mc_inconnus(l_mc)
714       l = o.wait_new_list()
715       #print "mc_inconnus_new_list: ",l
716       #CCAR: Il n' y a pas de retour vers le JDC
717
718    def aideEFICAS(self,event=None):
719       AIDE.go(master=self.parent)
720
721    def update_jdc_courant(self):
722       self.JDCDisplay_courant.update()
723