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