From: Erik B. <eb...@us...> - 2006-09-01 20:59:01
|
Update of /cvsroot/gexperts/gexperts/unstable/Src/Utils In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv29512/Src/Utils Modified Files: GX_OtaUtils.pas Log Message: function GxOtaGetProjectPersonality(Project: IOTAProject): string; function GxOtaProjectIsDotNet(Project: IOTAProject): Boolean; function GxOtaProjectIsDelphiDotNet(Project: IOTAProject): Boolean; function GxOtaProjectIsNativeCpp(Project: IOTAProject): Boolean; function GxOtaProjectIsNativeDelphi(Project: IOTAProject): Boolean; function GxOtaProjectIsEitherDelphi(Project: IOTAProject): Boolean; function GxOtaProjectIsCSharp(Project: IOTAProject): Boolean; function GxOtaGetProjectFileName(Project: IOTAProject; NormalizeBdsProj: Boolean = False): string; Index: GX_OtaUtils.pas =================================================================== RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Utils/GX_OtaUtils.pas,v retrieving revision 1.193 retrieving revision 1.194 diff -u -d -r1.193 -r1.194 --- GX_OtaUtils.pas 28 Jul 2006 02:52:56 -0000 1.193 +++ GX_OtaUtils.pas 1 Sep 2006 20:58:56 -0000 1.194 @@ -248,15 +248,23 @@ function GxOtaActiveDesignerIsCLX: Boolean; function GxOtaActiveDesignerIsNFM: Boolean; -// Get the personality identifier string for the current project, or blank for none +// Get the personality identifier string for the project, or blank for none +function GxOtaGetProjectPersonality(Project: IOTAProject): string; function GxOtaGetCurrentProjectPersonality: string; -// See if the current project is a .NET project -function GxOtaCurrentProjectIsDotNet: Boolean; +// See if a project is of a specific personality +function GxOtaProjectIsDotNet(Project: IOTAProject): Boolean; +function GxOtaProjectIsDelphiDotNet(Project: IOTAProject): Boolean; +function GxOtaProjectIsNativeCpp(Project: IOTAProject): Boolean; +function GxOtaProjectIsNativeDelphi(Project: IOTAProject): Boolean; +function GxOtaProjectIsEitherDelphi(Project: IOTAProject): Boolean; +function GxOtaProjectIsCSharp(Project: IOTAProject): Boolean; // See if the current project is of a specific personality +function GxOtaCurrentProjectIsDotNet: Boolean; function GxOtaCurrentProjectIsDelphiDotNet: Boolean; function GxOtaCurrentProjectIsNativeCpp: Boolean; function GxOtaCurrentProjectIsNativeDelphi: Boolean; +function GxOtaCurrentProjectIsEitherDelphi: Boolean; function GxOtaCurrentProjectIsCSharp: Boolean; // Check if the IDE supports a certain personality @@ -281,9 +289,11 @@ // See if there is an active project function GxOtaHaveCurrentProject: Boolean; -// Returns file name of currently active project; returns +// Returns file name of the project; returns // an empty string if there is no (active) project. -function GxOtaGetCurrentProjectFileName: string; +// Use NormalizeBdsProj to get the dpr instead of the bdsproj for Delphi projects +function GxOtaGetProjectFileName(Project: IOTAProject; NormalizeBdsProj: Boolean = False): string; +function GxOtaGetCurrentProjectFileName(NormalizeBdsProj: Boolean = False): string; // Returns the name of the currently active project; returns // an empty string if there is no (active) project. @@ -871,15 +881,12 @@ Result := (GxOtaGetActiveDesignerType = dNFM); end; -function GxOtaGetCurrentProjectPersonality: string; -var - Project: IOTAProject; +function GxOtaGetProjectPersonality(Project: IOTAProject): string; begin Result := ''; - Project := GxOtaGetCurrentProject; if Assigned(Project) then begin - {$IFDEF GX_VER160_up} //Delphi 8+ + {$IFDEF GX_VER160_up} //Delphi 8+ Result := Project.Personality; {$ELSE} // Delphi 7 or earlier if RunningCPPBuilder then @@ -890,29 +897,69 @@ end; end; +function GxOtaGetCurrentProjectPersonality: string; +begin + Result := GxOtaGetProjectPersonality(GxOtaGetCurrentProject); +end; + +function GxOtaProjectIsDotNet(Project: IOTAProject): Boolean; +begin + Result := StringInArray(GxOtaGetProjectPersonality(Project), [sDelphiDotNetPersonality, sCSharpPersonality, sVBPersonality]); +end; + +function GxOtaProjectIsDelphiDotNet(Project: IOTAProject): Boolean; +begin + Result := SameText(GxOtaGetProjectPersonality(Project), sDelphiDotNetPersonality); +end; + +function GxOtaProjectIsNativeCpp(Project: IOTAProject): Boolean; +begin + Result := SameText(GxOtaGetProjectPersonality(Project), sCBuilderPersonality); +end; + +function GxOtaProjectIsNativeDelphi(Project: IOTAProject): Boolean; +begin + Result := SameText(GxOtaGetProjectPersonality(Project), sDelphiPersonality); +end; + +function GxOtaProjectIsEitherDelphi(Project: IOTAProject): Boolean; +begin + Result := StringInArray(GxOtaGetProjectPersonality(Project), [sDelphiPersonality, sDelphiDotNetPersonality]); +end; + +function GxOtaProjectIsCSharp(Project: IOTAProject): Boolean; +begin + Result := SameText(GxOtaGetProjectPersonality(Project), sCSharpPersonality); +end; + function GxOtaCurrentProjectIsDotNet: Boolean; begin - Result := StringInArray(GxOtaGetCurrentProjectPersonality, [sDelphiDotNetPersonality, sCSharpPersonality, sVBPersonality]); + Result := GxOtaProjectIsDotNet(GxOtaGetCurrentProject); end; function GxOtaCurrentProjectIsDelphiDotNet: Boolean; begin - Result := SameText(GxOtaGetCurrentProjectPersonality, sDelphiDotNetPersonality); + Result := GxOtaProjectIsDelphiDotNet(GxOtaGetCurrentProject); end; function GxOtaCurrentProjectIsNativeCpp: Boolean; begin - Result := SameText(GxOtaGetCurrentProjectPersonality, sCBuilderPersonality); + Result := GxOtaProjectIsNativeCpp(GxOtaGetCurrentProject); end; function GxOtaCurrentProjectIsNativeDelphi: Boolean; begin - Result := SameText(GxOtaGetCurrentProjectPersonality, sDelphiPersonality); + Result := GxOtaProjectIsNativeDelphi(GxOtaGetCurrentProject); +end; + +function GxOtaCurrentProjectIsEitherDelphi: Boolean; +begin + Result := GxOtaProjectIsEitherDelphi(GxOtaGetCurrentProject); end; function GxOtaCurrentProjectIsCSharp: Boolean; begin - Result := SameText(GxOtaGetCurrentProjectPersonality, sCSharpPersonality); + Result := GxOtaProjectIsCSharp(GxOtaGetCurrentProject); end; {$IFDEF GX_VER160_up} @@ -986,15 +1033,21 @@ Result := IsIdeEditorForm(Screen.ActiveCustomForm) or IsEditControl(Screen.ActiveControl); end; -function GxOtaGetCurrentProjectFileName: string; -var - CurrentProject: IOTAProject; +function GxOtaGetProjectFileName(Project: IOTAProject; NormalizeBdsProj: Boolean = False): string; begin - CurrentProject := GxOtaGetCurrentProject; - if Assigned(CurrentProject) then - Result := CurrentProject.FileName - else - Result := ''; + Result := ''; + if Assigned(Project) then begin + Result := Project.FileName; + if NormalizeBdsProj and IsBdsproj(Result) then begin + if GxOtaProjectIsEitherDelphi(Project) then + Result := ChangeFileExt(Result, '.dpr'); + end; + end; +end; + +function GxOtaGetCurrentProjectFileName(NormalizeBdsProj: Boolean): string; +begin + Result := GxOtaGetProjectFileName(GxOtaGetCurrentProject, NormalizeBdsProj); end; function GxOtaGetProjectGroup: IOTAProjectGroup; |