1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2021 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 from __future__ import absolute_import
22 from Editeur import Objecttreeitem
24 from . import typeNode
25 from Extensions.i18n import tr
28 class Node(browser.JDCNode,typeNode.PopUpMenuRacine):
31 from .monChoixCommande import MonChoixCommande
32 return MonChoixCommande(self,self.item, self.editor)
35 def createPopUpMenu(self):
36 typeNode.PopUpMenuRacine.createPopUpMenu(self)
38 def addParameters(self,apres):
39 param=self.appendChild("PARAMETRE",pos=0)
44 class JDCTreeItem(Objecttreeitem.ObjectTreeItem):
47 def isExpandable(self):
53 def getLabelText(self):
54 # None --> fonte et couleur par defaut
55 return tr(self.object.nom),None,None
59 Retourne l'objet pointe par self
63 def getIconName(self):
64 if self.object.isValid():
65 return "ast-green-square"
67 return "ast-red-square"
70 # if self.object.etapes_niveaux != []:
71 # return range(len(self.object.etapes_niveaux))
73 # return range(len(self.object.etapes))
75 def addItem(self,name,pos):
76 cmd = self._object.addEntite(name,pos)
79 def suppItem(self,item) :
80 # item = item de l'ETAPE a supprimer du JDC
81 # item.getObject() = ETAPE ou COMMENTAIRE
84 itemobject=item.getObject()
85 if self.object.suppEntite(itemobject):
86 if itemobject.nature == "COMMENTAIRE" :
87 message = tr("Commentaire supprime")
89 message = tr("Commande %s supprimee",itemobject.nom)
92 message=tr("Pb interne : impossible de supprimer cet objet")
97 Retourne la liste des items fils de l'item jdc.
98 Cette liste est conservee et mise a jour a chaque appel
100 if self.object.etapes_niveaux != []:
101 liste = self.object.etapes_niveaux
103 liste = self.object.etapes
104 sublist=[None]*len(liste)
105 # suppression des items lies aux objets disparus
106 for item in self.sublist:
107 old_obj=item.getObject()
109 pos=liste.index(old_obj)
112 pass # objets supprimes ignores
113 # ajout des items lies aux nouveaux objets
116 if sublist[pos] is None:
117 # nouvel objet : on cree un nouvel item
118 item = self.makeObjecttreeitem(self.appliEficas, obj.nom + " : ", obj)
125 def getLNomsEtapes(self):
126 """ Retourne la liste des noms des etapes de self.object"""
127 return self.object.getLNomsEtapes()
129 def getListeCmd(self):
130 listeCmd = self.object.niveau.definition.getListeCmd()
134 treeitem =JDCTreeItem