Déclenche la copie de l'objet item avec pour cible
l'objet passé en argument : node_selected
"""
- #print 'je passe dans doPaste'
+ print 'je passe dans doPaste'
objet_a_copier = self.item.get_copie_objet()
child=node_selected.doPasteCommande(objet_a_copier,pos)
return child
self.appliEficas.trUtf8('Wrapper Files (*.xml);;''All Files (*)'))
return fichier
- #----------------------------------#
- def writeFile(self, fn, txt = None):
- #----------------------------------#
+ #---------------------------------------------------------------#
+ def writeFile(self, fn, txt = None, formatLigne="beautifie"):
+ #---------------------------------------------------------------#
"""
Public slot to write the text to a file.
fn = unicode(fn)
if txt == None :
- txt = self.get_text_JDC(self.format)
+ txt = self.get_text_JDC(self.format,formatLigne=formatLigne)
eol = '\n'
if len(txt) >= len(eol):
if txt[-len(eol):] != eol:
.arg(unicode(fn)).arg(str(why)))
return 0
- #-------------------------------------#
- def get_text_JDC(self,format,pourRun=0):
- #-------------------------------------#
+ #---------------------------------------------------------------#
+ def get_text_JDC(self,format,pourRun=0,formatLigne="beautifie"):
+ #---------------------------------------------------------------#
if self.code == "MAP" and not(generator.plugins.has_key(format)): format = "MAP"
if generator.plugins.has_key(format):
# Le generateur existe on l'utilise
self.generator=generator.plugins[format]()
try :
- jdc_formate=self.generator.gener(self.jdc,format='beautifie',config=self.appliEficas.CONFIGURATION)
+ jdc_formate=self.generator.gener(self.jdc,format=formatLigne,config=self.appliEficas.CONFIGURATION)
if pourRun : jdc_formate=self.generator.textePourRun
except ValueError,e:
QMessageBox.critical(self, tr("Erreur a la generation"),str(e))
#else :
pass
- #-----------------------------------------#
- def saveFile(self, path = None, saveas= 0):
- #-----------------------------------------#
+ #-------------------------------------------------------------#
+ def saveFile(self, path = None, saveas= 0, formatLigne="beautifie"):
+ #-------------------------------------------------------------#
"""
Public slot to save the text to a file.
fn = unicode(QDir.convertSeparators(fn))
newName = fn
- if not (self.writeFile(fn)): return (0, None)
+ if not (self.writeFile(fn,formatLigne=formatLigne)): return (0, None)
self.fichier = fn
self.modified = False
if self.fileInfo is None or saveas:
return (1, self.fichier)
#
#----------------------------------------------#
- def saveFileAs(self, path = None,fileName=None):
+ def sauveLigneFile(self):
#----------------------------------------------#
+ self.modified=1
+ return self.saveFile(formatLigne="Ligne")
+
+ #---------------------------------------------------------------#
+ def saveFileAs(self, path = None,fileName=None):
+ #---------------------------------------------------------------#
"""
Public slot to save a file with a new name.
self.fichier = fileName
self.modified=1
return self.saveFile()
- return self.saveFile(path,1)
+ return self.saveFile(path,1,"beautifie")
self.menuOptions.addAction(self.actionLecteur_Pdf)
self.menuOptions.setTitle(tr("Options"))
+ self.menuFichier.addAction(self.actionSauveLigne)
def CARMEL3D(self):
#if self.salome == 0 : return
self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
+ self.actionSauveLigne = QAction(self)
+ self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
self.connect(self.actionParametres_Eficas,SIGNAL("activated()"),self.optionEditeur)
self.connect(self.actionLecteur_Pdf,SIGNAL("activated()"),self.optionPdf)
self.connect(self.actionTraduitV9V10,SIGNAL("activated()"),self.traductionV9V10)
self.connect(self.actionTraduitV10V11,SIGNAL("activated()"),self.traductionV10V11)
+ self.connect(self.actionSauveLigne,SIGNAL("activated()"),self.sauveLigne)
# Pour Carmel
self.actionChercheGrpMaille = QAction(self)
if msg != "":
QMessageBox.warning(self, tr(u"Erreur"), msg)
+ def sauveLigne(self):
+ return self.viewmanager.sauveLigneCurrentEditor()
+
def fileSave(self):
return self.viewmanager.saveCurrentEditor()
if index < 0 : return
self.dict_editors[index].viewJdcPy()
+ def sauveLigneCurrentEditor(self):
+ index=self.myQtab.currentIndex()
+ if index < 0 : return
+ editor=self.dict_editors[index]
+ if editor in self.doubles.keys() :
+ QMessageBox.warning(
+ None,
+ tr("Fichier Duplique"),
+ tr("Le fichier ne sera pas sauvegarde."),
+ tr("&Annuler"))
+ return
+ ok, newName = editor.sauveLigneFile()
+ if ok :
+ fileName=os.path.basename(unicode(newName))
+ self.myQtab.setTabText(index,fileName)
+ return ok
+
def saveCurrentEditor(self):
index=self.myQtab.currentIndex()
if index < 0 : return
s=s+'\n'+texte
return s
+
+class FormatageLigne(Formatage) :
+ def __init__(self,l_jdc,code=None,mode=None,sep='=',l_max="**"):
+ Formatage.__init__(self,l_jdc,code=None,mode=None,sep='=',l_max="**")
+
+ def formate_jdc(self):
+ texte1=Formatage.formate_jdc(self)
+ newText=""
+ lignes=texte1.split("\n")
+ texte=""
+ pattern_debut_blanc = re.compile(r"^ \s*.*")
+ pattern_commentaire = re.compile(r"^\s*#.*")
+ pattern_vide=re.compile(r"\s*^$")
+ for l in lignes :
+ if pattern_commentaire.match(l) or pattern_vide.match(l):
+ newText+=l+"\n"
+ continue
+ if not pattern_debut_blanc.match(l) : texte=l
+ else : texte+=re.sub(r'^ \s*',' ',l)
+ if texte[-1]==";" :
+ newText+=texte+"\n"
+ texte=""
+ return newText
+
+
import Accas
import Extensions
from Extensions.parametre import ITEM_PARAMETRE
-from Formatage import Formatage
+from Formatage import Formatage
+from Formatage import FormatageLigne
from Extensions.param2 import Formula
+from Extensions.eficas_exception import EficasException
+from Extensions.i18n import tr
+
def entryPoint():
"""
"""
self.appli=obj.get_jdc_root().appli
#self.appli=obj.appli
+ print format
liste= self.generator(obj)
if format == 'brut':
self.text=liste
elif format == 'beautifie':
jdc_formate = Formatage(liste,mode='.py')
self.text=jdc_formate.formate_jdc()
+ elif format == 'Ligne':
+ jdc_formate = FormatageLigne(liste,mode='.py')
+ self.text=jdc_formate.formate_jdc()
else:
- raise "Format pas implemente : "+format
+ raise EficasException(tr("Format non implemente ") +format)
return self.text
def generator(self,obj):
elif isinstance(obj,Formula):
return self.generFormula(obj)
else:
- raise "Type d'objet non prevu",obj
+ raise EficasException(tr("Type d'objet non prevu") +obj)
def generJDC(self,obj):
"""