/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : PopUpErrorLog.pkg */ /* Version : 26 juillet 2000 */ /* Popup Error Log window specific functions by Loïc ARGELIES */ /* */ /***************************************************************************************/ /* control variables */ var ERRORLOG_ERRORLISTNBITEMSVISIBLE = 10 ;; var ERRORLOG_FILTER_WARNINGS = 0 ;; var ERRORLOG_FILTER_FATALS = 2 ;; var ERRORLOG_FILTER_MINORS = 1 ;; /* Definition of SITE INFO STRUCTURE */ struct Struct_ErrorLogInfo = [ m_Channel : Chn , /* channel */ ctrl_Container : ObjContainer , /* container */ ctrl_Label1 : CompText , /* Displaying : "Filter" */ ctrl_EditBox1 : CompText , /* for further use */ ctrl_ErrorList : CompList , /* Main list showing error descriptions */ ctrl_ComboFilter : CompCombo , /* Holds the filter options */ ctrl_ClearButton : CompRollOver , /* Clear button */ ctrl_LabelErrorDesc : CompText , /* Complete description of error */ ctrl_CurrentErrorDesc : S , /* Holds the current detailed error description */ ctrl_ExportButton : CompRollOver /* export button */ ] mkErrorLogInfo ;; fun ERRORLOG_SetDetailedErrorDescriptionMessage(errorInfo, txt) = { if errorInfo.ctrl_LabelErrorDesc == nil then nil else { set errorInfo.ctrl_CurrentErrorDesc = txt ; _SETcompText errorInfo.ctrl_LabelErrorDesc txt scsgui.SCSGUIsmallFont nil CT_BEGIN ; _PAINTcontainer errorInfo.ctrl_Container ; 0 } ; } ;; fun ERRORLOG_AddErrorMessageToList(errorInfo, error) = { if errorInfo.ctrl_ErrorList != nil then { let strcatn (itoa error.ErrorId)::". "::error.ErrorContent::nil -> txt in if error.ErrorLevel == nil then _ADDcompList errorInfo.ctrl_ErrorList 0 [txt nil] else if error.ErrorLevel == ERRORLOG_FILTER_WARNINGS then _ADDcompList errorInfo.ctrl_ErrorList 0 [txt nil] else if error.ErrorLevel == ERRORLOG_FILTER_FATALS then _ADDcompList errorInfo.ctrl_ErrorList 0 [txt nil] else if error.ErrorLevel == ERRORLOG_FILTER_MINORS then _ADDcompList errorInfo.ctrl_ErrorList 0 [txt nil] else _ADDcompList errorInfo.ctrl_ErrorList 0 [error.ErrorContent nil] ; _SETcompListFirst errorInfo.ctrl_ErrorList 0 ; ERRORLOG_SetDetailedErrorDescriptionMessage errorInfo (_locSCS "popuperrorlog-SELMESSAGE" nil); _PAINTcontainer errorInfo.ctrl_Container ; 0 ; } else 0 ; } ;; fun ERRORLOG_OnErrorPosted( errors, identifier, level, content, errorInfo) = { if errorInfo.ctrl_ComboFilter == nil then nil else let _GETcompComboClicked errorInfo.ctrl_ComboFilter -> [index _] in let if index == 0 then nil else if index == 1 then ERRORLOG_FILTER_WARNINGS else if index == 2 then ERRORLOG_FILTER_MINORS else if index == 3 then ERRORLOG_FILTER_FATALS else nil -> nFilter in if nFilter <= level then { ERRORLOG_AddErrorMessageToList errorInfo mkError [identifier content level] ; 0 } else nil ; } ;; fun ERRORLOG_OnErrorCompListDblClick(ctrl_complist, errorInfo, index) = { 0 } ;; fun ERRORLOG_OnErrorCompListClick(ctrl_complist, errorInfo, index) = { let _GETcompListValue ctrl_complist index -> [txt _] in let strfind "." txt 0 -> pos in let substr txt 0 pos -> code in let strcatn "ERRORDESC_"::code::nil -> sLocRef in ERRORLOG_SetDetailedErrorDescriptionMessage errorInfo (_locSCS sLocRef nil) ; } ;; fun ERRORLOG_FillErrorList(errorInfo, ErrorList) = { if ErrorList == nil then nil else let ErrorList -> [ error L2] in { ERRORLOG_AddErrorMessageToList errorInfo error ; ERRORLOG_FillErrorList errorInfo L2 ; 0 }; } ;; fun ERRORLOG_ApplyErrorListFilter(errorInfo, filternum) = { if errorInfo.ctrl_ErrorList == nil then nil else let SCSDATA_GetErrors -> errors in { _RSTcompList errorInfo.ctrl_ErrorList ; ERRORLOG_SetDetailedErrorDescriptionMessage errorInfo (_locSCS "popuperrorlog-SELMESSAGE" nil) ; ERRORLOG_FillErrorList errorInfo (ERRORS_Get errors filternum) ; _PAINTcontainer errorInfo.ctrl_Container ; 0 } ; } ;; fun ERRORLOG_OnComboFilterClick(combo, errorInfo, index) = { if index == 0 then ERRORLOG_ApplyErrorListFilter errorInfo nil else if index == 1 then ERRORLOG_ApplyErrorListFilter errorInfo ERRORLOG_FILTER_WARNINGS else if index == 2 then ERRORLOG_ApplyErrorListFilter errorInfo ERRORLOG_FILTER_MINORS else if index == 3 then ERRORLOG_ApplyErrorListFilter errorInfo ERRORLOG_FILTER_FATALS else nil; } ;; fun ERRORLOG_CleanMessages(rol, errorInfo, posx, posy, btn, mask) = ERRORS_Clear SCSDATA_GetErrors; _RSTcompList errorInfo.ctrl_ErrorList; ERRORLOG_SetDetailedErrorDescriptionMessage errorInfo nil; _PAINTcontainer errorInfo.ctrl_Container ;; fun ERRORLOG_ExportErrorsToFile(filename, errorInfo) = { /* build error string to save */ let errorInfo.ctrl_ErrorList -> list in let _GETcompListCount list -> nbelem in let nil -> stringlist in let _getmodifypack filename -> wfile in { _appendpack (strcat ctime time "\n\n") wfile ; while nbelem > 0 do { let _GETcompListValue list (nbelem-1) -> [txt _] in /*set stringlist = listcat txt::nil stringlist ;*/ _appendpack strcat txt "\n" wfile ; set nbelem = nbelem - 1 ; } ; 1 } ; GRAPHICDRESSING_MessageBox scsgui.SCSGUIwindowManager.WINMANAGmainCont (_locSCS "popuperrorlog-EXPORTEDTITLE" nil) (_locSCS "popuperrorlog-EXPORTEDSUBTITLE" nil) (_locSCS "popuperrorlog-EXPORTEDMESSAGE" nil) ; 1 } ;; fun ERRORLOG_OnSaveExportFileRequired (retval, filename, errorInfo) = SITE_DialogBoxRefCountDec ; if retval then ( let getPathFile filename "" -> [res _] in SCSGUI_SetLastDirectory res; ERRORLOG_ExportErrorsToFile filename errorInfo; ) else nil; 1 ;; fun ERRORLOG_OnExportButtonClick(rol, errorInfo, posx, posy, btn, mask) = { if (_GETcompListCount errorInfo.ctrl_ErrorList) >0 then { SITE_DialogBoxRefCountInc ; GRAPHICDRESSING_SelectDialogBox scsgui.SCSGUIchannel scsgui.SCSGUIwindowManager.WINMANAGmainCont (_locSCS "Log-File-Title" nil) @ERRORLOG_OnSaveExportFileRequired (EXPORT_ERROR_FILE_EXT::nil)::nil "log file (*.log)"::nil SCSGUI_GetLastDirectory errorInfo SELECT_DIALOG_BOX_SAVE; 1; } else { GRAPHICDRESSING_MessageBox scsgui.SCSGUIwindowManager.WINMANAGmainCont (_locSCS "popuperrorlog-NOEXPORTTITLE" nil) (_locSCS "popuperrorlog-NOEXPORTSUBTITLE" nil) (_locSCS "popuperrorlog-NOEXPORTMESSAGE" nil) ; 0 } };; fun ERRORLOG_RefreshErrorLogWindow(errorInfo) = /* Creates or redraw site options popup child window*/ { /* window controls creation */ let _GETcontainerPositionSize errorInfo.ctrl_Container -> [xcont ycont wcont hcont] in { /* Label "Filter" */ set errorInfo.ctrl_Label1 = UTILSGUI_SetOrCreateText errorInfo.m_Channel errorInfo.ctrl_Container GUI_LABEL errorInfo.ctrl_Label1 strcat (_locSCS "popuperrorlog-FILTER" nil) " " [10 35] [50 20] nil nil ; /* Error desc list */ if errorInfo.ctrl_ErrorList == nil then let GD_COMPLIST_HIGHLIGHT_TRANSPARENCY -> colortransp in let GD_COMPLIST_TEXT_COLOR -> txtcolor in let GD_COMPLIST_HIGHLIGHT_COLOR -> highlightcolor in { set errorInfo.ctrl_ErrorList = GRAPHICDRESSING_CRcompList errorInfo.m_Channel errorInfo.ctrl_Container nil [10 80] OBJ_ENABLE|OBJ_VISIBLE|LST_LEFT|LST_HIGHLIGHT_CLICKED|OBJ_MH_FLEX|OBJ_MW_FLEX OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|OBJ_KEYBOARD wcont-20 160 ERRORLOG_ERRORLISTNBITEMSVISIBLE LST_VERTICAL scsgui.SCSGUIsmallFont 0 [txtcolor nil 0 0] [highlightcolor colortransp] ; _CBcompListClick errorInfo.ctrl_ErrorList @ERRORLOG_OnErrorCompListClick errorInfo ; _CBcompListDblClick errorInfo.ctrl_ErrorList @ERRORLOG_OnErrorCompListDblClick errorInfo; let _CONVERTcompListToObjNode errorInfo.ctrl_ErrorList -> pere in TOOLTIP_StaticLink errorInfo.ctrl_Container pere scsgui.SCSGUIstaticToolTip _locSCS "LOC_TOOLTIP_ERROR_CPLIST" nil; /* get list of errors */ ERRORLOG_ApplyErrorListFilter errorInfo nil ; 0; } else 1 ; /* Combo which holds the filter options */ if errorInfo.ctrl_ComboFilter == nil then ( set errorInfo.ctrl_ComboFilter = GRAPHICDRESSING_CRcompCombo errorInfo.m_Channel errorInfo.ctrl_Container nil [45 35] OBJ_ENABLE|OBJ_VISIBLE OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|OBJ_KEYBOARD wcont-200 70 scsgui.SCSGUIsmallFont [GD_COMBO_TEXT_COLOR nil 0 0] [GD_COMBO_HIGHLIGHT_COLOR 50] 25 ; _CBcompComboClick errorInfo.ctrl_ComboFilter @ERRORLOG_OnComboFilterClick errorInfo ; _ADDcompCombo errorInfo.ctrl_ComboFilter 0 [(_locSCS "popuperrorlog-ALLMESSAGES" nil) nil]; _ADDcompCombo errorInfo.ctrl_ComboFilter 1 [(_locSCS "popuperrorlog-WARNINGS" nil) nil]; _ADDcompCombo errorInfo.ctrl_ComboFilter 2 [(_locSCS "popuperrorlog-MINORERR" nil) nil]; _ADDcompCombo errorInfo.ctrl_ComboFilter 3 [(_locSCS "popuperrorlog-FATALERR" nil) nil]; _SETcompComboClicked errorInfo.ctrl_ComboFilter 0 ; 0 ) else 0; if errorInfo.ctrl_LabelErrorDesc != nil then nil else GRAPHICDRESSING_CRcompRollOverWithText errorInfo.m_Channel errorInfo.ctrl_Container nil [10 hcont-55] OBJ_VISIBLE|OBJ_DISABLE|OBJ_LH_FLEX|OBJ_MW_FLEX OBJ_CONTAINER_MOVE|OBJ_KEYBOARD wcont-20 50 scsgui.SCSGUIsmallFont "" GD_DEFAULT_TEXT_BUTTON_COLOR; /* Label holding detailed error message descriptions */ set errorInfo.ctrl_LabelErrorDesc = UTILSGUI_SetOrCreateTextEx errorInfo.m_Channel errorInfo.ctrl_Container GUI_LABEL errorInfo.ctrl_LabelErrorDesc errorInfo.ctrl_CurrentErrorDesc [10 hcont-50] [wcont-20 40] nil nil OBJ_ENABLE|OBJ_VISIBLE|CT_CENTER|CT_LABEL|CT_WORDWRAP|OBJ_LH_FLEX|OBJ_MW_FLEX; let _GETstringSize scsgui.SCSGUIsmallFont (_locSCS "popuperrorlog-CLEAR" nil) -> [lfont1 hfont] in { if errorInfo.ctrl_ClearButton == nil then { let 10+hfont -> hbutton in set errorInfo.ctrl_ClearButton = _CBcompRollOverClick GRAPHICDRESSING_CRcompRollOverWithText errorInfo.m_Channel errorInfo.ctrl_Container nil [wcont-145 35] OBJ_VISIBLE|OBJ_ENABLE|OBJ_MW_FLEX OBJ_CONTAINER_MOVE|OBJ_KEYBOARD 70 hbutton scsgui.SCSGUIsmallFont (_locSCS "popuperrorlog-CLEAR" nil) GD_DEFAULT_TEXT_BUTTON_COLOR @ERRORLOG_CleanMessages errorInfo; 0 } else 0 ; if errorInfo.ctrl_ExportButton == nil then { let _GETstringSize scsgui.SCSGUIsmallFont (_locSCS "popuperrorlog-EXPORT" nil) -> [lfont2 hfont] in let 10+hfont -> hbutton in set errorInfo.ctrl_ExportButton = _CBcompRollOverClick GRAPHICDRESSING_CRcompRollOverWithText errorInfo.m_Channel errorInfo.ctrl_Container nil [wcont-(145-75) 35] OBJ_VISIBLE|OBJ_ENABLE|OBJ_LW_FLEX OBJ_CONTAINER_MOVE|OBJ_KEYBOARD 60 hbutton scsgui.SCSGUIsmallFont (_locSCS "popuperrorlog-EXPORT" nil) GD_DEFAULT_TEXT_BUTTON_COLOR @ERRORLOG_OnExportButtonClick errorInfo; 0 } else 0 ; } ; ERRORLOG_SetDetailedErrorDescriptionMessage errorInfo (_locSCS "popuperrorlog-SELMESSAGE" nil); _PAINTcontainer errorInfo.ctrl_Container ; } ; } ;; fun ERRORLOG_HideAllControls (cont) = { 0; };; fun ERRORLOG_SiteSelected( site, param, errorInfo )= { if param & REFLEX_UNSELECTION then ( ERRORLOG_HideAllControls errorInfo.ctrl_Container ; 0 ) else if param & REFLEX_SELECTION then ( ERRORLOG_RefreshErrorLogWindow errorInfo ; 0 ) else nil ; } ;; fun ERRORLOG_SiteModified( site, param, errorInfo )= { if param & REFLEX_UNSELECTION then ( 0 ) else 0; ( ERRORLOG_RefreshErrorLogWindow errorInfo ; 0 ) } ;; /* fonctions generiques aux fenetres pop-up */ fun ERRORLOG_OnPreDestroy (cont) = { let _GETcontainerPositionSize cont -> [popx popy popw poph] in { PARAMS_SetI SCSparameters "POPUP_ERRORLOG_POSITION_X" popx ; PARAMS_SetI SCSparameters "POPUP_ERRORLOG_POSITION_Y" popy ; PARAMS_SetI SCSparameters "POPUP_ERRORLOG_WIDTH" popw ; PARAMS_SetI SCSparameters "POPUP_ERRORLOG_HEIGHT" poph ; } ; 1 ; } ;; fun POPUPWIN_SetErrorLogCallbacks (cont, param, errorInfo ) = { /* s'inscrire aux call back de sélection d'élément */ REFLEX_CBsiteSelected mkfun3 @ERRORLOG_SiteSelected errorInfo ; REFLEX_CBsiteModified mkfun3 @ERRORLOG_SiteModified errorInfo ; POPUPWIN_CBpopupPreDestroy @ERRORLOG_OnPreDestroy cont ; /* sets news error callbacks */ let SCSDATA_GetErrors -> errors in ERRORS_SetCallbacks errors mkfun5 @ERRORLOG_OnErrorPosted errorInfo ; } ;; fun POPUPWIN_CreateErrorLog (Channel, win, code) = { let PARAMS_GetI SCSparameters "POPUP_ERRORLOG_POSITION_X" -> popx in let PARAMS_GetI SCSparameters "POPUP_ERRORLOG_POSITION_Y" -> popy in let PARAMS_GetI SCSparameters "POPUP_ERRORLOG_WIDTH" -> popw in let PARAMS_GetI SCSparameters "POPUP_ERRORLOG_HEIGHT" -> poph in let PARAMS_GetI SCSparameters "POPUP_ERRORLOG_MIN_WIDTH" -> popminw in let PARAMS_GetI SCSparameters "POPUP_ERRORLOG_MIN_HEIGHT" -> popminh in let POPUPWIN_CreatePopupWindow Channel win if (popx != nil) then popx else 0 if (popy != nil) then popy else 50 if (popminw != nil) then popminw else 200 if (popminh != nil) then popminh else 400 (_locSCS "popuperrorlog-TITLE" nil) code nil nil -> cont in let mkErrorLogInfo [Channel cont nil nil nil nil nil nil nil nil] -> errorInfo in { /* Sets callbacks */ POPUPWIN_SetErrorLogCallbacks cont code errorInfo ; /* Displays the window */ ERRORLOG_RefreshErrorLogWindow errorInfo ; /* reset previously saved width & height parameters */ if popw != nil then _SIZEEXcontainer cont popx popy popw poph else nil; [cont (_locSCS "popuperrorlog-TITLE" nil)] ; } ; } ;;