mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 11:30:28 +02:00
Packager: Redesign the "Broken dependencies" dialog using resources. Issue #28349, patch from Alexey Torgashin.
git-svn-id: trunk@49604 -
This commit is contained in:
parent
313c453367
commit
da1277952f
@ -80,6 +80,8 @@ resourcestring
|
|||||||
lisCancel = 'Cancel';
|
lisCancel = 'Cancel';
|
||||||
lisUnusedUnitsOf = 'Unused units of %s';
|
lisUnusedUnitsOf = 'Unused units of %s';
|
||||||
lisNo = 'No';
|
lisNo = 'No';
|
||||||
|
lisYes = 'Yes';
|
||||||
|
lisAbort = 'Abort';
|
||||||
lisContinue = 'Continue';
|
lisContinue = 'Continue';
|
||||||
lisBreak = 'Break';
|
lisBreak = 'Break';
|
||||||
lisExit = 'Exit';
|
lisExit = 'Exit';
|
||||||
@ -4326,6 +4328,7 @@ resourcestring
|
|||||||
+'%sSelect Yes to change all listed dependencies.'
|
+'%sSelect Yes to change all listed dependencies.'
|
||||||
+'%sSelect Ignore to break the dependencies and continue.';
|
+'%sSelect Ignore to break the dependencies and continue.';
|
||||||
lisA2PDependency = 'Dependency';
|
lisA2PDependency = 'Dependency';
|
||||||
|
lisA2PPackageOrProject = 'Package/Project';
|
||||||
lisA2PBrokenDependencies = 'Broken Dependencies';
|
lisA2PBrokenDependencies = 'Broken Dependencies';
|
||||||
|
|
||||||
// open installed packages dialog
|
// open installed packages dialog
|
||||||
|
@ -27,10 +27,10 @@
|
|||||||
***************************************************************************
|
***************************************************************************
|
||||||
|
|
||||||
Author: Mattias Gaertner
|
Author: Mattias Gaertner
|
||||||
|
Form resource added: Alexey Torgashin
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
TBrokenDependenciesDialog is the dialog showing, which dependencies are
|
TBrokenDependenciesDialog is the dialog showing, which dependencies are broken.
|
||||||
broken.
|
|
||||||
}
|
}
|
||||||
unit BrokenDependenciesDlg;
|
unit BrokenDependenciesDlg;
|
||||||
|
|
||||||
@ -39,184 +39,60 @@ unit BrokenDependenciesDlg;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Forms, Controls, Buttons, LResources, StdCtrls, ComCtrls,
|
Classes, SysUtils, Forms, StdCtrls, ComCtrls, ButtonPanel,
|
||||||
Dialogs,
|
LazarusIDEStrConsts, PackageDefs;
|
||||||
IDEWindowIntf, LazarusIDEStrConsts, Project, PackageDefs, PackageSystem;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
{ TBrokenDependenciesDialog }
|
{ TBrokenDependenciesDialog }
|
||||||
|
|
||||||
TBrokenDependenciesDialog = class(TForm)
|
TBrokenDependenciesDialog = class(TForm)
|
||||||
NoteLabel: TLabel;
|
ButtonPanel1: TButtonPanel;
|
||||||
DependencyListView: TListView;
|
DependencyListView: TListView;
|
||||||
procedure BrokenDependenciesDialogClose(Sender: TObject;
|
NoteLabel: TLabel;
|
||||||
var {%H-}CloseAction: TCloseAction);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure BrokenDependenciesDialogResize(Sender: TObject);
|
|
||||||
private
|
private
|
||||||
fButtons: TFPList; // list of TBitBtn
|
|
||||||
fButtonSet: TMsgDlgButtons;
|
|
||||||
function GetButtons(Btn: TMsgDlgBtn): TBitBtn;
|
|
||||||
procedure SetupComponents;
|
|
||||||
procedure ClearButtons;
|
|
||||||
public
|
|
||||||
DependencyList: TFPList;
|
DependencyList: TFPList;
|
||||||
constructor CreateNew(TheOwner: TComponent; Num: Integer = 0); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
property Buttons[Btn: TMsgDlgBtn]: TBitBtn read GetButtons;
|
|
||||||
procedure CreateButtons(BtnSet: TMsgDlgButtons);
|
|
||||||
procedure UpdateDependencyList;
|
procedure UpdateDependencyList;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
|
||||||
DefaultBrokenDepButtons = [mbYes,mbIgnore,mbCancel,mbAbort];
|
|
||||||
|
|
||||||
|
function ShowBrokenDependencies(DependencyList: TFPList): TModalResult;
|
||||||
function ShowBrokenDependencies(DependencyList: TFPList;
|
|
||||||
BtnSet: TMsgDlgButtons): TModalResult;
|
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
function ShowBrokenDependencies(DependencyList: TFPList;
|
function ShowBrokenDependencies(DependencyList: TFPList): TModalResult;
|
||||||
BtnSet: TMsgDlgButtons): TModalResult;
|
|
||||||
var
|
var
|
||||||
BrokenDependenciesDialog: TBrokenDependenciesDialog;
|
Dlg: TBrokenDependenciesDialog;
|
||||||
begin
|
begin
|
||||||
BrokenDependenciesDialog:=TBrokenDependenciesDialog.CreateNew(nil);
|
Dlg:=TBrokenDependenciesDialog.Create(nil);
|
||||||
BrokenDependenciesDialog.DependencyList:=DependencyList;
|
try
|
||||||
with BrokenDependenciesDialog do begin
|
Dlg.DependencyList:=DependencyList;
|
||||||
CreateButtons(BtnSet);
|
Dlg.UpdateDependencyList;
|
||||||
UpdateDependencyList;
|
Result:=Dlg.ShowModal;
|
||||||
Result:=ShowModal;
|
finally
|
||||||
Free;
|
Dlg.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TBrokenDependenciesDialog }
|
{ TBrokenDependenciesDialog }
|
||||||
|
|
||||||
procedure TBrokenDependenciesDialog.BrokenDependenciesDialogResize(
|
procedure TBrokenDependenciesDialog.FormCreate(Sender: TObject);
|
||||||
Sender: TObject);
|
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
y: Integer;
|
|
||||||
x: Integer;
|
|
||||||
CurButton: TBitBtn;
|
|
||||||
begin
|
begin
|
||||||
x:=ClientWidth;
|
|
||||||
NoteLabel.SetBounds(5,5,x-10,80);
|
|
||||||
y:=NoteLabel.Top+NoteLabel.Height+2;
|
|
||||||
with DependencyListView do
|
|
||||||
SetBounds(0,y,x,Parent.ClientHeight-y-40);
|
|
||||||
y:=ClientHeight-35;
|
|
||||||
for i:=fButtons.Count-1 downto 0 do begin
|
|
||||||
CurButton:=TBitBtn(fButtons[i]);
|
|
||||||
dec(x,CurButton.Width+10);
|
|
||||||
with CurButton do
|
|
||||||
SetBounds(x,y,80,Height);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TBrokenDependenciesDialog.GetButtons(Btn: TMsgDlgBtn): TBitBtn;
|
|
||||||
var
|
|
||||||
CurBtn: TMsgDlgBtn;
|
|
||||||
i: Integer;
|
|
||||||
begin
|
|
||||||
if not (Btn in fButtonSet) then begin
|
|
||||||
Result:=nil;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
i:=0;
|
|
||||||
for CurBtn:=Low(TMsgDlgButtons) to High(TMsgDlgButtons) do begin
|
|
||||||
if CurBtn=Btn then break;
|
|
||||||
if Btn in fButtonSet then inc(i);
|
|
||||||
end;
|
|
||||||
Result:=TBitBtn(fButtons[i]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TBrokenDependenciesDialog.BrokenDependenciesDialogClose(
|
|
||||||
Sender: TObject; var CloseAction: TCloseAction);
|
|
||||||
begin
|
|
||||||
IDEDialogLayoutList.SaveLayout(Self);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TBrokenDependenciesDialog.SetupComponents;
|
|
||||||
var
|
|
||||||
NewColumn: TListColumn;
|
|
||||||
begin
|
|
||||||
NoteLabel:=TLabel.Create(Self);
|
|
||||||
with NoteLabel do begin
|
|
||||||
Name:='NoteLabel';
|
|
||||||
Parent:=Self;
|
|
||||||
WordWrap:=true;
|
|
||||||
Caption:=Format(lisBDDChangingThePackageNameOrVersionBreaksDependencies,
|
|
||||||
[LineEnding, LineEnding]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
DependencyListView:=TListView.Create(Self);
|
|
||||||
with DependencyListView do begin
|
|
||||||
Name:='DependencyListView';
|
|
||||||
Parent:=Self;
|
|
||||||
ViewStyle:=vsReport;
|
|
||||||
NewColumn:=Columns.Add;
|
|
||||||
NewColumn.Width:=200;
|
|
||||||
NewColumn.Caption:='Package/Project';
|
|
||||||
NewColumn:=Columns.Add;
|
|
||||||
NewColumn.Caption:=lisA2PDependency;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TBrokenDependenciesDialog.ClearButtons;
|
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
|
||||||
for i:=0 to fButtons.Count-1 do
|
|
||||||
TBitBtn(fButtons[i]).Free;
|
|
||||||
fButtons.Clear;
|
|
||||||
end;
|
|
||||||
|
|
||||||
constructor TBrokenDependenciesDialog.CreateNew(TheOwner: TComponent;
|
|
||||||
Num: Integer);
|
|
||||||
begin
|
|
||||||
inherited CreateNew(TheOwner,Num);
|
|
||||||
Name:='BrokenDependenciesDialog';
|
|
||||||
Caption:=lisA2PBrokenDependencies;
|
Caption:=lisA2PBrokenDependencies;
|
||||||
fButtons:=TFPList.Create;
|
ButtonPanel1.OKButton.Caption:=lisYes;
|
||||||
SetupComponents;
|
ButtonPanel1.CloseButton.Caption:=dlgIgnoreVerb;
|
||||||
OnResize:=@BrokenDependenciesDialogResize;
|
|
||||||
Position:=poScreenCenter;
|
NoteLabel.Caption:=Format(lisBDDChangingThePackageNameOrVersionBreaksDependencies,
|
||||||
IDEDialogLayoutList.ApplyLayout(Self,500,300);
|
[LineEnding, LineEnding]);
|
||||||
OnResize(Self);
|
|
||||||
OnClose:=@BrokenDependenciesDialogClose;
|
DependencyListView.Columns[0].Caption:=lisA2PPackageOrProject;
|
||||||
|
DependencyListView.Columns[1].Caption:=lisA2PDependency;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TBrokenDependenciesDialog.Destroy;
|
|
||||||
begin
|
|
||||||
ClearButtons;
|
|
||||||
FreeAndNil(fButtons);
|
|
||||||
inherited Destroy;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TBrokenDependenciesDialog.CreateButtons(BtnSet: TMsgDlgButtons);
|
|
||||||
var
|
|
||||||
Btn: TMsgDlgBtn;
|
|
||||||
NewBitBtn: TBitBtn;
|
|
||||||
begin
|
|
||||||
ClearButtons;
|
|
||||||
fButtonSet:=BtnSet;
|
|
||||||
for Btn:=Low(TMsgDlgButtons) to High(TMsgDlgButtons) do begin
|
|
||||||
if Btn in fButtonSet then begin
|
|
||||||
NewBitBtn:=TBitBtn.Create(Self);
|
|
||||||
NewBitBtn.Name:='BitBtn'+IntToStr(fButtons.Count+1);
|
|
||||||
NewBitBtn.Kind:=MsgDlgBtnToBitBtnKind[Btn];
|
|
||||||
NewBitBtn.Parent:=Self;
|
|
||||||
if Btn=mbYes then NewBitBtn.Default:=true;
|
|
||||||
fButtons.Add(NewBitBtn);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
OnResize(Self);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TBrokenDependenciesDialog.UpdateDependencyList;
|
procedure TBrokenDependenciesDialog.UpdateDependencyList;
|
||||||
var
|
var
|
||||||
|
@ -95,17 +95,16 @@ begin
|
|||||||
NewVersion.Build := RoundToInt(VersionBuildSpinEdit.Value);
|
NewVersion.Build := RoundToInt(VersionBuildSpinEdit.Value);
|
||||||
|
|
||||||
// check for broken dependencies
|
// check for broken dependencies
|
||||||
BrokenDependencies := PackageGraph.GetBrokenDependenciesWhenChangingPkgID(LazPackage, LazPackage.Name, NewVersion);
|
BrokenDependencies := PackageGraph.GetBrokenDependenciesWhenChangingPkgID(LazPackage,
|
||||||
|
LazPackage.Name, NewVersion);
|
||||||
RenameDependencies := False;
|
RenameDependencies := False;
|
||||||
try
|
try
|
||||||
if BrokenDependencies.Count > 0 then
|
if BrokenDependencies.Count > 0 then
|
||||||
begin
|
begin
|
||||||
MsgResult := ShowBrokenDependencies(BrokenDependencies, DefaultBrokenDepButtons);
|
MsgResult := ShowBrokenDependencies(BrokenDependencies);
|
||||||
if MsgResult = mrYes then
|
if MsgResult = mrOK then // = Yes
|
||||||
RenameDependencies := True
|
RenameDependencies := True
|
||||||
else if MsgResult = mrNo then
|
else if MsgResult <> mrClose then // <> Ignore
|
||||||
RenameDependencies := False
|
|
||||||
else
|
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
|
@ -1305,8 +1305,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function FindLowestPkgDependencyNodeWithName(const PkgName: string
|
function FindLowestPkgDependencyNodeWithName(const PkgName: string): TAVLTreeNode;
|
||||||
): TAVLTreeNode;
|
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
if PackageDependencies=nil then exit;
|
if PackageDependencies=nil then exit;
|
||||||
|
@ -1251,11 +1251,11 @@ begin
|
|||||||
RenameDependencies:=false;
|
RenameDependencies:=false;
|
||||||
try
|
try
|
||||||
if BrokenDependencies.Count>0 then begin
|
if BrokenDependencies.Count>0 then begin
|
||||||
Result:=ShowBrokenDependencies(BrokenDependencies,
|
Result:=ShowBrokenDependencies(BrokenDependencies);
|
||||||
DefaultBrokenDepButtons);
|
if Result=mrOK then // = Yes
|
||||||
if Result=mrAbort then exit;
|
RenameDependencies:=true
|
||||||
if Result=mrRetry then continue;
|
else if Result<>mrClose then // <> Ignore
|
||||||
if Result=mrYes then RenameDependencies:=true;
|
exit;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
BrokenDependencies.Free;
|
BrokenDependencies.Free;
|
||||||
|
Loading…
Reference in New Issue
Block a user