Salome HOME
0f4d28ea3233ad7c87e76a39148fbe8108892e0a
[tools/eficas.git] / Ihm / I_OBJECT.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 """
23 import string
24
25 import Noyau
26
27 try:
28   import prefs
29   lang=prefs.lang
30 except:
31   lang='fr'
32
33 import CONNECTOR
34
35 class OBJECT:
36   from Noyau.N_CO import CO
37   from Noyau.N_ASSD import assd
38
39   def isMCList(self):
40     """ 
41         Retourne 1 si self est une MCList (liste de mots-clés), 0 sinon (défaut) 
42     """
43     return 0
44
45   def get_regles(self):
46     """ 
47        Retourne les règles de self 
48     """
49     if hasattr(self,'definition'):
50       return self.definition.regles
51     elif hasattr(self,'regles'):
52       return self.regles
53     else :
54       return []
55
56   def init_modif(self):
57     """
58        Met l'état de l'objet à modified et propage au parent
59        qui vaut None s'il n'existe pas
60     """
61     self.state = 'modified'
62     if self.parent:
63       self.parent.init_modif()
64
65   def fin_modif(self):
66       """
67       Méthode appelée après qu'une modification a été faite afin de déclencher
68       d'éventuels traitements post-modification
69       """
70       #print "fin_modif",self
71       # pour les objets autres que les commandes, aucun traitement spécifique 
72       # on remonte l'info de fin de modif au parent
73       CONNECTOR.Emit(self,"valid")
74       if self.parent:
75         self.parent.fin_modif()
76
77   def isrepetable(self):
78     """
79          Indique si l'objet est répétable
80     """
81     return 0
82
83   def liste_mc_presents(self):
84     """
85          Retourne la liste des noms des mots clés présents
86     """
87     return []
88
89   def get_docu(self):
90     return self.definition.get_docu()
91
92   def get_liste_mc_inconnus(self):
93      """
94      Retourne la liste des mots-clés inconnus dans self
95      """
96      return []
97
98   def verif_condition_regles(self,liste_presents):
99     """ 
100         Retourne la liste des mots-clés à rajouter pour satisfaire les règles
101         en fonction de la liste des mots-clés présents 
102     """
103     liste=[]
104     for regle in self.definition.regles:
105         liste=regle.verif_condition_regle(liste,liste_presents)
106     return liste
107
108   def verif_condition_bloc(self):
109     """ 
110         Evalue les conditions de tous les blocs fils possibles 
111         (en fonction du catalogue donc de la définition) de self et
112         retourne deux listes :
113           - la première contient les noms des blocs à rajouter
114           - la seconde contient les noms des blocs à supprimer
115     """
116     return [],[]
117
118   def get_genealogie(self):
119     """ 
120         Retourne la liste des noms des ascendants (noms de MCSIMP,MCFACT,MCBLOC
121         ou ETAPE) de self jusqu'au premier objet etape rencontré
122     """
123     if self.parent:
124        l=self.parent.get_genealogie()
125        l.append(string.strip(self.nom))
126        return l
127     else:
128        return [string.strip(self.nom)]
129
130   def get_fr(self):
131      """
132          Retourne la chaine d'aide contenue dans le catalogue
133          en tenant compte de la langue
134      """
135      try :
136         return getattr(self.definition,lang)
137      except:
138         return ''
139