mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 11:18:10 +02:00
IDE: package links dlg: delete links
git-svn-id: trunk@40001 -
This commit is contained in:
parent
4a0a600a00
commit
326e98ee73
@ -68,6 +68,7 @@ resourcestring
|
||||
lisNew = 'New';
|
||||
lisClose = 'Close';
|
||||
lrsRescanLplFiles = 'Rescan lpl files';
|
||||
lrsPLDDeleteSelected = 'Delete selected';
|
||||
lisBtnClose = '&Close';
|
||||
lisOk = 'OK';
|
||||
lisMenuOk = '&OK';
|
||||
@ -2299,6 +2300,7 @@ resourcestring
|
||||
lisBFOnRunProjectExecuteTheRunFileCommandInstead = 'On run project execute '
|
||||
+'the Run File command instead';
|
||||
lisCEFilter = '(filter)';
|
||||
lrsPLDUnableToDeleteFile = 'Unable to delete file "%s"';
|
||||
lisPESortFilesAlphabetically = 'Sort files alphabetically';
|
||||
lisPEShowDirectoryHierarchy = 'Show directory hierarchy';
|
||||
dlgCaseSensitive = '&Case sensitive';
|
||||
|
@ -151,6 +151,7 @@ object PackageLinksDialog: TPackageLinksDialog
|
||||
ClientWidth = 659
|
||||
TabOrder = 2
|
||||
object CloseBitBtn: TBitBtn
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = BtnPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = BtnPanel
|
||||
@ -168,9 +169,13 @@ object PackageLinksDialog: TPackageLinksDialog
|
||||
TabOrder = 0
|
||||
end
|
||||
object UpdateGlobalLinksButton: TButton
|
||||
Left = 7
|
||||
AnchorSideLeft.Control = DeleteSelectedButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = CloseBitBtn
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 150
|
||||
Height = 27
|
||||
Top = 7
|
||||
Top = 8
|
||||
Width = 152
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
@ -178,6 +183,20 @@ object PackageLinksDialog: TPackageLinksDialog
|
||||
OnClick = UpdateGlobalLinksButtonClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object DeleteSelectedButton: TButton
|
||||
AnchorSideLeft.Control = BtnPanel
|
||||
AnchorSideTop.Control = CloseBitBtn
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 7
|
||||
Height = 27
|
||||
Top = 8
|
||||
Width = 137
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'DeleteSelectedButton'
|
||||
OnClick = DeleteSelectedButtonClick
|
||||
TabOrder = 2
|
||||
end
|
||||
end
|
||||
object ProgressBar1: TProgressBar
|
||||
Left = 0
|
||||
@ -193,6 +212,7 @@ object PackageLinksDialog: TPackageLinksDialog
|
||||
top = 190
|
||||
end
|
||||
object GridPopupMenu: TPopupMenu
|
||||
OnPopup = GridPopupMenuPopup
|
||||
left = 206
|
||||
top = 288
|
||||
object CopyCellToClipboardMenuItem: TMenuItem
|
||||
|
@ -68,6 +68,7 @@ type
|
||||
TPackageLinksDialog = class(TForm)
|
||||
BtnPanel: TPanel;
|
||||
CloseBitBtn: TBitBtn;
|
||||
DeleteSelectedButton: TButton;
|
||||
FilterEdit: TEdit;
|
||||
LPKFileValidCheckBox: TCheckBox;
|
||||
LPKFileInvalidCheckBox: TCheckBox;
|
||||
@ -81,11 +82,13 @@ type
|
||||
PkgStringGrid: TStringGrid;
|
||||
UpdateGlobalLinksButton: TButton;
|
||||
procedure CopyCellToClipboardMenuItemClick(Sender: TObject);
|
||||
procedure DeleteSelectedButtonClick(Sender: TObject);
|
||||
procedure FilterEditChange(Sender: TObject);
|
||||
procedure FilterEditEnter(Sender: TObject);
|
||||
procedure FilterEditExit(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure GridPopupMenuPopup(Sender: TObject);
|
||||
procedure LPKFileValidCheckBoxChange(Sender: TObject);
|
||||
procedure LPKFileInvalidCheckBoxChange(Sender: TObject);
|
||||
procedure LPKParsingTimerTimer(Sender: TObject);
|
||||
@ -98,12 +101,17 @@ type
|
||||
FCountLPKValid: integer;
|
||||
FCountLPKInvalid: integer;
|
||||
FCountUserLinks: Integer;
|
||||
FLinks: TAvglVLTree;// tree of TPkgLinkInfo sorted for names
|
||||
FLinks: TAvglVLTree;// tree of TPkgLinkInfo sorted for name and version
|
||||
FCollectingOrigin: TPkgLinkOrigin;
|
||||
fFiles: TStringList;
|
||||
procedure RescanGlobalLinks;
|
||||
procedure UpdateFacets;
|
||||
procedure UpdatePackageList;
|
||||
procedure ClearLinks;
|
||||
procedure IteratePackages(APackage: TLazPackageID);
|
||||
function GetLinkAtRow(Row: integer): TPkgLinkInfo;
|
||||
function GetLinkWithEffectiveFilename(Filename: string;
|
||||
Origins: TPkgLinkOrigins): TPkgLinkInfo;
|
||||
public
|
||||
property CountLPKValid: integer read FCountLPKValid;
|
||||
property CountLPKInvalid: integer read FCountLPKInvalid;
|
||||
@ -133,9 +141,11 @@ end;
|
||||
|
||||
procedure TPackageLinksDialog.FormCreate(Sender: TObject);
|
||||
begin
|
||||
fFiles:=TStringList.Create;
|
||||
Caption:=lisPLDPackageLinks;
|
||||
ScopeGroupBox.Caption:=dlgScope;
|
||||
CopyCellToClipboardMenuItem.Caption:=srkmecCopy;
|
||||
DeleteSelectedButton.Caption:=lrsPLDDeleteSelected;
|
||||
UpdateGlobalLinksButton.Caption:=lrsRescanLplFiles;
|
||||
CloseBitBtn.Caption:=lisClose;
|
||||
FilterEdit.Text:=lisCEFilter;
|
||||
@ -158,6 +168,35 @@ begin
|
||||
PkgStringGrid.CopyToClipboard(true);
|
||||
end;
|
||||
|
||||
procedure TPackageLinksDialog.DeleteSelectedButtonClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
Link: TPkgLinkInfo;
|
||||
ErrMsg: String;
|
||||
begin
|
||||
ErrMsg:='';
|
||||
for i:=1 to PkgStringGrid.RowCount-1 do begin
|
||||
if PkgStringGrid.Cells[0,i]=PkgStringGrid.Columns[0].ValueChecked then begin
|
||||
Link:=GetLinkAtRow(i);
|
||||
if Link=nil then exit;
|
||||
if Link.Origin=ploGlobal then begin
|
||||
// delete lpl file
|
||||
if FileExistsCached(Link.LPLFilename) then begin
|
||||
if not DeleteFileUTF8(Link.LPLFilename) then
|
||||
ErrMsg+=Format(lrsPLDUnableToDeleteFile, [Link.LPLFilename])+
|
||||
LineEnding;
|
||||
end;
|
||||
end else begin
|
||||
// delete user link
|
||||
PkgLinks.RemoveUserLinks(Link);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
RescanGlobalLinks;
|
||||
UpdatePackageList;
|
||||
PkgLinks.SaveUserLinks;
|
||||
end;
|
||||
|
||||
procedure TPackageLinksDialog.FilterEditEnter(Sender: TObject);
|
||||
begin
|
||||
if FilterEdit.Text=lisCEFilter then
|
||||
@ -174,6 +213,12 @@ procedure TPackageLinksDialog.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
LPKInfoCache.EndLPKReader;
|
||||
ClearLinks;
|
||||
FreeAndNil(fFiles);
|
||||
end;
|
||||
|
||||
procedure TPackageLinksDialog.GridPopupMenuPopup(Sender: TObject);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TPackageLinksDialog.LPKFileValidCheckBoxChange(Sender: TObject);
|
||||
@ -211,8 +256,7 @@ end;
|
||||
|
||||
procedure TPackageLinksDialog.UpdateGlobalLinksButtonClick(Sender: TObject);
|
||||
begin
|
||||
PkgLinks.ClearGlobalLinks;
|
||||
PkgLinks.UpdateGlobalLinks;
|
||||
RescanGlobalLinks;
|
||||
UpdatePackageList;
|
||||
end;
|
||||
|
||||
@ -331,14 +375,12 @@ begin
|
||||
|
||||
i:=1;
|
||||
Node:=FLinks.FindLowest;
|
||||
fFiles.Clear;
|
||||
while Node<>nil do begin
|
||||
Link:=TPkgLinkInfo(Node.Data);
|
||||
Node:=Node.Successor;
|
||||
|
||||
Info:=Link.LPKInfo;
|
||||
if Info<>nil then begin
|
||||
|
||||
end;
|
||||
fFiles.Add(Link.EffectiveFilename);
|
||||
|
||||
PkgStringGrid.Cells[0,i]:=PkgStringGrid.Columns[0].ValueUnchecked;
|
||||
PkgStringGrid.Cells[1,i]:=Link.Name;
|
||||
@ -378,6 +420,12 @@ begin
|
||||
CountLPKInvalid)]);
|
||||
end;
|
||||
|
||||
procedure TPackageLinksDialog.RescanGlobalLinks;
|
||||
begin
|
||||
PkgLinks.ClearGlobalLinks;
|
||||
PkgLinks.UpdateGlobalLinks;
|
||||
end;
|
||||
|
||||
procedure TPackageLinksDialog.ClearLinks;
|
||||
begin
|
||||
if FLinks<>nil then begin
|
||||
@ -396,6 +444,34 @@ begin
|
||||
FLinks.Add(NewLink);
|
||||
end;
|
||||
|
||||
function TPackageLinksDialog.GetLinkAtRow(Row: integer): TPkgLinkInfo;
|
||||
var
|
||||
Origin: TPkgLinkOrigin;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (Row<1) or (Row>fFiles.Count) or (Row>=PkgStringGrid.RowCount) then exit;
|
||||
if PkgStringGrid.Cells[3,Row]=lisPLDGlobal then
|
||||
Origin:=ploGlobal
|
||||
else
|
||||
Origin:=ploUser;
|
||||
Result:=GetLinkWithEffectiveFilename(fFiles[Row-1],[Origin]);
|
||||
end;
|
||||
|
||||
function TPackageLinksDialog.GetLinkWithEffectiveFilename(Filename: string;
|
||||
Origins: TPkgLinkOrigins): TPkgLinkInfo;
|
||||
var
|
||||
Node: TAvgLvlTreeNode;
|
||||
begin
|
||||
Node:=FLinks.FindLowest;
|
||||
while Node<>nil do begin
|
||||
Result:=TPkgLinkInfo(Node.Data);
|
||||
if (Result.Origin in Origins) and (Result.EffectiveFilename=Filename) then
|
||||
exit;
|
||||
Node:=Node.Successor;
|
||||
end;
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
{ TPkgLinkInfo }
|
||||
|
||||
constructor TPkgLinkInfo.Create;
|
||||
|
Loading…
Reference in New Issue
Block a user