# to be created for each study. It contains at least the ui component builder that
# creates the menu and toolbar items (must be created for every study)
+from daGuiImpl import datassimGuiHelper
from daGuiImpl.datassimGuiManager import DatassimGuiUiComponentBuilder
class GUIcontext:
uiComponentBuilder = None
# called when popup menu is invoked
# popup menu and menu context are passed as parameters
def createPopupMenu( popup, context ):
- pass
-# activeStudyId = sgPyQt.getStudyId()
-# if omaModuleHelper.verbose() : print "OMAGUI.createPopupMenu(): context = %s" % context
-# ctx = _setContext( sgPyQt.getStudyId() )
-# selcount, selected = omaGuiHelper.getAllSelected(activeStudyId)
-# if selcount == 1:
-# selectedItem = omaGuiHelper.getSelectedItem(activeStudyId)
-# popup = ctx.uiComponentBuilder.createPopupMenuOnItem(popup, activeStudyId, selectedItem)
+ activeStudyId = sgPyQt.getStudyId()
+ ctx = _setContext(sgPyQt.getStudyId())
+ selcount, selected = datassimGuiHelper.getAllSelected(activeStudyId)
+ if selcount == 1:
+ selectedItem = datassimGuiHelper.getSelectedItem(activeStudyId)
+ popup = ctx.uiComponentBuilder.createPopupMenuOnItem(popup, activeStudyId, selectedItem)
def OnGUIEvent(actionId) :
"""
UI_ELT_IDS = Enumerate([
'DATASSIM_MENU_ID',
'NEW_DATASSIMCASE_ID',
+ 'EDIT_DATASSIMCASE_POP_ID',
+ 'DELETE_DATASSIMCASE_POP_ID',
+ 'YACS_EXPORT_POP_ID',
],offset=950)
ACTIONS_MAP={
UI_ELT_IDS.NEW_DATASSIMCASE_ID:"newDatassimCase",
+ UI_ELT_IDS.EDIT_DATASSIMCASE_POP_ID:"editDatassimCase",
}
class DatassimGuiUiComponentBuilder:
sgPyQt.createMenu(a, mid)
sgPyQt.createTool(a, tid)
+ # the following action are used in context popup
+ a = sgPyQt.createAction( UI_ELT_IDS.EDIT_DATASSIMCASE_POP_ID, "Edit case", "Edit case", "Edit the selected study case", "" )
+ a = sgPyQt.createAction( UI_ELT_IDS.DELETE_DATASSIMCASE_POP_ID, "Delete case", "Delete case", "Delete the selected study case", "" )
+ a = sgPyQt.createAction( UI_ELT_IDS.YACS_EXPORT_POP_ID, "Export to YACS", "Export to YACS", "Generate a YACS graph executing this case", "" )
+
+ def createPopupMenuOnItem(self,popup,salomeSudyId, item):
+ if datassimStudyEditor.isValidDatassimCaseItem(salomeSudyId, item):
+ popup.addAction( sgPyQt.action( UI_ELT_IDS.EDIT_DATASSIMCASE_POP_ID ) )
+ popup.addAction( sgPyQt.action( UI_ELT_IDS.DELETE_DATASSIMCASE_POP_ID ) )
+ popup.addAction( sgPyQt.action( UI_ELT_IDS.YACS_EXPORT_POP_ID ) )
+
+ return popup
+
class DatassimGuiActionImpl(EficasObserver):
"""
This class implements the ui actions concerning the management of oma study
def newDatassimCase(self):
self.__dlgEficasWrapper.displayNew()
+ def editDatassimCase(self):
+ global __cases__
+ salomeStudyId = datassimGuiHelper.getActiveStudyId()
+ salomeStudyItem = datassimGuiHelper.getSelectedItem(salomeStudyId)
+ case_key = (salomeStudyId, salomeStudyItem.GetName())
+ try:
+ case = __cases__[case_key]
+ self.__dlgEficasWrapper.Openfile(case.get_name())
+ callbackId = [salomeStudyId, salomeStudyItem]
+ self.__dlgEficasWrapper.setCallbackId(callbackId)
+ self.__dlgEficasWrapper.show()
+ except:
+ print "Oups - cannot edit case !"
+ traceback.print_exc()
+
+
# ==========================================================================
# Processing notifications from eficas
#
new_case = DatassimCase()
salomeStudyId = datassimGuiHelper.getActiveStudyId()
salomeStudyItem = datassimStudyEditor.addInStudy(salomeStudyId, new_case)
- case_key = (salomeStudyId, salomeStudyItem)
+ case_key = (salomeStudyId, salomeStudyItem.GetName())
__cases__[case_key] = new_case
datassimGuiHelper.refreshObjectBrowser()
callbackId = [salomeStudyId, salomeStudyItem]
self.__dlgEficasWrapper.setCallbackId(callbackId)
def _processEficasSaveEvent(self, eficasWrapper, eficasEvent):
+ global __cases__
callbackId = eficasEvent.callbackId
if callbackId is None:
raise DevelException("the callback data should not be None. Can't guess what are the study and case")
# Get Editor All infos we need !
file_name = eficasWrapper.getCaseName()
if file_name != "" :
- case_key = (targetSalomeStudyId, targetSalomeStudyItem)
- case =__cases__[case_key]
+ # Get case
+ old_case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetName())
+ case =__cases__[old_case_key]
+
+ # Set new informations
case.set_name(file_name)
datassimStudyEditor.updateItem(targetSalomeStudyId, targetSalomeStudyItem, case)
+
+ # Case key changed !
+ new_case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetName())
+ # A ne pas inverser !!!
+ __cases__.pop(old_case_key)
+ __cases__[new_case_key] = case
+
datassimGuiHelper.refreshObjectBrowser()
def _processEficasDestroyEvent(self, eficasWrapper, eficasEvent):
+ global __cases__
callbackId = eficasEvent.callbackId
if callbackId is None:
raise DevelException("the callback data should not be None. Can't guess what are the study and case")
if ( targetSalomeStudyId is None ) or ( targetSalomeStudyItem is None ):
raise DevelException("the parameters targetSalomeStudyId and targetSalomeStudyItem should not be None")
- case_key = (targetSalomeStudyId, targetSalomeStudyItem)
+ case_key = (targetSalomeStudyId, targetSalomeStudyItem.GetName())
__cases__.pop(case_key)
datassimStudyEditor.removeItem(targetSalomeStudyId, targetSalomeStudyItem)
datassimGuiHelper.refreshObjectBrowser()