IDE: added dialog to explore the current package links

git-svn-id: trunk@12811 -
This commit is contained in:
mattias 2007-11-10 13:59:51 +00:00
parent 5b8a949fe8
commit 12a7912211
11 changed files with 390 additions and 9 deletions

3
.gitattributes vendored
View File

@ -3225,6 +3225,9 @@ packager/pkgfileslcl.inc svneol=native#text/plain
packager/pkggraphexplorer.lfm svneol=native#text/plain
packager/pkggraphexplorer.lrs svneol=native#text/plain
packager/pkggraphexplorer.pas svneol=native#text/pascal
packager/pkglinksdlg.lfm svneol=native#text/plain
packager/pkglinksdlg.lrs svneol=native#text/plain
packager/pkglinksdlg.pas svneol=native#text/plain
packager/pkgmanager.pas svneol=native#text/pascal
packager/pkgoptionsdlg.lfm svneol=native#text/plain
packager/pkgoptionsdlg.lrs svneol=native#text/plain

View File

@ -779,7 +779,6 @@ begin
repeat
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='')
or ((FileInfo.Attr and faDirectory)<>0) then continue;
DebugLn(['TBuildManager.CheckUnitPathForAmbiguousPascalFiles AAA1 ',CurDir+FileInfo.Name]);
if FilenameIsPascalUnit(FileInfo.Name) then
CurUnitTree:=SourceUnitTree
else if (CompareFileExt(FileInfo.Name,CompiledExt,false)=0) then
@ -790,7 +789,7 @@ begin
if (CurUnitName='') or (not IsValidIdent(CurUnitName)) then
continue;
CurFilename:=CurDir+FileInfo.Name;
DebugLn(['TBuildManager.CheckUnitPathForAmbiguousPascalFiles ',CurUnitName,' ',CurFilename]);
//DebugLn(['TBuildManager.CheckUnitPathForAmbiguousPascalFiles ',CurUnitName,' ',CurFilename]);
// check if unit already found
ANode:=CurUnitTree.FindKey(PChar(CurUnitName),
TListSortCompare(@CompareUnitNameAndUnitFile));

View File

@ -161,6 +161,9 @@ resourcestring
lisMenuSaveAs = 'Save As ...';
lisMenuSaveAll = 'Save All';
lisMenuClose = 'Close';
lisPLDOnlyExistingFiles = 'Only existing files';
lisPLDShowGlobalLinks = 'Show global links';
lisPLDShowUserLinks = 'Show user links';
lisKMCloseAll = 'Close All';
lisCTDefDefineTemplates = 'Define templates';
lisMenuCloseAll = 'Close all editor files';
@ -274,6 +277,8 @@ resourcestring
lisMenuViewLocalVariables = 'Local Variables';
lisMenuViewCallStack = 'Call Stack';
lisMenuViewDebugOutput = 'Debug output';
lisMenuIDEInternals = 'IDE internals';
lisMenuPackageLinks = 'Package links ...';
lisMenuNewProject = 'New Project ...';
lisMenuNewProjectFromFile = 'New Project from file ...';
@ -1379,6 +1384,7 @@ resourcestring
dlgPromptOnReplace = 'Prompt On Replace';
lisAskBeforeReplacingEachFoundText = 'Ask before replacing each found text';
dlgSROrigin = 'Origin';
lisPLDExists = 'Exists';
dlgFromCursor = 'From Cursor';
dlgEntireScope = 'Entire Scope';
dlgScope = 'Scope';
@ -1412,6 +1418,7 @@ resourcestring
lisFRIinAllOpenPackagesAndProjects = 'in all open packages and projects';
lisFRIRenameAllReferences = 'Rename all References';
dlgGlobal = 'Global';
lisPLDUser = 'User';
dlgSelectedText = 'Selected Text';
dlgDirection = 'Direction';
lisFRForwardSearch = 'Forward search';
@ -3447,6 +3454,7 @@ resourcestring
lisAutomaticallyOnAddSymbol = 'symbol';
lisPckOptsThisPackageProvidesTheSameAsTheFollowingPackages = 'This package '
+'provides the same as the following packages:';
lisPLDPackageLinks = 'Package Links';
implementation

View File

@ -198,6 +198,8 @@ type
itmViewLocals: TIDEMenuCommand;
itmViewCallStack: TIDEMenuCommand;
itmViewDebugOutput: TIDEMenuCommand;
//itmViewIDEInternalsWindows: TIDEMenuSection;
itmViewPackageLinks: TIDEMenuCommand;
// project menu
//mnuProject: TIDEMenuSection;

View File

@ -535,6 +535,10 @@ begin
CreateMenuItem(itmViewDebugWindows,itmViewCallStack,'itmViewCallStack',lisMenuViewCallStack,'debugger_call_stack');
CreateMenuItem(itmViewDebugWindows,itmViewDebugOutput,'itmViewDebugOutput',lisMenuViewDebugOutput,'debugger_output');
end;
CreateMenuSubSection(ParentMI, itmViewIDEInternalsWindows, 'itmViewIDEInternalsWindows', lisMenuIDEInternals, '');
begin
CreateMenuItem(itmViewIDEInternalsWindows, itmViewPackageLinks, 'itmViewPackageLinks', lisMenuPackageLinks, '');
end;
end;
end;
@ -865,6 +869,7 @@ begin
itmViewAnchorEditor.Command:=GetCommand(ecViewAnchorEditor);
itmViewComponentPalette.Command:=GetCommand(ecToggleCompPalette);
itmViewIDESpeedButtons.Command:=GetCommand(ecToggleIDESpeedBtns);
//itmViewPackageLinks.Command:=GetCommand(ec?);
// project menu
itmProjectNew.Command:=GetCommand(ecNewProject);

View File

@ -309,6 +309,7 @@ var
itmViewUnitWindows: TIDEMenuSection;
itmViewSecondaryWindows: TIDEMenuSection;
itmViewDebugWindows: TIDEMenuSection;
itmViewIDEInternalsWindows: TIDEMenuSection;
// project menu
mnuProject: TIDEMenuSection;

View File

@ -66,7 +66,11 @@ type
ploUser
);
TPkgLinkOrigins = set of TPkgLinkOrigin;
const
AllPkgLinkOrigins = [low(TPkgLinkOrigin)..high(TPkgLinkOrigin)];
type
TPackageLink = class(TLazPackageID)
private
FAutoCheckExists: boolean;
@ -147,7 +151,8 @@ type
function FindLinkWithPkgName(const PkgName: string): TPackageLink;
function FindLinkWithDependency(Dependency: TPkgDependency): TPackageLink;
function FindLinkWithPackageID(APackageID: TLazPackageID): TPackageLink;
procedure IteratePackages(MustExist: boolean; Event: TIteratePackagesEvent);
procedure IteratePackages(MustExist: boolean; Event: TIteratePackagesEvent;
Origins: TPkgLinkOrigins = AllPkgLinkOrigins);
function AddUserLink(APackage: TLazPackage): TPackageLink;
function AddUserLink(const PkgFilename, PkgName: string): TPackageLink;
procedure RemoveLink(APackageID: TLazPackageID; FreeID: boolean);
@ -159,7 +164,9 @@ type
end;
var
PkgLinks: TPackageLinks; // set by the PkgBoss
PkgLinks: TPackageLinks = nil; // set by the PkgBoss
function ComparePackageLinks(Data1, Data2: Pointer): integer;
implementation
@ -735,10 +742,12 @@ begin
end;
procedure TPackageLinks.IteratePackages(MustExist: boolean;
Event: TIteratePackagesEvent);
Event: TIteratePackagesEvent; Origins: TPkgLinkOrigins);
begin
IteratePackagesInTree(MustExist,FUserLinksSortID,Event);
IteratePackagesInTree(MustExist,FGlobalLinks,Event);
if ploUser in Origins then
IteratePackagesInTree(MustExist,FUserLinksSortID,Event);
if ploGlobal in Origins then
IteratePackagesInTree(MustExist,FGlobalLinks,Event);
end;
function TPackageLinks.AddUserLink(APackage: TLazPackage): TPackageLink;

93
packager/pkglinksdlg.lfm Normal file
View File

@ -0,0 +1,93 @@
object PackageLinksDialog: TPackageLinksDialog
Left = 290
Height = 451
Top = 189
Width = 659
HorzScrollBar.Page = 658
VertScrollBar.Page = 450
Caption = 'PackageLinksDialog'
ClientHeight = 451
ClientWidth = 659
OnCreate = FormCreate
object CloseBitBtn: TBitBtn
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 579
Height = 36
Top = 409
Width = 74
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Around = 6
Caption = '&Close'
Kind = bkClose
ModalResult = 1
NumGlyphs = 0
TabOrder = 0
end
object ScopeGroupBox: TGroupBox
Height = 53
Width = 659
Align = alTop
AutoSize = True
Caption = 'ScopeGroupBox'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 6
ChildSizing.VerticalSpacing = 6
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 34
ClientWidth = 655
TabOrder = 1
object FileMustExistCheckBox: TCheckBox
Left = 6
Height = 22
Top = 6
Width = 168
Caption = 'FileMustExistCheckBox'
OnChange = FileMustExistCheckBoxChange
TabOrder = 0
end
object ShowGlobalLinksCheckBox: TCheckBox
Left = 180
Height = 22
Top = 6
Width = 193
Caption = 'ShowGlobalLinksCheckBox'
Checked = True
OnChange = ShowGlobalLinksCheckBoxChange
State = cbChecked
TabOrder = 1
end
object ShowUserLinksCheckBox: TCheckBox
Left = 379
Height = 22
Top = 6
Width = 183
Caption = 'ShowUserLinksCheckBox'
Checked = True
OnChange = ShowUserLinksCheckBoxChange
State = cbChecked
TabOrder = 2
end
end
object PkgStringGrid: TStringGrid
AnchorSideBottom.Control = CloseBitBtn
Height = 350
Top = 53
Width = 659
Align = alTop
Anchors = [akTop, akLeft, akRight, akBottom]
ColCount = 4
FixedColor = clBtnFace
FixedCols = 0
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goTabs, goColSpanning, goDblClickAutoSize, goSmoothScroll]
RowCount = 5
ScrollBars = ssAutoBoth
TabOrder = 2
TabStop = True
end
end

36
packager/pkglinksdlg.lrs Normal file
View File

@ -0,0 +1,36 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TPackageLinksDialog','FORMDATA',[
'TPF0'#19'TPackageLinksDialog'#18'PackageLinksDialog'#4'Left'#3'"'#1#6'Height'
+#3#195#1#3'Top'#3#189#0#5'Width'#3#147#2#18'HorzScrollBar.Page'#3#146#2#18'V'
+'ertScrollBar.Page'#3#194#1#7'Caption'#6#18'PackageLinksDialog'#12'ClientHei'
+'ght'#3#195#1#11'ClientWidth'#3#147#2#8'OnCreate'#7#10'FormCreate'#0#7'TBitB'
+'tn'#11'CloseBitBtn'#23'AnchorSideRight.Control'#7#5'Owner'#20'AnchorSideRig'
+'ht.Side'#7#9'asrBottom'#24'AnchorSideBottom.Control'#7#5'Owner'#21'AnchorSi'
+'deBottom.Side'#7#9'asrBottom'#4'Left'#3'C'#2#6'Height'#2'$'#3'Top'#3#153#1#5
+'Width'#2'J'#7'Anchors'#11#7'akRight'#8'akBottom'#0#8'AutoSize'#9#20'BorderS'
+'pacing.Around'#2#6#7'Caption'#6#6'&Close'#4'Kind'#7#7'bkClose'#11'ModalResu'
+'lt'#2#1#9'NumGlyphs'#2#0#8'TabOrder'#2#0#0#0#9'TGroupBox'#13'ScopeGroupBox'
+#6'Height'#2'5'#5'Width'#3#147#2#5'Align'#7#5'alTop'#8'AutoSize'#9#7'Caption'
+#6#13'ScopeGroupBox'#28'ChildSizing.LeftRightSpacing'#2#6#28'ChildSizing.Top'
+'BottomSpacing'#2#6#29'ChildSizing.HorizontalSpacing'#2#6#27'ChildSizing.Ver'
+'ticalSpacing'#2#6#18'ChildSizing.Layout'#7#29'cclLeftToRightThenTopToBottom'
+#27'ChildSizing.ControlsPerLine'#2#3#12'ClientHeight'#2'"'#11'ClientWidth'#3
+#143#2#8'TabOrder'#2#1#0#9'TCheckBox'#21'FileMustExistCheckBox'#4'Left'#2#6#6
+'Height'#2#22#3'Top'#2#6#5'Width'#3#168#0#7'Caption'#6#21'FileMustExistCheck'
+'Box'#8'OnChange'#7#27'FileMustExistCheckBoxChange'#8'TabOrder'#2#0#0#0#9'TC'
+'heckBox'#23'ShowGlobalLinksCheckBox'#4'Left'#3#180#0#6'Height'#2#22#3'Top'#2
+#6#5'Width'#3#193#0#7'Caption'#6#23'ShowGlobalLinksCheckBox'#7'Checked'#9#8
+'OnChange'#7#29'ShowGlobalLinksCheckBoxChange'#5'State'#7#9'cbChecked'#8'Tab'
+'Order'#2#1#0#0#9'TCheckBox'#21'ShowUserLinksCheckBox'#4'Left'#3'{'#1#6'Heig'
+'ht'#2#22#3'Top'#2#6#5'Width'#3#183#0#7'Caption'#6#21'ShowUserLinksCheckBox'
+#7'Checked'#9#8'OnChange'#7#27'ShowUserLinksCheckBoxChange'#5'State'#7#9'cbC'
+'hecked'#8'TabOrder'#2#2#0#0#0#11'TStringGrid'#13'PkgStringGrid'#24'AnchorSi'
+'deBottom.Control'#7#11'CloseBitBtn'#6'Height'#3'^'#1#3'Top'#2'5'#5'Width'#3
+#147#2#5'Align'#7#5'alTop'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akB'
+'ottom'#0#8'ColCount'#2#4#10'FixedColor'#7#9'clBtnFace'#9'FixedCols'#2#0#7'O'
+'ptions'#11#15'goFixedVertLine'#15'goFixedHorzLine'#10'goVertLine'#10'goHorz'
+'Line'#13'goRangeSelect'#11'goColSizing'#6'goTabs'#13'goColSpanning'#18'goDb'
+'lClickAutoSize'#14'goSmoothScroll'#0#8'RowCount'#2#5#10'ScrollBars'#7#10'ss'
+'AutoBoth'#8'TabOrder'#2#2#7'TabStop'#9#0#0#0
]);

217
packager/pkglinksdlg.pas Normal file
View File

@ -0,0 +1,217 @@
{ $Id: pkgmanager.pas 12718 2007-11-03 16:56:23Z mattias $ }
{
/***************************************************************************
pkgmanager.pas
--------------
***************************************************************************/
***************************************************************************
* *
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
***************************************************************************
Author: Mattias Gaertner
Abstract:
Dialog showing the package links of the IDE package systems.
}
unit PkgLinksDlg;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons, Grids, AVL_Tree,
FileProcs,
LazarusIDEStrConsts, PackageDefs, PackageLinks;
type
{ TPkgLinkInfo }
TPkgLinkInfo = class(TPackageLink)
public
procedure Assign(Source: TLazPackageID);
property Origin: TPkgLinkOrigin read FOrigin write FOrigin;
end;
{ TPackageLinksDialog }
TPackageLinksDialog = class(TForm)
CloseBitBtn: TBitBtn;
ShowUserLinksCheckBox: TCheckBox;
ShowGlobalLinksCheckBox: TCheckBox;
FileMustExistCheckBox: TCheckBox;
ScopeGroupBox: TGroupBox;
PkgStringGrid: TStringGrid;
procedure FileMustExistCheckBoxChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ShowGlobalLinksCheckBoxChange(Sender: TObject);
procedure ShowUserLinksCheckBoxChange(Sender: TObject);
private
FLinks: TAVLTree;// tree of TPkgLinkInfo sorted for names
FCollectingOrigin: TPkgLinkOrigin;
procedure UpdateAll;
procedure UpdatePackageList;
procedure ClearLinks;
procedure IteratePackages(APackage: TLazPackageID);
public
{ public declarations }
end;
function ShowPackageLinks: TModalResult;
implementation
function ShowPackageLinks: TModalResult;
var
PackageLinksDialog: TPackageLinksDialog;
begin
PackageLinksDialog:=TPackageLinksDialog.Create(nil);
try
Result:=PackageLinksDialog.ShowModal;
finally
PackageLinksDialog.Free;
end;
end;
{ TPackageLinksDialog }
procedure TPackageLinksDialog.FormCreate(Sender: TObject);
begin
Caption:=lisPLDPackageLinks;
CloseBitBtn.Caption:=lisMenuClose;
FileMustExistCheckBox.Caption:=lisPLDOnlyExistingFiles;
ShowGlobalLinksCheckBox.Caption:=lisPLDShowGlobalLinks;
ShowUserLinksCheckBox.Caption:=lisPLDShowUserLinks;
UpdateAll;
end;
procedure TPackageLinksDialog.ShowGlobalLinksCheckBoxChange(Sender: TObject);
begin
UpdatePackageList;
end;
procedure TPackageLinksDialog.ShowUserLinksCheckBoxChange(Sender: TObject);
begin
UpdatePackageList;
end;
procedure TPackageLinksDialog.FileMustExistCheckBoxChange(Sender: TObject);
begin
UpdatePackageList;
end;
procedure TPackageLinksDialog.UpdateAll;
begin
UpdatePackageList;
end;
procedure TPackageLinksDialog.UpdatePackageList;
var
Node: TAVLTreeNode;
Link: TPkgLinkInfo;
i: Integer;
OriginStr: String;
begin
ClearLinks;
FLinks:=TAVLTree.Create(@ComparePackageLinks);
if ShowGlobalLinksCheckBox.Checked then begin
FCollectingOrigin:=ploGlobal;
PkgLinks.IteratePackages(FileMustExistCheckBox.Checked,@IteratePackages,[ploGlobal]);
end;
if ShowUserLinksCheckBox.Checked then begin
FCollectingOrigin:=ploUser;
PkgLinks.IteratePackages(FileMustExistCheckBox.Checked,@IteratePackages,[ploUser]);
end;
PkgStringGrid.ColCount:=5;
PkgStringGrid.RowCount:=FLinks.Count+1;
PkgStringGrid.Cells[0, 0]:=lisDebugOptionsFrmName;
PkgStringGrid.Cells[1, 0]:=lisVersion;
PkgStringGrid.Cells[2, 0]:=dlgSROrigin;
PkgStringGrid.Cells[3, 0]:=lisPLDExists;
PkgStringGrid.Cells[4, 0]:=lisA2PFilename2;
i:=1;
Node:=FLinks.FindLowest;
while Node<>nil do begin
Link:=TPkgLinkInfo(Node.Data);
PkgStringGrid.Cells[0,i]:=Link.Name;
PkgStringGrid.Cells[1,i]:=Link.Version.AsString;
if Link.Origin=ploGlobal then
OriginStr:=dlgGlobal
else
OriginStr:=lisPLDUser;
PkgStringGrid.Cells[2,i]:=OriginStr;
PkgStringGrid.Cells[3,i]:=dbgs(FileExistsCached(Link.Filename));
PkgStringGrid.Cells[4,i]:=Link.Filename;
inc(i);
Node:=FLinks.FindSuccessor(Node);
end;
PkgStringGrid.AutoAdjustColumns;
end;
procedure TPackageLinksDialog.ClearLinks;
begin
if FLinks<>nil then begin
FLinks.FreeAndClear;
FreeAndNil(FLinks);
end;
end;
procedure TPackageLinksDialog.IteratePackages(APackage: TLazPackageID);
var
NewLink: TPkgLinkInfo;
begin
NewLink:=TPkgLinkInfo.Create;
NewLink.Assign(APackage);
NewLink.Origin:=FCollectingOrigin;
FLinks.Add(NewLink);
end;
{ TPkgLinkInfo }
procedure TPkgLinkInfo.Assign(Source: TLazPackageID);
var
Link: TPackageLink;
begin
AssignID(Source);
if Source is TPackageLink then begin
Link:=TPackageLink(Source);
Origin:=Link.Origin;
Filename:=Link.Filename;
AutoCheckExists:=Link.AutoCheckExists;
NotFoundCount:=Link.NotFoundCount;
LastCheckValid:=Link.LastCheckValid;
LastCheck:=Link.LastCheck;
FileDateValid:=Link.FileDateValid;
FileDate:=Link.FileDate;
end;
end;
initialization
{$I pkglinksdlg.lrs}
end.

View File

@ -61,7 +61,7 @@ uses
BrokenDependenciesDlg, CompilerOptions, ExtToolEditDlg, IDETranslations,
TransferMacros, MsgView, BuildLazDialog, NewDialog, IDEDialogs,
ProjectInspector, ComponentPalette, UnitEditor, AddFileToAPackageDlg,
LazarusPackageIntf, PublishProjectDlg, InstallPkgSetDlg,
LazarusPackageIntf, PublishProjectDlg, PkgLinksDlg, InstallPkgSetDlg,
// bosses
BaseBuildManager, BasePkgManager,
MainBar, MainIntf, MainBase;
@ -130,6 +130,7 @@ type
procedure MainIDEitmConfigCustomCompsClicked(Sender: TObject);
procedure MainIDEitmOpenRecentPackageClicked(Sender: TObject);
procedure MainIDEitmPkgOpenPackageClicked(Sender: TObject);
procedure MainIDEViewPackageLinksClicked(Sender: TObject);
// component palette
procedure IDEComponentPaletteEndUpdate(Sender: TObject;
@ -954,6 +955,11 @@ begin
DoShowOpenInstalledPckDlg;
end;
procedure TPkgManager.MainIDEViewPackageLinksClicked(Sender: TObject);
begin
ShowPackageLinks;
end;
procedure TPkgManager.MainIDEitmOpenRecentPackageClicked(Sender: TObject);
procedure UpdateEnvironment;
@ -1813,6 +1819,8 @@ begin
{$IFDEF CustomIDEComps}
itmCompsConfigCustomComps.OnClick :=@MainIDEitmConfigCustomCompsClicked;
{$ENDIF}
itmViewPackageLinks.OnClick := @MainIDEViewPackageLinksClicked;
end;
SetRecentPackagesMenu;