1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
{
***************************************************************************
* *
* This source is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This code is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
* *
***************************************************************************
}
unit MissingPkgFilesDlg;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ButtonPanel,
ComCtrls, FileProcs, LazFileCache,
PackageDefs, LazarusIDEStrConsts;
type
{ TMissingPkgFilesDialog }
TMissingPkgFilesDialog = class(TForm)
ButtonPanel1: TButtonPanel;
FilesTreeView: TTreeView;
procedure ButtonPanel1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
FLazPackage: TLazPackage;
procedure SetLazPackage(const AValue: TLazPackage);
procedure UpdateFilesList;
public
property LazPackage: TLazPackage read FLazPackage write SetLazPackage;
end;
function ShowMissingPkgFilesDialog(APackage: TLazPackage): TModalResult;
implementation
function ShowMissingPkgFilesDialog(APackage: TLazPackage): TModalResult;
var
Dlg: TMissingPkgFilesDialog;
begin
Dlg:=TMissingPkgFilesDialog.Create(nil);
try
Dlg.LazPackage:=APackage;
Result:=Dlg.ShowModal;
finally
Dlg.Free;
end;
end;
{$R *.lfm}
{ TMissingPkgFilesDialog }
procedure TMissingPkgFilesDialog.FormCreate(Sender: TObject);
begin
ButtonPanel1.CancelButton.Caption:=lisCancel;
end;
procedure TMissingPkgFilesDialog.ButtonPanel1Click(Sender: TObject);
begin
if LazPackage<>nil then
LazPackage.RemoveNonExistingFiles;
end;
procedure TMissingPkgFilesDialog.SetLazPackage(const AValue: TLazPackage);
begin
if FLazPackage=AValue then exit;
FLazPackage:=AValue;
if LazPackage<>nil then
Caption:=Format(lisPEMissingFilesOfPackage, [LazPackage.IDAsString]);
UpdateFilesList;
end;
procedure TMissingPkgFilesDialog.UpdateFilesList;
var
i: Integer;
j: Integer;
PkgFile: TPkgFile;
RealFilename: String;
s: String;
begin
FilesTreeView.BeginUpdate;
i:=0;
if LazPackage<>nil then begin
for j:=0 to LazPackage.FileCount-1 do begin
PkgFile:=LazPackage.Files[j];
RealFilename:=PkgFile.GetResolvedFilename;
if (RealFilename<>'') and FileExistsCached(RealFilename) then continue;
s:=PkgFile.Filename;
if FilesTreeView.Items.TopLvlCount>i then
FilesTreeView.Items.TopLvlItems[i].Text:=s
else
FilesTreeView.Items.Add(nil,s);
inc(i);
end;
end;
if i=0 then begin
s:=lisPENoFilesMissingAllFilesExist;
if FilesTreeView.Items.TopLvlCount>i then
FilesTreeView.Items.TopLvlItems[i].Text:=s
else
FilesTreeView.Items.Add(nil,s);
end;
while FilesTreeView.Items.TopLvlCount>i do
FilesTreeView.Items.TopLvlItems[FilesTreeView.Items.TopLvlCount-1].Free;
FilesTreeView.EndUpdate;
if i>0 then begin
ButtonPanel1.OKButton.Caption:=lisPERemoveFiles;
end else begin
ButtonPanel1.OKButton.Caption:=lisMenuOk;
end;
end;
end.
|