Salome HOME
bug de CBChecked a True
[tools/eficas.git] / InterfaceQT4 / compocommandecomm.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 import traceback
21 import string
22
23 from Editeur import Objecttreeitem
24 from Extensions.eficas_exception import EficasException
25 import compocomm
26
27 class COMMANDE_COMMTreeItem(Objecttreeitem.ObjectTreeItem):
28     itemNode=compocomm.Node
29
30     def init(self):
31       self.setfunction = self.set_valeur
32
33     def GetIconName(self):
34       """
35       Retourne le nom de l'icône associée au noeud qui porte self,
36       dépendant de la validité de l'objet
37       NB : une commande commentarisée est toujours valide ...
38       """
39       if self.isvalid():
40           return "ast-green-percent"
41       else:
42           return "ast-red-percent"
43
44     def GetLabelText(self):
45         """ Retourne 3 valeurs :
46         - le texte à afficher dans le noeud représentant l'item
47         - la fonte dans laquelle afficher ce texte
48         - la couleur du texte
49         """
50         return 'commentaire'
51
52     def get_valeur(self):
53       """
54       Retourne la valeur de la commande commentarisée cad son texte
55       """
56       return self.object.get_valeur() or ''
57     
58     def GetText(self):
59         texte = self.object.valeur
60         texte = string.split(texte,'\n')[0]
61         if len(texte) < 25 :
62             return texte
63         else :
64             return texte[0:24]
65
66     def set_valeur(self,valeur):
67       """
68       Afefcte valeur à l'objet commande commentarisée
69       """
70       self.object.set_valeur(valeur)
71       
72     def GetSubList(self):
73       """
74       Retourne la liste des fils de self
75       """
76       return []
77
78     def uncomment(self):
79       """
80       Demande à l'objet commande commentarisée de se décommentariser.
81       Si l'opération s'effectue correctement, retourne l'objet commande
82       et éventuellement le nom de la sd produite, sinon lève une exception
83       """
84       try:
85         commande,nom = self.object.uncomment()
86         #self.parent.children[pos].select()
87       except Exception as e:
88         traceback.print_exc()
89         raise EficasException(e)
90       return commande,nom
91   
92 import Accas
93 treeitem =COMMANDE_COMMTreeItem
94 objet = Accas.COMMANDE_COMM