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
23 from Extensions.i18n import tr
26 from Editeur import Objecttreeitem
29 class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel):
31 def getPanelGroupe(self,parentQt,commande):
32 maDefinition=self.item.get_definition()
33 monObjet=self.item.object
36 if hasattr(parentQt,'niveau'): self.niveau=parentQt.niveau+1
38 if hasattr(self,'plie') :print self.item.nom, self.plie
39 if hasattr(self,'plie') and self.plie==True :
40 from monWidgetFactPlie import MonWidgetFactPlie
41 widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande)
43 from monWidgetFact import MonWidgetFact
44 widget=MonWidgetFact(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande)
48 def createPopUpMenu(self):
49 typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self)
52 class FACTTreeItem(Objecttreeitem.ObjectTreeItem):
55 def IsExpandable(self):
61 def GetLabelText(self):
62 """ Retourne 3 valeurs :
63 - le texte à afficher dans le noeud representant l'item
64 - la fonte dans laquelle afficher ce texte
67 # None --> fonte et couleur par defaut
68 return self.object.getlabeltext(),None,None
71 return self.object.isvalid()
76 def GetIconName(self):
77 if self.object.isvalid():
78 return "ast-green-los"
79 elif self.object.isoblig():
85 keys=self.object.mc_dict.keys()
90 Reactualise la liste des items fils stockes dans self.sublist
92 liste=self.object.mc_liste
93 sublist=[None]*len(liste)
94 # suppression des items lies aux objets disparus
95 for item in self.sublist:
96 old_obj=item.getObject()
98 pos=liste.index(old_obj)
101 pass # objets supprimes ignores
102 # ajout des items lies aux nouveaux objets
105 if sublist[pos] is None:
106 # nouvel objet : on cree un nouvel item
107 def setfunction(value, object=obj):
109 item = self.make_objecttreeitem(self.appli, obj.nom + " : ", obj, setfunction)
116 def additem(self,name,pos):
117 objet = self.object.addentite(name,pos)
120 def suppitem(self,item) :
122 Cette methode a pour fonction de supprimer l'item passee en argument
123 des fils de l'item FACT qui est son pere
124 - item = item du MOCLE a supprimer du MOCLE pere
125 - item.getObject() = MCSIMP ou MCBLOC
127 itemobject=item.getObject()
128 if itemobject.isoblig() :
129 #self.editor.affiche_infos(tr('Impossible de supprimer un mot-cle obligatoire '),Qt.red)
130 return (0, tr('Impossible de supprimer un mot-cle obligatoire '))
132 if self.object.suppentite(itemobject):
133 message = tr("Mot-cle %s supprime")+ unicode(itemobject.nom)
134 #self.editor.affiche_commentaire(message)
137 #self.editor.affiche_infos(tr('Pb interne : impossible de supprimer ce mot-cle'),Qt.red)
138 return (0,tr('Pb interne : impossible de supprimer ce mot-cle'))
142 treeitem = FACTTreeItem