mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 01:26:31 +02:00
IDE: When adding the path of a new file to project search path, ask which build modes to add it to. Issue #23714.
git-svn-id: trunk@43592 -
This commit is contained in:
parent
3c1bd6b897
commit
dcc0a1c2d1
@ -1,19 +1,19 @@
|
|||||||
object GenericCheckListForm: TGenericCheckListForm
|
object GenericCheckListForm: TGenericCheckListForm
|
||||||
Left = 452
|
Left = 389
|
||||||
Height = 301
|
Height = 277
|
||||||
Top = 526
|
Top = 544
|
||||||
Width = 343
|
Width = 343
|
||||||
ActiveControl = CheckListBox1
|
ActiveControl = CheckListBox1
|
||||||
Caption = 'GenericCheckListForm'
|
Caption = 'GenericCheckListForm'
|
||||||
ClientHeight = 301
|
ClientHeight = 277
|
||||||
ClientWidth = 343
|
ClientWidth = 343
|
||||||
OnShow = FormShow
|
OnShow = FormShow
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
LCLVersion = '1.1'
|
LCLVersion = '1.3'
|
||||||
object ButtonPanel1: TButtonPanel
|
object ButtonPanel1: TButtonPanel
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 33
|
Height = 33
|
||||||
Top = 262
|
Top = 238
|
||||||
Width = 331
|
Width = 331
|
||||||
OKButton.Name = 'OKButton'
|
OKButton.Name = 'OKButton'
|
||||||
OKButton.DefaultCaption = True
|
OKButton.DefaultCaption = True
|
||||||
@ -30,13 +30,25 @@ object GenericCheckListForm: TGenericCheckListForm
|
|||||||
ShowBevel = False
|
ShowBevel = False
|
||||||
end
|
end
|
||||||
object CheckListBox1: TCheckListBox
|
object CheckListBox1: TCheckListBox
|
||||||
|
AnchorSideTop.Control = InfoLabel
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 256
|
Height = 216
|
||||||
Top = 0
|
Top = 15
|
||||||
Width = 343
|
Width = 343
|
||||||
Align = alClient
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
OnItemClick = CheckListBox1ItemClick
|
OnItemClick = CheckListBox1ItemClick
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
|
object InfoLabel: TLabel
|
||||||
|
Left = 0
|
||||||
|
Height = 15
|
||||||
|
Top = 0
|
||||||
|
Width = 343
|
||||||
|
Align = alTop
|
||||||
|
Caption = 'InfoLabel'
|
||||||
|
ParentColor = False
|
||||||
|
WordWrap = True
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,7 +6,8 @@ unit GenericCheckList;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ButtonPanel, CheckLst, Buttons;
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ButtonPanel,
|
||||||
|
CheckLst, Buttons, StdCtrls;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -15,12 +16,14 @@ type
|
|||||||
TGenericCheckListForm = class(TForm)
|
TGenericCheckListForm = class(TForm)
|
||||||
ButtonPanel1: TButtonPanel;
|
ButtonPanel1: TButtonPanel;
|
||||||
CheckListBox1: TCheckListBox;
|
CheckListBox1: TCheckListBox;
|
||||||
|
InfoLabel: TLabel;
|
||||||
procedure CheckListBox1ItemClick(Sender: TObject; {%H-}Index: integer);
|
procedure CheckListBox1ItemClick(Sender: TObject; {%H-}Index: integer);
|
||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
private
|
private
|
||||||
fActionBtn: TBitBtn;
|
fActionBtn: TBitBtn;
|
||||||
procedure UpdateButtons;
|
procedure UpdateButtons;
|
||||||
public
|
public
|
||||||
|
constructor Create(TheOwner: TComponent); override;
|
||||||
constructor CreateWithActionButton(aCaption: TCaption; aResourceGlyphName: string = '');
|
constructor CreateWithActionButton(aCaption: TCaption; aResourceGlyphName: string = '');
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
end;
|
end;
|
||||||
@ -34,10 +37,16 @@ implementation
|
|||||||
|
|
||||||
{ TGenericCheckListForm }
|
{ TGenericCheckListForm }
|
||||||
|
|
||||||
|
constructor TGenericCheckListForm.Create(TheOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(TheOwner);
|
||||||
|
InfoLabel.Caption := '';
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TGenericCheckListForm.CreateWithActionButton(aCaption: TCaption;
|
constructor TGenericCheckListForm.CreateWithActionButton(aCaption: TCaption;
|
||||||
aResourceGlyphName: string);
|
aResourceGlyphName: string);
|
||||||
begin
|
begin
|
||||||
inherited Create(Nil);
|
Create(Nil);
|
||||||
fActionBtn := TBitBtn.Create(ButtonPanel1);
|
fActionBtn := TBitBtn.Create(ButtonPanel1);
|
||||||
fActionBtn.Caption := aCaption;
|
fActionBtn.Caption := aCaption;
|
||||||
fActionBtn.ModalResult := mrYes; // ActionButton will return mrYes.
|
fActionBtn.ModalResult := mrYes; // ActionButton will return mrYes.
|
||||||
|
@ -702,9 +702,10 @@ resourcestring
|
|||||||
+'to project, because there is already a unit with the same name in the Project.';
|
+'to project, because there is already a unit with the same name in the Project.';
|
||||||
lisAddToProject = 'Add %s to project?';
|
lisAddToProject = 'Add %s to project?';
|
||||||
lisTheFile = 'The file %s%s%s';
|
lisTheFile = 'The file %s%s%s';
|
||||||
lisAddToUnitSearchPath = 'Add to unit search path?';
|
lisTheNewIncludeFileIsNotYetInTheIncludeSearchPathAdd =
|
||||||
lisTheNewUnitIsNotYetInTheUnitSearchPathAddDirectory = 'The new unit is not '
|
'The new include file is not yet in the include search path.%sAdd directory %s to build modes?';
|
||||||
+'yet in the unit search path.%sAdd directory %s?';
|
lisTheNewUnitIsNotYetInTheUnitSearchPathAddDirectory =
|
||||||
|
'The new unit is not yet in the unit search path.%sAdd directory %s to build modes?';
|
||||||
lisisAlreadyPartOfTheProject = '%s is already part of the Project.';
|
lisisAlreadyPartOfTheProject = '%s is already part of the Project.';
|
||||||
lisRemoveFromProject = 'Remove from Project';
|
lisRemoveFromProject = 'Remove from Project';
|
||||||
lisCreateAProjectFirst = 'Create a project first!';
|
lisCreateAProjectFirst = 'Create a project first!';
|
||||||
@ -3844,8 +3845,7 @@ resourcestring
|
|||||||
+'dependency from the installation list of packages?';
|
+'dependency from the installation list of packages?';
|
||||||
lisERRORInvalidBuildMode = 'ERROR: invalid build mode "%s"';
|
lisERRORInvalidBuildMode = 'ERROR: invalid build mode "%s"';
|
||||||
lisAvailableProjectBuildModes = 'Available project build modes:';
|
lisAvailableProjectBuildModes = 'Available project build modes:';
|
||||||
lisThisProjectHasOnlyTheDefaultBuildMode = 'This project has only the '
|
lisThisProjectHasOnlyTheDefaultBuildMode = 'This project has only the default build mode.';
|
||||||
+'default build mode.';
|
|
||||||
lisPkgMangstaticPackagesConfigFile = 'static packages config file';
|
lisPkgMangstaticPackagesConfigFile = 'static packages config file';
|
||||||
lisPkgMangUnableToCreateTargetDirectoryForLazarus = 'Unable to create '
|
lisPkgMangUnableToCreateTargetDirectoryForLazarus = 'Unable to create '
|
||||||
+'target directory for Lazarus:%s%s%s%s.%sThis directory is needed for '
|
+'target directory for Lazarus:%s%s%s%s.%sThis directory is needed for '
|
||||||
@ -5066,9 +5066,6 @@ resourcestring
|
|||||||
lisAddPackageToProject2 = 'Add package to project';
|
lisAddPackageToProject2 = 'Add package to project';
|
||||||
lisAddUnitNotRecommended = 'Add unit (not recommended)';
|
lisAddUnitNotRecommended = 'Add unit (not recommended)';
|
||||||
lisAddPackageToProject = 'Add package %s to project?';
|
lisAddPackageToProject = 'Add package %s to project?';
|
||||||
lisAddToIncludeSearchPath = 'Add to include search path?';
|
|
||||||
lisTheNewIncludeFileIsNotYetInTheIncludeSearchPathAdd = 'The new include '
|
|
||||||
+'file is not yet in the include search path.%sAdd directory %s?';
|
|
||||||
lisOnBreakLineIEReturnOrEnterKey = 'On break line (i.e. return or enter key)';
|
lisOnBreakLineIEReturnOrEnterKey = 'On break line (i.e. return or enter key)';
|
||||||
lisSetupDefaultIndentation = '(Set up default indentation)';
|
lisSetupDefaultIndentation = '(Set up default indentation)';
|
||||||
lisIndentationForPascalSources = 'Indentation for Pascal sources';
|
lisIndentationForPascalSources = 'Indentation for Pascal sources';
|
||||||
|
21
ide/main.pp
21
ide/main.pp
@ -6639,7 +6639,7 @@ var
|
|||||||
ActiveSourceEditor: TSourceEditor;
|
ActiveSourceEditor: TSourceEditor;
|
||||||
ActiveUnitInfo: TUnitInfo;
|
ActiveUnitInfo: TUnitInfo;
|
||||||
s, ShortUnitName: string;
|
s, ShortUnitName: string;
|
||||||
DependencyAdded: boolean;
|
OkToAdd: boolean;
|
||||||
Owners: TFPList;
|
Owners: TFPList;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
APackage: TLazPackage;
|
APackage: TLazPackage;
|
||||||
@ -6712,12 +6712,12 @@ begin
|
|||||||
if IDEMessageDialog(lisConfirmation, Format(lisAddToProject, [s]),
|
if IDEMessageDialog(lisConfirmation, Format(lisAddToProject, [s]),
|
||||||
mtConfirmation, [mbYes, mbCancel]) in [mrOk, mrYes]
|
mtConfirmation, [mbYes, mbCancel]) in [mrOk, mrYes]
|
||||||
then begin
|
then begin
|
||||||
DependencyAdded:=false;
|
OkToAdd:=True;
|
||||||
if FilenameIsPascalUnit(ActiveUnitInfo.Filename) then
|
if FilenameIsPascalUnit(ActiveUnitInfo.Filename) then
|
||||||
DependencyAdded:=SourceFileMgr.CheckDirIsInSearchPath(ActiveUnitInfo,False,False)
|
OkToAdd:=SourceFileMgr.CheckDirIsInSearchPath(ActiveUnitInfo,False,False)
|
||||||
else if CompareFileExt(ActiveUnitInfo.Filename,'inc',false)=0 then
|
else if CompareFileExt(ActiveUnitInfo.Filename,'inc',false)=0 then
|
||||||
DependencyAdded:=SourceFileMgr.CheckDirIsInSearchPath(ActiveUnitInfo,False,True);
|
OkToAdd:=SourceFileMgr.CheckDirIsInSearchPath(ActiveUnitInfo,False,True);
|
||||||
if not DependencyAdded then begin
|
if OkToAdd then begin
|
||||||
ActiveUnitInfo.IsPartOfProject:=true;
|
ActiveUnitInfo.IsPartOfProject:=true;
|
||||||
Project1.Modified:=true;
|
Project1.Modified:=true;
|
||||||
if (FilenameIsPascalUnit(ActiveUnitInfo.Filename))
|
if (FilenameIsPascalUnit(ActiveUnitInfo.Filename))
|
||||||
@ -12950,15 +12950,15 @@ var
|
|||||||
ActiveSourceEditor: TSourceEditor;
|
ActiveSourceEditor: TSourceEditor;
|
||||||
ActiveUnitInfo: TUnitInfo;
|
ActiveUnitInfo: TUnitInfo;
|
||||||
ShortUnitName: String;
|
ShortUnitName: String;
|
||||||
DependencyAdded: boolean;
|
OkToAdd: boolean;
|
||||||
begin
|
begin
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
//debugln(['TMainIDE.ProjInspectorAddUnitToProject ',AnUnitInfo.Filename]);
|
//debugln(['TMainIDE.ProjInspectorAddUnitToProject ',AnUnitInfo.Filename]);
|
||||||
BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]);
|
BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]);
|
||||||
AnUnitInfo.IsPartOfProject:=true;
|
AnUnitInfo.IsPartOfProject:=true;
|
||||||
DependencyAdded:=false;
|
OkToAdd:=True;
|
||||||
if FilenameIsPascalUnit(AnUnitInfo.Filename) then begin
|
if FilenameIsPascalUnit(AnUnitInfo.Filename) then begin
|
||||||
DependencyAdded:=SourceFileMgr.CheckDirIsInSearchPath(AnUnitInfo,False,False);
|
OkToAdd:=SourceFileMgr.CheckDirIsInSearchPath(AnUnitInfo,False,False);
|
||||||
if (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags) then begin
|
if (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags) then begin
|
||||||
AnUnitInfo.ReadUnitNameFromSource(false);
|
AnUnitInfo.ReadUnitNameFromSource(false);
|
||||||
ShortUnitName:=AnUnitInfo.Unit_Name;
|
ShortUnitName:=AnUnitInfo.Unit_Name;
|
||||||
@ -12975,12 +12975,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else if CompareFileExt(AnUnitInfo.Filename,'inc',false)=0 then
|
else if CompareFileExt(AnUnitInfo.Filename,'inc',false)=0 then
|
||||||
DependencyAdded:=SourceFileMgr.CheckDirIsInSearchPath(AnUnitInfo,False,True);
|
OkToAdd:=SourceFileMgr.CheckDirIsInSearchPath(AnUnitInfo,False,True);
|
||||||
Project1.Modified:=true;
|
Project1.Modified:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.ProjInspectorRemoveFile(Sender: TObject; AnUnitInfo: TUnitInfo
|
function TMainIDE.ProjInspectorRemoveFile(Sender: TObject; AnUnitInfo: TUnitInfo): TModalresult;
|
||||||
): TModalresult;
|
|
||||||
var
|
var
|
||||||
UnitInfos: TFPList;
|
UnitInfos: TFPList;
|
||||||
begin
|
begin
|
||||||
|
@ -41,7 +41,7 @@ uses
|
|||||||
SourceEditor, EditorOptions, CustomFormEditor, FormEditor, EmptyMethodsDlg,
|
SourceEditor, EditorOptions, CustomFormEditor, FormEditor, EmptyMethodsDlg,
|
||||||
BaseDebugManager, ControlSelection, TransferMacros, EnvironmentOpts,
|
BaseDebugManager, ControlSelection, TransferMacros, EnvironmentOpts,
|
||||||
BuildManager, Designer, EditorMacroListViewer, KeywordFuncLists,
|
BuildManager, Designer, EditorMacroListViewer, KeywordFuncLists,
|
||||||
FindRenameIdentifier,
|
FindRenameIdentifier, GenericCheckList,
|
||||||
{$IFDEF EnableNewExtTools}
|
{$IFDEF EnableNewExtTools}
|
||||||
etMessagesWnd,
|
etMessagesWnd,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
@ -2499,24 +2499,24 @@ end;
|
|||||||
|
|
||||||
function TLazSourceFileManager.CheckDirIsInSearchPath(UnitInfo: TUnitInfo;
|
function TLazSourceFileManager.CheckDirIsInSearchPath(UnitInfo: TUnitInfo;
|
||||||
AllowAddingDependencies, IsIncludeFile: Boolean): Boolean;
|
AllowAddingDependencies, IsIncludeFile: Boolean): Boolean;
|
||||||
// Returns true if a dependency was added.
|
// Check if the given unit's path is on Unit- or Include-search path.
|
||||||
|
// Returns true if it is OK to add the unit to current project.
|
||||||
var
|
var
|
||||||
CurDirectory, CurPath, ShortDir: String;
|
CurDirectory, CurPath, ShortDir: String;
|
||||||
DlgCapt, DlgMsg: String;
|
DlgMsg: String;
|
||||||
Owners: TFPList;
|
Owners: TFPList;
|
||||||
APackage: TLazPackage;
|
APackage: TLazPackage;
|
||||||
|
ListForm: TGenericCheckListForm;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=True;
|
||||||
if UnitInfo.IsVirtual then exit;
|
if UnitInfo.IsVirtual then exit;
|
||||||
if IsIncludeFile then begin
|
if IsIncludeFile then begin
|
||||||
CurPath:=Project1.CompilerOptions.GetIncludePath(false);
|
CurPath:=Project1.CompilerOptions.GetIncludePath(false);
|
||||||
DlgCapt:=lisAddToIncludeSearchPath;
|
|
||||||
DlgMsg:=lisTheNewIncludeFileIsNotYetInTheIncludeSearchPathAdd;
|
DlgMsg:=lisTheNewIncludeFileIsNotYetInTheIncludeSearchPathAdd;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
CurPath:=Project1.CompilerOptions.GetUnitPath(false);
|
CurPath:=Project1.CompilerOptions.GetUnitPath(false);
|
||||||
DlgCapt:=lisAddToUnitSearchPath;
|
|
||||||
DlgMsg:=lisTheNewUnitIsNotYetInTheUnitSearchPathAddDirectory;
|
DlgMsg:=lisTheNewUnitIsNotYetInTheUnitSearchPathAddDirectory;
|
||||||
end;
|
end;
|
||||||
CurDirectory:=AppendPathDelim(UnitInfo.GetDirectory);
|
CurDirectory:=AppendPathDelim(UnitInfo.GetDirectory);
|
||||||
@ -2533,9 +2533,9 @@ begin
|
|||||||
Format(lisAddPackageToProject, [APackage.IDAsString]),
|
Format(lisAddPackageToProject, [APackage.IDAsString]),
|
||||||
mtConfirmation,[mbYes,mbCancel],'')<>mrYes
|
mtConfirmation,[mbYes,mbCancel],'')<>mrYes
|
||||||
then
|
then
|
||||||
Exit(False);
|
|
||||||
PkgBoss.AddProjectDependency(Project1,APackage);
|
|
||||||
Exit(True);
|
Exit(True);
|
||||||
|
PkgBoss.AddProjectDependency(Project1,APackage);
|
||||||
|
Exit(False);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2547,12 +2547,26 @@ begin
|
|||||||
ShortDir:=CurDirectory;
|
ShortDir:=CurDirectory;
|
||||||
if (not Project1.IsVirtual) then
|
if (not Project1.IsVirtual) then
|
||||||
ShortDir:=CreateRelativePath(ShortDir,Project1.ProjectDirectory);
|
ShortDir:=CreateRelativePath(ShortDir,Project1.ProjectDirectory);
|
||||||
if IDEMessageDialog(DlgCapt,Format(DlgMsg,[LineEnding,CurDirectory]),mtConfirmation,[mbYes,mbNo])=mrYes
|
ListForm:=TGenericCheckListForm.Create(Nil);
|
||||||
then with Project1.CompilerOptions do
|
try
|
||||||
|
//lisApplyForBuildModes = 'Apply for build modes:';
|
||||||
|
ListForm.Caption:=lisAvailableProjectBuildModes;
|
||||||
|
ListForm.InfoLabel.Caption:=Format(DlgMsg,[LineEnding,CurDirectory]);
|
||||||
|
for i:=0 to Project1.BuildModes.Count-1 do begin
|
||||||
|
ListForm.CheckListBox1.Items.Add(Project1.BuildModes[i].Identifier);
|
||||||
|
ListForm.CheckListBox1.Checked[i]:=True;
|
||||||
|
end;
|
||||||
|
if ListForm.ShowModal<>mrOK then Exit(False);
|
||||||
|
for i:=0 to Project1.BuildModes.Count-1 do
|
||||||
|
if ListForm.CheckListBox1.Checked[i] then
|
||||||
|
with Project1.BuildModes[i].CompilerOptions do
|
||||||
if IsIncludeFile then
|
if IsIncludeFile then
|
||||||
IncludePath:=MergeSearchPaths(IncludePath,ShortDir)
|
IncludePath:=MergeSearchPaths(IncludePath,ShortDir)
|
||||||
else
|
else
|
||||||
OtherUnitFiles:=MergeSearchPaths(OtherUnitFiles,ShortDir);
|
OtherUnitFiles:=MergeSearchPaths(OtherUnitFiles,ShortDir);
|
||||||
|
finally
|
||||||
|
ListForm.Free;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user