From 96ac4b3fccec48e4c94cb79bbce8c324f218d407 Mon Sep 17 00:00:00 2001 From: Renaud Barate Date: Mon, 2 Dec 2013 14:06:20 +0000 Subject: [PATCH] Add new type SalomeEntry to handle selection from Salome object browser --- src/EFICASGUI/eficasSalome.py | 45 ++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/EFICASGUI/eficasSalome.py b/src/EFICASGUI/eficasSalome.py index 3be453b5..04aff588 100644 --- a/src/EFICASGUI/eficasSalome.py +++ b/src/EFICASGUI/eficasSalome.py @@ -453,29 +453,22 @@ class MyEficas( qtEficas.Appli ): retourne une liste pour etre coherent avec selectGroupFromSalome Note: Appele par EFICAS lorsqu'on clique sur le bouton ajouter la liste du panel SalomeEntry """ - names, msg = [], '' try: - atLeastOneStudy = self.editor.study - if not atLeastOneStudy: - return names, msg + if self.editor.study._non_existent(): + raise Exception(self.tr(u"L'étude Salome n'existe plus")) entries = salome.sg.getAllSelected() nbEntries = len( entries ) if nbEntries < 1: - msg = self.tr(u"Veuillez selectionner une entree de l'arbre d'etude de Salome") - QMessageBox.information(self, self.tr(u"Selection depuis Salome"), msg) - return [], msg + raise Exception(self.tr(u"Veuillez sélectionner une entrée de l'arbre d'étude de Salome")) elif nbEntries > 1 : - msg = self.tr(u"Une seule entrée doit être sélectionnée dans l'arbre d'étude de Salome") - QMessageBox.information(self, self.tr(u"Sélection depuis Salome"),msg) - return [], msg - - value = salome.sg.getSelected(0) + raise Exception(self.tr(u"Une seule entrée doit être sélectionnée dans l'arbre d'étude de Salome")) + value = kwType.get_selected_value(entries[0], self.editor) msg = self.tr(u"L'entrée de l'arbre d'étude de Salome a été sélectionnée") return [value], msg except Exception, e: - QMessageBox.information(self, self.tr(u"Sélection depuis Salome"), unicode(e)) - return [], unicode(e) + QMessageBox.information(self, self.tr(u"Sélection depuis Salome"), unicode(e)) + return [], unicode(e) #--------------------------------------------- @@ -665,6 +658,30 @@ class MyEficas( qtEficas.Appli ): traceback.print_exc() logger.debug(10*'#'+":pb dans envoievisu") + +class SalomeEntry: + """ + This class replaces the class Accas.SalomeEntry (defined in EFICAS tool) + when Eficas is launched in Salome context. It handles the objects that can + be selected from Salome object browser. + By default, the selected value is the entry of the selected item in the + object browser. This class can be subclassed to provide more advanced + functions. + """ + + help_message = u"Une entrée de l'arbre d'étude de Salome est attendue" + + def __init__(self, entryStr): + self._entry = entryStr + + @staticmethod + def __convert__(entryStr): + return SalomeEntry(entryStr) + + @staticmethod + def get_selected_value(selected_entry, study_editor): + return selected_entry + #------------------------------------------------------------------------------------------------------- # Point d'entree lancement EFICAS -- 2.39.2