Salome HOME
PN pour notation scientifique
[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(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(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_old(self):
66       return self.object.isactif()
67
68   def IsExpandable(self):
69       return 1
70     
71   def GetLabelText(self):
72       """ Retourne 3 valeurs :
73         - le texte à afficher dans le noeud représentant l'item
74         - la fonte dans laquelle afficher ce texte
75         - la couleur du texte
76       """
77       if self.isactif():
78           fonte = Fonte_Niveau
79       else :
80           fonte = Fonte_Niveau_inactif
81       return self.labeltext,fonte,'#00008b'
82     
83   def GetIconName(self):
84       if self.isactif():
85           if self.object.isvalid():
86               return "ast-green-text"
87           else:
88               return "ast-red-text"
89       else:
90           return "ast-white-text"
91   
92   def keys(self):
93       if self.object.etapes_niveaux != []:
94           return range(len(self.object.etapes_niveaux))
95       else:
96           return range(len(self.object.etapes))
97
98   def GetSubList(self):
99     sublist=[]
100     for key in self.keys():
101       if self.object.etapes_niveaux != []:
102           liste = self.object.etapes_niveaux
103       else:
104           liste = self.object.etapes
105       try:
106         value = liste[key]
107       except KeyError:
108         continue
109       def setfunction(value, key=key, object=liste):
110         object[key] = value
111       item =self.make_objecttreeitem(self.appli,value.ident() + " : ", value, setfunction)
112       sublist.append(item)
113     return sublist
114
115   def additem(self,name,pos):
116       if isinstance(name,Objecttreeitem.TreeItem) :
117           cmd=self.object.addentite(name.getObject(),pos)
118       else :
119           cmd = self.object.addentite(name,pos)
120       item = self.make_objecttreeitem(self.appli,cmd.nom + " : ", cmd)
121       return item
122
123   def suppitem(self,item) :
124     # item = item de l'ETAPE à supprimer du JDC
125     # item.getObject() = ETAPE ou COMMENTAIRE
126     # self.object = JDC
127     itemobject=item.getObject()
128     if self.object.suppentite(itemobject):
129        if isinstance(item.object,commentaire.COMMENTAIRE):
130           message = "Commentaire supprimé"
131        else :
132           message = "Commande " + itemobject.nom + " supprimée"
133        self.appli.affiche_infos(message)
134        return 1
135     else:
136        self.appli.affiche_infos("Pb interne : impossible de supprimer cet objet")
137        return 0
138
139   def GetText(self):
140       return ''
141
142     
143 import Accas
144 treeitem = NIVEAUTreeItem
145 objet = Accas.ETAPE_NIVEAU