/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : ScsData.pkg */ /* Version : 26 Mai 2000 */ /* SCS specific data */ /* */ /***************************************************************************************/ proto SITE_ProcessApplicationQuit = fun [] I ;; proto SITE_GetModificationState = fun [Site] I ;; var DMS_FILE_EXT = ".dms";; var OLD_DMS_FILE_EXT = ".scs";; var DME_FILE_EXT = ".dme";; var DMC_FILE_EXT = ".dmc";; var EXPORT_ERROR_FILE_EXT = ".log";; var CLASS_LIST_FILE = "classList.cfg";; /* Control variables */ var SITE_nbModalDialogBoxOpened = 0 ;; var SITE_bRequiredQuit = 0 ;; var SITE_bRequiredCloseProject = 0 ;; /**************************************************************************************** STRUCT ****************************************************************************************/ struct REFmoduleClass = [ RMCfilename : S , /* module class filename */ RMCmoduleClass : ModuleClass /* module class */ ] mkREFmoduleClass ;; struct ScsData = [ SCSsites : [Site r1] , /* sites in memory */ SCSmoduleBuffer : [[Module r1 r1 r1 r1] r1] , /* modules node list buffer */ SCSzoneBuffer : [[Zone r1 r1 r1 r1] r1] , /* zones node list buffer */ SCSlinkBuffer : [Link r1] , /* link list buffer */ SCSassoBuffer : [Association r1] , /* association list buffer */ SCSblackboxClass : REFmoduleClass , /* blackbox class reference */ SCSmoduleClasses : [REFmoduleClass r1 r1 r1 r1] , /* module class tree */ SCSreflexLists : ReflexLists , /* reflex function lists */ SCSselectLists : [SelectLists r1] , /* selection lists with priority */ SCSselectSite : Site , /* current selected site */ SCScurrentKeyModule : I , /* key for module edition */ SCSerrors : Errors /* element to handle errors (cf. SCSerrors.html) */ ] mkScsData ;; typeof scs = ScsData;; /**************************************************************************************** SITES FUNCTIONS ****************************************************************************************/ /* --------------------- Modal dialog boxes references count handling */ fun SITE_SetQuitFlag(value) = { set SITE_bRequiredQuit = value ; } ;; fun SITE_GetQuitFlag() = { SITE_bRequiredQuit ; } ;; fun SITE_IsModalDialogBoxOpened()= { SITE_nbModalDialogBoxOpened ; } ;; fun SITE_DialogBoxRefCountInc() = { set SITE_nbModalDialogBoxOpened = SITE_nbModalDialogBoxOpened + 1 ; } ;; fun SITE_OnAllModalDialogBoxesClosed()= { /* Process here application quitting, project closing, etc */ if SITE_GetQuitFlag then { SITE_SetQuitFlag 0 ; SITE_ProcessApplicationQuit ; 0 } else { SITE_SetQuitFlag 0 ; 0 } } ;; fun SITE_DialogBoxRefCountDec() = { if SITE_nbModalDialogBoxOpened < 2 then { set SITE_nbModalDialogBoxOpened = 0 ; SITE_OnAllModalDialogBoxesClosed ; 0 } else { set SITE_nbModalDialogBoxOpened = SITE_nbModalDialogBoxOpened - 1 ; 0 } ; } ;; /* ----------------------- End of Modal dialog boxes references count handling */ /**************************************************************************************** Get and increase the current module key module ****************************************************************************************/ fun SCSDATA_GetCurrentKeyModule () = set scs.SCScurrentKeyModule = scs.SCScurrentKeyModule + 1;; fun SCSDATA_ClearModuleBuffer () = set scs.SCSmoduleBuffer = nil ;; fun SCSDATA_GetModuleBuffer () = scs.SCSmoduleBuffer ;; /**************************************************************************************** Move module list to buffer ****************************************************************************************/ fun SCSDATA_BufferizeModuleNode (moduleNode) = set scs.SCSmoduleBuffer = moduleNode::(scs.SCSmoduleBuffer); 1 ;; fun SCSDATA_ClearLinkBuffer () = set scs.SCSlinkBuffer = nil ;; fun SCSDATA_GetLinkBuffer () = scs.SCSlinkBuffer ;; /**************************************************************************************** Move link list to buffer ****************************************************************************************/ fun SCSDATA_BufferizeLink (links) = set scs.SCSlinkBuffer = listcat links (scs.SCSlinkBuffer); 1 ;; fun SCSDATA_ClearZoneBuffer () = set scs.SCSzoneBuffer = nil ;; fun SCSDATA_GetZoneBuffer () = scs.SCSzoneBuffer ;; fun SCSDATA_ClearAssociationBuffer () = set scs.SCSassoBuffer = nil ;; fun SCSDATA_GetAssociationBuffer () = scs.SCSassoBuffer ;; /**************************************************************************************** Move association list to buffer ****************************************************************************************/ fun SCSDATA_BufferizeAssociation (associations) = set scs.SCSassoBuffer = listcat associations (scs.SCSassoBuffer); 1 ;; fun SCSDATA_GetSiteList () = { scs.SCSsites ; } ;; fun SCSDATA_IsModifInSiteListTail(sitelist) = { if sitelist != nil then { let sitelist -> [site Lnext] in { if SITE_GetModificationState site then 1 else (SCSDATA_IsModifInSiteListTail Lnext) ; } ; } else 0 ; } ;; fun SCSDATA_IsModificationInSiteList() = { let SCSDATA_GetSiteList -> sitelist in { SCSDATA_IsModifInSiteListTail sitelist ; } } ;; /**************************************************************************************** Move zone def to buffer ****************************************************************************************/ fun SCSDATA_BufferizeZoneNode (def) = set scs.SCSzoneBuffer = def::(scs.SCSzoneBuffer); 1 ;; /**************************************************************************************** CLASS FUNCTIONS ****************************************************************************************/ fun SCSDATA_SearchClassREF (elt, class) = class == (elt.RMCmoduleClass) ;; fun SCSDATA_SearchClassByClass (class) = TREE_Val TREE_SearchNodeWithFunction (scs.SCSmoduleClasses) @SCSDATA_SearchClassREF class TREE_PRE_ORDER ;; fun SCSDATA_SearchClassName (node, filename) = let TREE_Val node -> elt in !strcmpi filename (elt.RMCfilename) ;; fun SCSDATA_SearchClassByFileName2 (node, treeList, filename) = if treeList == nil then nil else let TREE_ListOfAllBrothers (TREE_FirstChild node) -> listChild in if (tl tl treeList) == nil then /* current header of list is the filename class */ TREE_Val search_in_list listChild @SCSDATA_SearchClassName filename else /* current header of list is a subdirectory */ let search_in_list listChild @SCSDATA_SearchClassName (hd treeList) -> foundNode in if foundNode != nil then SCSDATA_SearchClassByFileName2 foundNode (tl treeList) filename else nil /* tree structure not found */ ;; fun SCSDATA_SearchClassByFileName (filename) = let SCSDATA_SearchClassByFileName2 scs.SCSmoduleClasses (splitFilePath filename) filename -> classREF in classREF.RMCmoduleClass ;; fun SCSDATA_GetBlackBoxClass ()= scs.SCSblackboxClass.RMCmoduleClass ;; fun SCSDATA_GetBlackBoxClassRef ()= scs.SCSblackboxClass ;; /**************************************************************************************** return the node where the new class of module have to be added if the current tree structure for the new class of module doesn't exist, it is created ****************************************************************************************/ /* is leaf1 sorted before leaf2 */ fun SCSDATA_IsLeafSortedBefore( node1, node2 )= (strcmpi MODULECLASS_GetFormatedName node1.RMCmoduleClass MODULECLASS_GetFormatedName node2.RMCmoduleClass) < 0;; fun SCSDATA_IsNodeSortedBefore( node1, node2 )= (strcmpi node1.RMCfilename node2.RMCfilename) < 0;; fun SCSDATA_SetNextBrother( node, nodeToAdd )= let TREE_NextBrother node -> brother in if (brother == nil) || (SCSDATA_IsLeafSortedBefore TREE_Val nodeToAdd TREE_Val brother) then TREE_AddNodeAsNextBrother node nodeToAdd else SCSDATA_SetNextBrother brother nodeToAdd ;; fun SCSDATA_GetClassTree (node, treeList) = if treeList == nil then nil else if (tl tl treeList) == nil then /* current header of list is the filename class */ node else /* current header of list is a subdirectory */ let TREE_ListOfAllBrothers TREE_FirstChild node -> listChild in let search_in_list listChild @SCSDATA_SearchClassName (hd treeList) -> foundNode in if foundNode != nil then SCSDATA_GetClassTree foundNode (tl treeList) else let TREE_MkNode (mkREFmoduleClass [(hd treeList) nil]) -> newNode in ( let TREE_FirstChild node -> firstChild in if (firstChild == nil) || (SCSDATA_IsNodeSortedBefore TREE_Val newNode TREE_Val firstChild) then TREE_AddNodeToChildHead node newNode else SCSDATA_SetNextBrother firstChild newNode; SCSDATA_GetClassTree newNode (tl treeList) ) ;; fun SCSDATA_AddClassREF (filename, class) = let SCSDATA_GetClassTree scs.SCSmoduleClasses (splitFilePath filename) -> father in let (TREE_MkNode (mkREFmoduleClass [filename class])) -> nodeToAdd in let TREE_FirstChild father -> firstChild in if (firstChild == nil) || (SCSDATA_IsNodeSortedBefore TREE_Val nodeToAdd TREE_Val firstChild) then TREE_AddNodeToChildHead father nodeToAdd else SCSDATA_SetNextBrother firstChild nodeToAdd ;; fun SCSDATA_LoadModuleClass (fileNameClass, param) = let MODULECLASS_Load fileNameClass -> class in if class == nil then nil else SCSDATA_AddClassREF fileNameClass class ;; fun SCSDATA_HardLoadAllDMSModuleClass () = let getAllFiles ""::nil DMC_FILE_EXT -> list2 in ( _storepack linebuild list2 strcat SCS_PATH CLASS_LIST_FILE; list2 ) ;; fun SCSDATA_LoadAllDMSModuleClass () = let let _getpack _checkpack strcat SCS_PATH CLASS_LIST_FILE -> Slist1 in if Slist1 != nil then lineextr Slist1 else SCSDATA_HardLoadAllDMSModuleClass -> listOfDMCfile in apply_on_list listOfDMCfile @SCSDATA_LoadModuleClass nil ;; fun SCSDATA_ReloadModuleClass (fileNameClass, param) = if (SCSDATA_SearchClassByFileName fileNameClass) == nil then let MODULECLASS_Load fileNameClass -> class in if class == nil then nil else SCSDATA_AddClassREF fileNameClass class else nil ;; fun SCSDATA_ReloadMergeAllDMSModuleClass () = let SCSDATA_HardLoadAllDMSModuleClass -> listOfDMCfile in apply_on_list listOfDMCfile @SCSDATA_ReloadModuleClass nil ;; /**************************************************************************************** ZONE TREE FUNCTIONS ****************************************************************************************/ /**************************************************************************************** Gets the errors handling element ****************************************************************************************/ fun SCSDATA_GetErrors () = if scs.SCSerrors == nil then nil else scs.SCSerrors ;; /**************************************************************************************** create a new SCS data ****************************************************************************************/ fun SCSDATA_Create () = { set scs = mkScsData [ nil nil nil nil nil mkREFmoduleClass [strcat SCS_PATH BLACKBOX_FILEPATH MODULECLASS_Load strcat SCS_PATH BLACKBOX_FILEPATH] (TREE_MkNode (mkREFmoduleClass [nil nil])) (mkReflexLists [nil nil nil nil nil]) (mkSelectLists [REFLEX_PRIORITY_ONE nil nil nil nil]):: (mkSelectLists [REFLEX_PRIORITY_TWO nil nil nil nil]):: (mkSelectLists [REFLEX_PRIORITY_THREE nil nil nil nil])::nil nil 0 ERRORS_Create nil ]; set SITE_nbModalDialogBoxOpened = 0 ; SITE_UpdateRecentFiles; SCSDATA_LoadAllDMSModuleClass ; } ;; fun SCSDATA_Destroy () = /* MAC ICI : mettre à jour !!! */ 0 ;;