Packager: Redesign the "Broken dependencies" dialog using resources. Issue , patch from Alexey Torgashin.

git-svn-id: trunk@49604 -
This commit is contained in:
juha 2015-08-06 10:32:04 +00:00
parent 313c453367
commit da1277952f
5 changed files with 42 additions and 165 deletions

View File

@ -80,6 +80,8 @@ resourcestring
lisCancel = 'Cancel';
lisUnusedUnitsOf = 'Unused units of %s';
lisNo = 'No';
lisYes = 'Yes';
lisAbort = 'Abort';
lisContinue = 'Continue';
lisBreak = 'Break';
lisExit = 'Exit';
@ -4326,6 +4328,7 @@ resourcestring
+'%sSelect Yes to change all listed dependencies.'
+'%sSelect Ignore to break the dependencies and continue.';
lisA2PDependency = 'Dependency';
lisA2PPackageOrProject = 'Package/Project';
lisA2PBrokenDependencies = 'Broken Dependencies';
// open installed packages dialog

View File

@ -27,10 +27,10 @@
***************************************************************************
Author: Mattias Gaertner
Form resource added: Alexey Torgashin
Abstract:
TBrokenDependenciesDialog is the dialog showing, which dependencies are
broken.
TBrokenDependenciesDialog is the dialog showing, which dependencies are broken.
}
unit BrokenDependenciesDlg;
@ -39,184 +39,60 @@ unit BrokenDependenciesDlg;
interface
uses
Classes, SysUtils, Forms, Controls, Buttons, LResources, StdCtrls, ComCtrls,
Dialogs,
IDEWindowIntf, LazarusIDEStrConsts, Project, PackageDefs, PackageSystem;
Classes, SysUtils, Forms, StdCtrls, ComCtrls, ButtonPanel,
LazarusIDEStrConsts, PackageDefs;
type
{ TBrokenDependenciesDialog }
TBrokenDependenciesDialog = class(TForm)
NoteLabel: TLabel;
ButtonPanel1: TButtonPanel;
DependencyListView: TListView;
procedure BrokenDependenciesDialogClose(Sender: TObject;
var {%H-}CloseAction: TCloseAction);
procedure BrokenDependenciesDialogResize(Sender: TObject);
NoteLabel: TLabel;
procedure FormCreate(Sender: TObject);
private
fButtons: TFPList; // list of TBitBtn
fButtonSet: TMsgDlgButtons;
function GetButtons(Btn: TMsgDlgBtn): TBitBtn;
procedure SetupComponents;
procedure ClearButtons;
public
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;
end;
const
DefaultBrokenDepButtons = [mbYes,mbIgnore,mbCancel,mbAbort];
function ShowBrokenDependencies(DependencyList: TFPList;
BtnSet: TMsgDlgButtons): TModalResult;
function ShowBrokenDependencies(DependencyList: TFPList): TModalResult;
implementation
{$R *.lfm}
function ShowBrokenDependencies(DependencyList: TFPList;
BtnSet: TMsgDlgButtons): TModalResult;
function ShowBrokenDependencies(DependencyList: TFPList): TModalResult;
var
BrokenDependenciesDialog: TBrokenDependenciesDialog;
Dlg: TBrokenDependenciesDialog;
begin
BrokenDependenciesDialog:=TBrokenDependenciesDialog.CreateNew(nil);
BrokenDependenciesDialog.DependencyList:=DependencyList;
with BrokenDependenciesDialog do begin
CreateButtons(BtnSet);
UpdateDependencyList;
Result:=ShowModal;
Free;
Dlg:=TBrokenDependenciesDialog.Create(nil);
try
Dlg.DependencyList:=DependencyList;
Dlg.UpdateDependencyList;
Result:=Dlg.ShowModal;
finally
Dlg.Free;
end;
end;
{ TBrokenDependenciesDialog }
procedure TBrokenDependenciesDialog.BrokenDependenciesDialogResize(
Sender: TObject);
var
i: Integer;
y: Integer;
x: Integer;
CurButton: TBitBtn;
procedure TBrokenDependenciesDialog.FormCreate(Sender: TObject);
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;
fButtons:=TFPList.Create;
SetupComponents;
OnResize:=@BrokenDependenciesDialogResize;
Position:=poScreenCenter;
IDEDialogLayoutList.ApplyLayout(Self,500,300);
OnResize(Self);
OnClose:=@BrokenDependenciesDialogClose;
ButtonPanel1.OKButton.Caption:=lisYes;
ButtonPanel1.CloseButton.Caption:=dlgIgnoreVerb;
NoteLabel.Caption:=Format(lisBDDChangingThePackageNameOrVersionBreaksDependencies,
[LineEnding, LineEnding]);
DependencyListView.Columns[0].Caption:=lisA2PPackageOrProject;
DependencyListView.Columns[1].Caption:=lisA2PDependency;
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;
var

View File

@ -95,17 +95,16 @@ begin
NewVersion.Build := RoundToInt(VersionBuildSpinEdit.Value);
// check for broken dependencies
BrokenDependencies := PackageGraph.GetBrokenDependenciesWhenChangingPkgID(LazPackage, LazPackage.Name, NewVersion);
BrokenDependencies := PackageGraph.GetBrokenDependenciesWhenChangingPkgID(LazPackage,
LazPackage.Name, NewVersion);
RenameDependencies := False;
try
if BrokenDependencies.Count > 0 then
begin
MsgResult := ShowBrokenDependencies(BrokenDependencies, DefaultBrokenDepButtons);
if MsgResult = mrYes then
MsgResult := ShowBrokenDependencies(BrokenDependencies);
if MsgResult = mrOK then // = Yes
RenameDependencies := True
else if MsgResult = mrNo then
RenameDependencies := False
else
else if MsgResult <> mrClose then // <> Ignore
exit;
end;
finally

View File

@ -1305,8 +1305,7 @@ begin
end;
end;
function FindLowestPkgDependencyNodeWithName(const PkgName: string
): TAVLTreeNode;
function FindLowestPkgDependencyNodeWithName(const PkgName: string): TAVLTreeNode;
begin
Result:=nil;
if PackageDependencies=nil then exit;

View File

@ -1251,11 +1251,11 @@ begin
RenameDependencies:=false;
try
if BrokenDependencies.Count>0 then begin
Result:=ShowBrokenDependencies(BrokenDependencies,
DefaultBrokenDepButtons);
if Result=mrAbort then exit;
if Result=mrRetry then continue;
if Result=mrYes then RenameDependencies:=true;
Result:=ShowBrokenDependencies(BrokenDependencies);
if Result=mrOK then // = Yes
RenameDependencies:=true
else if Result<>mrClose then // <> Ignore
exit;
end;
finally
BrokenDependencies.Free;