X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Editeur%2Fbureau.py;h=c67df204bbda432ef168bbe9c4ff09a88fca2363;hb=5426be33502dbb6f6701dc8ab303ec7a3990954d;hp=c0776c075820b2daf73687f6914b1302694180bf;hpb=36ca867c4099d6a804374b8f6a2b897d9ea69a09;p=tools%2Feficas.git diff --git a/Editeur/bureau.py b/Editeur/bureau.py index c0776c07..c67df204 100644 --- a/Editeur/bureau.py +++ b/Editeur/bureau.py @@ -22,7 +22,7 @@ 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 widgets import askopenfilename,asksaveasfilename @@ -38,6 +38,7 @@ from jdcdisplay import JDCDISPLAY from utils import extension_fichier,stripPath,save_in_file from widgets import Fenetre,Ask_Format_Fichier from fenetre_mc_inconnus import fenetre_mc_inconnus +from Ihm import CONNECTOR import comploader @@ -77,6 +78,7 @@ class BUREAU: 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'), @@ -108,6 +110,7 @@ class BUREAU: comploader.charger_composants() self.cree_cataitem() self.text_reel="" + self.initialdir = self.appli.CONFIGURATION.initialdir def cree_cataitem(self): """ @@ -131,15 +134,44 @@ 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,event=None): + def newJDC_include(self,event=None): """ Initialise un nouveau JDC 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() + + def newJDC(self,event=None): + """ + Initialise un nouveau JDC include vierge + """ self.appli.statusbar.reset_affichage_infos() CONTEXT.unset_current_step() @@ -153,7 +185,7 @@ class BUREAU: self.ShowJDC(J,self.JDCName) self.appli.toolbar.active_boutons() - def ShowJDC(self,JDC,nom,label_onglet=None,JDCDISPLAY=JDCDISPLAY): + 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 @@ -172,18 +204,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() texte = "Jeu de commandes :" + self.JDCName+" ouvert" + CONNECTOR.Connect(JDC,"close",self.onClose,(self.JDCDisplay_courant,)) self.appli.affiche_infos(texte) + 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 """ - if self.JDCDisplay_courant == None: - return if self.JDCDisplay_courant.modified == 'o' : message = "Voulez-vous sauvegarder le jeu de commandes "+self.JDC.nom+" courant ?" reponse = askyesno(title="Sauvegarde du jdc courant", @@ -193,17 +261,20 @@ 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() @@ -235,12 +306,12 @@ class BUREAU: texte_cr = str(cr) self.visu_texte_cr = Fenetre(self.appli,titre=titre,texte=texte_cr) - def openJDC(self,file=None,units=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"),("Tous",'*')) + filetypes = ( ("format "+self.appli.format_fichier.get(), ".com*"),("Tous",'*')) elif self.code == 'HOMARD' : filetypes = ( ("format "+self.appli.format_fichier.get(), ".py"),("Tous",'*')) else: @@ -248,9 +319,6 @@ class BUREAU: if not hasattr(self,'initialdir'): self.initialdir = self.appli.CONFIGURATION.initialdir - if file.__class__.__name__ in ('Event',): - file=None - if not file : file = askopenfilename(title="Ouverture d'un fichier de commandes Aster", defaultextension=".comm", @@ -277,6 +345,8 @@ class BUREAU: 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") @@ -302,10 +372,12 @@ class BUREAU: 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 @@ -313,7 +385,7 @@ class BUREAU: if not self.JDC.isvalid(): self.appli.top.update() self.visuCR(mode='JDC') - + # On a ouvert un Patron def GetLabelJDC(self,nb_jdc = 'absent'): """ @@ -373,18 +445,19 @@ class BUREAU: from panelsSalome import SALOME_UNIQUE_BASE_Panel if len(SALOME_UNIQUE_BASE_Panel.dict_fichier_unite) > 0 : self.appli.salome.creeConfigTxt(self.appli.CONFIGURATION.initialdir,SALOME_UNIQUE_BASE_Panel.dict_fichier_unite) - try : - #if ( 1 == 1 ) : + #try : + if ( 1 == 1 ) : import eficasCL MyCLinit=eficasCL.CLinit() MyCLinit.traiteCL() - except : - #else : + MyCLinit.clean() + #except : + else : pass #PN Fin Ajout --> Salome # 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) : + 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 : @@ -406,8 +479,9 @@ class BUREAU: sauvegarde = asksaveasfilename(title=titre, defaultextension=defext, filetypes = filtyp, - initialdir = self.appli.CONFIGURATION.initialdir) - #initialdir = self.appli.CONFIGURATION.rep_user) + initialdir = self.initialdir) + #initialdir = self.appli.CONFIGURATION.initialdir) + #initialdir = self.appli.CONFIGURATION.rep_user) if sauvegarde : # PN ajout --> Salome # Pour sauvegarde dans l etude si lancement depuis salome @@ -422,11 +496,12 @@ class BUREAU: import eficasCL MyCLinit=eficasCL.CLinit() MyCLinit.traiteCL() + MyCLinit.clean() #except : else : pass # PN fin ajout --> Salome - if not save_in_file(sauvegarde,self.jdc_fini) : + if not save_in_file(sauvegarde,self.jdc_fini,None) : showinfo("Erreur","Problème à la sauvegarde du fichier "+`sauvegarde`) return 0 else : @@ -438,6 +513,7 @@ class BUREAU: # 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 : @@ -505,8 +581,7 @@ class BUREAU: Lance la suppression du noeud courant """ if not self.JDCDisplay_courant : return - if self.JDCDisplay_courant.modified == 'n' : - self.JDCDisplay_courant.init_modif() + self.JDCDisplay_courant.init_modif() self.JDCDisplay_courant.node_selected.delete() def visuJDC_py(self,event=None): @@ -564,8 +639,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': @@ -615,6 +689,7 @@ class BUREAU: """ test = 1 for JDCDisplay in liste : + self.JDCDisplay_courant=JDCDisplay self.JDC = JDCDisplay.jdc test = test * self.saveJDC(echo = 'non') return test