Salome HOME
modif du 1010
[tools/eficas.git] / Ihm / I_OBJECT.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013   EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 """
21 """
22 import string
23 import Noyau
24
25 import CONNECTOR
26
27 class OBJECT:
28   from Noyau.N_CO import CO
29   from Noyau.N_ASSD import assd
30
31   def isMCList(self):
32     """ 
33         Retourne 1 si self est une MCList (liste de mots-cles), 0 sinon (defaut) 
34     """
35     return 0
36
37   def get_regles(self):
38     """ 
39        Retourne les regles de self 
40     """
41     if hasattr(self,'definition'):
42       return self.definition.regles
43     elif hasattr(self,'regles'):
44       return self.regles
45     else :
46       return []
47
48   def init_modif(self):
49     """
50        Met l'etat de l'objet a modified et propage au parent
51        qui vaut None s'il n'existe pas
52     """
53     self.state = 'modified'
54     if self.parent:
55       self.parent.init_modif()
56
57   def fin_modif(self):
58       """
59       Methode appelee apres qu'une modification a ete faite afin de declencher
60       d'eventuels traitements post-modification
61       """
62       #print "fin_modif",self
63       # pour les objets autres que les commandes, aucun traitement specifique 
64       # on remonte l'info de fin de modif au parent
65       CONNECTOR.Emit(self,"valid")
66       if self.parent:
67         self.parent.fin_modif()
68
69   def isrepetable(self):
70     """
71          Indique si l'objet est repetable
72     """
73     return 0
74
75   def liste_mc_presents(self):
76     """
77          Retourne la liste des noms des mots cles presents
78     """
79     return []
80
81   def get_docu(self):
82     return self.definition.get_docu()
83
84   def get_liste_mc_inconnus(self):
85      """
86      Retourne la liste des mots-cles inconnus dans self
87      """
88      return []
89
90   def verif_condition_regles(self,liste_presents):
91     """ 
92         Retourne la liste des mots-cles a rajouter pour satisfaire les regles
93         en fonction de la liste des mots-cles presents 
94     """
95     liste=[]
96     for regle in self.definition.regles:
97         liste=regle.verif_condition_regle(liste,liste_presents)
98     return liste
99
100   def verif_condition_bloc(self):
101     """ 
102         Evalue les conditions de tous les blocs fils possibles 
103         (en fonction du catalogue donc de la definition) de self et
104         retourne deux listes :
105           - la premiere contient les noms des blocs a rajouter
106           - la seconde contient les noms des blocs a supprimer
107     """
108     return [],[]
109
110   def get_genealogie_precise(self):
111     if self.parent:
112        l=self.parent.get_genealogie_precise()
113        l.append(string.strip(self.nom))
114        return l
115     else:
116        return [string.strip(self.nom)]
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 rencontre
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      #if 1 :
137         return getattr(self.definition,self.jdc.lang)
138      except:
139      #else:
140         try :
141             return getattr(self.definition,"fr")
142         except :
143             return ''
144
145   def update_concept(self,sd):
146      pass
147
148   def normalize(self):
149      """ Retourne l'objet normalise. En general self sauf si
150          pour etre insere dans l'objet pere il doit etre 
151          wrappe dans un autre objet (voir mot cle facteur).
152      """
153      return self
154
155   def delete_mc_global(self):
156      return
157
158   def update_mc_global(self):
159      return
160
161   #def __del__(self):
162   #   print "__del__",self
163
164 class ErrorObj(OBJECT):pass
165