mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-14 15:19:11 +02:00
IDE: adding unit to project: add question when unit belongs to other package
git-svn-id: trunk@23759 -
This commit is contained in:
parent
7ff9ae8e45
commit
03419d8ebb
@ -4583,6 +4583,9 @@ resourcestring
|
|||||||
lisImitateIndentationOfCurrentUnitProjectOrPackage = 'Imitate indentation '
|
lisImitateIndentationOfCurrentUnitProjectOrPackage = 'Imitate indentation '
|
||||||
+'of current unit, project or package';
|
+'of current unit, project or package';
|
||||||
lisAddPackageRequirement = 'Add package requirement?';
|
lisAddPackageRequirement = 'Add package requirement?';
|
||||||
|
lisTheUnitBelongsToPackage = 'The unit belongs to package %s.';
|
||||||
|
lisAddPackageToProject2 = 'Add package to project';
|
||||||
|
lisAddUnitNotRecommended = 'Add unit (not recommended)';
|
||||||
lisAddPackageToProject = 'Add package %s to project?';
|
lisAddPackageToProject = 'Add package %s to project?';
|
||||||
lisOnBreakLineIEReturnOrEnterKey = 'On break line (i.e. return or enter key)';
|
lisOnBreakLineIEReturnOrEnterKey = 'On break line (i.e. return or enter key)';
|
||||||
lisOnPasteFromClipboard = 'On paste from clipboard';
|
lisOnPasteFromClipboard = 'On paste from clipboard';
|
||||||
|
39
ide/main.pp
39
ide/main.pp
@ -9733,6 +9733,10 @@ var
|
|||||||
ActiveUnitInfo: TUnitInfo;
|
ActiveUnitInfo: TUnitInfo;
|
||||||
s, ShortUnitName: string;
|
s, ShortUnitName: string;
|
||||||
DependencyAdded: boolean;
|
DependencyAdded: boolean;
|
||||||
|
Owners: TFPList;
|
||||||
|
i: Integer;
|
||||||
|
APackage: TLazPackage;
|
||||||
|
MsgResult: TModalResult;
|
||||||
begin
|
begin
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
if not BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]) then exit;
|
if not BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]) then exit;
|
||||||
@ -9757,7 +9761,37 @@ begin
|
|||||||
MessageDlg(Format(
|
MessageDlg(Format(
|
||||||
lisUnableToAddToProjectBecauseThereIsAlreadyAUnitWith, [s]),
|
lisUnableToAddToProjectBecauseThereIsAlreadyAUnitWith, [s]),
|
||||||
mtInformation, [mbOk], 0);
|
mtInformation, [mbOk], 0);
|
||||||
end else begin
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Owners:=PkgBoss.GetPossibleOwnersOfUnit(ActiveUnitInfo.Filename,[]);
|
||||||
|
try
|
||||||
|
if (Owners<>nil) then begin
|
||||||
|
for i:=0 to Owners.Count-1 do begin
|
||||||
|
if TObject(Owners[i]) is TLazPackage then begin
|
||||||
|
APackage:=TLazPackage(Owners[i]);
|
||||||
|
MsgResult:=IDEQuestionDialog(lisAddPackageRequirement,
|
||||||
|
Format(lisTheUnitBelongsToPackage, [APackage.IDAsString]),
|
||||||
|
mtConfirmation, [mrYes, lisAddPackageToProject2,
|
||||||
|
mrIgnore, lisAddUnitNotRecommended,
|
||||||
|
mrCancel],'');
|
||||||
|
case MsgResult of
|
||||||
|
mrYes:
|
||||||
|
begin
|
||||||
|
PkgBoss.AddProjectDependency(Project1,APackage);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
mrIgnore: ;
|
||||||
|
else
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Owners.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
if FilenameIsPascalUnit(ActiveUnitInfo.Filename)
|
if FilenameIsPascalUnit(ActiveUnitInfo.Filename)
|
||||||
and (EnvironmentOptions.CharcaseFileAction<>ccfaIgnore) then
|
and (EnvironmentOptions.CharcaseFileAction<>ccfaIgnore) then
|
||||||
begin
|
begin
|
||||||
@ -9773,7 +9807,7 @@ begin
|
|||||||
if MessageDlg(Format(lisAddToProject, [s]), mtConfirmation, [mbYes,
|
if MessageDlg(Format(lisAddToProject, [s]), mtConfirmation, [mbYes,
|
||||||
mbCancel], 0) in [mrOk,mrYes]
|
mbCancel], 0) in [mrOk,mrYes]
|
||||||
then begin
|
then begin
|
||||||
CheckUnitDirIsInSearchPath(ActiveUnitInfo,true,DependencyAdded);
|
CheckUnitDirIsInSearchPath(ActiveUnitInfo,false,DependencyAdded);
|
||||||
if not DependencyAdded then begin
|
if not DependencyAdded then begin
|
||||||
ActiveUnitInfo.IsPartOfProject:=true;
|
ActiveUnitInfo.IsPartOfProject:=true;
|
||||||
Project1.Modified:=true;
|
Project1.Modified:=true;
|
||||||
@ -9791,7 +9825,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoRemoveFromProjectDialog: TModalResult;
|
function TMainIDE.DoRemoveFromProjectDialog: TModalResult;
|
||||||
|
Loading…
Reference in New Issue
Block a user