1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2010 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
22 This file centralizes the definitions and implementations of ui components used
23 in the GUI part of the module.
26 __author__ = "aribes/gboulant"
29 from PyQt4.QtCore import QObject
30 from PyQt4.QtCore import * # Import from PyQT
31 from PyQt4 import QtGui,QtCore
33 sgPyQt = SalomePyQt.SalomePyQt()
35 from daGuiImpl.enumerate import Enumerate
36 from daGuiImpl.adaoCase import AdaoCase
37 from daEficasWrapper.adaoEficasWrapper import AdaoEficasWrapper
39 from daUtils.adaoEficasEvent import *
41 import adaoStudyEditor
47 # ==============================================================================
48 # Classes to manage the building of UI components
49 # ==============================================================================
51 UI_ELT_IDS = Enumerate([
56 'SAVE_AS_ADAOCASE_ID',
59 'EDIT_ADAOCASE_POP_ID',
64 UI_ELT_IDS.NEW_ADAOCASE_ID:"newAdaoCase",
65 UI_ELT_IDS.OPEN_ADAOCASE_ID:"openAdaoCase",
66 UI_ELT_IDS.SAVE_ADAOCASE_ID:"saveAdaoCase",
67 UI_ELT_IDS.SAVE_AS_ADAOCASE_ID:"saveasAdaoCase",
68 UI_ELT_IDS.CLOSE_ADAOCASE_ID:"closeAdaoCase",
70 UI_ELT_IDS.EDIT_ADAOCASE_POP_ID:"editAdaoCase",
71 UI_ELT_IDS.YACS_EXPORT_POP_ID:"exportCaseToYACS",
75 class AdaoCaseManager(EficasObserver):
77 Cette classe gére les cas ADAO et coordonne les GUI de SALOME (l'étude)
78 et le GUI de l'objet Eficas (héritage du module Eficas)
83 # Création d'un dictionnaire de cas
84 # Key == ref objet editor eficas (on est sur qu'elle est unique, cas duplication)
85 # Value == objet AdaoCase()
88 # Création des deux managers
89 self.salome_manager = AdaoGuiUiComponentBuilder()
90 self.eficas_manager = AdaoEficasWrapper(parent=SalomePyQt.SalomePyQt().getDesktop())
92 # On s'enregistre comme observer pour les évènements venant d'Eficas
93 # Les évènements du salome_manager viennent par le biais de la méthode
95 self.eficas_manager.addObserver(self)
97 # Création du GUI Eficas
98 self.eficas_manager.init_gui()
100 # Création du viewer QT
101 # Scroll Widget (pour les petites résolutions)
102 area = QtGui.QScrollArea(SalomePyQt.SalomePyQt().getDesktop());
103 area.setWidget(self.eficas_manager)
104 area.setWidgetResizable(1)
106 self.eficas_viewId = sgPyQt.createView(wmType, area)
108 # On interdit que la vue soit fermée
109 # Cela simplifier grandement le code
110 sgPyQt.setViewClosable(self.eficas_viewId, False)
112 # On s'abonne au gestionnaire de selection
113 self.selection_manager = sgPyQt.getSelection()
114 QtCore.QObject.connect(self.selection_manager, QtCore.SIGNAL('currentSelectionChanged()'), self.currentSelectionChanged)
118 # Gestion de l'activation/désactivation du module
123 self.eficas_manager.setEnabled(True)
124 self.harmonizeSelectionFromEficas()
126 def deactivate(self):
127 self.eficas_manager.setEnabled(False)
131 # Gestion de la sélection entre le GUI d'Eficas
132 # et l'arbre d'étude de SALOME
136 # Depuis l'étude SALOME
137 def currentSelectionChanged(self):
139 Cette méthode permet de changer le tab vu dans eficas
140 selon la sélection de l'utilisateur dans l'étude SALOME
142 adaoLogger.debug("currentSelectionChanged")
143 salomeStudyItem = adaoGuiHelper.getSelectedItem()
144 for case_editor, adao_case in self.cases.iteritems():
145 if adao_case.salome_study_item.GetID() == salomeStudyItem.GetID():
146 self.eficas_manager.selectCase(adao_case.eficas_editor)
150 def _processEficasTabChanged(self, eficasWrapper, eficasEvent):
152 Gestion de la synchonisation entre le tab courant d'Eficas
153 et la selection dans l'étude SALOME
155 editor = eficasEvent.callbackId
156 for case_editor, adao_case in self.cases.iteritems():
157 if case_editor is editor:
158 adaoGuiHelper.selectItem(adao_case.salome_study_item.GetID())
161 # On remet la sélection dans SALOME grâce au tab dans Eficas
162 def harmonizeSelectionFromEficas(self):
164 Cette méthode permet d'harmoniser la sélection dans l'étude
165 grâce au tab courant d'Eficas
167 adaoLogger.error("harmonizeSelectionFromEficas NOT YET IMPLEMENTED")
170 # 1: Get current tab index in Eficas
171 # 2: sync with SALOME GUI is a tab is opened
175 # Gestion de la création d'un nouveau cas
176 # 1: la fonction newAdaoCase est appelée par le GUI SALOME
177 # 2: la fonction _processEficasNewEvent est appelée par le manager EFICAS
181 def newAdaoCase(self):
182 adaoLogger.debug("Création d'un nouveau cas adao")
183 self.eficas_manager.adaofileNew(AdaoCase())
185 def _processEficasNewEvent(self, eficasWrapper, eficasEvent):
186 adao_case = eficasEvent.callbackId
188 salomeStudyId = adaoGuiHelper.getActiveStudyId()
189 salomeStudyItem = adaoStudyEditor.addInStudy(salomeStudyId, adao_case)
190 # Affichage correct dans l'étude
191 adaoGuiHelper.refreshObjectBrowser()
192 adaoGuiHelper.selectItem(salomeStudyItem.GetID())
193 # Finalisation des données du cas
194 adao_case.salome_study_id = salomeStudyId
195 adao_case.salome_study_item = salomeStudyItem
197 self.cases[adao_case.eficas_editor] = adao_case
201 # Gestion de l'ouverture d'un cas
202 # 1: la fonction openAdaoCase est appelée par le GUI SALOME
203 # 2: la fonction _processEficasOpenEvent est appelée par le manager EFICAS
207 # Rq: l'ouverture d'un cas adao est un cas particulier de la création d'un cas adao
209 def openAdaoCase(self):
210 adaoLogger.debug("Ouverture d'un cas adao")
211 self.eficas_manager.adaoFileOpen(AdaoCase())
213 def _processEficasOpenEvent(self, eficasWrapper, eficasEvent):
214 self._processEficasNewEvent(eficasWrapper, eficasEvent)
218 # Gestion de la sauvegarde d'un cas
219 # 1: la fonction saveAdaoCase est appelée par le GUI SALOME
220 # 1 bis: la fonction saveasAdaoCase est appelée par le GUI SALOME
221 # 2: la fonction _processEficasSaveEvent est appelée par le manager EFICAS
225 def saveAdaoCase(self):
226 adaoLogger.debug("Sauvegarde du cas s'il y a modification")
227 # A priori, l'utilisateur s'attend à sauvegarder le cas qui est ouvert
228 # dans le GUI d'Eficas
229 self.harmonizeSelectionFromEficas()
230 salomeStudyItem = adaoGuiHelper.getSelectedItem()
231 for case_name, adao_case in self.cases.iteritems():
232 if adao_case.salome_study_item.GetID() == salomeStudyItem.GetID():
233 self.eficas_manager.adaoFileSave(adao_case)
236 def saveasAdaoCase(self):
237 adaoLogger.debug("Sauvegarde du cas s'il y a modification (version save as)")
238 # A priori, l'utilisateur s'attend à sauvegarder le cas qui est ouvert
239 # dans le GUI d'Eficas
240 self.harmonizeSelectionFromEficas()
241 salomeStudyItem = adaoGuiHelper.getSelectedItem()
242 for case_name, adao_case in self.cases.iteritems():
243 if adao_case.salome_study_item.GetID() == salomeStudyItem.GetID():
244 self.eficas_manager.adaoFileSaveAs(adao_case)
247 def _processEficasSaveEvent(self, eficasWrapper, eficasEvent):
248 adao_case = eficasEvent.callbackId
249 # On met à jour l'étude
250 adaoStudyEditor.updateItem(adao_case.salome_study_id, adao_case.salome_study_item, adao_case)
251 # Affichage correct dans l'étude
252 adaoGuiHelper.refreshObjectBrowser()
253 adaoGuiHelper.selectItem(adao_case.salome_study_item.GetID())
255 self.cases[adao_case.name] = adao_case
259 # Méthodes secondaires permettant de rediriger les évènements
260 # de SALOME et d'Eficas vers les bonnes méthodes de la classe
264 # Gestion des évènements venant du manager Eficas
266 EficasEvent.EVENT_TYPES.CLOSE : "_processEficasCloseEvent",
267 EficasEvent.EVENT_TYPES.SAVE : "_processEficasSaveEvent",
268 EficasEvent.EVENT_TYPES.NEW : "_processEficasNewEvent",
269 EficasEvent.EVENT_TYPES.DESTROY : "_processEficasDestroyEvent",
270 EficasEvent.EVENT_TYPES.OPEN : "_processEficasOpenEvent",
271 EficasEvent.EVENT_TYPES.TABCHANGED : "_processEficasTabChanged",
272 EficasEvent.EVENT_TYPES.REOPEN : "_processEficasReOpenEvent"
275 def processEficasEvent(self, eficasWrapper, eficasEvent):
277 Implementation of the interface EficasObserver. The implementation is a
278 switch on the possible types of events defined in EficasEvent.EVENT_TYPES.
281 functionName = self.__processOptions.get(eficasEvent.eventType, lambda : "_processEficasUnknownEvent")
282 return getattr(self,functionName)(eficasWrapper, eficasEvent)
284 def _processEficasUnknownEvent(self, eficasWrapper, eficasEvent):
285 adaoLogger.error("Unknown Eficas Event")
287 # Gestion des évènements venant du GUI de SALOME
288 def processGUIEvent(self, actionId):
290 Main switch function for ui actions processing
292 if ACTIONS_MAP.has_key(actionId):
294 functionName = ACTIONS_MAP[actionId]
295 getattr(self,functionName)()
297 traceback.print_exc()
299 adaoLogger.warning("The requested action is not implemented: " + str(actionId))
301 class AdaoGuiUiComponentBuilder:
303 The initialisation of this class creates the graphic components involved
304 in the GUI (menu, menu item, toolbar). A ui component builder should be
305 created for each opened study and associated to its context.
308 self.initUiComponents()
310 def initUiComponents(self):
314 # create top-level menu
315 mid = sgPyQt.createMenu( "ADAO", -1, UI_ELT_IDS.ADAO_MENU_ID, sgPyQt.defaultMenuGroup() )
317 tid = sgPyQt.createTool( "ADAO" )
319 a = sgPyQt.createAction( UI_ELT_IDS.NEW_ADAOCASE_ID, "New case", "New case", "Create a new adao case", "" )
320 sgPyQt.createMenu(a, mid)
321 sgPyQt.createTool(a, tid)
322 a = sgPyQt.createAction( UI_ELT_IDS.OPEN_ADAOCASE_ID, "Open case", "Open case", "Open an adao case", "" )
323 sgPyQt.createMenu(a, mid)
324 sgPyQt.createTool(a, tid)
325 a = sgPyQt.createAction( UI_ELT_IDS.SAVE_ADAOCASE_ID, "Save case", "Save case", "Save an adao case", "" )
326 sgPyQt.createMenu(a, mid)
327 sgPyQt.createTool(a, tid)
328 a = sgPyQt.createAction( UI_ELT_IDS.SAVE_AS_ADAOCASE_ID, "Save as case", "Save as case", "Save an adao case as", "" )
329 sgPyQt.createMenu(a, mid)
330 sgPyQt.createTool(a, tid)
331 a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close case", "Close case", "Close an adao case", "" )
332 sgPyQt.createMenu(a, mid)
333 sgPyQt.createTool(a, tid)
335 # the following action are used in context popup
336 a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close case", "Close case", "Close the selected case", "" )
338 a = sgPyQt.createAction( UI_ELT_IDS.EDIT_ADAOCASE_POP_ID, "Edit case", "Edit case", "Edit the selected study case", "" )
339 a = sgPyQt.createAction( UI_ELT_IDS.YACS_EXPORT_POP_ID, "Export to YACS", "Export to YACS", "Generate a YACS graph executing this case", "" )
341 def createPopupMenuOnItem(self,popup,salomeSudyId, item):
342 if adaoStudyEditor.isValidAdaoCaseItem(salomeSudyId, item):
343 popup.addAction( sgPyQt.action( UI_ELT_IDS.CLOSE_ADAOCASE_ID ) )
345 popup.addAction( sgPyQt.action( UI_ELT_IDS.EDIT_ADAOCASE_POP_ID ) )
346 popup.addAction( sgPyQt.action( UI_ELT_IDS.YACS_EXPORT_POP_ID ) )
350 class AdaoGuiActionImpl(EficasObserver):
352 This class implements the ui actions concerning the management of oma study
358 # This dialog is created once so that it can be recycled for each call
360 #self.__dlgNewStudyCase = DlgNewStudyCase()
361 self.__parent = SalomePyQt.SalomePyQt().getDesktop()
362 self.__dlgEficasWrapper = AdaoEficasWrapper(parent=SalomePyQt.SalomePyQt().getDesktop())
363 self.__dlgEficasWrapper.addObserver(self)
364 self.__Eficas_viewId = -1
366 # ==========================================================================
367 # Processing of ui actions
369 def processAction(self,actionId):
371 Main switch function for ui actions processing
373 if ACTIONS_MAP.has_key(actionId):
375 functionName = ACTIONS_MAP[actionId]
376 getattr(self,functionName)()
378 traceback.print_exc()
380 msg = "The requested action is not implemented: " + str(actionId)
383 def showEficas(self):
384 if self.__Eficas_viewId == -1:
385 self.__dlgEficasWrapper.init_gui()
389 area = QtGui.QScrollArea(SalomePyQt.SalomePyQt().getDesktop());
390 area.setWidget( self.__dlgEficasWrapper)
391 area.setWidgetResizable(1)
394 self.__Eficas_viewId = sgPyQt.createView(wmType, area)
395 sgPyQt.setViewClosable(self.__Eficas_viewId, False)
397 if SalomePyQt.SalomePyQt().getActiveView() != self.__Eficas_viewId :
398 result_activate = SalomePyQt.SalomePyQt().activateView(self.__Eficas_viewId)
399 if result_activate == False:
400 self.__dlgEficasWrapper.init_gui()
403 area = QtGui.QScrollArea(SalomePyQt.SalomePyQt().getDesktop());
404 area.setWidget( self.__dlgEficasWrapper)
405 area.setWidgetResizable(1)
408 self.__Eficas_viewId = sgPyQt.createView(wmType, area)
409 sgPyQt.setViewClosable(self.__Eficas_viewId, False)
410 self.__dlgEficasWrapper.setEnabled(True)
415 def deactivate(self):
417 if self.__Eficas_viewId != -1:
418 self.__dlgEficasWrapper.setEnabled(False)
420 # Actions from SALOME GUI
422 def newAdaoCase(self):
424 adaoLogger.debug("newAdaoCase")
426 self.__dlgEficasWrapper.fileNew()
428 def openAdaoCase(self):
430 adaoLogger.debug("openAdaoCase")
433 fichier = QtGui.QFileDialog.getOpenFileName(SalomePyQt.SalomePyQt().getDesktop(),
434 self.__dlgEficasWrapper.trUtf8('Ouvrir Fichier'),
435 self.__dlgEficasWrapper.CONFIGURATION.savedir,
436 self.__dlgEficasWrapper.trUtf8('JDC Files (*.comm);;''All Files (*)'))
437 if fichier.isNull(): return
438 new_case = AdaoCase()
439 new_case.set_filename(str(fichier))
440 new_case.set_name(str(fichier.split('/')[-1]))
441 salomeStudyId = adaoGuiHelper.getActiveStudyId()
442 salomeStudyItem = adaoStudyEditor.addInStudy(salomeStudyId, new_case)
443 case_key = (salomeStudyId, salomeStudyItem.GetID())
444 __cases__[case_key] = new_case
446 # Open file in Eficas
447 self.__dlgEficasWrapper.Openfile(new_case.get_filename())
448 callbackId = [salomeStudyId, salomeStudyItem]
449 self.__dlgEficasWrapper.setCallbackId(callbackId)
451 adaoGuiHelper.refreshObjectBrowser()
453 def editAdaoCase(self):
455 adaoLogger.debug("editAdaoCase")
459 salomeStudyId = adaoGuiHelper.getActiveStudyId()
460 salomeStudyItem = adaoGuiHelper.getSelectedItem(salomeStudyId)
461 case_key = (salomeStudyId, salomeStudyItem.GetID())
463 # ShowEficas, If case is an empty case - case is destroyed by reopen
466 case = __cases__[case_key]
467 # Search if case is in Eficas !
468 callbackId = [salomeStudyId, salomeStudyItem]
469 case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId)
471 # If case is not in eficas Open It !
472 if case_open_in_eficas == False:
473 if case.get_filename() != "":
474 self.__dlgEficasWrapper.Openfile(case.get_filename())
475 callbackId = [salomeStudyId, salomeStudyItem]
476 self.__dlgEficasWrapper.setCallbackId(callbackId)
478 # Case has been destroyed - create a new one
479 self.__dlgEficasWrapper.fileNew()
481 def closeAdaoCase(self):
483 adaoLogger.debug("closeAdaoCase")
486 # First step: get selected case
487 salomeStudyId = adaoGuiHelper.getActiveStudyId()
488 salomeStudyItem = adaoGuiHelper.getSelectedItem(salomeStudyId)
490 # Check if there is a selected case
491 if salomeStudyItem is None:
492 print "[Close case] Please select a case"
495 callbackId = [salomeStudyId, salomeStudyItem]
496 case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId)
498 # If case is in eficas close it !
499 if case_open_in_eficas:
500 # fileClose: remove the CallbackId
501 # fileClose: sends a destroy event
502 self.__dlgEficasWrapper.fileClose()
504 # Test if case exists
505 case_key = (salomeStudyId, salomeStudyItem.GetID())
506 if __cases__.has_key(case_key):
507 __cases__.pop(case_key)
508 adaoStudyEditor.removeItem(salomeStudyId, salomeStudyItem)
509 adaoGuiHelper.refreshObjectBrowser()
511 def saveAdaoCase(self):
513 adaoLogger.debug("saveAdaoCase")
516 def saveasAdaoCase(self):
518 adaoLogger.debug("saveasAdaoCase")
521 def exportCaseToYACS(self):
523 adaoLogger.debug("exportCaseToYACS")
526 # Get case from study
527 salomeStudyId = adaoGuiHelper.getActiveStudyId()
528 salomeStudyItem = adaoGuiHelper.getSelectedItem(salomeStudyId)
529 case_key = (salomeStudyId, salomeStudyItem.GetID())
530 case = __cases__[case_key]
532 # Generates YACS schema and export it
533 msg = case.exportCaseToYACS()
535 # If msg is not empty -> error found
537 adaoGuiHelper.gui_warning(self.__parent, msg)
539 # ==========================================================================
540 # Processing notifications from adaoEficasWrapper
543 EficasEvent.EVENT_TYPES.CLOSE : "_processEficasCloseEvent",
544 EficasEvent.EVENT_TYPES.SAVE : "_processEficasSaveEvent",
545 EficasEvent.EVENT_TYPES.NEW : "_processEficasNewEvent",
546 EficasEvent.EVENT_TYPES.DESTROY : "_processEficasDestroyEvent",
547 EficasEvent.EVENT_TYPES.OPEN : "_processEficasOpenEvent",
548 EficasEvent.EVENT_TYPES.REOPEN : "_processEficasReOpenEvent"
550 def processEficasEvent(self, eficasWrapper, eficasEvent):
552 Implementation of the interface EficasObserver. The implementation is a
553 switch on the possible types of events defined in EficasEvent.EVENT_TYPES.
556 functionName = self.__processOptions.get(eficasEvent.eventType, lambda : "_processEficasUnknownEvent")
557 return getattr(self,functionName)(eficasWrapper, eficasEvent)
559 def _processEficasCloseEvent(self, eficasWrapper, eficasEvent):
562 def _processEficasNewEvent(self, eficasWrapper, eficasEvent):
565 new_case = AdaoCase()
566 case_name = eficasWrapper.getCaseName()
567 new_case.set_name(case_name)
568 salomeStudyId = adaoGuiHelper.getActiveStudyId()
569 salomeStudyItem = adaoStudyEditor.addInStudy(salomeStudyId, new_case)
570 case_key = (salomeStudyId, salomeStudyItem.GetID())
571 __cases__[case_key] = new_case
572 adaoGuiHelper.refreshObjectBrowser()
573 callbackId = [salomeStudyId, salomeStudyItem]
574 self.__dlgEficasWrapper.setCallbackId(callbackId)
576 # We need to select the case
577 adaoGuiHelper.selectItem(salomeStudyItem.GetID())
580 def _processEficasOpenEvent(self, eficasWrapper, eficasEvent):
583 # Ouverture du fichier
584 self.__dlgEficasWrapper.Openfile(self.__dlgEficasWrapper.getOpenFileName())
586 # Creation d'un nouveau cas
587 new_case = AdaoCase()
588 salomeStudyId = adaoGuiHelper.getActiveStudyId()
589 salomeStudyItem = adaoStudyEditor.addInStudy(salomeStudyId, new_case)
590 case_key = (salomeStudyId, salomeStudyItem.GetID())
591 __cases__[case_key] = new_case
593 # Connexion du nouveau cas
594 callbackId = [salomeStudyId, salomeStudyItem]
595 self.__dlgEficasWrapper.setCallbackId(callbackId)
597 # On sauvegarde le cas
598 self._processEficasSaveEvent(self.__dlgEficasWrapper, None, callbackId)
600 def _processEficasSaveEvent(self, eficasWrapper, eficasEvent, callbackId=None):
602 if callbackId is None:
603 callbackId = eficasEvent.callbackId
604 if callbackId is None:
605 raise DevelException("the callback data should not be None. Can't guess what are the study and case")
606 [targetSalomeStudyId,targetSalomeStudyItem] = callbackId
607 if ( targetSalomeStudyId is None ) or ( targetSalomeStudyItem is None ):
608 raise DevelException("the parameters targetSalomeStudyId and targetSalomeStudyItem should not be None")
610 [targetSalomeStudyId,targetSalomeStudyItem] = callbackId
612 # Get Editor All infos we need !
613 case_name = eficasWrapper.getCaseName()
614 file_case_name = eficasWrapper.getFileCaseName()
617 old_case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetID())
618 case =__cases__[old_case_key]
620 # Set new informations
621 case.set_name(case_name)
622 if str(case_name).startswith("Untitled"):
625 case.set_filename(file_case_name)
626 adaoStudyEditor.updateItem(targetSalomeStudyId, targetSalomeStudyItem, case)
629 #new_case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetID())
630 # A ne pas inverser !!!
631 #__cases__.pop(old_case_key)
632 #__cases__[new_case_key] = case
634 adaoGuiHelper.refreshObjectBrowser()
636 def _processEficasDestroyEvent(self, eficasWrapper, eficasEvent):
638 callbackId = eficasEvent.callbackId
639 if callbackId is None:
640 raise DevelException("the callback data should not be None. Can't guess what are the study and case")
641 [targetSalomeStudyId,targetSalomeStudyItem] = callbackId
642 if ( targetSalomeStudyId is None ) or ( targetSalomeStudyItem is None ):
643 raise DevelException("the parameters targetSalomeStudyId and targetSalomeStudyItem should not be None")
645 case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetID())
646 __cases__.pop(case_key)
647 adaoStudyEditor.removeItem(targetSalomeStudyId, targetSalomeStudyItem)
648 adaoGuiHelper.refreshObjectBrowser()
651 # Normalement on ne ferme plus le GUI donc on ne passe plus par là
652 def _processEficasReOpenEvent(self, eficasWrapper, eficasEvent):
654 adaoLogger.warning("_processEficasReOpenEvent")
658 callbackId = eficasEvent.callbackId
659 [salomeStudyId, salomeStudyItem] = callbackId
660 case_key = (salomeStudyId, salomeStudyItem.GetID())
661 case = __cases__[case_key]
662 # Search if case is in Eficas !
663 callbackId = [salomeStudyId, salomeStudyItem]
664 case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId)
665 # If case is not in eficas Open It !
666 if case_open_in_eficas == False:
667 if case.get_filename() != "":
668 self.__dlgEficasWrapper.Openfile(case.get_filename())
669 callbackId = [salomeStudyId, salomeStudyItem]
670 self.__dlgEficasWrapper.setCallbackId(callbackId)
672 # Since I am an empty case I destroy myself before reloading
673 adaoStudyEditor.removeItem(salomeStudyId, salomeStudyItem)
674 adaoGuiHelper.refreshObjectBrowser()
675 __cases__.pop(case_key)
676 callbackId = [salomeStudyId, salomeStudyItem]
677 self.__dlgEficasWrapper.removeCallbackId(callbackId)
679 print "Oups - cannot reopen case !"
680 traceback.print_exc()
682 def _processEficasUnknownEvent(self, eficasWrapper, eficasEvent):
683 print "Unknown Eficas Event"