]> SALOME platform Git repositories - tools/eficas.git/blob - Editeur/componiveau.py
Salome HOME
CCAR: modifications pour :
[tools/eficas.git] / Editeur / componiveau.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 from Tkinter import *
23 import Pmw
24
25 import Objecttreeitem
26 import panels
27 import fontes
28 from Extensions import commentaire 
29
30 Fonte_Niveau = fontes.canvas_gras_italique
31 Fonte_Niveau_inactif = fontes.canvas_italique
32
33 class NIVEAUPanel(panels.OngletPanel):
34     def init(self):
35         """ Initialise les frame des panneaux contextuels relatifs à un JDC """
36         panneau=Pmw.PanedWidget(self,orient='horizontal')
37         panneau.add('left',min=0.4,max=0.6,size=0.5)
38         panneau.add('right',min=0.4,max=0.6,size=0.5)
39         panneau.pack(expand=1,fill='both')
40         self.bouton_com.pack_forget()
41         self.makeJDCPage(panneau.pane('left'))
42
43 import treewidget
44 class Node(treewidget.Node):
45     def verif_condition_BAK(self):
46         """
47         on lance la vérification des conditions de chaque bloc de self
48         on crée ou supprime les noeuds concernés
49         (self est d'un niveau inférieur ou égal à l'ETAPE)
50         """
51         return 0
52
53     def replace_enfant_BAK(self,item):
54         """ Retourne le noeud fils à éventuellement remplacer """
55         return None
56
57
58 class NIVEAUTreeItem(Objecttreeitem.ObjectTreeItem):
59   panel = NIVEAUPanel
60   itemNode=Node
61
62   def isactif(self):
63       return self.object.isactif()
64     
65   def IsExpandable(self):
66       return 1
67     
68   def GetLabelText(self):
69       """ Retourne 3 valeurs :
70         - le texte à afficher dans le noeud représentant l'item
71         - la fonte dans laquelle afficher ce texte
72         - la couleur du texte
73       """
74       if self.isactif():
75           fonte = Fonte_Niveau
76       else :
77           fonte = Fonte_Niveau_inactif
78       return self.labeltext,fonte,'#00008b'
79     
80   def GetIconName(self):
81       if self.isactif():
82           if self.object.isvalid():
83               return "ast-green-text"
84           else:
85               return "ast-red-text"
86       else:
87           return "ast-white-text"
88   
89   def keys(self):
90       if self.object.etapes_niveaux != []:
91           return range(len(self.object.etapes_niveaux))
92       else:
93           return range(len(self.object.etapes))
94
95   def GetSubList(self):
96     sublist=[]
97     for key in self.keys():
98       if self.object.etapes_niveaux != []:
99           liste = self.object.etapes_niveaux
100       else:
101           liste = self.object.etapes
102       try:
103         value = liste[key]
104       except KeyError:
105         continue
106       def setfunction(value, key=key, object=liste):
107         object[key] = value
108       item =self.make_objecttreeitem(self.appli,value.ident() + " : ", value, setfunction)
109       sublist.append(item)
110     return sublist
111
112   def additem(self,name,pos):
113       if isinstance(name,Objecttreeitem.TreeItem) :
114           cmd=self.object.addentite(name.getObject(),pos)
115       else :
116           cmd = self.object.addentite(name,pos)
117       item = self.make_objecttreeitem(self.appli,cmd.nom + " : ", cmd)
118       return item
119
120   def suppitem(self,item) :
121     # item = item de l'ETAPE à supprimer du JDC
122     # item.getObject() = ETAPE ou COMMENTAIRE
123     # self.object = JDC
124     itemobject=item.getObject()
125     if self.object.suppentite(itemobject):
126        if isinstance(item.object,commentaire.COMMENTAIRE):
127           message = "Commentaire supprimé"
128        else :
129           message = "Commande " + itemobject.nom + " supprimée"
130        self.appli.affiche_infos(message)
131        return 1
132     else:
133        self.appli.affiche_infos("Pb interne : impossible de supprimer cet objet")
134        return 0
135
136   def GetText(self):
137       return ''
138
139     
140 import Accas
141 treeitem = NIVEAUTreeItem
142 objet = Accas.ETAPE_NIVEAU