//TH-Header //***************************************************************************************** // Copyright (c) 2001 Michael Kurz // All rights reserved. // If you want to use this source in your applications conatct: // // $FileName : cWorkSpaceHandlerEx.Pkg // $ProjectName : The Hammer. // $Author : Michael Kurz // $Created : 22.03.2001 21:14 // // Contents: // Modifies the OpenPath with the WorkSpace settings regarding to a special WorkSpace // of a special VDF version. //***************************************************************************************** //TH-RevisionStart // 22.06.2001 21:15 Added CurrenFileListPath Mk SERVER // 03.03.2003 **WvA // The workspace handler class is completely revised to support all current // versions of Visual DataFlex known if compiled with VDF7 // // psVersion - indicates the current version of VDF used // // All properties prefixed with "Current" can be queried for the current workspace // settings // // psCurWrkSpace = holds the current workspace tag // // // //TH-RevisionEnd Use Windows.pkg Use cLineParser.pkg Use vWin32fh.pkg Use cRegistry.pkg Use cIniFile.pkg Use cWorkspaceHandlerBase.pkg Use cWorkspaceLibrary.pkg Use mProfile_StringVersion.pkg Use cFileBrowser.pkg Use cSearchPath.pkg Use set.pkg // Modifies the OpenPath with the WorkSpace settings regarding to a special WorkSpace // of a special VDF version. Class cWorkSpaceHandlerEx Is a cWorkspaceHandlerBase Procedure Construct_Object Forward Send construct_object Set pbUpdateCurrentWorkspace To True // This will update the registry of the current workspace when set to true Object oLibraries is a cWorkspaceLibrary // contains the studio workspace files of any library Set phoLibraries to Self End_Object End_Procedure // Construct_Object Procedure Delete_Data Handle hoID Forward Send Delete_Data Get Object_ID Of oLibraries To hoID If (hoID) Begin Send Delete_Data To oLibraries End End_Procedure // Delete_Data // // Return the pkg folder for the currently selected runtime. // Function CurrentRuntimePkgPath Returns String String sPath Get psVdfRootDir To sPath Get vFolderFormat sPath To sPath Move (sPath+"Pkg") To sPath Function_Return sPath End_Function // CurrentRuntimePkgPath // **WvA: 07-05-2005 Added for webapp debugger support // // Returns the URL as is defined in the webapp.cfg file // for use with the debugger. // Function WebAppTestURL Returns String String sAppSrcPath String sPath String sFile String sLine String sTag String sTestURL Integer iChannel Boolean bExists Move "" To sTestURL Get CurrentAppSrcPath To sAppSrcPath If (sAppSrcPath<>"") Begin Get NextPathInFolder sAppSrcPath To sPath // **WvA Use Get StripNextPath sPath sAppSrcPath To sPath // Get NextPathInFolder sAppSrc To sPath // to enumerate thru a list of paths. I only need this in the first folder now. Get vFolderFormat sPath To sPath Move (sPath+"webapp.cfg") To sFile Get vFilePathExists sFile To bExists If (bExists) Begin // // Read Workspace INI // **WvA: ToDo Check for FREE channel! // Direct_Input sFile While (Not(seqeof)) Readln sLine Move (Trim(sLine)) To sLine If (Pos("=",sLine)) Begin Move (Trim(Left(sLine, (Pos("=", sLine)-1) ))) To sTag Move (Replace(sTag, sLine, "")) To sLine Move (Trim(Replace("=", sLine, ""))) To sLine If (lowercase(sTag)="testurl") Move sLine To sTestURL End Loop Close_Input End Else Begin Send info_box ("WebApp Configuration file <"+sFile+"> not found.") End End Else Begin Send info_box ("AppSrcPath is not set.") End Function_Return sTestURL End_Function // WebAppTestURL Procedure ReadLibrarySection String sSWSfile String sWSfile String sHome Boolean bExists Integer iCount Integer iLib Integer iLibCount Handle hoIniFile Handle hoArLib String sLibItem String sLibrary String sPath tWSLibrary LibConfig tWSLibrary[] WSLibraries // Send Delete_Data Of oLibraries Move (ResizeArray(WSLibraries,0)) To WSLibraries Get vFilePathExists sSWSfile to bExists If (bExists) Begin Get Create (RefClass(cIniFile)) To hoIniFile If (hoIniFile<>0) Begin Set psFileName Of hoIniFile To sSWSfile Get ParseFolderName sWSfile To sPath Get SectionExists Of hoIniFile "Libraries" To bExists If (bExists) Begin Get Create (RefClass(Array)) To hoArLib If (hoArLib) Begin Send ReadSection Of hoIniFile "Libraries" hoArLib Get Item_Count Of hoArLib To iLibCount For iLib From 0 To (iLibCount-1) Get Value Of hoArLib Item iLib To sLibItem Get ReadString Of hoIniFile "Libraries" sLibItem "" To sLibrary If (sLibrary<>"") Begin If (Left(sLibrary,1)<>"." and Left(sLibrary,1)<>"\") Begin // DAW doesn't register libraries local to the workspace with a preceding dot. If (Pos(":",sLibrary)=0) Begin Move (".\"+sLibrary) to sLibrary End End Get AnsiNametoOemName sLibrary To sLibrary Get ConvertRelativePath sHome sLibrary sPath To sLibrary Get Item_Count Of oLibraries To iCount Set Value Of oLibraries iCount To sLibrary // Recurse to see if there are nested libraries Get Configuration Of oLibraries iCount To LibConfig If (LibConfig.sWsFile<>"" and LibConfig.sHome<>"") Begin Move LibConfig To WSLibraries[SizeOfArray(WSLibraries)] Send ReadLibrarySection sLibrary LibConfig.sWsFile LibConfig.sHome End End Loop Send Destroy Of hoArLib End End Send Destroy of hoIniFile End End Set pWSLibraries Of oLibraries to WSLibraries End_Procedure // ReadLibrarySection // // Find the filename for the current workspace and libraries // Function FindFileForWorkspace String sFile Returns String Boolean bExists String sFileName String sPaths String sPath // First check df_open_path, this will include files in the runtime pkg folder // and base workspace folders Get_File_Path sFile to sFileName If (sFileName="") Begin Get LibraryAppSrcPaths of oLibraries to sPaths If (sPaths<>"") Begin While (Pos(";",sPaths)) Move (Left(sPaths,Pos(";",sPaths)-1)) to sPath Move (Replace(sPath+";",sPaths,"")) to sPaths Get vFolderFormat sPath to sPath Get vFilePathExists (sPath+sFile) to bExists If (bExists) Begin Move (sPath+sFile) to sFileName Move "" to sPaths // stop End Loop End End Function_Return sFileName End_Function // // Reads the recent workspaces from the registry // Where we used to work with so called workspace tags, // we are now seeing the use of so called .sws files. // These files contain a pointer to a workspace .ws file that // contains the actual workspace info. // Procedure ReadRecentWorkspaces String sVersion Handle hoRegistry Number nVer String sKey String sValue String sFile String sPath Boolean bOpen Boolean bExist Integer iCount Integer iItem Get StringVDfVersionToNum sVersion To nVer If (nVer<180) Begin Move (CS_SWDAWVDFTOOLS+sVersion+CS_BS+CS_STUDIO+"\RecentWorkspaces\") To sKey End Else Begin Move (CS_SWDAWDFTOOLS +sVersion+CS_BS+CS_STUDIO+"\RecentWorkspaces\") To sKey End Get Create U_cRegistry To hoRegistry If (hoRegistry) Begin Set pfAccessRights Of hoRegistry To KEY_READ Get OpenKey Of hoRegistry sKey To bOpen If (bOpen) Begin Get CountOfValues Of hoRegistry To iCount For iItem From 1 To iCount Move ("Recent"+trim(iItem)) To sValue Get ValueExists Of hoRegistry sValue To bExist If (bExist) Begin Get ReadString Of hoRegistry sValue To sFile Get vFilePathExists sFile To bExist If ((sFile<>"") and (bExist)) Begin Send AddWorkspaceFromSwsFile sVersion sFile End End Loop Send CloseKey Of hoRegistry End Send Destroy Of hoRegistry End End_Procedure // ReadRecentWorkspaces // // Reads the last used workspace folder from the registry // This is the default place to open our new file open dialog // when trying to browse for a project. // Function LastWorkspaceFolder Returns String Handle hoRegistry Number nVer String sKey String sValue String sPath String sVersion Boolean bOpen Boolean bExist Get psVdfVersion To sVersion Get StringVDfVersionToNum sVersion To nVer If (nVer<180) Begin Move (CS_SWDAWVDFTOOLS+sVersion+CS_BS+CS_STUDIOWORKSPACES+"\") To sKey End Else Begin Move (CS_SWDAWDFTOOLS+sVersion+CS_BS+CS_STUDIOWORKSPACES+"\") To sKey End Move "" To sPath Get Create U_cRegistry To hoRegistry If (hoRegistry) Begin Set pfAccessRights Of hoRegistry To KEY_READ Get OpenKey Of hoRegistry sKey To bOpen If (bOpen) Begin Move ("LastWorkspaceFolder") To sValue Get ValueExists Of hoRegistry sValue To bExist If (bExist) Begin Get ReadString Of hoRegistry sValue To sPath End Send CloseKey Of hoRegistry End Send Destroy Of hoRegistry End Function_Return sPath End_Function // LastWorkspaceFolder // // If The Hammer tries to open a non DataFlex driver for the first // time while editing and then throwing up the auto-login prompt, there // are drivers that then crash our editor. // Triggering the auto-login prompt when opening the workspace is fine // and subsequent opens on files do no longer crash the editor. // Procedure LoadNonEmbeddedDriverAutoLoginPrompt Integer iFileNum Boolean bHasDBDriver Boolean bOpened String sOldFilelist String sFileList String sRootName Move False to bHasDBDriver Get_Attribute DF_FILELIST_NAME To sOldFileList Get CurrentFileListPath to sFileList If (sFileList<>"") Begin Set_Attribute DF_FILELIST_NAME To sFileList Move 0 to iFileNum Repeat Get_Attribute DF_FILE_NEXT_USED of iFileNum to iFileNum If (iFileNum<>0) Begin Get_Attribute DF_FILE_ROOT_NAME of iFileNum to sRootName If (Pos(":",sRootName) or Pos(".int",lowercase(sRootName))) Begin Send Ignore_all to Error_Info_Object // errors here should not be fatal Open iFileNum // trigger autologin popup Send Trap_All to Error_Info_Object Get_Attribute DF_FILE_OPENED of iFileNum to bOpened If (bOpened) Begin Close iFileNum // also close again as we do not want to keep the file open End Move True to bHasDBDriver Move 0 to iFileNum End End Until (iFileNum = 0) Set_Attribute DF_FILELIST_NAME To sOldFileList End End_Procedure // LoadNonEmbeddedDriverAutoLoginPrompt Procedure UnloadNonEmbeddedDrivers Integer iDriver iDrivers iDriverCount iDriversToUnload String sName String[] sDriversToUnload Get_Attribute DF_NUMBER_DRIVERS to iDriverCount For iDriver from 1 to iDriverCount Get_Attribute DF_DRIVER_NAME of iDriver to sName If (sName <> "DATAFLEX") Begin Move sName to sDriversToUnload[iDriversToUnload] Increment iDriversToUnload End Loop Close DF_ALL Send UnRegisterAllConnections of ghoConnection For iDriver from 0 to (iDriversToUnload-1) Unload_Driver sDriversToUnload[iDriver] Loop End_Procedure Procedure End_Construct_Object // As we should have only one workspace handler object per application we can set // a global var to the Object ID for easy access. If (ghoWorkspaceHandlerEx=0) Begin // first one wins Move Self to ghoWorkSpaceHandlerEx End Forward Send End_Construct_Object End_Procedure // End_Construct_Object End_Class