mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2026-01-22 01:41:38 +01:00
Packager: Add online packages to the "New Requirement" dialog. The changes are only visible when Opkman is installed.
git-svn-id: trunk@56607 -
This commit is contained in:
parent
15993c4c74
commit
d5b7b913fd
@ -6,6 +6,8 @@ interface
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
Classes,
|
||||
Forms,
|
||||
// LazUtils
|
||||
LazFileUtils,
|
||||
// IdeIntf
|
||||
@ -104,7 +106,7 @@ type
|
||||
|
||||
TOPMInterface = class
|
||||
public
|
||||
function InstallPackage(APkgLink: TPackageLink): Boolean; virtual; abstract;
|
||||
function InstallPackages(APkgLinks: TList): TModalResult; virtual; abstract;
|
||||
end;
|
||||
|
||||
var
|
||||
|
||||
@ -29,7 +29,7 @@ unit opkman_intf;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, contnrs, fpjson,
|
||||
Classes, SysUtils, Forms, Dialogs, Controls, contnrs, fpjson,
|
||||
// IdeIntf
|
||||
LazIDEIntf, PackageIntf, PackageLinkIntf, PackageDependencyIntf,
|
||||
// OPM
|
||||
@ -52,7 +52,7 @@ type
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
public
|
||||
|
||||
function InstallPackages(APkgLinks: TList): TModalResult; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -155,6 +155,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TOPMInterfaceEx.InstallPackages(APkgLinks: TList): TModalResult;
|
||||
begin
|
||||
Result := mrOk;
|
||||
MessageDlg('Not yet implemented!', mtInformation, [mbOk], 0)
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
||||
@ -2769,10 +2769,7 @@ resourcestring
|
||||
lisFRForwardSearch = 'Forwar&d search';
|
||||
lisFRBackwardSearch = '&Backward search';
|
||||
dlgReplaceAll = 'Replace &All';
|
||||
lisLocalPkg = 'Local packages (%s)';
|
||||
lisOnlinePkg = 'Online packages (%s)';
|
||||
lisPkgInstConf = 'Do you wish to install the following packages from the main repository:';
|
||||
|
||||
|
||||
// IDEOptionDefs
|
||||
dlgGetPosition = 'Get position';
|
||||
dlgLeftPos = 'Left:';
|
||||
@ -3987,8 +3984,15 @@ resourcestring
|
||||
lisProjFiles = 'Files:';
|
||||
lisProjAddAddFilesToProject = 'Add Files to Project';
|
||||
lisProjAddPackageName = 'Package Name:';
|
||||
lisProjAddPackageType = 'Package Type:';
|
||||
lisProjAddLocalPkg = 'Local (%s)';
|
||||
lisProjAddOnlinePkg = 'Online (%s)';
|
||||
lisProjAddMinimumVersionOptional = 'Minimum Version (optional):';
|
||||
lisProjAddMaximumVersionOptional = 'Maximum Version (optional):';
|
||||
lisProjAddInstConfCaption = 'Install package';
|
||||
lisProjAddInstConf = 'Do you wish to install the following online package:';
|
||||
lisProjAddInstErrCaption = 'Install error';
|
||||
lisProjAddInstErr = 'One or more online package could not be installed!';
|
||||
|
||||
// component palette
|
||||
lisKMNewPackage = 'New package';
|
||||
|
||||
@ -8,7 +8,7 @@ object AddPkgDependencyDialog: TAddPkgDependencyDialog
|
||||
ClientHeight = 401
|
||||
ClientWidth = 449
|
||||
Constraints.MinHeight = 250
|
||||
Constraints.MinWidth = 250
|
||||
Constraints.MinWidth = 300
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '1.9.0.0'
|
||||
@ -47,25 +47,26 @@ object AddPkgDependencyDialog: TAddPkgDependencyDialog
|
||||
end
|
||||
object DependPkgNameListBox: TListBox
|
||||
AnchorSideLeft.Control = DependMinVersionEdit
|
||||
AnchorSideTop.Control = DependPkgNameFilter
|
||||
AnchorSideTop.Control = pnLocalPkg
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = DependPkgNameFilter
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = DependMinVersionEdit
|
||||
Left = 161
|
||||
Height = 265
|
||||
Top = 36
|
||||
Height = 239
|
||||
Top = 62
|
||||
Width = 280
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 6
|
||||
BorderSpacing.Bottom = 6
|
||||
ItemHeight = 0
|
||||
ItemHeight = 16
|
||||
MultiSelect = True
|
||||
OnDrawItem = DependPkgNameListBoxDrawItem
|
||||
OnSelectionChange = DependPkgNameListBoxSelectionChange
|
||||
Options = []
|
||||
ScrollWidth = 282
|
||||
Style = lbOwnerDrawFixed
|
||||
TabOrder = 1
|
||||
Style = lbOwnerDrawVariable
|
||||
TabOrder = 3
|
||||
end
|
||||
object DependMinVersionEdit: TEdit
|
||||
AnchorSideLeft.Control = DependMaxVersionEdit
|
||||
@ -78,7 +79,7 @@ object AddPkgDependencyDialog: TAddPkgDependencyDialog
|
||||
Width = 280
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 6
|
||||
TabOrder = 2
|
||||
TabOrder = 4
|
||||
Text = 'DependMinVersionEdit'
|
||||
end
|
||||
object DependMaxVersionEdit: TEdit
|
||||
@ -94,7 +95,7 @@ object AddPkgDependencyDialog: TAddPkgDependencyDialog
|
||||
Width = 280
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 3
|
||||
TabOrder = 3
|
||||
TabOrder = 5
|
||||
Text = 'DependMaxVersionEdit'
|
||||
end
|
||||
object DependMinVersionLabel: TLabel
|
||||
@ -143,33 +144,31 @@ object AddPkgDependencyDialog: TAddPkgDependencyDialog
|
||||
CloseButton.OnClick = CloseButtonClick
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.DefaultCaption = True
|
||||
TabOrder = 4
|
||||
TabOrder = 6
|
||||
ShowGlyphs = []
|
||||
end
|
||||
object pnLocalPkg: TPanel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = DependPkgNameListBox
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = DependPkgNameListBox
|
||||
Left = 24
|
||||
AnchorSideLeft.Control = DependPkgNameListBox
|
||||
AnchorSideTop.Control = DependPkgNameFilter
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 161
|
||||
Height = 19
|
||||
Top = 159
|
||||
Width = 131
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 24
|
||||
BorderSpacing.Right = 6
|
||||
Top = 37
|
||||
Width = 48
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 7
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 19
|
||||
ClientWidth = 131
|
||||
ClientWidth = 48
|
||||
Color = 15138790
|
||||
ParentColor = False
|
||||
TabOrder = 5
|
||||
TabOrder = 1
|
||||
object cbLocalPkg: TCheckBox
|
||||
Left = 0
|
||||
Height = 19
|
||||
Top = 0
|
||||
Width = 100
|
||||
Caption = 'Local packages'
|
||||
Width = 48
|
||||
Caption = 'Local'
|
||||
Checked = True
|
||||
Color = clDefault
|
||||
OnChange = cbLocalPkgChange
|
||||
@ -179,34 +178,48 @@ object AddPkgDependencyDialog: TAddPkgDependencyDialog
|
||||
end
|
||||
end
|
||||
object pnOnlinePkg: TPanel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = pnLocalPkg
|
||||
AnchorSideLeft.Control = pnLocalPkg
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = DependPkgNameFilter
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = DependPkgNameListBox
|
||||
Left = 24
|
||||
Left = 216
|
||||
Height = 19
|
||||
Top = 187
|
||||
Width = 131
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 24
|
||||
BorderSpacing.Top = 9
|
||||
BorderSpacing.Right = 6
|
||||
Top = 37
|
||||
Width = 55
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 7
|
||||
BorderSpacing.Top = 7
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 19
|
||||
ClientWidth = 131
|
||||
ClientWidth = 55
|
||||
Color = 14017529
|
||||
ParentColor = False
|
||||
TabOrder = 6
|
||||
TabOrder = 2
|
||||
object cbOnlinePkg: TCheckBox
|
||||
Left = 0
|
||||
Height = 19
|
||||
Top = 0
|
||||
Width = 107
|
||||
Caption = 'Online packages'
|
||||
Width = 55
|
||||
Caption = 'Online'
|
||||
Checked = True
|
||||
OnChange = cbLocalPkgChange
|
||||
State = cbChecked
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object DependPkgTypeLabel: TLabel
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = DependPkgNameFilter
|
||||
Left = 41
|
||||
Height = 15
|
||||
Top = 39
|
||||
Width = 114
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Top = 3
|
||||
BorderSpacing.Right = 6
|
||||
BorderSpacing.CellAlignHorizontal = ccaLeftTop
|
||||
BorderSpacing.CellAlignVertical = ccaCenter
|
||||
Caption = 'DependPkgTypeLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
||||
|
||||
@ -32,6 +32,7 @@ type
|
||||
DependMinVersionLabel: TLabel;
|
||||
DependPkgNameFilter: TListFilterEdit;
|
||||
DependPkgNameLabel: TLabel;
|
||||
DependPkgTypeLabel: TLabel;
|
||||
DependPkgNameListBox: TListBox;
|
||||
pnLocalPkg: TPanel;
|
||||
pnOnlinePkg: TPanel;
|
||||
@ -43,6 +44,8 @@ type
|
||||
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure OKButtonClick(Sender: TObject);
|
||||
function FindPackageLink(const ALazPackageID: TLazPackageID): TPackageLink;
|
||||
function InstallOnlinePackages: TModalResult;
|
||||
private
|
||||
fUpdating: Boolean;
|
||||
fSL: TStringList;
|
||||
@ -96,6 +99,9 @@ begin
|
||||
TIDEImages.AssignImage(DependPkgNameFilter.Glyph, 'btnfiltercancel');
|
||||
|
||||
DependPkgNameLabel.Caption:=lisProjAddPackageName;
|
||||
DependPkgTypeLabel.Caption:=lisProjAddPackageType;
|
||||
cbLocalPkg.Caption:=lisProjAddLocalPkg;
|
||||
cbOnlinePkg.Caption:=lisProjAddOnlinePkg;
|
||||
DependMinVersionLabel.Caption:=lisProjAddMinimumVersionOptional;
|
||||
DependMinVersionEdit.Text:='';
|
||||
DependMaxVersionLabel.Caption:=lisProjAddMaximumVersionOptional;
|
||||
@ -113,17 +119,37 @@ end;
|
||||
procedure TAddPkgDependencyDialog.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
begin
|
||||
fSL.Free;
|
||||
fSL := nil;
|
||||
IDEDialogLayoutList.SaveLayout(Self);
|
||||
end;
|
||||
|
||||
procedure TAddPkgDependencyDialog.FormCreate(Sender: TObject);
|
||||
begin
|
||||
fSL := TStringList.Create;
|
||||
DependPkgTypeLabel.Visible := OPMInterface <> nil;
|
||||
pnLocalPkg.Visible := OPMInterface <> nil;
|
||||
pnOnlinePkg.Visible := OPMInterface <> nil;
|
||||
BP.CloseButton.Visible := False;
|
||||
end;
|
||||
|
||||
function TAddPkgDependencyDialog.FindPackageLink(const ALazPackageID:
|
||||
TLazPackageID): TPackageLink;
|
||||
var
|
||||
I: Integer;
|
||||
begin
|
||||
Result := nil;
|
||||
if (fSL = nil) or (fSL.Count = 0) then
|
||||
Exit;
|
||||
for I := 0 to fSL.Count - 1 do
|
||||
begin
|
||||
if TLazPackageID(fSL.Objects[I]) = ALazPackageID then
|
||||
begin
|
||||
Result := TPackageLink(fSL.Objects[I]);
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAddPkgDependencyDialog.DependPkgNameListBoxDrawItem(
|
||||
Control: TWinControl; Index: Integer; ARect: TRect; State: TOwnerDrawState);
|
||||
var
|
||||
@ -139,26 +165,24 @@ begin
|
||||
end
|
||||
else
|
||||
begin
|
||||
Pen.Color := (Control as TListBox).Color;
|
||||
Pen.Color := (Control as TListBox).Font.Color;
|
||||
Brush.Color := (Control as TListBox).Color;
|
||||
if Assigned(OPMInterface) then
|
||||
begin
|
||||
PackageLink := TPackageLink(fSL.Objects[Index]);
|
||||
if PackageLink.Origin = ploOnline then
|
||||
Brush.Color := pnOnlinePkg.Color
|
||||
else
|
||||
Brush.Color := pnLocalPkg.Color
|
||||
PackageLink := FindPackageLink(TLazPackageID(DependPkgNameListBox.Items.Objects[Index]));
|
||||
if PackageLink <> nil then
|
||||
begin
|
||||
if PackageLink.Origin = ploOnline then
|
||||
Brush.Color := pnOnlinePkg.Color
|
||||
else
|
||||
Brush.Color := pnLocalPkg.Color
|
||||
end;
|
||||
end
|
||||
else
|
||||
Brush.Color := (Control as TListBox).Color;
|
||||
end;
|
||||
FillRect(ARect);
|
||||
ItemText := (Control as TListBox).Items[Index];
|
||||
InflateRect(ARect, -1, -1);
|
||||
DrawText(Handle, PChar(ItemText), Length(ItemText), ARect, DT_LEFT or DT_VCENTER or DT_SINGLELINE);
|
||||
if odFocused In State then
|
||||
begin
|
||||
Brush.Color := (Control as TListBox).Color;
|
||||
DrawFocusRect(ARect);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -168,14 +192,14 @@ var
|
||||
PackageLink: TPackageLink;
|
||||
begin
|
||||
Result := False;
|
||||
if (OPMInterface = nil) or (fSL.Count = 0) then
|
||||
if (OPMInterface = nil) or (fSL = nil) or (fSL.Count = 0) then
|
||||
Exit;
|
||||
for I := 0 to DependPkgNameListBox.Count - 1 do
|
||||
begin
|
||||
if DependPkgNameListBox.Selected[I] then
|
||||
begin
|
||||
PackageLink := TPackageLink(fSL.Objects[I]);
|
||||
if PackageLink.Origin = ploOnline then
|
||||
PackageLink := FindPackageLink(TLazPackageID(DependPkgNameListBox.Items.Objects[I]));
|
||||
if (PackageLink <> nil) and (PackageLink.Origin = ploOnline) then
|
||||
begin
|
||||
Result := True;
|
||||
Break;
|
||||
@ -195,32 +219,48 @@ begin
|
||||
UpdateAvailableDependencyNames;
|
||||
end;
|
||||
|
||||
procedure TAddPkgDependencyDialog.CloseButtonClick(Sender: TObject);
|
||||
function TAddPkgDependencyDialog.InstallOnlinePackages: TModalResult;
|
||||
var
|
||||
PkgList: String;
|
||||
I: Integer;
|
||||
PackageLink: TPackageLink;
|
||||
PkgList: TList;
|
||||
PkgListStr: String;
|
||||
begin
|
||||
ModalResult := mrNone;
|
||||
PkgList := '';
|
||||
for I := 0 to DependPkgNameListBox.Count - 1 do
|
||||
begin
|
||||
if DependPkgNameListBox.Selected[I] then
|
||||
Result := mrOk;
|
||||
PkgList := TList.Create;
|
||||
try
|
||||
PkgListStr := '';
|
||||
for I := 0 to DependPkgNameListBox.Count - 1 do
|
||||
begin
|
||||
if TPackageLink(fSL.Objects[I]).Origin = ploOnline then
|
||||
if DependPkgNameListBox.Selected[I] then
|
||||
begin
|
||||
if PkgList = '' then
|
||||
PkgList := '"' + DependPkgNameListBox.Items[I] + '"'
|
||||
else
|
||||
PkgList := PkgList + ', "' + DependPkgNameListBox.Items[I] + '"';
|
||||
PackageLink := FindPackageLink(TLazPackageID(DependPkgNameListBox.Items.Objects[I]));
|
||||
if (PackageLink <> nil) and (PackageLink.Origin = ploOnline) then
|
||||
begin
|
||||
PkgList.Add(PackageLink);
|
||||
if PkgListStr = '' then
|
||||
PkgListStr := '"' + PackageLink.Name + '"'
|
||||
else
|
||||
PkgListStr := PkgListStr + ', "' + PackageLink.Name + '"';
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if PkgList.Count > 0 then
|
||||
begin
|
||||
if IDEMessageDialog(lisProjAddInstConfCaption, lisProjAddInstConf + ' ' + PkgListStr + ' ?', mtInformation, [mbYes, mbNo]) = mrYes then
|
||||
Result := OPMInterface.InstallPackages(PkgList);
|
||||
end;
|
||||
finally
|
||||
PkgList.Free;
|
||||
PkgList := nil;
|
||||
end;
|
||||
if PkgList <> '' then
|
||||
begin
|
||||
if MessageDlg(lisPkgInstConf + sLineBreak + PkgList + ' ?', mtInformation, [mbYes, mbNo], 0) = mrNo then
|
||||
Exit;
|
||||
MessageDlg('Not yet implemented!', mtInformation, [mbOk], 0)
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAddPkgDependencyDialog.CloseButtonClick(Sender: TObject);
|
||||
begin
|
||||
ModalResult := mrNone;
|
||||
if InstallOnlinePackages <> mrOk then
|
||||
IDEMessageDialog(lisProjAddInstErrCaption, lisProjAddInstErr, mtError, [mbOk]);
|
||||
end;
|
||||
|
||||
procedure TAddPkgDependencyDialog.AddUniquePackagesToList(APackageID: TLazPackageID);
|
||||
@ -270,8 +310,8 @@ begin
|
||||
end;
|
||||
if Assigned(OPMInterface) then
|
||||
begin
|
||||
cbLocalPkg.Caption := Format(lisLocalPkg, [IntToStr(CntLocalPkg)]);
|
||||
cbOnlinePkg.Caption := Format(lisOnlinePkg, [IntToStr(CntOnlinePkg)]);
|
||||
cbLocalPkg.Caption := Format(lisProjAddLocalPkg, [IntToStr(CntLocalPkg)]);
|
||||
cbOnlinePkg.Caption := Format(lisProjAddOnlinePkg, [IntToStr(CntOnlinePkg)]);
|
||||
BP.CloseButton.Visible := IsInstallButtonVisible;
|
||||
end;
|
||||
finally
|
||||
|
||||
Loading…
Reference in New Issue
Block a user