mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 10:40:43 +02:00
IDE: add form to package: add dependency LCL
git-svn-id: trunk@35025 -
This commit is contained in:
parent
cf7d30b101
commit
139a3f1c56
78
ide/main.pp
78
ide/main.pp
@ -8635,6 +8635,9 @@ var
|
|||||||
SrcNoteBook: TSourceNotebook;
|
SrcNoteBook: TSourceNotebook;
|
||||||
AShareEditor: TSourceEditor;
|
AShareEditor: TSourceEditor;
|
||||||
DisableAutoSize: Boolean;
|
DisableAutoSize: Boolean;
|
||||||
|
APackage: TLazPackage;
|
||||||
|
IsPartOfProject: Boolean;
|
||||||
|
RequiredPackages: String;
|
||||||
begin
|
begin
|
||||||
//debugln('TMainIDE.DoNewEditorFile A NewFilename=',NewFilename);
|
//debugln('TMainIDE.DoNewEditorFile A NewFilename=',NewFilename);
|
||||||
// empty NewFilename is ok, it will be auto generated
|
// empty NewFilename is ok, it will be auto generated
|
||||||
@ -8660,24 +8663,63 @@ begin
|
|||||||
AProject:=TProject(NewOwner)
|
AProject:=TProject(NewOwner)
|
||||||
else
|
else
|
||||||
AProject:=Project1;
|
AProject:=Project1;
|
||||||
|
if NewOwner is TLazPackage then
|
||||||
|
APackage:=TLazPackage(NewOwner)
|
||||||
|
else
|
||||||
|
APackage:=nil;
|
||||||
|
|
||||||
// check if the new file fits into the project
|
OldUnitIndex:=AProject.IndexOfFilename(NewFilename);
|
||||||
|
if OldUnitIndex>=0 then begin
|
||||||
|
// the file is not really new
|
||||||
|
// => close form
|
||||||
|
Result:=CloseUnitComponent(AProject.Units[OldUnitIndex],
|
||||||
|
[cfCloseDependencies,cfSaveDependencies]);
|
||||||
|
if Result<>mrOk then exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
IsPartOfProject:=(nfIsPartOfProject in NewFlags)
|
||||||
|
or (NewOwner is TProject)
|
||||||
|
or (AProject.FileIsInProjectDir(NewFilename)
|
||||||
|
and (not (nfIsNotPartOfProject in NewFlags)));
|
||||||
|
|
||||||
|
// add required packages
|
||||||
|
//debugln(['TMainIDE.DoNewFile NewFileDescriptor.RequiredPackages="',NewFileDescriptor.RequiredPackages,'" ',DbgSName(NewFileDescriptor)]);
|
||||||
|
RequiredPackages:=NewFileDescriptor.RequiredPackages;
|
||||||
|
if (RequiredPackages='') and (NewFileDescriptor.ResourceClass<>nil) then
|
||||||
|
begin
|
||||||
|
if (NewFileDescriptor.ResourceClass.InheritsFrom(TForm))
|
||||||
|
or (NewFileDescriptor.ResourceClass.InheritsFrom(TFrame)) then
|
||||||
|
RequiredPackages:='LCL';
|
||||||
|
end;
|
||||||
|
if RequiredPackages<>'' then
|
||||||
|
begin
|
||||||
|
if IsPartOfProject then begin
|
||||||
|
if PkgBoss.AddProjectDependencies(Project1,RequiredPackages)<>mrOk then exit;
|
||||||
|
end;
|
||||||
|
if APackage<>nil then
|
||||||
|
begin
|
||||||
|
if PkgBoss.AddPackageDependency(APackage,RequiredPackages)<>mrOk then exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// check if the new file fits
|
||||||
Result:=NewFileDescriptor.CheckOwner(nfQuiet in NewFlags);
|
Result:=NewFileDescriptor.CheckOwner(nfQuiet in NewFlags);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
|
|
||||||
// create new codebuffer and apply naming conventions
|
// create new codebuffer and apply naming conventions
|
||||||
|
NewBuffer:=nil;
|
||||||
|
NewUnitName:='';
|
||||||
Result:=CreateNewCodeBuffer(NewFileDescriptor,NewOwner,NewFilename,NewBuffer,
|
Result:=CreateNewCodeBuffer(NewFileDescriptor,NewOwner,NewFilename,NewBuffer,
|
||||||
NewUnitName);
|
NewUnitName);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
|
|
||||||
NewFilename:=NewBuffer.Filename;
|
NewFilename:=NewBuffer.Filename;
|
||||||
|
|
||||||
OldUnitIndex:=AProject.IndexOfFilename(NewFilename);
|
OldUnitIndex:=AProject.IndexOfFilename(NewFilename);
|
||||||
if OldUnitIndex>=0 then begin
|
if OldUnitIndex>=0 then begin
|
||||||
// the file is not really new
|
// the file is not really new
|
||||||
NewUnitInfo:=AProject.Units[OldUnitIndex];
|
NewUnitInfo:=AProject.Units[OldUnitIndex];
|
||||||
// close form
|
// => close form
|
||||||
Result:=CloseUnitComponent(NewUnitInfo,
|
Result:=CloseUnitComponent(NewUnitInfo,[cfCloseDependencies,cfSaveDependencies]);
|
||||||
[cfCloseDependencies,cfSaveDependencies]);
|
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
// assign source
|
// assign source
|
||||||
NewUnitInfo.Source:=NewBuffer;
|
NewUnitInfo.Source:=NewBuffer;
|
||||||
@ -8706,31 +8748,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// add to project
|
// add to project
|
||||||
with NewUnitInfo do begin
|
NewUnitInfo.Loaded:=true;
|
||||||
Loaded:=true;
|
NewUnitInfo.IsPartOfProject:=IsPartOfProject;
|
||||||
IsPartOfProject:=(nfIsPartOfProject in NewFlags)
|
|
||||||
or (NewOwner is TProject)
|
|
||||||
or (AProject.FileIsInProjectDir(NewFilename)
|
|
||||||
and (not (nfIsNotPartOfProject in NewFlags)));
|
|
||||||
end;
|
|
||||||
if OldUnitIndex<0 then begin
|
if OldUnitIndex<0 then begin
|
||||||
Project1.AddFile(NewUnitInfo,
|
AProject.AddFile(NewUnitInfo,
|
||||||
NewFileDescriptor.AddToProject
|
NewFileDescriptor.AddToProject
|
||||||
and NewFileDescriptor.IsPascalUnit
|
and NewFileDescriptor.IsPascalUnit
|
||||||
and NewUnitInfo.IsPartOfProject
|
and NewUnitInfo.IsPartOfProject
|
||||||
and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags));
|
and (pfMainUnitHasUsesSectionForAllUnits in AProject.Flags));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// syntax highlighter type
|
// syntax highlighter type
|
||||||
NewUnitInfo.DefaultSyntaxHighlighter := FilenameToLazSyntaxHighlighter(NewFilename);
|
NewUnitInfo.DefaultSyntaxHighlighter := FilenameToLazSyntaxHighlighter(NewFilename);
|
||||||
|
|
||||||
// required packages
|
|
||||||
if NewUnitInfo.IsPartOfProject and (NewFileDescriptor.RequiredPackages<>'')
|
|
||||||
then begin
|
|
||||||
if PkgBoss.AddProjectDependencies(Project1,NewFileDescriptor.RequiredPackages
|
|
||||||
)<>mrOk then exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if nfOpenInEditor in NewFlags then begin
|
if nfOpenInEditor in NewFlags then begin
|
||||||
// open a new sourceeditor
|
// open a new sourceeditor
|
||||||
SrcNoteBook := SourceEditorManager.ActiveOrNewSourceWindow;
|
SrcNoteBook := SourceEditorManager.ActiveOrNewSourceWindow;
|
||||||
@ -8770,10 +8800,10 @@ begin
|
|||||||
if (NewUnitInfo.Component<>nil)
|
if (NewUnitInfo.Component<>nil)
|
||||||
and NewFileDescriptor.UseCreateFormStatements
|
and NewFileDescriptor.UseCreateFormStatements
|
||||||
and NewUnitInfo.IsPartOfProject
|
and NewUnitInfo.IsPartOfProject
|
||||||
and Project1.AutoCreateForms
|
and AProject.AutoCreateForms
|
||||||
and (pfMainUnitHasCreateFormStatements in Project1.Flags) then
|
and (pfMainUnitHasCreateFormStatements in AProject.Flags) then
|
||||||
begin
|
begin
|
||||||
Project1.AddCreateFormToProjectFile(NewUnitInfo.Component.ClassName,
|
AProject.AddCreateFormToProjectFile(NewUnitInfo.Component.ClassName,
|
||||||
NewUnitInfo.Component.Name);
|
NewUnitInfo.Component.Name);
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
|
@ -425,6 +425,7 @@ begin
|
|||||||
Name:=FileDescNameLCLForm;
|
Name:=FileDescNameLCLForm;
|
||||||
ResourceClass:=TForm;
|
ResourceClass:=TForm;
|
||||||
UseCreateFormStatements:=true;
|
UseCreateFormStatements:=true;
|
||||||
|
RequiredPackages:='LCL';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFileDescPascalUnitWithForm.GetInterfaceUsesSection: string;
|
function TFileDescPascalUnitWithForm.GetInterfaceUsesSection: string;
|
||||||
@ -535,6 +536,7 @@ begin
|
|||||||
ResourceClass := TFrame;
|
ResourceClass := TFrame;
|
||||||
UseCreateFormStatements := False;
|
UseCreateFormStatements := False;
|
||||||
DeclareClassVariable := False;
|
DeclareClassVariable := False;
|
||||||
|
RequiredPackages:='LCL';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFileDescPascalUnitWithFrame.GetInterfaceUsesSection: string;
|
function TFileDescPascalUnitWithFrame.GetInterfaceUsesSection: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user