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.
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.
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.
20 # ======================================================================
24 import os,traceback,sys
25 from qtCommun import QTPanel
26 from qtCommun import QTPanelTBW1
27 from qtCommun import QTPanelTBW2
28 from qtCommun import QTPanelTBW3
29 from PyQt4.QtGui import *
30 from PyQt4.QtCore import *
32 from desInclude import Ui_DInc1
35 class DInc(Ui_DInc1,QDialog):
36 def __init__(self,parent ,modal ) :
37 QDialog.__init__(self,parent)
38 if hasattr(parent,"leLayout"):
39 parent.leLayout.removeWidget(parent.leLayout.widgetActive)
40 parent.leLayout.widgetActive.close()
41 parent.leLayout.addWidget(self)
42 parent.leLayout.widgetActive=self
44 parent.partieDroite=QWidget()
45 parent.leLayout=QGridLayout(parent.partieDroite)
46 parent.leLayout.addWidget(self)
47 parent.addWidget(parent.partieDroite)
48 parent.leLayout.widgetActive=self
55 class MonIncludePanel(DInc,QTPanelTBW1,QTPanelTBW2,QTPanelTBW3):
57 Classe définissant le panel associé aux mots-clés qui demandent
58 à l'utilisateur de choisir une seule valeur parmi une liste de valeurs
61 def __init__(self,node, parent = None,name = None,fl = 0):
62 #print "MonIncludePanel"
63 DInc.__init__(self,parent,fl)
64 QTPanel.__init__(self,node,parent)
65 QTPanelTBW2.__init__(self,node,parent)
66 QTPanelTBW1.__init__(self,node,parent)
67 self.connecterSignaux()
70 if not hasattr(self.node.item.object,'fichier_unite'):
76 self.TWChoix.removeTab(3)
77 self.TWChoix.setCurrentIndex(2)
78 self.LENomFichier.setText(self.node.item.object.fichier_ini)
82 self.TWChoix.removeTab(2)
83 self.TWChoix.setCurrentIndex(2)
85 def BBrowsePressed(self):
86 print self.node.makeEdit
89 def BOkIncPressed (self):
90 self.LENomFichReturnPressed()
92 def LENomFichReturnPressed(self):
93 nomFichier=str(self.LENomFichier.text())
94 if not os.path.isfile(nomFichier) :
95 commentaire = "Fichier introuvable"
96 self.Commentaire.setText(QString(commentaire))
97 self.editor.affiche_infos(commentaire)
100 text=self.convert_file(nomFichier)
102 # Si probleme a la lecture-conversion on arrete le traitement
107 self.node.item.object.change_fichier_init(nomFichier,text)
108 commentaire = "Fichier modifie : " + self.node.item.get_nom()
109 self.Commentaire.setText(QString(commentaire))
110 self.editor.affiche_infos(commentaire)
112 l=traceback.format_exception_only("Fichier invalide",sys.exc_info()[1])
113 QMessageBox.critical( self, "Erreur fatale au chargement du fichier Include", l[0])
114 commentaire = "Fichier invalide"
115 self.Commentaire.setText(QString(commentaire))
116 self.editor.affiche_infos(commentaire)
120 def convert_file(self,file):
122 Methode pour convertir le fichier file dans le format courant
124 format=self.editor.format_fichier
126 if convert.plugins.has_key(format):
127 # Le convertisseur existe on l'utilise
128 p=convert.plugins[format]()
130 text=p.convert('execnoparseur')
132 commentaire = "Impossible de lire le fichier : Format inconnu"
133 self.Commentaire.setText(QString(commentaire))
134 self.editor.affiche_infos(commentaire)
138 def BChangeFilePressed(self):
139 userDir=os.path.expanduser("~/Eficas_install/")
140 fn = QFileDialog.getOpenFileName(self.node.appliEficas,
141 self.node.appliEficas.trUtf8('Fichier Include'),
142 self.node.appliEficas.trUtf8('All Files (*);;''JDC Files (*.comm);;'))
147 fn = os.path.abspath((unicode(fn)))
148 self.LENomFichier.setText(fn)
149 self.LENomFichReturnPressed()
151 def connecterSignaux(self):
152 self.connect(self.LBNouvCommande,SIGNAL("doubleClicked(QListBoxItem*)"),self.LBNouvCommandeClicked)
153 self.connect(self.LEFiltre,SIGNAL("textChanged(const QString&)"),self.LEFiltreTextChanged)
154 self.connect(self.LEFiltre,SIGNAL("returnPressed()"),self.LEfiltreReturnPressed)
155 self.connect(self.bSup,SIGNAL("pressed()"),self.BSupPressed)
156 self.connect(self.bOk,SIGNAL("clicked()"),self.BOkPressed)
157 self.connect(self.RBGroupe,SIGNAL("clicked()"),self.BuildTabCommand)
158 self.connect(self.RBalpha,SIGNAL("clicked()"),self.BuildTabCommand)
159 self.connect(self.bHelp,SIGNAL("clicked()"),self.ViewDoc)
160 self.connect(self.BNext,SIGNAL("pressed()"),self.BNextPressed)
161 self.connect(self.BBrowse,SIGNAL("clicked()"),self.BBrowsePressed)
163 self.connect(self.BChangeFile,SIGNAL("clicked()"),self.BChangeFilePressed)
164 self.connect(self.LENomFichier,SIGNAL("returnPressed()"),self.LENomFichReturnPressed)
169 QTPanel.ViewDoc(self)
171 def BSupPressed(self):
172 QTPanel.BSupPressed(self)
174 def BOkPressed(self):
175 QTPanel.BOkPressed(self)
177 def BNextPressed(self):
178 QTPanelTBW2.BNextPressed(self)
180 def BuildTabCommand(self):
181 QTPanelTBW2.BuildLBNouvCommande(self)
183 def LEFiltreTextChanged(self):
184 QTPanelTBW2.LEFiltreTextChanged(self)
186 def LEfiltreReturnPressed(self):
187 QTPanelTBW2.LEfiltreReturnPressed(self)
189 def LBNouvCommandeClicked(self):
190 QTPanelTBW2.LBNouvCommandeClicked(self)
192 def LENomConceptReturnPressed(self):
193 QTPanelTBW3.LENomConceptReturnPressed(self)