Salome HOME
Select Valeur dans un fichier
[tools/eficas.git] / InterfaceQT4 / compojdc.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 from Editeur import Objecttreeitem
22 import browser
23 import typeNode
24 from Extensions.i18n import tr
25
26
27 class Node(browser.JDCNode,typeNode.PopUpMenuRacine):
28     def getPanel(self):
29         """
30         """
31         #if self.affichage_onglet==1 :
32         #   from monRacinePanel_onglet import MonRacinePanel
33         #   return MonRacinePanel(self,parent=self.editor)
34         from monRacinePanel import MonRacinePanel
35         return MonRacinePanel(self,parent=self.editor)
36
37     def getPanel2(self):
38         from monChoixCommande import MonChoixCommande
39         return MonChoixCommande(self,self.item, self.editor)
40         
41
42     def createPopUpMenu(self):
43         typeNode.PopUpMenuRacine.createPopUpMenu(self)
44
45     def addParameters(self,apres):
46         param=self.append_child("PARAMETRE",pos=0)
47         return param
48        
49
50
51 class JDCTreeItem(Objecttreeitem.ObjectTreeItem):
52   itemNode=Node
53   
54   def IsExpandable(self):
55     return 1
56
57   def GetText(self):
58       return  "    "
59
60   def GetLabelText(self):
61       # None --> fonte et couleur par defaut
62       return tr(self.object.nom),None,None
63
64   def get_jdc(self):
65     """
66     Retourne l'objet pointe par self
67     """
68     return self.object
69   
70   def GetIconName(self):
71     if self.object.isvalid():
72       return "ast-green-square"
73     else:
74       return "ast-red-square"
75
76   def keys(self):
77       if self.object.etapes_niveaux != []:
78           return range(len(self.object.etapes_niveaux))
79       else:
80           return range(len(self.object.etapes))
81
82   def additem(self,name,pos):
83       cmd = self._object.addentite(name,pos)
84       return cmd
85
86   def suppitem(self,item) :
87     # item             = item de l'ETAPE a supprimer du JDC
88     # item.getObject() = ETAPE ou COMMENTAIRE
89     # self.object      = JDC
90
91     itemobject=item.getObject()
92     if self.object.suppentite(itemobject):
93        if itemobject.nature == "COMMENTAIRE" :
94           message = tr("Commentaire supprime")
95        else :
96           message = tr("Commande %s supprimee",itemobject.nom)
97        return 1,message
98     else:
99        message=tr("Pb interne : impossible de supprimer cet objet")
100        return 0,message
101
102   def GetSubList(self):
103     """
104        Retourne la liste des items fils de l'item jdc.
105        Cette liste est conservee et mise a jour a chaque appel
106     """
107     if self.object.etapes_niveaux != []:
108         liste = self.object.etapes_niveaux
109     else:
110         liste = self.object.etapes
111     sublist=[None]*len(liste)
112     # suppression des items lies aux objets disparus
113     for item in self.sublist:
114        old_obj=item.getObject()
115        if old_obj in liste:
116           pos=liste.index(old_obj)
117           sublist[pos]=item
118        else:
119           pass # objets supprimes ignores
120     # ajout des items lies aux nouveaux objets
121     pos=0
122     for obj in liste:
123        if sublist[pos] is None:
124           # nouvel objet : on cree un nouvel item
125           item = self.make_objecttreeitem(self.appli, obj.nom + " : ", obj)
126           sublist[pos]=item
127        pos=pos+1
128
129     self.sublist=sublist
130     return self.sublist
131
132   def get_l_noms_etapes(self):
133       """ Retourne la liste des noms des etapes de self.object"""
134       return self.object.get_l_noms_etapes()
135
136   def get_liste_cmd(self):
137       listeCmd = self.object.niveau.definition.get_liste_cmd()
138       return listeCmd
139
140 import Accas
141 treeitem =JDCTreeItem
142 objet = Accas.JDC