1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 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
23 from . import typeNode
24 from Extensions.i18n import tr
27 from Editeur import Objecttreeitem
31 class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel):
33 def getPanelGroupe(self,parentQt,commande):
34 maDefinition=self.item.get_definition()
35 monObjet=self.item.object
38 if hasattr(parentQt,'niveau'): self.niveau=parentQt.niveau+1
40 #if hasattr(self,'plie') :print self.item.nom, self.plie
41 if hasattr(self,'plie') and self.plie==True :
42 from .monWidgetFactPlie import MonWidgetFactPlie
43 widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande)
45 from .monWidgetFact import MonWidgetFact
46 widget=MonWidgetFact(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande)
50 def createPopUpMenu(self):
51 typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self)
54 class FACTTreeItem(Objecttreeitem.ObjectTreeItem):
57 def IsExpandable(self):
63 def GetLabelText(self):
64 """ Retourne 3 valeurs :
65 - le texte à afficher dans le noeud representant l'item
66 - la fonte dans laquelle afficher ce texte
69 # None --> fonte et couleur par defaut
70 return self.object.getlabeltext(),None,None
73 return self.object.isvalid()
78 def GetIconName(self):
79 if self.object.isvalid():
80 return "ast-green-los"
81 elif self.object.isoblig():
88 # keys=self.object.mc_dict
93 Reactualise la liste des items fils stockes dans self.sublist
95 liste=self.object.mc_liste
96 sublist=[None]*len(liste)
97 # suppression des items lies aux objets disparus
98 for item in self.sublist:
99 old_obj=item.getObject()
101 pos=liste.index(old_obj)
104 pass # objets supprimes ignores
105 # ajout des items lies aux nouveaux objets
108 if sublist[pos] is None:
109 # nouvel objet : on cree un nouvel item
110 def setfunction(value, object=obj):
112 item = self.make_objecttreeitem(self.appli, obj.nom + " : ", obj, setfunction)
119 def additem(self,name,pos):
120 objet = self.object.addentite(name,pos)
123 def suppitem(self,item) :
125 Cette methode a pour fonction de supprimer l'item passee en argument
126 des fils de l'item FACT qui est son pere
127 - item = item du MOCLE a supprimer du MOCLE pere
128 - item.getObject() = MCSIMP ou MCBLOC
130 itemobject=item.getObject()
131 if itemobject.isoblig() :
132 #self.editor.affiche_infos(tr('Impossible de supprimer un mot-cle obligatoire '),Qt.red)
133 return (0, tr('Impossible de supprimer un mot-cle obligatoire '))
135 if self.object.suppentite(itemobject):
136 message = tr("Mot-cle %s supprime")+ six.text_type(itemobject.nom)
137 #self.editor.affiche_commentaire(message)
140 #self.editor.affiche_infos(tr('Pb interne : impossible de supprimer ce mot-cle'),Qt.red)
141 return (0,tr('Pb interne : impossible de supprimer ce mot-cle'))
145 treeitem = FACTTreeItem