Salome HOME
Meilleure gestion du code
[modules/adao.git] / src / daSalome / daGUI / daGuiImpl / adaoGuiManager.py
1 # -*- coding: utf-8 -*-
2 #  Copyright (C) 2010 EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 """
22 This file centralizes the definitions and implementations of ui components used
23 in the GUI part of the module.
24 """
25
26 __author__ = "aribes/gboulant"
27
28 import traceback
29 from PyQt4.QtCore import QObject
30 from PyQt4.QtCore import *        # Import from PyQT
31 from PyQt4 import QtGui,QtCore
32 import SalomePyQt
33 sgPyQt = SalomePyQt.SalomePyQt()
34
35 from daGuiImpl.enumerate import Enumerate
36 from daGuiImpl.adaoCase import AdaoCase
37 from daEficasWrapper.adaoEficasWrapper import AdaoEficasWrapper
38
39 from daUtils.adaoEficasEvent import *
40 import adaoGuiHelper
41 import adaoStudyEditor
42 import adaoLogger
43
44 __cases__ = {}
45
46 #
47 # ==============================================================================
48 # Classes to manage the building of UI components
49 # ==============================================================================
50 #
51 UI_ELT_IDS = Enumerate([
52         'ADAO_MENU_ID',
53         'NEW_ADAOCASE_ID',
54         'OPEN_ADAOCASE_ID',
55         'SAVE_ADAOCASE_ID',
56         'SAVE_AS_ADAOCASE_ID',
57         'CLOSE_ADAOCASE_ID',
58
59         'EDIT_ADAOCASE_POP_ID',
60         'YACS_EXPORT_POP_ID',
61         ],offset=6950)
62
63 ACTIONS_MAP={
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",
69
70     UI_ELT_IDS.EDIT_ADAOCASE_POP_ID:"editAdaoCase",
71     UI_ELT_IDS.YACS_EXPORT_POP_ID:"exportCaseToYACS",
72 }
73
74
75 class AdaoCaseManager(EficasObserver):
76   """
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)
79   """
80
81   def __init__(self):
82
83     # Création d'un dictionnaire de cas
84     # Key   == nom du cas
85     # Value == objet AdaoCase()
86     self.cases = {}
87
88     # Création des deux managers
89     self.salome_manager = AdaoGuiUiComponentBuilder()
90     self.eficas_manager = AdaoEficasWrapper(parent=SalomePyQt.SalomePyQt().getDesktop())
91
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
94     # processGUIEvent
95     self.eficas_manager.addObserver(self)
96
97     # Création du GUI Eficas
98     self.eficas_manager.init_gui()
99
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)
105     wmType = "ADAO View"
106     self.eficas_viewId = sgPyQt.createView(wmType, area)
107
108     # On interdit que la vue soit fermée
109     # Cela simplifier grandement le code
110     sgPyQt.setViewClosable(self.eficas_viewId, False)
111
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)
115
116 ######
117 #
118 # Gestion de l'activation/désactivation du module
119 #
120 ######
121
122   def activate(self):
123     self.eficas_manager.setEnabled(True)
124     self.harmonizeSelectionFromEficas()
125
126   def deactivate(self):
127     self.eficas_manager.setEnabled(False)
128
129 #######
130 #
131 # Gestion de la sélection entre le GUI d'Eficas
132 # et l'arbre d'étude de SALOME
133 #
134 ######
135
136   # Depuis l'étude SALOME
137   def currentSelectionChanged(self):
138     """
139     Cette méthode permet de changer le tab vu dans eficas
140     selon la sélection de l'utilisateur dans l'étude SALOME
141     """
142     adaoLogger.debug("currentSelectionChanged")
143     salomeStudyItem = adaoGuiHelper.getSelectedItem()
144     for case_name, 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)
147         break
148
149   # Depuis Eficas
150   def _processEficasTabChanged(self, eficasWrapper, eficasEvent):
151     """
152     Gestion de la synchonisation entre le tab courant d'Eficas
153     et la selection dans l'étude SALOME
154     """
155     editor = eficasEvent.callbackId
156     for case_name, adao_case in self.cases.iteritems():
157       if adao_case.eficas_editor is editor:
158         adaoGuiHelper.selectItem(adao_case.salome_study_item.GetID())
159         break
160
161   # On remet la sélection dans SALOME grâce au tab dans Eficas
162   def harmonizeSelectionFromEficas(self):
163     """
164     Cette méthode permet d'harmoniser la sélection dans l'étude
165     grâce au tab courant d'Eficas
166     """
167     adaoLogger.error("harmonizeSelectionFromEficas NOT YET IMPLEMENTED")
168     if self.cases:
169       pass
170       # 1: Get current tab index in Eficas
171       # 2: sync with SALOME GUI is a tab is opened
172
173 #######
174 #
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
178 #
179 ######
180
181   def newAdaoCase(self):
182     adaoLogger.debug("Création d'un nouveau cas adao")
183     self.eficas_manager.adaofileNew(AdaoCase())
184
185   def _processEficasNewEvent(self, eficasWrapper, eficasEvent):
186     adao_case = eficasEvent.callbackId
187     # Ajout dand l'étude
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
196     # Ajout du cas
197     self.cases[adao_case.name] = adao_case
198
199 #######
200 #
201 # Gestion de la sauvegarde d'un cas
202 # 1: la fonction saveAdaoCase est appelée par le GUI SALOME
203 # 2: la fonction _processEficasSaveEvent est appelée par le manager EFICAS
204 #
205 ######
206
207   def saveAdaoCase(self):
208     adaoLogger.debug("Sauvegarde du cas s'il y a modification")
209     # A priori, l'utilisateur s'attend à sauvegarder le cas qui est ouvert
210     # dans le GUI d'Eficas
211     self.harmonizeSelectionFromEficas()
212     salomeStudyItem = adaoGuiHelper.getSelectedItem()
213     for case_name, adao_case in self.cases.iteritems():
214       if adao_case.salome_study_item.GetID() == salomeStudyItem.GetID():
215         self.eficas_manager.adaoFileSave(adao_case)
216         break
217
218   def _processEficasSaveEvent(self, eficasWrapper, eficasEvent):
219     adao_case = eficasEvent.callbackId
220     # On met à jour l'étude
221     adaoStudyEditor.updateItem(adao_case.salome_study_id, adao_case.salome_study_item, adao_case)
222     # Affichage correct dans l'étude
223     adaoGuiHelper.refreshObjectBrowser()
224     adaoGuiHelper.selectItem(adao_case.salome_study_item.GetID())
225     # Ajout du cas
226     self.cases[adao_case.name] = adao_case
227
228 #######
229 #
230 # Méthodes secondaire permettant de rediriger les évènements
231 # de SALOME et d'Eficas vers les bonnes méthodes de la classe
232 #
233 ######
234
235   # Gestion des évènements venant du manager Eficas
236   __processOptions={
237       EficasEvent.EVENT_TYPES.CLOSE      : "_processEficasCloseEvent",
238       EficasEvent.EVENT_TYPES.SAVE       : "_processEficasSaveEvent",
239       EficasEvent.EVENT_TYPES.NEW        : "_processEficasNewEvent",
240       EficasEvent.EVENT_TYPES.DESTROY    : "_processEficasDestroyEvent",
241       EficasEvent.EVENT_TYPES.OPEN       : "_processEficasOpenEvent",
242       EficasEvent.EVENT_TYPES.REOPEN     : "_processEficasReOpenEvent",
243       EficasEvent.EVENT_TYPES.TABCHANGED : "_processEficasTabChanged"
244       }
245
246   def processEficasEvent(self, eficasWrapper, eficasEvent):
247       """
248       Implementation of the interface EficasObserver. The implementation is a
249       switch on the possible types of events defined in EficasEvent.EVENT_TYPES.
250       @overload
251       """
252       functionName = self.__processOptions.get(eficasEvent.eventType, lambda : "_processEficasUnknownEvent")
253       return getattr(self,functionName)(eficasWrapper, eficasEvent)
254
255   def _processEficasUnknownEvent(self, eficasWrapper, eficasEvent):
256     adaoLogger.error("Unknown Eficas Event")
257
258   # Gestion des évènements venant du GUI de SALOME
259   def processGUIEvent(self, actionId):
260     """
261     Main switch function for ui actions processing
262     """
263     if ACTIONS_MAP.has_key(actionId):
264       try:
265           functionName = ACTIONS_MAP[actionId]
266           getattr(self,functionName)()
267       except:
268           traceback.print_exc()
269     else:
270       adaoLogger.warning("The requested action is not implemented: " + str(actionId))
271
272 class AdaoGuiUiComponentBuilder:
273     """
274     The initialisation of this class creates the graphic components involved
275     in the GUI (menu, menu item, toolbar). A ui component builder should be
276     created for each opened study and associated to its context.
277     """
278     def __init__(self):
279         self.initUiComponents()
280
281     def initUiComponents(self):
282
283         objectTR = QObject()
284
285         # create top-level menu
286         mid = sgPyQt.createMenu( "ADAO", -1, UI_ELT_IDS.ADAO_MENU_ID, sgPyQt.defaultMenuGroup() )
287         # create toolbar
288         tid = sgPyQt.createTool( "ADAO" )
289
290         a = sgPyQt.createAction( UI_ELT_IDS.NEW_ADAOCASE_ID, "New case", "New case", "Create a new adao case", "" )
291         sgPyQt.createMenu(a, mid)
292         sgPyQt.createTool(a, tid)
293         a = sgPyQt.createAction( UI_ELT_IDS.OPEN_ADAOCASE_ID, "Open case", "Open case", "Open an adao case", "" )
294         sgPyQt.createMenu(a, mid)
295         sgPyQt.createTool(a, tid)
296         a = sgPyQt.createAction( UI_ELT_IDS.SAVE_ADAOCASE_ID, "Save case", "Save case", "Save an adao case", "" )
297         sgPyQt.createMenu(a, mid)
298         sgPyQt.createTool(a, tid)
299         a = sgPyQt.createAction( UI_ELT_IDS.SAVE_AS_ADAOCASE_ID, "Save as case", "Save as case", "Save an adao case as", "" )
300         sgPyQt.createMenu(a, mid)
301         sgPyQt.createTool(a, tid)
302         a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close case", "Close case", "Close an adao case", "" )
303         sgPyQt.createMenu(a, mid)
304         sgPyQt.createTool(a, tid)
305
306         # the following action are used in context popup
307         a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close case", "Close case", "Close the selected case", "" )
308
309         a = sgPyQt.createAction( UI_ELT_IDS.EDIT_ADAOCASE_POP_ID, "Edit case", "Edit case", "Edit the selected study case", "" )
310         a = sgPyQt.createAction( UI_ELT_IDS.YACS_EXPORT_POP_ID, "Export to YACS", "Export to YACS", "Generate a YACS graph executing this case", "" )
311
312     def createPopupMenuOnItem(self,popup,salomeSudyId, item):
313         if adaoStudyEditor.isValidAdaoCaseItem(salomeSudyId, item):
314           popup.addAction( sgPyQt.action( UI_ELT_IDS.CLOSE_ADAOCASE_ID ) )
315
316           popup.addAction( sgPyQt.action( UI_ELT_IDS.EDIT_ADAOCASE_POP_ID ) )
317           popup.addAction( sgPyQt.action( UI_ELT_IDS.YACS_EXPORT_POP_ID ) )
318
319         return popup
320
321 class AdaoGuiActionImpl(EficasObserver):
322     """
323     This class implements the ui actions concerning the management of oma study
324     cases.
325     """
326
327     def __init__(self):
328         pass
329         # This dialog is created once so that it can be recycled for each call
330         # to newOmaCase().
331         #self.__dlgNewStudyCase = DlgNewStudyCase()
332         self.__parent = SalomePyQt.SalomePyQt().getDesktop()
333         self.__dlgEficasWrapper = AdaoEficasWrapper(parent=SalomePyQt.SalomePyQt().getDesktop())
334         self.__dlgEficasWrapper.addObserver(self)
335         self.__Eficas_viewId = -1
336
337     # ==========================================================================
338     # Processing of ui actions
339     #
340     def processAction(self,actionId):
341         """
342         Main switch function for ui actions processing
343         """
344         if ACTIONS_MAP.has_key(actionId):
345             try:
346                 functionName = ACTIONS_MAP[actionId]
347                 getattr(self,functionName)()
348             except:
349                 traceback.print_exc()
350         else:
351             msg = "The requested action is not implemented: " + str(actionId)
352             print msg
353
354     def showEficas(self):
355       if self.__Eficas_viewId == -1:
356         self.__dlgEficasWrapper.init_gui()
357
358
359         # Scroll Widget
360         area = QtGui.QScrollArea(SalomePyQt.SalomePyQt().getDesktop());
361         area.setWidget( self.__dlgEficasWrapper)
362         area.setWidgetResizable(1)
363
364         wmType = "ADAO View"
365         self.__Eficas_viewId = sgPyQt.createView(wmType, area)
366         sgPyQt.setViewClosable(self.__Eficas_viewId, False)
367       else:
368         if SalomePyQt.SalomePyQt().getActiveView() != self.__Eficas_viewId :
369           result_activate = SalomePyQt.SalomePyQt().activateView(self.__Eficas_viewId)
370           if result_activate == False:
371             self.__dlgEficasWrapper.init_gui()
372
373             # Scroll Widget
374             area = QtGui.QScrollArea(SalomePyQt.SalomePyQt().getDesktop());
375             area.setWidget( self.__dlgEficasWrapper)
376             area.setWidgetResizable(1)
377
378             wmType = "ADAO View"
379             self.__Eficas_viewId = sgPyQt.createView(wmType, area)
380             sgPyQt.setViewClosable(self.__Eficas_viewId, False)
381         self.__dlgEficasWrapper.setEnabled(True)
382
383     def activate(self):
384       self.showEficas()
385
386     def deactivate(self):
387       self.showEficas()
388       if self.__Eficas_viewId != -1:
389         self.__dlgEficasWrapper.setEnabled(False)
390
391     # Actions from SALOME GUI
392
393     def newAdaoCase(self):
394
395       adaoLogger.debug("newAdaoCase")
396       self.showEficas()
397       self.__dlgEficasWrapper.fileNew()
398
399     def openAdaoCase(self):
400
401       adaoLogger.debug("openAdaoCase")
402       self.showEficas()
403       global __cases__
404       fichier = QtGui.QFileDialog.getOpenFileName(SalomePyQt.SalomePyQt().getDesktop(),
405                                                   self.__dlgEficasWrapper.trUtf8('Ouvrir Fichier'),
406                                                   self.__dlgEficasWrapper.CONFIGURATION.savedir,
407                                                   self.__dlgEficasWrapper.trUtf8('JDC Files (*.comm);;''All Files (*)'))
408       if fichier.isNull(): return
409       new_case = AdaoCase()
410       new_case.set_filename(str(fichier))
411       new_case.set_name(str(fichier.split('/')[-1]))
412       salomeStudyId   = adaoGuiHelper.getActiveStudyId()
413       salomeStudyItem = adaoStudyEditor.addInStudy(salomeStudyId, new_case)
414       case_key = (salomeStudyId, salomeStudyItem.GetID())
415       __cases__[case_key] = new_case
416
417       # Open file in Eficas
418       self.__dlgEficasWrapper.Openfile(new_case.get_filename())
419       callbackId = [salomeStudyId, salomeStudyItem]
420       self.__dlgEficasWrapper.setCallbackId(callbackId)
421       self.showEficas()
422       adaoGuiHelper.refreshObjectBrowser()
423
424     def editAdaoCase(self):
425
426       adaoLogger.debug("editAdaoCase")
427       global __cases__
428
429       # Take study item
430       salomeStudyId   = adaoGuiHelper.getActiveStudyId()
431       salomeStudyItem = adaoGuiHelper.getSelectedItem(salomeStudyId)
432       case_key = (salomeStudyId, salomeStudyItem.GetID())
433
434       # ShowEficas, If case is an empty case - case is destroyed by reopen
435       self.showEficas()
436       try:
437         case = __cases__[case_key]
438         # Search if case is in Eficas !
439         callbackId = [salomeStudyId, salomeStudyItem]
440         case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId)
441
442         # If case is not in eficas Open It !
443         if case_open_in_eficas == False:
444           if case.get_filename() != "":
445             self.__dlgEficasWrapper.Openfile(case.get_filename())
446             callbackId = [salomeStudyId, salomeStudyItem]
447             self.__dlgEficasWrapper.setCallbackId(callbackId)
448       except:
449         # Case has been destroyed - create a new one
450         self.__dlgEficasWrapper.fileNew()
451
452     def closeAdaoCase(self):
453
454       adaoLogger.debug("closeAdaoCase")
455       global __cases__
456
457       # First step: get selected case
458       salomeStudyId   = adaoGuiHelper.getActiveStudyId()
459       salomeStudyItem = adaoGuiHelper.getSelectedItem(salomeStudyId)
460
461       # Check if there is a selected case
462       if salomeStudyItem is None:
463         print "[Close case] Please select a case"
464         return
465
466       callbackId = [salomeStudyId, salomeStudyItem]
467       case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId)
468
469       # If case is in eficas close it !
470       if case_open_in_eficas:
471         # fileClose: remove the CallbackId
472         # fileClose: sends a destroy event
473         self.__dlgEficasWrapper.fileClose()
474       else:
475         # Test if case exists
476         case_key = (salomeStudyId, salomeStudyItem.GetID())
477         if __cases__.has_key(case_key):
478           __cases__.pop(case_key)
479           adaoStudyEditor.removeItem(salomeStudyId, salomeStudyItem)
480           adaoGuiHelper.refreshObjectBrowser()
481
482     def saveAdaoCase(self):
483
484       adaoLogger.debug("saveAdaoCase")
485       global __cases__
486
487     def saveasAdaoCase(self):
488
489       adaoLogger.debug("saveasAdaoCase")
490       global __cases__
491
492     def exportCaseToYACS(self):
493
494       adaoLogger.debug("exportCaseToYACS")
495       global __cases__
496
497       # Get case from study
498       salomeStudyId   = adaoGuiHelper.getActiveStudyId()
499       salomeStudyItem = adaoGuiHelper.getSelectedItem(salomeStudyId)
500       case_key = (salomeStudyId, salomeStudyItem.GetID())
501       case = __cases__[case_key]
502
503       # Generates YACS schema and export it
504       msg = case.exportCaseToYACS()
505
506       # If msg is not empty -> error found
507       if msg != "":
508         adaoGuiHelper.gui_warning(self.__parent, msg)
509
510     # ==========================================================================
511     # Processing notifications from adaoEficasWrapper
512     #
513     __processOptions={
514         EficasEvent.EVENT_TYPES.CLOSE   : "_processEficasCloseEvent",
515         EficasEvent.EVENT_TYPES.SAVE    : "_processEficasSaveEvent",
516         EficasEvent.EVENT_TYPES.NEW     : "_processEficasNewEvent",
517         EficasEvent.EVENT_TYPES.DESTROY : "_processEficasDestroyEvent",
518         EficasEvent.EVENT_TYPES.OPEN    : "_processEficasOpenEvent",
519         EficasEvent.EVENT_TYPES.REOPEN  : "_processEficasReOpenEvent"
520         }
521     def processEficasEvent(self, eficasWrapper, eficasEvent):
522         """
523         Implementation of the interface EficasObserver. The implementation is a
524         switch on the possible types of events defined in EficasEvent.EVENT_TYPES.
525         @overload
526         """
527         functionName = self.__processOptions.get(eficasEvent.eventType, lambda : "_processEficasUnknownEvent")
528         return getattr(self,functionName)(eficasWrapper, eficasEvent)
529
530     def _processEficasCloseEvent(self, eficasWrapper, eficasEvent):
531         pass
532
533     def _processEficasNewEvent(self, eficasWrapper, eficasEvent):
534       global __cases__
535
536       new_case = AdaoCase()
537       case_name = eficasWrapper.getCaseName()
538       new_case.set_name(case_name)
539       salomeStudyId   = adaoGuiHelper.getActiveStudyId()
540       salomeStudyItem = adaoStudyEditor.addInStudy(salomeStudyId, new_case)
541       case_key = (salomeStudyId, salomeStudyItem.GetID())
542       __cases__[case_key] = new_case
543       adaoGuiHelper.refreshObjectBrowser()
544       callbackId = [salomeStudyId, salomeStudyItem]
545       self.__dlgEficasWrapper.setCallbackId(callbackId)
546
547       # We need to select the case
548       adaoGuiHelper.selectItem(salomeStudyItem.GetID())
549
550
551     def _processEficasOpenEvent(self, eficasWrapper, eficasEvent):
552       global __cases__
553
554       # Ouverture du fichier
555       self.__dlgEficasWrapper.Openfile(self.__dlgEficasWrapper.getOpenFileName())
556
557       # Creation d'un nouveau cas
558       new_case = AdaoCase()
559       salomeStudyId   = adaoGuiHelper.getActiveStudyId()
560       salomeStudyItem = adaoStudyEditor.addInStudy(salomeStudyId, new_case)
561       case_key = (salomeStudyId, salomeStudyItem.GetID())
562       __cases__[case_key] = new_case
563
564       # Connexion du nouveau cas
565       callbackId = [salomeStudyId, salomeStudyItem]
566       self.__dlgEficasWrapper.setCallbackId(callbackId)
567
568       # On sauvegarde le cas
569       self._processEficasSaveEvent(self.__dlgEficasWrapper, None, callbackId)
570
571     def _processEficasSaveEvent(self, eficasWrapper, eficasEvent, callbackId=None):
572         global __cases__
573         if callbackId is None:
574           callbackId = eficasEvent.callbackId
575           if callbackId is None:
576             raise DevelException("the callback data should not be None. Can't guess what are the study and case")
577           [targetSalomeStudyId,targetSalomeStudyItem] = callbackId
578           if ( targetSalomeStudyId is None ) or ( targetSalomeStudyItem is None ):
579             raise DevelException("the parameters targetSalomeStudyId and targetSalomeStudyItem should not be None")
580         else:
581           [targetSalomeStudyId,targetSalomeStudyItem] = callbackId
582
583         # Get Editor All infos we need !
584         case_name = eficasWrapper.getCaseName()
585         file_case_name = eficasWrapper.getFileCaseName()
586         if case_name != "" :
587           # Get case
588           old_case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetID())
589           case =__cases__[old_case_key]
590
591           # Set new informations
592           case.set_name(case_name)
593           if str(case_name).startswith("Untitled"):
594             pass
595           else:
596             case.set_filename(file_case_name)
597           adaoStudyEditor.updateItem(targetSalomeStudyId, targetSalomeStudyItem, case)
598
599           # Case key changed !
600           #new_case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetID())
601           # A ne pas inverser !!!
602           #__cases__.pop(old_case_key)
603           #__cases__[new_case_key] = case
604
605           adaoGuiHelper.refreshObjectBrowser()
606
607     def _processEficasDestroyEvent(self, eficasWrapper, eficasEvent):
608         global __cases__
609         callbackId = eficasEvent.callbackId
610         if callbackId is None:
611             raise DevelException("the callback data should not be None. Can't guess what are the study and case")
612         [targetSalomeStudyId,targetSalomeStudyItem] = callbackId
613         if ( targetSalomeStudyId is None ) or ( targetSalomeStudyItem is None ):
614             raise DevelException("the parameters targetSalomeStudyId and targetSalomeStudyItem should not be None")
615
616         case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetID())
617         __cases__.pop(case_key)
618         adaoStudyEditor.removeItem(targetSalomeStudyId, targetSalomeStudyItem)
619         adaoGuiHelper.refreshObjectBrowser()
620
621     # Deprecated
622     # Normalement on ne ferme plus le GUI donc on ne passe plus par là
623     def _processEficasReOpenEvent(self, eficasWrapper, eficasEvent):
624
625       adaoLogger.warning("_processEficasReOpenEvent")
626       global __cases__
627
628       try:
629         callbackId = eficasEvent.callbackId
630         [salomeStudyId, salomeStudyItem] = callbackId
631         case_key = (salomeStudyId, salomeStudyItem.GetID())
632         case = __cases__[case_key]
633         # Search if case is in Eficas !
634         callbackId = [salomeStudyId, salomeStudyItem]
635         case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId)
636         # If case is not in eficas Open It !
637         if case_open_in_eficas == False:
638           if case.get_filename() != "":
639             self.__dlgEficasWrapper.Openfile(case.get_filename())
640             callbackId = [salomeStudyId, salomeStudyItem]
641             self.__dlgEficasWrapper.setCallbackId(callbackId)
642           else:
643             # Since I am an empty case I destroy myself before reloading
644             adaoStudyEditor.removeItem(salomeStudyId, salomeStudyItem)
645             adaoGuiHelper.refreshObjectBrowser()
646             __cases__.pop(case_key)
647             callbackId = [salomeStudyId, salomeStudyItem]
648             self.__dlgEficasWrapper.removeCallbackId(callbackId)
649       except:
650         print "Oups - cannot reopen case !"
651         traceback.print_exc()
652
653     def _processEficasUnknownEvent(self, eficasWrapper, eficasEvent):
654       print "Unknown Eficas Event"