1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2017 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 from __future__ import absolute_import
23 from builtins import object
26 from PyQt5.QtCore import Qt
27 from .monViewRegles import ViewRegles
28 from Extensions.i18n import tr
30 class GereRegles(object) :
32 def appellebuildLBRegles(self):
33 from .browser import JDCTree
34 if isinstance(self,JDCTree):
35 self.appellebuildLBReglesForJdC()
37 self.appellebuildLBReglesForCommand()
38 self.buildLBRegles(self.listeRegles,self.listeNomsEtapes)
41 def appellebuildLBReglesForCommand(self):
42 self.listeRegles = self.item.getRegles()
43 self.listeNomsEtapes = self.item.getMcPresents()
45 def appellebuildLBReglesForJdC(self):
46 self.listeRegles=self.item.getRegles()
47 self.listeNomsEtapes = self.item.getLNomsEtapes()
50 def buildLBRegles(self,listeRegles,listeNomsEtapes):
52 if len(listeRegles) > 0:
53 for regle in listeRegles :
54 texteRegle=regle.getText()
55 texteMauvais,test = regle.verif(listeNomsEtapes)
56 for ligne in texteRegle.split("\n") :
57 if ligne == "" : continue
58 if ligne[0]=="\t" : ligne=" "+ligne[1:]
60 self.liste.append((ligne,Qt.black))
62 self.liste.append((ligne,Qt.red))
63 self.liste.append(("",Qt.red))
64 if self.liste==[] : self.liste.append(("pas de regle de construction pour ce jeu de commandes",Qt.black))
67 def afficheRegles(self):
68 titre="Regles pour "+self.item.nom
69 w = ViewRegles( self.editor,self.liste,titre )