def __init__(self, parent, code="DATASSIM"):
EficasWrapper.__init__(self, parent, code)
+ def init_gui(self):
+ EficasWrapper.init_gui(self)
+ print "self.__myCallbackId", self.__myCallbackId
+ save_CallbackId = self.__myCallbackId.copy()
+ for editor, myCallbackId in save_CallbackId.iteritems():
+ self.notifyObserver(EficasEvent.EVENT_TYPES.REOPEN, callbackId=myCallbackId)
+
# Association de l'objet editor avec le callbackId
def setCallbackId(self, callbackId):
index = self.viewmanager.myQtab.currentIndex()
for editor, myCallbackId in self.__myCallbackId.iteritems():
if myCallbackId[0] == callbackId[0]:
if myCallbackId[1].GetID() == callbackId[1].GetID():
- rtn = True
- for indexEditor in self.viewmanager.dict_editors.keys():
- if editor is self.viewmanager.dict_editors[indexEditor]:
- self.viewmanager.myQtab.setCurrentIndex(indexEditor)
+ try:
+ for indexEditor in self.viewmanager.dict_editors.keys():
+ if editor is self.viewmanager.dict_editors[indexEditor]:
+ self.viewmanager.myQtab.setCurrentIndex(indexEditor)
+ rtn = True
+ except:
+ pass
return rtn
def fileClose(self):
'SAVE',
'DESTROY',
'OPEN',
+ 'REOPEN',
'NEW'
])
self.__codetype = code
self.__jdc = None
+ self.__salome = salome
+ self.__parent = parent
# variables for the notification procedure
self.__observer = None
print "noversion"
session.parse( eficasArg )
- qtEficas.Appli.__init__( self,code=code,salome=salome,parent=parent)
+ # qtEficas.Appli.__init__( self,code=code,salome=salome,parent=parent)
+ def init_gui(self):
+ import InterfaceQT4.readercata
+ if hasattr(InterfaceQT4.readercata,'reader') :
+ del InterfaceQT4.readercata.reader
+ qtEficas.Appli.__init__( self,code=self.__codetype,salome=self.__salome,parent=self.__parent)
def setCodeType(self,code):
self.__codetype = code
raise DevelException("the argument should implement the function processEficasEvent")
self.__observer = observer
- def notifyObserver(self, eventType):
+ def notifyObserver(self, eventType, callbackId=None):
if eventType != EficasEvent.EVENT_TYPES.NEW and eventType != EficasEvent.EVENT_TYPES.OPEN:
- eficasEvent = EficasEvent(eventType, self.getCallbackId())
+ if callbackId is None :
+ eficasEvent = EficasEvent(eventType, self.getCallbackId())
+ else:
+ eficasEvent = EficasEvent(eventType, callbackId)
else:
eficasEvent = EficasEvent(eventType)
self.__observer.processEficasEvent(self, eficasEvent)
cases.
"""
__dlgEficasWrapper = None
+ __Eficas_viewId = -1
def __init__(self):
pass
msg = "The requested action is not implemented: " + str(actionId)
print msg
+ def showEficas(self):
+ if self.__Eficas_viewId == -1:
+ print "First showEficas"
+ self.__dlgEficasWrapper.init_gui()
+ self.__Eficas_viewId = SalomePyQt.SalomePyQt().createViewWithMain(self.__dlgEficasWrapper)
+ else:
+ print "myViewId =", self.__Eficas_viewId
+ print "activeView =", SalomePyQt.SalomePyQt().getActiveView()
+ if SalomePyQt.SalomePyQt().getActiveView() != self.__Eficas_viewId :
+ result_activate = SalomePyQt.SalomePyQt().activateView(self.__Eficas_viewId)
+ if result_activate == False:
+ print "View was close - create a new eficas widget"
+ self.__dlgEficasWrapper.init_gui()
+ self.__Eficas_viewId = SalomePyQt.SalomePyQt().createViewWithMain(self.__dlgEficasWrapper)
+
+
def newDatassimCase(self):
- self.__dlgEficasWrapper.displayNew()
+ self.showEficas()
+ self.__dlgEficasWrapper.fileNew()
def openDatassimCase(self):
+ self.showEficas()
global __cases__
fichier = QtGui.QFileDialog.getOpenFileName(SalomePyQt.SalomePyQt().getDesktop(),
self.__dlgEficasWrapper.trUtf8('Ouvrir Fichier'),
self.__dlgEficasWrapper.Openfile(new_case.get_filename())
callbackId = [salomeStudyId, salomeStudyItem]
self.__dlgEficasWrapper.setCallbackId(callbackId)
- self.__dlgEficasWrapper.show()
+ self.showEficas()
datassimGuiHelper.refreshObjectBrowser()
def editDatassimCase(self):
+ # First we show eficas - all cases are reloaded
global __cases__
+
+ # Take study item
salomeStudyId = datassimGuiHelper.getActiveStudyId()
salomeStudyItem = datassimGuiHelper.getSelectedItem(salomeStudyId)
case_key = (salomeStudyId, salomeStudyItem.GetID())
+
+ # ShowEficas, If case is an empty case - case is destroyed by reopen
+ self.showEficas()
try:
case = __cases__[case_key]
# Search if case is in Eficas !
callbackId = [salomeStudyId, salomeStudyItem]
case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId)
+
# If case is not in eficas Open It !
if case_open_in_eficas == False:
- self.__dlgEficasWrapper.Openfile(case.get_filename())
- callbackId = [salomeStudyId, salomeStudyItem]
- self.__dlgEficasWrapper.setCallbackId(callbackId)
- self.__dlgEficasWrapper.show()
+ if case.get_filename() != "":
+ self.__dlgEficasWrapper.Openfile(case.get_filename())
+ callbackId = [salomeStudyId, salomeStudyItem]
+ self.__dlgEficasWrapper.setCallbackId(callbackId)
except:
print "Oups - cannot edit case !"
traceback.print_exc()
EficasEvent.EVENT_TYPES.SAVE : "_processEficasSaveEvent",
EficasEvent.EVENT_TYPES.NEW : "_processEficasNewEvent",
EficasEvent.EVENT_TYPES.DESTROY : "_processEficasDestroyEvent",
- EficasEvent.EVENT_TYPES.OPEN : "_processEficasOpenEvent"
+ EficasEvent.EVENT_TYPES.OPEN : "_processEficasOpenEvent",
+ EficasEvent.EVENT_TYPES.REOPEN : "_processEficasReOpenEvent"
}
def processEficasEvent(self, eficasWrapper, eficasEvent):
"""
def _processEficasNewEvent(self, eficasWrapper, eficasEvent):
global __cases__
new_case = DatassimCase()
+ case_name = eficasWrapper.getCaseName()
+ new_case.set_name(case_name)
salomeStudyId = datassimGuiHelper.getActiveStudyId()
salomeStudyItem = datassimStudyEditor.addInStudy(salomeStudyId, new_case)
case_key = (salomeStudyId, salomeStudyItem.GetID())
callbackId = [salomeStudyId, salomeStudyItem]
self.__dlgEficasWrapper.setCallbackId(callbackId)
+ def _processEficasReOpenEvent(self, eficasWrapper, eficasEvent):
+ global __cases__
+ try:
+ callbackId = eficasEvent.callbackId
+ [salomeStudyId, salomeStudyItem] = callbackId
+ case_key = (salomeStudyId, salomeStudyItem.GetID())
+ case = __cases__[case_key]
+ # Search if case is in Eficas !
+ callbackId = [salomeStudyId, salomeStudyItem]
+ print "selectCase"
+ case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId)
+ # If case is not in eficas Open It !
+ if case_open_in_eficas == False:
+ print "reopen selectCase"
+ if case.get_filename() != "":
+ self.__dlgEficasWrapper.Openfile(case.get_filename())
+ callbackId = [salomeStudyId, salomeStudyItem]
+ self.__dlgEficasWrapper.setCallbackId(callbackId)
+ else:
+ # Since I am an empty case I destroy myself before reloading
+ datassimStudyEditor.removeItem(salomeStudyId, salomeStudyItem)
+ datassimGuiHelper.refreshObjectBrowser()
+ __cases__.pop(case_key)
+ self.__dlgEficasWrapper.fileNew()
+ except:
+ print "Oups - cannot reopen case !"
+ traceback.print_exc()
+
def _processEficasOpenEvent(self, eficasWrapper, eficasEvent):
global __cases__
case =__cases__[old_case_key]
# Set new informations
- case.set_filename(file_case_name)
case.set_name(case_name)
+ if str(case_name).startswith("Untitled"):
+ pass
+ else:
+ case.set_filename(file_case_name)
datassimStudyEditor.updateItem(targetSalomeStudyId, targetSalomeStudyItem, case)
# Case key changed !