From c1636ed4e7bcb4748c93467695ce9eadef2ea4d4 Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 16 Jun 2013 19:18:06 +0000 Subject: [PATCH] cody: unit deps: additional files git-svn-id: trunk@41731 - --- components/codetools/ide/codyunitdepwnd.lfm | 398 +++++--------------- components/codetools/ide/codyunitdepwnd.pas | 208 ++++++---- 2 files changed, 238 insertions(+), 368 deletions(-) diff --git a/components/codetools/ide/codyunitdepwnd.lfm b/components/codetools/ide/codyunitdepwnd.lfm index e1a4bde2a4..07b755d634 100644 --- a/components/codetools/ide/codyunitdepwnd.lfm +++ b/components/codetools/ide/codyunitdepwnd.lfm @@ -1,7 +1,7 @@ object UnitDependenciesWindow: TUnitDependenciesWindow - Left = 949 + Left = 1165 Height = 440 - Top = 246 + Top = 178 Width = 620 Caption = 'UnitDependenciesWindow' ClientHeight = 440 @@ -43,341 +43,108 @@ object UnitDependenciesWindow: TUnitDependenciesWindow ClientWidth = 616 object ScopePanel: TPanel Left = 0 - Height = 280 + Height = 33 Top = 0 Width = 616 Align = alTop AutoSize = True - ClientHeight = 280 + ClientHeight = 33 ClientWidth = 616 TabOrder = 0 - object ShowScopeCheckBox: TCheckBox + object UnitScopeAddFilesCheckBox: TCheckBox AnchorSideLeft.Control = ScopePanel - AnchorSideTop.Control = ScopePanel + AnchorSideTop.Control = UnitScopeAddFilesComboBox + AnchorSideTop.Side = asrCenter Left = 3 Height = 24 - Top = 1 - Width = 91 - BorderSpacing.Left = 2 - BorderSpacing.Right = 2 - Caption = 'Show Scope' + Top = 4 + Width = 111 + BorderSpacing.Around = 2 + Caption = 'Additional files:' + ParentShowHint = False + ShowHint = True TabOrder = 0 end - object StartSearchingInGroupBox: TGroupBox - AnchorSideLeft.Control = ScopePanel - AnchorSideTop.Control = ShowScopeCheckBox - AnchorSideTop.Side = asrBottom + object UnitScopeAddFilesButton: TButton + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = UnitScopeAddFilesComboBox + AnchorSideTop.Side = asrCenter AnchorSideRight.Control = ScopePanel AnchorSideRight.Side = asrBottom - Left = 1 - Height = 155 - Top = 25 - Width = 614 - Anchors = [akTop, akLeft, akRight] + Left = 562 + Height = 27 + Top = 3 + Width = 53 + Anchors = [akTop, akRight] AutoSize = True - Caption = 'StartSearchingInGroupBox' - ClientHeight = 138 - ClientWidth = 610 + Caption = 'Browse' TabOrder = 1 - object ScopeStartIncludeUnitsInGrpsSrcDirsCheckBox: TCheckBox - AnchorSideLeft.Control = StartSearchingInGroupBox - AnchorSideTop.Control = ScopeStartGroupsButton - AnchorSideTop.Side = asrBottom - Left = 2 - Height = 24 - Top = 31 - Width = 282 - BorderSpacing.Around = 2 - Caption = 'ScopeStartIncludeUnitsInGrpsSrcDirsCheckBox' - TabOrder = 0 - end - object UnitScopeAddFilesCheckBox: TCheckBox - AnchorSideLeft.Control = StartSearchingInGroupBox - AnchorSideTop.Control = UnitScopeAddFilesEdit - AnchorSideTop.Side = asrCenter - Left = 2 - Height = 24 - Top = 57 - Width = 111 - BorderSpacing.Around = 2 - Caption = 'Additional files:' - TabOrder = 1 - end - object UnitScopeAddFilesEdit: TEdit - AnchorSideLeft.Control = UnitScopeAddFilesCheckBox - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = ScopeStartIncludeUnitsInGrpsSrcDirsCheckBox - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = UnitScopeAddFilesButton - Left = 115 - Height = 25 - Top = 57 - Width = 440 - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Around = 2 - TabOrder = 2 - Text = 'UnitScopeAddFilesEdit' - end - object UnitScopeNameOnlyFilterCheckBox: TCheckBox - AnchorSideLeft.Control = StartSearchingInGroupBox - AnchorSideTop.Control = UnitScopeNameOnlyFilterEdit - AnchorSideTop.Side = asrCenter - Left = 2 - Height = 24 - Top = 84 - Width = 149 - BorderSpacing.Around = 2 - Caption = 'Only units with names:' - TabOrder = 3 - end - object UnitScopeNameOnlyFilterEdit: TEdit - AnchorSideLeft.Control = UnitScopeNameOnlyFilterCheckBox - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = UnitScopeAddFilesEdit - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = UnitScopeNameOnlyFilterRegExCheckBox - Left = 153 - Height = 25 - Top = 84 - Width = 322 - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Around = 2 - TabOrder = 4 - Text = 'UnitScopeNameOnlyFilterEdit' - end - object UnitScopeNameOnlyFilterRegExCheckBox: TCheckBox - AnchorSideTop.Control = UnitScopeNameOnlyFilterEdit - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = StartSearchingInGroupBox - AnchorSideRight.Side = asrBottom - Left = 477 - Height = 24 - Top = 84 - Width = 131 - Anchors = [akTop, akRight] - BorderSpacing.Around = 2 - Caption = 'Regular Expression' - TabOrder = 5 - end - object UnitScopeNameExcludeFilterCheckBox: TCheckBox - AnchorSideLeft.Control = StartSearchingInGroupBox - AnchorSideTop.Control = UnitScopeNameExcludeFilterEdit - AnchorSideTop.Side = asrCenter - Left = 2 - Height = 24 - Top = 111 - Width = 167 - BorderSpacing.Around = 2 - Caption = 'Exclude units with names:' - TabOrder = 6 - end - object UnitScopeNameExcludeFilterEdit: TEdit - AnchorSideLeft.Control = UnitScopeNameExcludeFilterCheckBox - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = UnitScopeNameOnlyFilterEdit - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = UnitScopeNameExcludeFilterRegExCheckBox - Left = 171 - Height = 25 - Top = 111 - Width = 304 - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Around = 2 - TabOrder = 7 - Text = 'UnitScopeNameExcludeFilterEdit' - end - object UnitScopeNameExcludeFilterRegExCheckBox: TCheckBox - AnchorSideTop.Control = UnitScopeNameExcludeFilterEdit - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = StartSearchingInGroupBox - AnchorSideRight.Side = asrBottom - Left = 477 - Height = 24 - Top = 111 - Width = 131 - Anchors = [akTop, akRight] - BorderSpacing.Around = 2 - Caption = 'Regular Expression' - TabOrder = 8 - end - object ScopeStartGroupsButton: TButton - AnchorSideLeft.Control = StartSearchingInGroupBox - AnchorSideTop.Control = StartSearchingInGroupBox - Left = 2 - Height = 27 - Top = 2 - Width = 150 - AutoSize = True - BorderSpacing.Around = 2 - Caption = 'ScopeStartGroupsButton' - TabOrder = 9 - end - object UnitScopeAddFilesButton: TButton - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = UnitScopeAddFilesEdit - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = StartSearchingInGroupBox - AnchorSideRight.Side = asrBottom - Left = 557 - Height = 27 - Top = 56 - Width = 53 - Anchors = [akTop, akRight] - AutoSize = True - Caption = 'Browse' - TabOrder = 10 - end end - object ContinueSearchingInGroupBox: TGroupBox - AnchorSideLeft.Control = ScopePanel - AnchorSideTop.Control = StartSearchingInGroupBox - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = ScopePanel - AnchorSideRight.Side = asrBottom - Left = 1 - Height = 99 - Top = 180 - Width = 614 + object UnitScopeAddFilesComboBox: TComboBox + AnchorSideLeft.Control = UnitScopeAddFilesCheckBox + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = ScopePanel + AnchorSideRight.Control = UnitScopeAddFilesButton + Left = 116 + Height = 27 + Top = 3 + Width = 444 Anchors = [akTop, akLeft, akRight] - AutoSize = True - Caption = 'ContinueSearchingInGroupBox' - ClientHeight = 82 - ClientWidth = 610 + BorderSpacing.Around = 2 + ItemHeight = 0 TabOrder = 2 - object ContinueInUsedPackagesCheckBox: TCheckBox - AnchorSideLeft.Control = ContinueSearchingInGroupBox - AnchorSideTop.Control = ContinueSearchingInGroupBox - Left = 2 - Height = 24 - Top = 2 - Width = 216 - BorderSpacing.Around = 2 - Caption = 'ContinueInUsedPackagesCheckBox' - TabOrder = 0 - end - object ContinueOnlyPkgWithNameCheckBox: TCheckBox - AnchorSideLeft.Control = ContinueSearchingInGroupBox - AnchorSideTop.Control = ContinueOnlyPkgEdit - AnchorSideTop.Side = asrCenter - Left = 2 - Height = 24 - Top = 28 - Width = 172 - BorderSpacing.Around = 2 - Caption = 'Only packages with names:' - TabOrder = 1 - end - object ContinueOnlyPkgEdit: TEdit - AnchorSideLeft.Control = ContinueOnlyPkgWithNameCheckBox - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = ContinueInUsedPackagesCheckBox - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = ContinueOnlyPkgWithNameRegExCheckBox - Left = 176 - Height = 25 - Top = 28 - Width = 299 - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Around = 2 - TabOrder = 2 - Text = 'ContinueOnlyPkgEdit' - end - object ContinueOnlyPkgWithNameRegExCheckBox: TCheckBox - AnchorSideTop.Control = ContinueOnlyPkgEdit - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = ContinueSearchingInGroupBox - AnchorSideRight.Side = asrBottom - Left = 477 - Height = 24 - Top = 28 - Width = 131 - Anchors = [akTop, akRight] - BorderSpacing.Around = 2 - Caption = 'Regular Expression' - TabOrder = 3 - end - object ContinueExcludePkgCheckBox: TCheckBox - AnchorSideLeft.Control = ContinueSearchingInGroupBox - AnchorSideTop.Control = ContinueExcludePkgEdit - AnchorSideTop.Side = asrCenter - Left = 2 - Height = 24 - Top = 55 - Width = 190 - BorderSpacing.Around = 2 - Caption = 'Exclude packages with names:' - TabOrder = 4 - end - object ContinueExcludePkgEdit: TEdit - AnchorSideLeft.Control = ContinueExcludePkgCheckBox - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = ContinueOnlyPkgEdit - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = ContinueExcludePkgRegExCheckBox - Left = 194 - Height = 25 - Top = 55 - Width = 281 - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Around = 2 - TabOrder = 5 - Text = 'ContinueExcludePkgEdit' - end - object ContinueExcludePkgRegExCheckBox: TCheckBox - AnchorSideTop.Control = ContinueExcludePkgEdit - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = ContinueSearchingInGroupBox - AnchorSideRight.Side = asrBottom - Left = 477 - Height = 24 - Top = 55 - Width = 131 - Anchors = [akTop, akRight] - BorderSpacing.Around = 2 - Caption = 'Regular Expression' - TabOrder = 6 - end + Text = 'UnitScopeAddFilesComboBox' end end object AllUnitsGroupBox: TGroupBox Left = 0 - Height = 109 - Top = 280 + Height = 356 + Top = 33 Width = 248 Align = alLeft Caption = 'AllUnitsGroupBox' - ClientHeight = 92 + ClientHeight = 339 ClientWidth = 244 TabOrder = 1 object AllUnitsShowGroupNodesSpeedButton: TSpeedButton AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = AllUnitsGroupBox + AnchorSideTop.Control = AllUnitsFilterEdit + AnchorSideTop.Side = asrCenter AnchorSideRight.Control = AllUnitsShowDirsSpeedButton Left = 198 Height = 22 - Top = 0 + Top = 1 Width = 23 + AllowAllUp = True Anchors = [akTop, akRight] + GroupIndex = 12 + ShowHint = True + ParentShowHint = False end object AllUnitsShowDirsSpeedButton: TSpeedButton AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = AllUnitsGroupBox + AnchorSideTop.Control = AllUnitsFilterEdit + AnchorSideTop.Side = asrCenter AnchorSideRight.Control = AllUnitsGroupBox AnchorSideRight.Side = asrBottom Left = 221 Height = 22 - Top = 0 + Top = 1 Width = 23 + AllowAllUp = True Anchors = [akTop, akRight] + GroupIndex = 13 + ShowHint = True + ParentShowHint = False end object AllUnitsFilterEdit: TEdit AnchorSideLeft.Control = AllUnitsGroupBox AnchorSideTop.Control = AllUnitsGroupBox - AnchorSideRight.Control = AllUnitsShowGroupNodesSpeedButton + AnchorSideRight.Control = AllUnitsMultiselectSpeedButton Left = 0 Height = 25 Top = 0 - Width = 198 + Width = 175 Anchors = [akTop, akLeft, akRight] TabOrder = 0 Text = 'AllUnitsFilterEdit' @@ -388,9 +155,11 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideRight.Control = AllUnitsSearchPrevSpeedButton Left = 198 Height = 22 - Top = 68 + Top = 315 Width = 23 Anchors = [akTop, akRight] + ShowHint = True + ParentShowHint = False end object AllUnitsSearchPrevSpeedButton: TSpeedButton AnchorSideTop.Control = AllUnitsSearchEdit @@ -399,9 +168,11 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideRight.Side = asrBottom Left = 221 Height = 22 - Top = 68 + Top = 315 Width = 23 Anchors = [akTop, akRight] + ShowHint = True + ParentShowHint = False end object AllUnitsTreeView: TTreeView AnchorSideLeft.Control = AllUnitsGroupBox @@ -411,12 +182,14 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = AllUnitsSearchEdit Left = 0 - Height = 42 + Height = 289 Top = 25 Width = 244 Anchors = [akTop, akLeft, akRight, akBottom] DefaultItemHeight = 18 + ReadOnly = True TabOrder = 1 + Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] end object AllUnitsSearchEdit: TEdit AnchorSideLeft.Control = AllUnitsGroupBox @@ -425,27 +198,42 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideBottom.Side = asrBottom Left = 0 Height = 25 - Top = 67 + Top = 314 Width = 198 Anchors = [akLeft, akRight, akBottom] TabOrder = 2 Text = 'AllUnitsSearchEdit' end + object AllUnitsMultiselectSpeedButton: TSpeedButton + AnchorSideTop.Control = AllUnitsFilterEdit + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = AllUnitsShowGroupNodesSpeedButton + Left = 175 + Height = 22 + Top = 1 + Width = 23 + AllowAllUp = True + Anchors = [akTop, akRight] + GroupIndex = 11 + OnClick = AllUnitsMultiselectSpeedButtonClick + ShowHint = True + ParentShowHint = False + end end object UnitsSplitter: TSplitter Left = 248 - Height = 109 - Top = 280 + Height = 356 + Top = 33 Width = 5 end object SelectedUnitsGroupBox: TGroupBox Left = 253 - Height = 109 - Top = 280 + Height = 356 + Top = 33 Width = 363 Align = alClient Caption = 'SelectedUnitsGroupBox' - ClientHeight = 92 + ClientHeight = 339 ClientWidth = 359 TabOrder = 3 object SelUnitsSearchNextSpeedButton: TSpeedButton @@ -454,9 +242,11 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideRight.Control = SelUnitsSearchPrevSpeedButton Left = 313 Height = 22 - Top = 69 + Top = 315 Width = 23 Anchors = [akTop, akRight] + ShowHint = True + ParentShowHint = False end object SelUnitsSearchPrevSpeedButton: TSpeedButton AnchorSideTop.Control = SelUnitsSearchEdit @@ -465,18 +255,22 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideRight.Side = asrBottom Left = 336 Height = 22 - Top = 69 + Top = 315 Width = 23 Anchors = [akTop, akRight] + ShowHint = True + ParentShowHint = False end object SelUnitsSearchEdit: TEdit AnchorSideLeft.Control = SelectedUnitsGroupBox AnchorSideRight.Control = SelUnitsSearchNextSpeedButton + AnchorSideBottom.Control = SelectedUnitsGroupBox + AnchorSideBottom.Side = asrBottom Left = 0 Height = 25 - Top = 68 + Top = 314 Width = 313 - Anchors = [akTop, akLeft, akRight] + Anchors = [akLeft, akRight, akBottom] TabOrder = 0 Text = 'SelUnitsSearchEdit' end @@ -487,12 +281,14 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = SelUnitsSearchEdit Left = 0 - Height = 68 + Height = 314 Top = 0 Width = 359 Anchors = [akTop, akLeft, akRight, akBottom] DefaultItemHeight = 18 + ReadOnly = True TabOrder = 1 + Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] end end end diff --git a/components/codetools/ide/codyunitdepwnd.pas b/components/codetools/ide/codyunitdepwnd.pas index 848618b3ef..9dd572ded8 100644 --- a/components/codetools/ide/codyunitdepwnd.pas +++ b/components/codetools/ide/codyunitdepwnd.pas @@ -24,30 +24,16 @@ IDE Window showing dependencies of units and packages. ToDo: - - change dialog to window - add refresh button to rescan - delay update pages when not visible - update pages when becoming visible - - scope: - - start units: - - list of project/packages - - flag for project, package: add all units in owner's source directories - - include units: semicolon separated list of file masks - - only those units with name fitting simple or regular expression - - exclude units with name fitting simple or regular expression - - button to use active unit as start - - used units: - - flag add units in packages used by owners - - only those packages with name fitting regular expression - - not packages with name fitting regular expression - - only those units with name fitting simple or regular expression - - exclude units with name fitting simple or regular expression + - additional files as start units - view: - flag show nodes for project/package - flag show nodes for directories - - text search with highlight, next, previous - - filter units simple or reg ex - flag allow multiselect + - filter units + - text search with highlight, next, previous - double click: open one unit - selected units - show owner units as tree structure @@ -67,9 +53,9 @@ interface uses Classes, SysUtils, AVL_Tree, LazLogger, LazFileUtils, Forms, Controls, ExtCtrls, ComCtrls, StdCtrls, Buttons, LvlGraphCtrl, - LazIDEIntf, ProjectIntf, IDEWindowIntf, PackageIntf, + LazIDEIntf, ProjectIntf, IDEWindowIntf, PackageIntf, SrcEditorIntf, CodeToolManager, DefineTemplates, CodeToolsStructs, - CTUnitGraph, CTUnitGroupGraph; + CTUnitGraph, CTUnitGroupGraph, FileProcs; const GroupPrefixProject = '-Project-'; @@ -81,6 +67,7 @@ type TUnitDependenciesWindow = class(TForm) AllUnitsFilterEdit: TEdit; + AllUnitsMultiselectSpeedButton: TSpeedButton; AllUnitsSearchEdit: TEdit; AllUnitsSearchNextSpeedButton: TSpeedButton; AllUnitsSearchPrevSpeedButton: TSpeedButton; @@ -89,50 +76,35 @@ type AllUnitsShowGroupNodesSpeedButton: TSpeedButton; AllUnitsTreeView: TTreeView; BtnPanel: TPanel; - ContinueExcludePkgCheckBox: TCheckBox; - ContinueExcludePkgEdit: TEdit; - ContinueExcludePkgRegExCheckBox: TCheckBox; - ContinueInUsedPackagesCheckBox: TCheckBox; - ContinueOnlyPkgWithNameCheckBox: TCheckBox; - ContinueOnlyPkgEdit: TEdit; - ContinueOnlyPkgWithNameRegExCheckBox: TCheckBox; - ContinueSearchingInGroupBox: TGroupBox; MainPageControl: TPageControl; ProgressBar1: TProgressBar; GroupsTabSheet: TTabSheet; GroupsSplitter: TSplitter; - ScopeStartGroupsButton: TButton; SelectedUnitsGroupBox: TGroupBox; SelUnitsSearchEdit: TEdit; SelUnitsSearchNextSpeedButton: TSpeedButton; SelUnitsSearchPrevSpeedButton: TSpeedButton; SelUnitsTreeView: TTreeView; - StartSearchingInGroupBox: TGroupBox; UnitScopeAddFilesButton: TButton; UnitScopeAddFilesCheckBox: TCheckBox; - UnitScopeAddFilesEdit: TEdit; - ScopeStartIncludeUnitsInGrpsSrcDirsCheckBox: TCheckBox; ScopePanel: TPanel; - ShowScopeCheckBox: TCheckBox; - UnitScopeNameExcludeFilterCheckBox: TCheckBox; - UnitScopeNameExcludeFilterEdit: TEdit; - UnitScopeNameExcludeFilterRegExCheckBox: TCheckBox; - UnitScopeNameOnlyFilterCheckBox: TCheckBox; - UnitScopeNameOnlyFilterEdit: TEdit; - UnitScopeNameOnlyFilterRegExCheckBox: TCheckBox; + UnitScopeAddFilesComboBox: TComboBox; UnitsSplitter: TSplitter; UnitsTabSheet: TTabSheet; Timer1: TTimer; + procedure AllUnitsMultiselectSpeedButtonClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure GroupsLvlGraphSelectionChanged(Sender: TObject); procedure OnIdle(Sender: TObject; var {%H-}Done: Boolean); procedure Timer1Timer(Sender: TObject); private + FAllUnitsMultiSelect: boolean; FCurrentUnit: TUGUnit; FIdleConnected: boolean; FUsesGraph: TUsesGraph; FGroups: TUGGroups; // referenced by Nodes.Data of GroupsLvlGraph + procedure SetAllUnitsMultiSelect(AValue: boolean); procedure SetCurrentUnit(AValue: TUGUnit); procedure SetIdleConnected(AValue: boolean); procedure CreateGroups; @@ -141,6 +113,9 @@ type procedure CreateFPCSrcGroups; procedure GuessGroupOfUnits; procedure AddStartAndTargetUnits; + procedure AddAdditionalFilesAsStartUnits; + procedure SetupGroupsTabSheet; + procedure SetupUnitsTabSheet; procedure UpdateAll; procedure UpdateGroupsLvlGraph; procedure UpdateUnitsLvlGraph; @@ -156,6 +131,7 @@ type property UsesGraph: TUsesGraph read FUsesGraph; property Groups: TUGGroups read FGroups; property CurrentUnit: TUGUnit read FCurrentUnit write SetCurrentUnit; + property AllUnitsMultiSelect: boolean read FAllUnitsMultiSelect write SetAllUnitsMultiSelect; end; var @@ -192,40 +168,20 @@ begin Caption:='Unit Dependencies'; - IDEDialogLayoutList.ApplyLayout(Self,600,400); + MainPageControl.ActivePage:=UnitsTabSheet; - UnitsTabSheet.Caption:='Units'; - GroupsTabSheet.Caption:='Projects and packages'; - - GroupsLvlGraph:=TLvlGraphControl.Create(Self); - with GroupsLvlGraph do - begin - Name:='GroupsLvlGraph'; - Caption:=''; - Align:=alTop; - Height:=200; - NodeStyle.GapBottom:=5; - Parent:=GroupsTabSheet; - OnSelectionChanged:=@GroupsLvlGraphSelectionChanged; - end; - - GroupsSplitter.Top:=GroupsLvlGraph.Height; - - UnitsLvlGraph:=TLvlGraphControl.Create(Self); - with UnitsLvlGraph do - begin - Name:='UnitsLvlGraph'; - Caption:=''; - Align:=alClient; - NodeStyle.GapBottom:=5; - Parent:=GroupsTabSheet; - end; - - MainPageControl.ActivePage:=GroupsTabSheet; + SetupUnitsTabSheet; + SetupGroupsTabSheet; IdleConnected:=true; end; +procedure TUnitDependenciesWindow.AllUnitsMultiselectSpeedButtonClick( + Sender: TObject); +begin + AllUnitsMultiSelect:=AllUnitsMultiselectSpeedButton.Down; +end; + procedure TUnitDependenciesWindow.FormDestroy(Sender: TObject); begin IdleConnected:=false; @@ -437,9 +393,20 @@ begin FCurrentUnit:=AValue; end; +procedure TUnitDependenciesWindow.SetAllUnitsMultiSelect(AValue: boolean); +begin + if FAllUnitsMultiSelect=AValue then Exit; + FAllUnitsMultiSelect:=AValue; + AllUnitsMultiselectSpeedButton.Down:=AllUnitsMultiSelect; + AllUnitsTreeView.MultiSelect:=AllUnitsMultiSelect; +end; + procedure TUnitDependenciesWindow.AddStartAndTargetUnits; var aProject: TLazProject; + i: Integer; + SrcEdit: TSourceEditorInterface; + AFilename: String; begin UsesGraph.TargetAll:=true; @@ -450,6 +417,113 @@ begin // ToDo: add all open packages + // add all source editor files + for i:=0 to SourceEditorManagerIntf.SourceEditorCount-1 do begin + SrcEdit:=SourceEditorManagerIntf.SourceEditors[i]; + AFilename:=SrcEdit.FileName; + if FilenameIsPascalUnit(AFilename) then + UsesGraph.AddStartUnit(AFilename); + end; + + // additional units and directories + AddAdditionalFilesAsStartUnits; +end; + +procedure TUnitDependenciesWindow.AddAdditionalFilesAsStartUnits; +var + List: TCaption; + aFilename: String; + Files: TStrings; + i: Integer; + p: Integer; +begin + List:=UnitScopeAddFilesComboBox.Text; + p:=1; + while p<=length(List) do begin + aFilename:=TrimAndExpandFilename(GetNextDelimitedItem(List,';',p)); + if (AFilename='') then continue; + if not FileExistsCached(aFilename) then continue; + if DirPathExistsCached(aFilename) then begin + aFilename:=AppendPathDelim(aFilename); + // add all units in directory + Files:=nil; + try + CodeToolBoss.DirectoryCachePool.GetListing(aFilename,Files,false); + if Files<>nil then begin + for i:=0 to Files.Count-1 do begin + if FilenameIsPascalUnit(Files[i]) then + UsesGraph.AddStartUnit(aFilename+Files[i]); + end; + end; + finally + Files.Free; + end; + end else begin + // add a single file + UsesGraph.AddStartUnit(aFilename); + end; + end; +end; + +procedure TUnitDependenciesWindow.SetupGroupsTabSheet; +begin + GroupsTabSheet.Caption:='Projects and packages'; + + GroupsLvlGraph:=TLvlGraphControl.Create(Self); + with GroupsLvlGraph do + begin + Name:='GroupsLvlGraph'; + Caption:=''; + Align:=alTop; + Height:=200; + NodeStyle.GapBottom:=5; + Parent:=GroupsTabSheet; + OnSelectionChanged:=@GroupsLvlGraphSelectionChanged; + end; + + GroupsSplitter.Top:=GroupsLvlGraph.Height; + + UnitsLvlGraph:=TLvlGraphControl.Create(Self); + with UnitsLvlGraph do + begin + Name:='UnitsLvlGraph'; + Caption:=''; + Align:=alClient; + NodeStyle.GapBottom:=5; + Parent:=GroupsTabSheet; + end; +end; + +procedure TUnitDependenciesWindow.SetupUnitsTabSheet; +begin + UnitsTabSheet.Caption:='Units'; + + // start searching + UnitScopeAddFilesCheckBox.Caption:='Additional directories:'; + UnitScopeAddFilesCheckBox.Hint:='By default only the project units and the source editor units are searched. Add here a list of directories separated by semicolon to search as well.'; + UnitScopeAddFilesComboBox.Text:=''; + UnitScopeAddFilesButton.Caption:='Browse'; + + // view all units + AllUnitsFilterEdit.Text:='(Filter)'; + AllUnitsMultiselectSpeedButton.Hint:='Allow to select multiple units'; + AllUnitsShowDirsSpeedButton.Hint:='Show nodes for directories'; + AllUnitsShowDirsSpeedButton.LoadGlyphFromLazarusResource('pkg_hierarchical'); + AllUnitsShowGroupNodesSpeedButton.Hint:='Show nodes for project and packages'; + AllUnitsShowGroupNodesSpeedButton.LoadGlyphFromLazarusResource('pkg_hierarchical'); + + AllUnitsSearchEdit.Text:='(Filter)'; + AllUnitsSearchNextSpeedButton.Hint:='Search next occurence of this phrase'; + AllUnitsSearchNextSpeedButton.LoadGlyphFromLazarusResource('arrow_down'); + AllUnitsSearchPrevSpeedButton.Hint:='Search previous occurence of this phrase'; + AllUnitsSearchPrevSpeedButton.LoadGlyphFromLazarusResource('arrow_up'); + + // selected units + SelUnitsSearchEdit.Text:='(Filter)'; + SelUnitsSearchNextSpeedButton.Hint:='Search next unit of this phrase'; + SelUnitsSearchNextSpeedButton.LoadGlyphFromLazarusResource('arrow_down'); + SelUnitsSearchPrevSpeedButton.Hint:='Search previous unit of this phrase'; + SelUnitsSearchPrevSpeedButton.LoadGlyphFromLazarusResource('arrow_up'); end; procedure TUnitDependenciesWindow.UpdateAll;