mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 10:19:12 +02:00
IDE: package editor: drop files
git-svn-id: trunk@45562 -
This commit is contained in:
parent
bbf6c0d283
commit
f80cce26fe
@ -864,7 +864,7 @@ function PkgFileTypeIdentToType(const s: string): TPkgFileType;
|
|||||||
function LazPackageTypeIdentToType(const s: string): TLazPackageType;
|
function LazPackageTypeIdentToType(const s: string): TLazPackageType;
|
||||||
function GetPkgFileTypeLocalizedName(FileType: TPkgFileType): string;
|
function GetPkgFileTypeLocalizedName(FileType: TPkgFileType): string;
|
||||||
function NameToAutoUpdatePolicy(const s: string): TPackageUpdatePolicy;
|
function NameToAutoUpdatePolicy(const s: string): TPackageUpdatePolicy;
|
||||||
function FileNameToPkgFileType(const AFilename: string): TPkgFileType;
|
function FileNameToPkgFileType(AFilename: string): TPkgFileType;
|
||||||
|
|
||||||
procedure SortDependencyListAlphabetically(Dependencies: TFPList);
|
procedure SortDependencyListAlphabetically(Dependencies: TFPList);
|
||||||
procedure LoadPkgDependencyList(XMLConfig: TXMLConfig; const ThePath: string;
|
procedure LoadPkgDependencyList(XMLConfig: TXMLConfig; const ThePath: string;
|
||||||
@ -965,19 +965,35 @@ begin
|
|||||||
Result:=pupAsNeeded;
|
Result:=pupAsNeeded;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function FileNameToPkgFileType(const AFilename: string): TPkgFileType;
|
function FileNameToPkgFileType(AFilename: string): TPkgFileType;
|
||||||
|
var
|
||||||
|
Code: TCodeBuffer;
|
||||||
|
SrcType: String;
|
||||||
|
HasName: Boolean;
|
||||||
begin
|
begin
|
||||||
if CompareFileExt(AFilename,'.lfm',true)=0 then
|
HasName:=ExtractFileNameOnly(AFilename)<>'';
|
||||||
Result:=pftLFM
|
if HasName then begin
|
||||||
else if CompareFileExt(AFilename,'.lrs',true)=0 then
|
if CompareFileExt(AFilename,'.lfm',true)=0 then
|
||||||
Result:=pftLRS
|
exit(pftLFM)
|
||||||
else if CompareFileExt(AFilename,'.inc',true)=0 then
|
else if CompareFileExt(AFilename,'.lrs',true)=0 then
|
||||||
Result:=pftInclude
|
exit(pftLRS)
|
||||||
else if FilenameIsPascalUnit(AFilename) then
|
else if CompareFileExt(AFilename,'.inc',true)=0 then
|
||||||
Result:=pftUnit
|
exit(pftInclude)
|
||||||
else if CompareFileExt(AFilename,'.xml',true)=0 then
|
else if CompareFileExt(AFilename,'.xml',true)=0 then
|
||||||
Result:=pftIssues
|
exit(pftIssues)
|
||||||
else if FileIsText(AFilename) then
|
else if FilenameIsPascalUnit(AFilename) then begin
|
||||||
|
Result:=pftUnit;
|
||||||
|
AFilename:=CleanAndExpandFilename(AFilename);
|
||||||
|
Code:=CodeToolBoss.LoadFile(aFilename,true,false);
|
||||||
|
if Code<>nil then begin
|
||||||
|
SrcType:=CodeToolBoss.GetSourceType(Code,false);
|
||||||
|
if CompareText(SrcType,'unit')<>0 then
|
||||||
|
Result:=pftInclude;
|
||||||
|
end;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if FileIsText(AFilename) then
|
||||||
Result:=pftText
|
Result:=pftText
|
||||||
else
|
else
|
||||||
Result:=pftBinary;
|
Result:=pftBinary;
|
||||||
|
@ -312,6 +312,8 @@ type
|
|||||||
AnIncludeFile: string; var IgnoreUnitPaths: TFilenameToStringTree);
|
AnIncludeFile: string; var IgnoreUnitPaths: TFilenameToStringTree);
|
||||||
procedure ExtendIncPathForNewIncludeFile(const AnIncludeFile: string;
|
procedure ExtendIncPathForNewIncludeFile(const AnIncludeFile: string;
|
||||||
var IgnoreIncPaths: TFilenameToStringTree);
|
var IgnoreIncPaths: TFilenameToStringTree);
|
||||||
|
function ExtendUnitSearchPath(NewUnitPaths: string): boolean;
|
||||||
|
function ExtendIncSearchPath(NewIncPaths: string): boolean;
|
||||||
function CanBeAddedToProject: boolean;
|
function CanBeAddedToProject: boolean;
|
||||||
function CheckDrag(Sender, Source: TObject; X, Y: Integer;
|
function CheckDrag(Sender, Source: TObject; X, Y: Integer;
|
||||||
out SrcPkgEdit: TPackageEditorForm;
|
out SrcPkgEdit: TPackageEditorForm;
|
||||||
@ -1358,9 +1360,63 @@ end;
|
|||||||
|
|
||||||
procedure TPackageEditorForm.FormDropFiles(Sender: TObject;
|
procedure TPackageEditorForm.FormDropFiles(Sender: TObject;
|
||||||
const FileNames: array of String);
|
const FileNames: array of String);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
NewFilename: String;
|
||||||
|
NewFileType: TPkgFileType;
|
||||||
|
NewUnitName: String;
|
||||||
|
HasRegister: Boolean;
|
||||||
|
NewFlags: TPkgFileFlags;
|
||||||
|
Code: TCodeBuffer;
|
||||||
|
NewUnitPaths: String;
|
||||||
|
CurDir: String;
|
||||||
|
NewIncPaths: String;
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF VerbosePkgEditDrag}
|
||||||
debugln(['TPackageEditorForm.FormDropFiles ',length(FileNames)]);
|
debugln(['TPackageEditorForm.FormDropFiles ',length(FileNames)]);
|
||||||
IntfGetDropFilesTarget;
|
{$ENDIF}
|
||||||
|
if length(FileNames)=0 then exit;
|
||||||
|
BeginUdate;
|
||||||
|
try
|
||||||
|
NewUnitPaths:='';
|
||||||
|
NewIncPaths:='';
|
||||||
|
for i:=0 to high(Filenames) do begin
|
||||||
|
NewFilename:=CleanAndExpandFilename(FileNames[i]);
|
||||||
|
if not FileExistsUTF8(NewFilename) then continue;
|
||||||
|
if DirPathExists(NewFilename) then continue;
|
||||||
|
if LazPackage.FindPkgFile(NewFilename,true,false)<>nil then continue;
|
||||||
|
NewFileType:=FileNameToPkgFileType(NewFilename);
|
||||||
|
NewFlags:=[];
|
||||||
|
HasRegister:=false;
|
||||||
|
NewUnitName:='';
|
||||||
|
if (NewFileType=pftUnit) then begin
|
||||||
|
Code:=CodeToolBoss.LoadFile(NewFilename,true,false);
|
||||||
|
NewUnitName:=CodeToolBoss.GetSourceName(Code,false);
|
||||||
|
if NewUnitName='' then
|
||||||
|
NewUnitName:=ExtractFileNameOnly(NewFilename);
|
||||||
|
if LazPackage.FindUsedUnit(NewUnitName)=nil then
|
||||||
|
Include(NewFlags,pffAddToPkgUsesSection);
|
||||||
|
CodeToolBoss.HasInterfaceRegisterProc(Code,HasRegister);
|
||||||
|
if HasRegister then
|
||||||
|
Include(NewFlags,pffHasRegisterProc);
|
||||||
|
end;
|
||||||
|
{$IFDEF VerbosePkgEditDrag}
|
||||||
|
debugln(['TPackageEditorForm.FormDropFiles Adding files: ',NewFilename,' Unit=',NewUnitName,' Type=',PkgFileTypeIdents[NewFileType],' use=',pffAddToPkgUsesSection in NewFlags,' hasregister=',pffHasRegisterProc in NewFlags]);
|
||||||
|
{$ENDIF}
|
||||||
|
LazPackage.AddFile(NewFilename,NewUnitName,NewFileType,NewFlags,cpNormal);
|
||||||
|
CurDir:=ChompPathDelim(ExtractFilePath(NewFilename));
|
||||||
|
if NewFileType=pftUnit then
|
||||||
|
NewUnitPaths:=MergeSearchPaths(NewUnitPaths,CurDir)
|
||||||
|
else
|
||||||
|
NewIncPaths:=MergeSearchPaths(NewIncPaths,CurDir);
|
||||||
|
UpdateAll(false);
|
||||||
|
end;
|
||||||
|
// extend unit and include search path
|
||||||
|
if not ExtendUnitSearchPath(NewUnitPaths) then exit;
|
||||||
|
if not ExtendIncSearchPath(NewIncPaths) then exit;
|
||||||
|
finally
|
||||||
|
EndUpdate;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPackageEditorForm.RevertClick(Sender: TObject);
|
procedure TPackageEditorForm.RevertClick(Sender: TObject);
|
||||||
@ -2850,6 +2906,49 @@ begin
|
|||||||
IncludePath:=MergeSearchPaths(IncludePath,ShortDirectory);
|
IncludePath:=MergeSearchPaths(IncludePath,ShortDirectory);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPackageEditorForm.ExtendUnitSearchPath(NewUnitPaths: string): boolean;
|
||||||
|
var
|
||||||
|
CurUnitPaths: String;
|
||||||
|
r: TModalResult;
|
||||||
|
begin
|
||||||
|
CurUnitPaths:=LazPackage.CompilerOptions.ParsedOpts.GetParsedValue(pcosUnitPath);
|
||||||
|
NewUnitPaths:=RemoveSearchPaths(NewUnitPaths,CurUnitPaths);
|
||||||
|
if NewUnitPaths<>'' then begin
|
||||||
|
NewUnitPaths:=CreateRelativeSearchPath(NewUnitPaths,LazPackage.Directory);
|
||||||
|
r:=IDEMessageDialog('Extend Unit Path?',
|
||||||
|
'Extend unit search path of package "'+LazPackage.Name+'" with'
|
||||||
|
+'"'+NewUnitPaths+'"?',mtConfirmation,[mbYes,mbNo,mbCancel]);
|
||||||
|
case r of
|
||||||
|
mrYes: LazPackage.CompilerOptions.OtherUnitFiles:=
|
||||||
|
MergeSearchPaths(LazPackage.CompilerOptions.OtherUnitFiles,NewUnitPaths);
|
||||||
|
mrNo: ;
|
||||||
|
else exit(false);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TPackageEditorForm.ExtendIncSearchPath(NewIncPaths: string): boolean;
|
||||||
|
var
|
||||||
|
CurIncPaths: String;
|
||||||
|
r: TModalResult;
|
||||||
|
begin
|
||||||
|
CurIncPaths:=LazPackage.CompilerOptions.ParsedOpts.GetParsedValue(pcosIncludePath);
|
||||||
|
NewIncPaths:=RemoveSearchPaths(NewIncPaths,CurIncPaths);
|
||||||
|
if NewIncPaths<>'' then begin
|
||||||
|
NewIncPaths:=CreateRelativeSearchPath(NewIncPaths,LazPackage.Directory);
|
||||||
|
r:=IDEMessageDialog('Extend Include Path?',
|
||||||
|
'Extend include file search path of package "'+LazPackage.Name+'" with'
|
||||||
|
+'"'+NewIncPaths+'"?',mtConfirmation,[mbYes,mbNo,mbCancel]);
|
||||||
|
case r of
|
||||||
|
mrYes: LazPackage.CompilerOptions.IncludePath:=
|
||||||
|
MergeSearchPaths(LazPackage.CompilerOptions.IncludePath,NewIncPaths);
|
||||||
|
mrNo: ;
|
||||||
|
else exit(false);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TPackageEditorForm.CanBeAddedToProject: boolean;
|
function TPackageEditorForm.CanBeAddedToProject: boolean;
|
||||||
begin
|
begin
|
||||||
if LazPackage=nil then exit(false);
|
if LazPackage=nil then exit(false);
|
||||||
@ -3415,11 +3514,8 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
PkgFile: TPkgFile;
|
PkgFile: TPkgFile;
|
||||||
NewDir: String;
|
NewDir: String;
|
||||||
CurUnitPaths: String;
|
|
||||||
CurIncPaths: String;
|
|
||||||
NewUnitPaths: String;
|
NewUnitPaths: String;
|
||||||
NewIncPaths: String;
|
NewIncPaths: String;
|
||||||
r: TModalResult;
|
|
||||||
OldFilename: String;
|
OldFilename: String;
|
||||||
begin
|
begin
|
||||||
NewUnitPaths:='';
|
NewUnitPaths:='';
|
||||||
@ -3436,35 +3532,9 @@ var
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
// unit paths
|
// unit paths
|
||||||
CurUnitPaths:=LazPackage.CompilerOptions.ParsedOpts.GetParsedValue(pcosUnitPath);
|
if not ExtendUnitSearchPath(NewUnitPaths) then exit(false);
|
||||||
NewUnitPaths:=RemoveSearchPaths(NewUnitPaths,CurUnitPaths);
|
|
||||||
if NewUnitPaths<>'' then begin
|
|
||||||
NewUnitPaths:=CreateRelativeSearchPath(NewUnitPaths,LazPackage.Directory);
|
|
||||||
r:=IDEMessageDialog('Extend Unit Path?',
|
|
||||||
'Extend unit search path of package "'+LazPackage.Name+'" with'
|
|
||||||
+'"'+NewUnitPaths+'"?',mtConfirmation,[mbYes,mbNo,mbCancel]);
|
|
||||||
case r of
|
|
||||||
mrYes: LazPackage.CompilerOptions.OtherUnitFiles:=
|
|
||||||
MergeSearchPaths(LazPackage.CompilerOptions.OtherUnitFiles,NewUnitPaths);
|
|
||||||
mrNo: ;
|
|
||||||
else exit(false);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
// include paths
|
// include paths
|
||||||
CurIncPaths:=LazPackage.CompilerOptions.ParsedOpts.GetParsedValue(pcosIncludePath);
|
if not ExtendIncSearchPath(NewIncPaths) then exit(false);
|
||||||
NewIncPaths:=RemoveSearchPaths(NewIncPaths,CurIncPaths);
|
|
||||||
if NewIncPaths<>'' then begin
|
|
||||||
NewIncPaths:=CreateRelativeSearchPath(NewIncPaths,LazPackage.Directory);
|
|
||||||
r:=IDEMessageDialog('Extend Include Path?',
|
|
||||||
'Extend include file search path of package "'+LazPackage.Name+'" with'
|
|
||||||
+'"'+NewIncPaths+'"?',mtConfirmation,[mbYes,mbNo,mbCancel]);
|
|
||||||
case r of
|
|
||||||
mrYes: LazPackage.CompilerOptions.IncludePath:=
|
|
||||||
MergeSearchPaths(LazPackage.CompilerOptions.IncludePath,NewUnitPaths);
|
|
||||||
mrNo: ;
|
|
||||||
else exit(false);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user