//TH-Header //***************************************************************************************** // Copyright (c) 2014 KURANT Project // All rights reserved. // // $FileName : Workspace.SL // $ProjectName : The Hammer 2.0 // $Authors : Wil van Antwerpen, Michael Kurz, Sergey V. Natarov // $Created : 01.25.2014 01:08 // $Type : LGPL // // Contents: WorkSpace Selector // //***************************************************************************************** //TH-RevisionStart //TH-RevisionEnd // Project Object Structure // oWorkSpace is a cWorkspacePanel // oTextBox1 is a Textbox // oVDFVersion is a ComboForm // oDisplay_fm is a ComboForm // oWorkspaceList is a cWorkspaceList // oLineControl1 is a cLineControl // oInfo_bn is a Button // oBrowse_bn is a Button // oSelect_bn is a Button // oClose_bn is a Button // Register all objects Register_Object oBrowse_bn Register_Object oClose_bn Register_Object oDisplay_fm Register_Object oInfo_bn Register_Object oLineControl1 Register_Object oSelect_bn Register_Object oTextBox1 Register_Object oVDFVersion Register_Object oWorkSpace Register_Object oWorkspaceList Use cWorkSpacePanel.pkg Use WorkSpaceInfo.DG Use vWin32fh.pkg Use cWorkSpaceSortArray.pkg Use cWorkspaceList.pkg Use cLineControl.pkg Cd_Popup_Object oWorkSpace Is a cWorkspacePanel Set Label To "Select Workspace..." Set Location to 10 101 Set Size To 239 232 Set Border_Style To Border_Thick Object oTextBox1 Is a Textbox Set Label To "&Display:" Set Location To 6 4 Set Size To 10 43 Set Justification_Mode To jMode_Left // The label for the display combo has a bug in VDF7 during resizing (it goes to // position 0,0) This is our work around Procedure OnResize Integer cyx Delegate Get GUISize To cyx Set GUILocation To (Hi(GUILocation(Self))) (Low(cyx)-184) End_Procedure End_Object // oTextBox1 Object oVDFVersion Is a ComboForm Object oVDFVersionArray Is a cWorkSpaceSortArray Set pbCheckRuntimeInstalled To True End_Object // oVDFVersionArray Set Label To "VDF &Version:" Set Size To 13 50 Set Location To 4 53 Set Form_Border To 0 Set Label_Col_Offset To 2 Set Label_Justification_Mode To jMode_Right On_Key kCancel Send Close_Panel Set entry_state Item 0 To False Set combo_sort_state To False // **WvA: 28-10-2004 Display VDF10 below VDF9 // // Enumerate the registry keys to get a list of all the installed VDF revisions. Procedure Combo_Fill_List Integer hoArray Integer iLoop String sValue Move (oVdfVersionArray(Self)) To hoArray If (hoArray) Begin Send LoadArray Of hoArray If (Item_Count(hoArray)=0) Begin // There's a bug that sometimes the array doesn't get filled when calling it the first time.. calling it again // fixes this.. no logical explanation at all.. but it works. Send LoadArray Of hoArray End Move 0 To iLoop While (iLoop Self) Procedure_Return Get psVersion To sCrntVersion Get value To sVer Get piCurrentItem Of oWorkspaceList To iCurrent Get WorkSpaceTag Of ghoWorkspaceHandlerEx iCurrent To sSelectedTag // If ((sVer<>sCrntVersion) Or (gsWorkspaceName<>sSelectedTag)) Begin Set psVersion To sVer Send FillList To (oWorkspaceList(Self)) Get StringVdfVersionToNum Of ghoWorkspaceHandlerEx sVer To nVer If (nVer<120) Begin Set Enabled_State Of (oBrowse_bn(Self)) To False End Else Begin Set Enabled_State Of (oBrowse_bn(Self)) To True End // End Get Item_Count Of (oWorkspaceList(Self)) To iCount If (iCount>0) Begin If (Enabled_State(oInfo_bn(Self))=False) Begin Set Enabled_State Of (oInfo_bn(Self)) To True Set Enabled_State Of (oSelect_bn(Self)) To True End End Else Begin Set Enabled_State Of (oInfo_bn(Self)) To False Set Enabled_State Of (oSelect_bn(Self)) To False End End_Procedure Procedure Previous Send Activate To (oClose_bn(Self)) End_Procedure // Previous End_Object // oVDFVersion Object oDisplay_fm Is a ComboForm Set Size To 13 85 Set Location To 4 140 Set Form_Border To 0 Set Label_Justification_Mode To jMode_Right Set Combo_Sort_State To FALSE On_Key kCancel Send Close_Panel Set entry_state Item 0 To False Define CS_WSDISP_DESCRIPTION For "Description" Define CS_WSDISP_KEY For "Key" Define CS_WSDISP_BOTH For "Both" Procedure Combo_Fill_List // Fill the combo list with Send Combo_Add_Item Send Combo_Add_Item CS_WSDISP_DESCRIPTION Send Combo_Add_Item CS_WSDISP_KEY Send Combo_Add_Item CS_WSDISP_BOTH End_Procedure // Combo_fill_list // notification of a selection change or edit change Procedure OnChange String sValue Integer iOldDisplayMode iNewDisplayMode If (focus(Self) <> Self) Procedure_Return Get pcDisplayWSList To iOldDisplayMode Get Value To sValue // the current selected item Case Begin Case (sValue = CS_WSDISP_DESCRIPTION) Move ctWSDisplayDescription To iNewDisplayMode Case break Case (sValue = CS_WSDISP_KEY) Move ctWSDisplayKey To iNewDisplayMode Case break Case Else Move ctWSDisplayBoth To iNewDisplayMode Case End If (iOldDisplayMode <> iNewDisplayMode) Begin Set pcDisplayWSList To iNewDisplayMode Send FillList To (oWorkspaceList(Self)) End End_Procedure // OnChange Procedure Next Send activate To (oWorkspaceList(Self)) End_Procedure Procedure OnResize Integer cyx Delegate Get GUISize To cyx Set GUILocation To (Hi(GUILocation(Self))) (Low(cyx)-Low(GUISize(Self))-15) End_Procedure End_Object // oDisplay_fm Object oWorkspaceList Is a cWorkspaceList Set Size To 160 218 Set Location To 28 5 On_Key kCancel Send Close_Panel On_Key kEnter Send Enter Procedure Enter Send Select End_Procedure Procedure Mouse_Click Send Enter End_Procedure // **WvA 27-6-2003 Added Dynamic Update State logic Procedure FillList String sCur sVer Integer hKeyWrkSpc Number nVer Integer bExists Integer iWrk iWorkspaceCount iDisplayMode String sVDF sVDFRoot sWSName sWSPath sWStag sLine String sMessage Get psVersion To sVer Get pcDisplayWSList To iDisplayMode // Clear the list control Send Delete_Data Get CurrentWorkspace sVer To sCur Send DoSetLabel sCur Send DoEnumerateWorkspaces To ghoWorkspaceHandlerEx sVer Get WorkspaceCount Of ghoWorkspaceHandlerEx To iWorkspaceCount If iWorkSpaceCount Ge 0 Begin Set Dynamic_Update_State To False For iWrk From 0 To (iWorkSpaceCount - 1) Get WorkSpaceName Of ghoWorkspaceHandlerEx Item iWrk To sWSName Get WorkSpaceTag Of ghoWorkspaceHandlerEx Item iWrk To sWSTag Get WorkSpacePath Of ghoWorkspaceHandlerEx Item iWrk To sWSPath If (Trim(sWSTag) = sCur) Begin Set piCurrentItem To (Item_Count(Self)) End Case Begin Case (iDisplayMode = ctWSDisplayDescription) Send Add_Item MSG_None sWSName Case break Case (iDisplayMode = ctWSDisplayKey) Send Add_Item MSG_None sWSTag Case break Case Else Send Add_Item MSG_None (sWSName+" - [ "+sWSTag+" ]") Case End Loop Set Dynamic_Update_State To True End Set Current_Item To (piCurrentItem(Self)) End_Procedure // FillList Procedure OnResize Integer cyx lyx Delegate Get GUISize To cyx Set GUISize To (Hi(cyx)-110) (Low(cyx)-22) End_Procedure End_Object // oWorkspaceList Object oLineControl1 Is a cLineControl Set Size To 2 218 Set Location To 22 5 End_Object // oLineControl1 Object oInfo_bn Is a Button Set Label To "&Info..." Set Location To 194 5 On_Key kCancel Send Close_Panel Procedure OnClick Send Request_Info End_Procedure // OnClick //Set Object_Shadow_State To True Procedure OnResize Integer cyx lyx Integer iOffset Get piButtonBarOffset To iOffset Delegate Get GUISize To cyx Set GUILocation To (Hi(cyx)-Hi(GuiSize(Self))-iOffset) (Low(GUILocation(Self))) End_Procedure End_Object // oInfo_bn Object oBrowse_bn is a Button Set Label to "&Browse..." Set Location to 194 61 Procedure OnClick Send Request_Browse End_Procedure // OnClick Procedure OnResize Integer cyx lyx Integer iOffset Get piButtonBarOffset To iOffset Delegate Get GUISize To cyx Set GUILocation To (Hi(cyx)-Hi(GuiSize(Self))-iOffset) (Low(GUILocation(Self))) End_Procedure End_Object // oBrowse_bn Object oSelect_bn Is a Button Set Label To "&Select" Set Location To 194 117 Set Default_State To True On_Key kCancel Send Close_Panel Procedure OnClick Send Select End_Procedure // OnClick Procedure OnResize Integer cyx lyx Integer iOffset Get piButtonBarOffset To iOffset Delegate Get GUISize To cyx Set GUILocation To (Hi(cyx)-Hi(GuiSize(Self))-iOffset) (Low(cyx)-(Low(GUISize(Self))*2)-25) End_Procedure End_Object // oSelect_bn Object oClose_bn Is a Button Set Label To "&Close" Set Location To 194 173 On_Key kCancel Send Close_Panel Procedure OnClick Send Close_Panel End_Procedure // OnClick Procedure OnResize Integer cyx lyx Integer iOffset Get piButtonBarOffset To iOffset Delegate Get GUISize To cyx Set GUILocation To (Hi(cyx)-Hi(GuiSize(Self))-iOffset) (Low(cyx)-Low(GUISize(Self))-15) End_Procedure End_Object // oClose_bn On_Key KEY_ALT+KEY_V Send Activate To oVDFVersion On_Key Key_Alt+Key_D Send Activate To oDisplay_fm On_Key Key_Alt+Key_I Send Request_Info //Activate To oInfo_bn On_Key Key_Alt+Key_S Send Activate To oSelect_bn On_Key Key_Alt+Key_C Send Activate To oClose_bn Procedure mMinSize If (piMinSize(Self)=0) Set piMinSize To (Size(Self)) End_Procedure Send mMinSize Procedure DoSetLabel String sWrkSpcTag String sLabel If (sWrkSpcTag<>"") Begin Move sWrkSpcTag To sLabel If (Pos(".sws",Lowercase(sLabel))<>0) Begin Get DeriveDescriptionFromStudioFile Of ghoWorkspaceHandlerEx sLabel To sLabel End Move ("Select Workspace - ["+sLabel+"]") To sLabel End Else Move "Select Workspace..." To sLabel Set Label To sLabel End_Procedure // DoSetLabel Procedure Popup_Group String #ver Forward Send Popup_Group Get psVDFVersion Of ghoWorkSpaceHandlerEx To #ver Set value Of (oVDFVersion(Self)) To #ver Send Activate To (oWorkspaceList(Self)) // set value above already sends an onchange //Send onChange To (oVDFVersion(Self)) End_Procedure // // Returns the currently selected workspace tag and // sets the psCurrentWorkspace property // Function CurrentWorkspace String sVer Returns String String sCur Get fsCurrentWorkspace Of ghoWorkspaceHandlerEx sVer To sCur Set psCurrentWorkSpace To sCur Function_Return sCur End_Function // CurrentWorkspace // Selects the Workspace passed in sWrkSpcTag // // - Updates the Current Workspace tag in the registry with what we selected (sWrkSpcTag) // - Sets our global VDFVersion property // - Updates all the Currentxxxxxxx properties in the workspace handler // and changes the Open_Path // - Saves the Editor properties Procedure SelectCurrentWorkSpace String sWrkSpcTag String sKey sVer Get psVersion To sVer // Update the Current workspace TaG in the registry Send ChangeCurrentWorkspace Of ghoWorkSpaceHandlerEx sWrkSpcTag sVer Set psVDFVersion Of ghoWorkSpaceHandlerEx To sVer Send doLoadVDFVersionInfo To ghoWorkSpaceHandlerEx // Set the global VDF Version equal to our selection Set VDFVersion Of Desktop To sVer Send DoSetOpenPath to ghoWorkSpaceHandlerEx sWrkSpcTag Send LoadNonEmbeddedDriverAutoLoginPrompt of ghoWorkSpaceHandlerEx Send SaveIni to ghoEditorProperties // Save it here because the SmartDosBox needs the info. End_Procedure // SelectCurrentWorkSpace // Perform the actual selection Procedure Select Integer iChanged iOk Integer iCurrent String sWrkSpc sDir String sWSName sWSPath sVer Number nVer Get pnVersion To nVer Get psVersion To sVer Move (Current_Item(oWorkspaceList(Self))) To iCurrent Get WorkspaceTag Of ghoWorkSpaceHandlerEx Item iCurrent To sWrkSpc Get WorkspaceName Of ghoWorkSpaceHandlerEx Item iCurrent To sWSName Get WorkspacePath Of ghoWorkSpaceHandlerEx Item iCurrent To sWSPath Set psBufferWsTag Of ghoWorkSpaceHandlerEx To sWrkSpc // psversion == psbuffervdfversion //Set psBufferVdfVersion Of ghoWorkSpaceHandlerEx To sVer Set psBufferWsName Of ghoWorkSpaceHandlerEx To sWSName Set psBufferHome Of ghoWorkSpaceHandlerEx To sWSPath // Changed to support Reopen of Files based on Workspace // 18.05.01 Bernhard Get RequestChangeWorkspace Of desktop sWrkSpc To iChanged If iChanged Begin Send SelectCurrentWorkSpace sWrkSpc Get CurrentAppSrcPath Of ghoWorkSpaceHandlerEx To sDir Send SelectWorkingDirectory sDir // Added 17.05.01 Bernhard Send OnWorkSpaceChanged End Send Close_Panel End_Procedure // Select // Procedure WorkSpaceInfoCallBack Integer iObj String sVer sNewKey sWrkSpc sName sDir sPath sVal Integer iOk iCurrent String sWSName sWSPath Get psVersion To sVer Move (Current_Item(oWorkspaceList(Self))) To iCurrent Get WorkspaceTag Of ghoWorkSpaceHandlerEx Item iCurrent To sWrkSpc Get WorkspaceName Of ghoWorkSpaceHandlerEx Item iCurrent To sWSName Get WorkspacePath Of ghoWorkSpaceHandlerEx Item iCurrent To sWSPath Set psBufferWsTag Of ghoWorkSpaceHandlerEx To sWrkSpc // psversion == psbuffervdfversion //Set psBufferVdfVersion Of ghoWorkSpaceHandlerEx To sVer Set psBufferWsName Of ghoWorkSpaceHandlerEx To sWSName Set psBufferHome Of ghoWorkSpaceHandlerEx To sWSPath Get DoReadApplicationWorkspace Of ghoWorkSpaceHandlerEx sWrkSpc sVer sWSPath True To iOK If Not (iOk) Begin Error 350 "Failed to read the data for the Application's workspace" Procedure_Return End End_Procedure // WorkSpaceInfoCallBack // Popup the workspace info dialog Procedure Request_Info Send Popup To (oWorkSpaceInfo(Self)) End_Procedure Procedure Request_Browse String sFileTypes String sCaptionText String sInitFolder String sFile String sStudio String sVdfRootDir Boolean bExists Move "Select a workspace to register" To sCaptionText Move "Workspaces files|*.sws;*.ws|Studio Workspace files|*.sws|All files|*.*" To sFileTypes Get LastWorkspaceFolder Of ghoWorkSpaceHandlerEx To sInitFolder Get vSelect_File sFileTypes sCaptionText sInitFolder To sFile If (sFile<>"") Begin Get psVdfRootDir Of ghoWorkSpaceHandlerEx To sVdfRootDir Move (sVdfRootDir+"Bin\Studio.exe") To sStudio Get vFilePathExists sStudio To bExists If (bExists) Begin Runprogram Wait (sStudio+' -x"'+sFile+'"') // refresh list after exiting the studio Send FillList To (oWorkspaceList(Self)) End Else Begin Send Info_box "Unable to locate the Visual DataFlex Studio to register this workspace." End End End_Procedure // Request_Browse Procedure OnResize Integer old_rw# old_cl# new_rw# new_cl# min_rw# min_cl# iResize Forward Send OnResize // Get size To old_cl# Move (hi(old_cl#)) To old_rw# Move (low(old_cl#)) To old_cl# Send adjust_logicals Get size To new_cl# Move (hi(new_cl#)) To new_rw# Move (low(new_cl#)) To new_cl# // Get Minimum Size of the View... Move (hi(piMinSize(Self))) To min_rw# Move (low(piMinSize(Self))) To min_cl# If (min_rw#+min_cl#) Begin If (New_rw#