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 sgPyQt.activateView(self.eficas_viewId)
125 self.harmonizeSelectionFromEficas()
127 def deactivate(self):
128 self.eficas_manager.setEnabled(False)
132 # Gestion de la sélection entre le GUI d'Eficas
133 # et l'arbre d'étude de SALOME
137 # Depuis l'étude SALOME
138 def currentSelectionChanged(self):
140 Cette méthode permet de changer le tab vu dans eficas
141 selon la sélection de l'utilisateur dans l'étude SALOME
143 adaoLogger.debug("currentSelectionChanged")
144 salomeStudyItem = adaoGuiHelper.getSelectedItem()
145 for case_editor, adao_case in self.cases.iteritems():
146 if adao_case.salome_study_item.GetID() == salomeStudyItem.GetID():
147 self.eficas_manager.selectCase(adao_case.eficas_editor)
151 def _processEficasTabChanged(self, eficasWrapper, eficasEvent):
153 Gestion de la synchonisation entre le tab courant d'Eficas
154 et la selection dans l'étude SALOME
156 editor = eficasEvent.callbackId
157 for case_editor, adao_case in self.cases.iteritems():
158 if case_editor is editor:
159 adaoGuiHelper.selectItem(adao_case.salome_study_item.GetID())
162 # On remet la sélection dans SALOME grâce au tab dans Eficas
163 def harmonizeSelectionFromEficas(self):
165 Cette méthode permet d'harmoniser la sélection dans l'étude
166 grâce au tab courant d'Eficas
168 adaoLogger.error("harmonizeSelectionFromEficas NOT YET IMPLEMENTED")
171 # 1: Get current tab index in Eficas
172 # 2: sync with SALOME GUI is a tab is opened
176 # Gestion de la création d'un nouveau cas
177 # 1: la fonction newAdaoCase est appelée par le GUI SALOME
178 # 2: la fonction _processEficasNewEvent est appelée par le manager EFICAS
182 def newAdaoCase(self):
183 adaoLogger.debug("Création d'un nouveau cas adao")
184 self.eficas_manager.adaofileNew(AdaoCase())
186 def _processEficasNewEvent(self, eficasWrapper, eficasEvent):
187 adao_case = eficasEvent.callbackId
189 salomeStudyId = adaoGuiHelper.getActiveStudyId()
190 salomeStudyItem = adaoStudyEditor.addInStudy(salomeStudyId, adao_case)
191 # Affichage correct dans l'étude
192 adaoGuiHelper.refreshObjectBrowser()
193 adaoGuiHelper.selectItem(salomeStudyItem.GetID())
194 # Finalisation des données du cas
195 adao_case.salome_study_id = salomeStudyId
196 adao_case.salome_study_item = salomeStudyItem
198 self.cases[adao_case.eficas_editor] = adao_case
202 # Gestion de l'ouverture d'un cas
203 # 1: la fonction openAdaoCase est appelée par le GUI SALOME
204 # 2: la fonction _processEficasOpenEvent est appelée par le manager EFICAS
208 # Rq: l'ouverture d'un cas adao est un cas particulier de la création d'un cas adao
210 def openAdaoCase(self):
211 adaoLogger.debug("Ouverture d'un cas adao")
212 self.eficas_manager.adaoFileOpen(AdaoCase())
214 def _processEficasOpenEvent(self, eficasWrapper, eficasEvent):
215 self._processEficasNewEvent(eficasWrapper, eficasEvent)
219 # Gestion de la sauvegarde d'un cas
220 # 1: la fonction saveAdaoCase est appelée par le GUI SALOME
221 # 1 bis: la fonction saveasAdaoCase est appelée par le GUI SALOME
222 # 2: la fonction _processEficasSaveEvent est appelée par le manager EFICAS
226 def saveAdaoCase(self):
227 adaoLogger.debug("Sauvegarde du cas s'il y a modification")
228 # A priori, l'utilisateur s'attend à sauvegarder le cas qui est ouvert
229 # dans le GUI d'Eficas
230 self.harmonizeSelectionFromEficas()
231 salomeStudyItem = adaoGuiHelper.getSelectedItem()
232 for case_name, adao_case in self.cases.iteritems():
233 if adao_case.salome_study_item.GetID() == salomeStudyItem.GetID():
234 self.eficas_manager.adaoFileSave(adao_case)
237 def saveasAdaoCase(self):
238 adaoLogger.debug("Sauvegarde du cas s'il y a modification (version save as)")
239 # A priori, l'utilisateur s'attend à sauvegarder le cas qui est ouvert
240 # dans le GUI d'Eficas
241 self.harmonizeSelectionFromEficas()
242 salomeStudyItem = adaoGuiHelper.getSelectedItem()
243 for case_name, adao_case in self.cases.iteritems():
244 if adao_case.salome_study_item.GetID() == salomeStudyItem.GetID():
245 self.eficas_manager.adaoFileSaveAs(adao_case)
248 def _processEficasSaveEvent(self, eficasWrapper, eficasEvent):
249 adao_case = eficasEvent.callbackId
250 # On met à jour l'étude
251 adaoStudyEditor.updateItem(adao_case.salome_study_id, adao_case.salome_study_item, adao_case)
252 # Affichage correct dans l'étude
253 adaoGuiHelper.refreshObjectBrowser()
254 adaoGuiHelper.selectItem(adao_case.salome_study_item.GetID())
256 self.cases[adao_case.name] = adao_case
260 # Gestion de la fermeture d'un cas
261 # 1: la fonction closeAdaoCase est appelée par le GUI SALOME
262 # 2: la fonction _processEficasCloseEvent est appelée par le manager EFICAS
266 def closeAdaoCase(self):
267 adaoLogger.debug("Fermeture d'un cas")
268 # A priori, l'utilisateur s'attend à sauvegarder le cas qui est ouvert
269 # dans le GUI d'Eficas
270 self.harmonizeSelectionFromEficas()
271 salomeStudyItem = adaoGuiHelper.getSelectedItem()
272 for case_name, adao_case in self.cases.iteritems():
273 if adao_case.salome_study_item.GetID() == salomeStudyItem.GetID():
274 self.eficas_manager.adaoFileClose(adao_case)
277 def _processEficasCloseEvent(self, eficasWrapper, eficasEvent):
278 editor = eficasEvent.callbackId
279 # Recuperation du cas
280 adao_case = self.cases[editor]
281 # Suppression de l'objet dans l'étude
282 adaoStudyEditor.removeItem(adao_case.salome_study_id, adao_case.salome_study_item)
283 adaoGuiHelper.refreshObjectBrowser()
285 del self.cases[editor]
289 # Méthodes secondaires permettant de rediriger les évènements
290 # de SALOME et d'Eficas vers les bonnes méthodes de la classe
294 # Gestion des évènements venant du manager Eficas
296 EficasEvent.EVENT_TYPES.CLOSE : "_processEficasCloseEvent",
297 EficasEvent.EVENT_TYPES.SAVE : "_processEficasSaveEvent",
298 EficasEvent.EVENT_TYPES.NEW : "_processEficasNewEvent",
299 EficasEvent.EVENT_TYPES.CLOSE : "_processEficasCloseEvent",
300 EficasEvent.EVENT_TYPES.OPEN : "_processEficasOpenEvent",
301 EficasEvent.EVENT_TYPES.TABCHANGED : "_processEficasTabChanged",
302 EficasEvent.EVENT_TYPES.REOPEN : "_processEficasReOpenEvent"
305 def processEficasEvent(self, eficasWrapper, eficasEvent):
307 Implementation of the interface EficasObserver. The implementation is a
308 switch on the possible types of events defined in EficasEvent.EVENT_TYPES.
311 functionName = self.__processOptions.get(eficasEvent.eventType, lambda : "_processEficasUnknownEvent")
312 return getattr(self,functionName)(eficasWrapper, eficasEvent)
314 def _processEficasUnknownEvent(self, eficasWrapper, eficasEvent):
315 adaoLogger.error("Unknown Eficas Event")
317 # Gestion des évènements venant du GUI de SALOME
318 def processGUIEvent(self, actionId):
320 Main switch function for ui actions processing
322 if ACTIONS_MAP.has_key(actionId):
324 functionName = ACTIONS_MAP[actionId]
325 getattr(self,functionName)()
327 traceback.print_exc()
329 adaoLogger.warning("The requested action is not implemented: " + str(actionId))
331 class AdaoGuiUiComponentBuilder:
333 The initialisation of this class creates the graphic components involved
334 in the GUI (menu, menu item, toolbar). A ui component builder should be
335 created for each opened study and associated to its context.
338 self.initUiComponents()
340 def initUiComponents(self):
344 # create top-level menu
345 mid = sgPyQt.createMenu( "ADAO", -1, UI_ELT_IDS.ADAO_MENU_ID, sgPyQt.defaultMenuGroup() )
347 tid = sgPyQt.createTool( "ADAO" )
349 a = sgPyQt.createAction( UI_ELT_IDS.NEW_ADAOCASE_ID, "New case", "New case", "Create a new adao case", "" )
350 sgPyQt.createMenu(a, mid)
351 sgPyQt.createTool(a, tid)
352 a = sgPyQt.createAction( UI_ELT_IDS.OPEN_ADAOCASE_ID, "Open case", "Open case", "Open an adao case", "" )
353 sgPyQt.createMenu(a, mid)
354 sgPyQt.createTool(a, tid)
355 a = sgPyQt.createAction( UI_ELT_IDS.SAVE_ADAOCASE_ID, "Save case", "Save case", "Save an adao case", "" )
356 sgPyQt.createMenu(a, mid)
357 sgPyQt.createTool(a, tid)
358 a = sgPyQt.createAction( UI_ELT_IDS.SAVE_AS_ADAOCASE_ID, "Save as case", "Save as case", "Save an adao case as", "" )
359 sgPyQt.createMenu(a, mid)
360 sgPyQt.createTool(a, tid)
361 a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close case", "Close case", "Close an adao case", "" )
362 sgPyQt.createMenu(a, mid)
363 sgPyQt.createTool(a, tid)
365 # the following action are used in context popup
366 a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close case", "Close case", "Close the selected case", "" )
368 a = sgPyQt.createAction( UI_ELT_IDS.EDIT_ADAOCASE_POP_ID, "Edit case", "Edit case", "Edit the selected study case", "" )
369 a = sgPyQt.createAction( UI_ELT_IDS.YACS_EXPORT_POP_ID, "Export to YACS", "Export to YACS", "Generate a YACS graph executing this case", "" )
371 def createPopupMenuOnItem(self,popup,salomeSudyId, item):
372 if adaoStudyEditor.isValidAdaoCaseItem(salomeSudyId, item):
373 popup.addAction( sgPyQt.action( UI_ELT_IDS.CLOSE_ADAOCASE_ID ) )
375 popup.addAction( sgPyQt.action( UI_ELT_IDS.EDIT_ADAOCASE_POP_ID ) )
376 popup.addAction( sgPyQt.action( UI_ELT_IDS.YACS_EXPORT_POP_ID ) )
380 class AdaoGuiActionImpl(EficasObserver):
382 This class implements the ui actions concerning the management of oma study
388 # This dialog is created once so that it can be recycled for each call
390 #self.__dlgNewStudyCase = DlgNewStudyCase()
391 self.__parent = SalomePyQt.SalomePyQt().getDesktop()
392 self.__dlgEficasWrapper = AdaoEficasWrapper(parent=SalomePyQt.SalomePyQt().getDesktop())
393 self.__dlgEficasWrapper.addObserver(self)
394 self.__Eficas_viewId = -1
396 # ==========================================================================
397 # Processing of ui actions
399 def processAction(self,actionId):
401 Main switch function for ui actions processing
403 if ACTIONS_MAP.has_key(actionId):
405 functionName = ACTIONS_MAP[actionId]
406 getattr(self,functionName)()
408 traceback.print_exc()
410 msg = "The requested action is not implemented: " + str(actionId)
413 def showEficas(self):
414 if self.__Eficas_viewId == -1:
415 self.__dlgEficasWrapper.init_gui()
419 area = QtGui.QScrollArea(SalomePyQt.SalomePyQt().getDesktop());
420 area.setWidget( self.__dlgEficasWrapper)
421 area.setWidgetResizable(1)
424 self.__Eficas_viewId = sgPyQt.createView(wmType, area)
425 sgPyQt.setViewClosable(self.__Eficas_viewId, False)
427 if SalomePyQt.SalomePyQt().getActiveView() != self.__Eficas_viewId :
428 result_activate = SalomePyQt.SalomePyQt().activateView(self.__Eficas_viewId)
429 if result_activate == False:
430 self.__dlgEficasWrapper.init_gui()
433 area = QtGui.QScrollArea(SalomePyQt.SalomePyQt().getDesktop());
434 area.setWidget( self.__dlgEficasWrapper)
435 area.setWidgetResizable(1)
438 self.__Eficas_viewId = sgPyQt.createView(wmType, area)
439 sgPyQt.setViewClosable(self.__Eficas_viewId, False)
440 self.__dlgEficasWrapper.setEnabled(True)
445 def deactivate(self):
447 if self.__Eficas_viewId != -1:
448 self.__dlgEficasWrapper.setEnabled(False)
450 # Actions from SALOME GUI
452 def newAdaoCase(self):
454 adaoLogger.debug("newAdaoCase")
456 self.__dlgEficasWrapper.fileNew()
458 def openAdaoCase(self):
460 adaoLogger.debug("openAdaoCase")
463 fichier = QtGui.QFileDialog.getOpenFileName(SalomePyQt.SalomePyQt().getDesktop(),
464 self.__dlgEficasWrapper.trUtf8('Ouvrir Fichier'),
465 self.__dlgEficasWrapper.CONFIGURATION.savedir,
466 self.__dlgEficasWrapper.trUtf8('JDC Files (*.comm);;''All Files (*)'))
467 if fichier.isNull(): return
468 new_case = AdaoCase()
469 new_case.set_filename(str(fichier))
470 new_case.set_name(str(fichier.split('/')[-1]))
471 salomeStudyId = adaoGuiHelper.getActiveStudyId()
472 salomeStudyItem = adaoStudyEditor.addInStudy(salomeStudyId, new_case)
473 case_key = (salomeStudyId, salomeStudyItem.GetID())
474 __cases__[case_key] = new_case
476 # Open file in Eficas
477 self.__dlgEficasWrapper.Openfile(new_case.get_filename())
478 callbackId = [salomeStudyId, salomeStudyItem]
479 self.__dlgEficasWrapper.setCallbackId(callbackId)
481 adaoGuiHelper.refreshObjectBrowser()
483 def editAdaoCase(self):
485 adaoLogger.debug("editAdaoCase")
489 salomeStudyId = adaoGuiHelper.getActiveStudyId()
490 salomeStudyItem = adaoGuiHelper.getSelectedItem(salomeStudyId)
491 case_key = (salomeStudyId, salomeStudyItem.GetID())
493 # ShowEficas, If case is an empty case - case is destroyed by reopen
496 case = __cases__[case_key]
497 # Search if case is in Eficas !
498 callbackId = [salomeStudyId, salomeStudyItem]
499 case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId)
501 # If case is not in eficas Open It !
502 if case_open_in_eficas == False:
503 if case.get_filename() != "":
504 self.__dlgEficasWrapper.Openfile(case.get_filename())
505 callbackId = [salomeStudyId, salomeStudyItem]
506 self.__dlgEficasWrapper.setCallbackId(callbackId)
508 # Case has been destroyed - create a new one
509 self.__dlgEficasWrapper.fileNew()
511 def closeAdaoCase(self):
513 adaoLogger.debug("closeAdaoCase")
516 # First step: get selected case
517 salomeStudyId = adaoGuiHelper.getActiveStudyId()
518 salomeStudyItem = adaoGuiHelper.getSelectedItem(salomeStudyId)
520 # Check if there is a selected case
521 if salomeStudyItem is None:
522 print "[Close case] Please select a case"
525 callbackId = [salomeStudyId, salomeStudyItem]
526 case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId)
528 # If case is in eficas close it !
529 if case_open_in_eficas:
530 # fileClose: remove the CallbackId
531 # fileClose: sends a destroy event
532 self.__dlgEficasWrapper.fileClose()
534 # Test if case exists
535 case_key = (salomeStudyId, salomeStudyItem.GetID())
536 if __cases__.has_key(case_key):
537 __cases__.pop(case_key)
538 adaoStudyEditor.removeItem(salomeStudyId, salomeStudyItem)
539 adaoGuiHelper.refreshObjectBrowser()
541 def saveAdaoCase(self):
543 adaoLogger.debug("saveAdaoCase")
546 def saveasAdaoCase(self):
548 adaoLogger.debug("saveasAdaoCase")
551 def exportCaseToYACS(self):
553 adaoLogger.debug("exportCaseToYACS")
556 # Get case from study
557 salomeStudyId = adaoGuiHelper.getActiveStudyId()
558 salomeStudyItem = adaoGuiHelper.getSelectedItem(salomeStudyId)
559 case_key = (salomeStudyId, salomeStudyItem.GetID())
560 case = __cases__[case_key]
562 # Generates YACS schema and export it
563 msg = case.exportCaseToYACS()
565 # If msg is not empty -> error found
567 adaoGuiHelper.gui_warning(self.__parent, msg)
569 # ==========================================================================
570 # Processing notifications from adaoEficasWrapper
573 EficasEvent.EVENT_TYPES.CLOSE : "_processEficasCloseEvent",
574 EficasEvent.EVENT_TYPES.SAVE : "_processEficasSaveEvent",
575 EficasEvent.EVENT_TYPES.NEW : "_processEficasNewEvent",
576 EficasEvent.EVENT_TYPES.OPEN : "_processEficasOpenEvent",
577 EficasEvent.EVENT_TYPES.REOPEN : "_processEficasReOpenEvent"
579 def processEficasEvent(self, eficasWrapper, eficasEvent):
581 Implementation of the interface EficasObserver. The implementation is a
582 switch on the possible types of events defined in EficasEvent.EVENT_TYPES.
585 functionName = self.__processOptions.get(eficasEvent.eventType, lambda : "_processEficasUnknownEvent")
586 return getattr(self,functionName)(eficasWrapper, eficasEvent)
588 def _processEficasCloseEvent(self, eficasWrapper, eficasEvent):
591 def _processEficasNewEvent(self, eficasWrapper, eficasEvent):
594 new_case = AdaoCase()
595 case_name = eficasWrapper.getCaseName()
596 new_case.set_name(case_name)
597 salomeStudyId = adaoGuiHelper.getActiveStudyId()
598 salomeStudyItem = adaoStudyEditor.addInStudy(salomeStudyId, new_case)
599 case_key = (salomeStudyId, salomeStudyItem.GetID())
600 __cases__[case_key] = new_case
601 adaoGuiHelper.refreshObjectBrowser()
602 callbackId = [salomeStudyId, salomeStudyItem]
603 self.__dlgEficasWrapper.setCallbackId(callbackId)
605 # We need to select the case
606 adaoGuiHelper.selectItem(salomeStudyItem.GetID())
609 def _processEficasOpenEvent(self, eficasWrapper, eficasEvent):
612 # Ouverture du fichier
613 self.__dlgEficasWrapper.Openfile(self.__dlgEficasWrapper.getOpenFileName())
615 # Creation d'un nouveau cas
616 new_case = AdaoCase()
617 salomeStudyId = adaoGuiHelper.getActiveStudyId()
618 salomeStudyItem = adaoStudyEditor.addInStudy(salomeStudyId, new_case)
619 case_key = (salomeStudyId, salomeStudyItem.GetID())
620 __cases__[case_key] = new_case
622 # Connexion du nouveau cas
623 callbackId = [salomeStudyId, salomeStudyItem]
624 self.__dlgEficasWrapper.setCallbackId(callbackId)
626 # On sauvegarde le cas
627 self._processEficasSaveEvent(self.__dlgEficasWrapper, None, callbackId)
629 def _processEficasSaveEvent(self, eficasWrapper, eficasEvent, callbackId=None):
631 if callbackId is None:
632 callbackId = eficasEvent.callbackId
633 if callbackId is None:
634 raise DevelException("the callback data should not be None. Can't guess what are the study and case")
635 [targetSalomeStudyId,targetSalomeStudyItem] = callbackId
636 if ( targetSalomeStudyId is None ) or ( targetSalomeStudyItem is None ):
637 raise DevelException("the parameters targetSalomeStudyId and targetSalomeStudyItem should not be None")
639 [targetSalomeStudyId,targetSalomeStudyItem] = callbackId
641 # Get Editor All infos we need !
642 case_name = eficasWrapper.getCaseName()
643 file_case_name = eficasWrapper.getFileCaseName()
646 old_case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetID())
647 case =__cases__[old_case_key]
649 # Set new informations
650 case.set_name(case_name)
651 if str(case_name).startswith("Untitled"):
654 case.set_filename(file_case_name)
655 adaoStudyEditor.updateItem(targetSalomeStudyId, targetSalomeStudyItem, case)
658 #new_case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetID())
659 # A ne pas inverser !!!
660 #__cases__.pop(old_case_key)
661 #__cases__[new_case_key] = case
663 adaoGuiHelper.refreshObjectBrowser()
665 def _processEficasDestroyEvent(self, eficasWrapper, eficasEvent):
667 callbackId = eficasEvent.callbackId
668 if callbackId is None:
669 raise DevelException("the callback data should not be None. Can't guess what are the study and case")
670 [targetSalomeStudyId,targetSalomeStudyItem] = callbackId
671 if ( targetSalomeStudyId is None ) or ( targetSalomeStudyItem is None ):
672 raise DevelException("the parameters targetSalomeStudyId and targetSalomeStudyItem should not be None")
674 case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetID())
675 __cases__.pop(case_key)
676 adaoStudyEditor.removeItem(targetSalomeStudyId, targetSalomeStudyItem)
677 adaoGuiHelper.refreshObjectBrowser()
680 # Normalement on ne ferme plus le GUI donc on ne passe plus par là
681 def _processEficasReOpenEvent(self, eficasWrapper, eficasEvent):
683 adaoLogger.warning("_processEficasReOpenEvent")
687 callbackId = eficasEvent.callbackId
688 [salomeStudyId, salomeStudyItem] = callbackId
689 case_key = (salomeStudyId, salomeStudyItem.GetID())
690 case = __cases__[case_key]
691 # Search if case is in Eficas !
692 callbackId = [salomeStudyId, salomeStudyItem]
693 case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId)
694 # If case is not in eficas Open It !
695 if case_open_in_eficas == False:
696 if case.get_filename() != "":
697 self.__dlgEficasWrapper.Openfile(case.get_filename())
698 callbackId = [salomeStudyId, salomeStudyItem]
699 self.__dlgEficasWrapper.setCallbackId(callbackId)
701 # Since I am an empty case I destroy myself before reloading
702 adaoStudyEditor.removeItem(salomeStudyId, salomeStudyItem)
703 adaoGuiHelper.refreshObjectBrowser()
704 __cases__.pop(case_key)
705 callbackId = [salomeStudyId, salomeStudyItem]
706 self.__dlgEficasWrapper.removeCallbackId(callbackId)
708 print "Oups - cannot reopen case !"
709 traceback.print_exc()
711 def _processEficasUnknownEvent(self, eficasWrapper, eficasEvent):
712 print "Unknown Eficas Event"