From d82797827f82f2a29f11aae4e749d653e22469d1 Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 16 Jun 2013 19:42:45 +0000 Subject: [PATCH] cody: unit deps: search options git-svn-id: trunk@41733 - --- components/codetools/ide/codyunitdepwnd.lfm | 86 ++++++++++++------- components/codetools/ide/codyunitdepwnd.pas | 92 +++++++++++++-------- 2 files changed, 114 insertions(+), 64 deletions(-) diff --git a/components/codetools/ide/codyunitdepwnd.lfm b/components/codetools/ide/codyunitdepwnd.lfm index c64b88be0a..d808984aba 100644 --- a/components/codetools/ide/codyunitdepwnd.lfm +++ b/components/codetools/ide/codyunitdepwnd.lfm @@ -43,17 +43,17 @@ object UnitDependenciesWindow: TUnitDependenciesWindow ClientWidth = 616 object ScopePanel: TPanel Left = 0 - Height = 33 + Height = 59 Top = 0 Width = 616 Align = alTop AutoSize = True - ClientHeight = 33 + ClientHeight = 59 ClientWidth = 616 TabOrder = 0 - object UnitScopeAddFilesCheckBox: TCheckBox + object SearchCustomFilesCheckBox: TCheckBox AnchorSideLeft.Control = ScopePanel - AnchorSideTop.Control = UnitScopeAddFilesComboBox + AnchorSideTop.Control = SearchCustomFilesComboBox AnchorSideTop.Side = asrCenter Left = 3 Height = 24 @@ -61,14 +61,14 @@ object UnitDependenciesWindow: TUnitDependenciesWindow Width = 111 BorderSpacing.Around = 2 Caption = 'Additional files:' - OnChange = UnitScopeAddFilesCheckBoxChange + OnChange = SearchCustomFilesCheckBoxChange ParentShowHint = False ShowHint = True TabOrder = 0 end - object UnitScopeAddFilesButton: TButton + object SearchCustomFilesBrowseButton: TButton AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = UnitScopeAddFilesComboBox + AnchorSideTop.Control = SearchCustomFilesComboBox AnchorSideTop.Side = asrCenter AnchorSideRight.Control = ScopePanel AnchorSideRight.Side = asrBottom @@ -79,14 +79,14 @@ object UnitDependenciesWindow: TUnitDependenciesWindow Anchors = [akTop, akRight] AutoSize = True Caption = 'Browse' - OnClick = UnitScopeAddFilesButtonClick + OnClick = SearchCustomFilesBrowseButtonClick TabOrder = 1 end - object UnitScopeAddFilesComboBox: TComboBox - AnchorSideLeft.Control = UnitScopeAddFilesCheckBox + object SearchCustomFilesComboBox: TComboBox + AnchorSideLeft.Control = SearchCustomFilesCheckBox AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = ScopePanel - AnchorSideRight.Control = UnitScopeAddFilesButton + AnchorSideRight.Control = SearchCustomFilesBrowseButton Left = 116 Height = 27 Top = 3 @@ -94,19 +94,47 @@ object UnitDependenciesWindow: TUnitDependenciesWindow Anchors = [akTop, akLeft, akRight] BorderSpacing.Around = 2 ItemHeight = 0 - OnChange = UnitScopeAddFilesComboBoxChange + OnChange = SearchCustomFilesComboBoxChange TabOrder = 2 - Text = 'UnitScopeAddFilesComboBox' + Text = 'SearchCustomFilesComboBox' + end + object SearchPkgsCheckBox: TCheckBox + AnchorSideLeft.Control = ScopePanel + AnchorSideTop.Control = SearchCustomFilesComboBox + AnchorSideTop.Side = asrBottom + Left = 3 + Height = 24 + Top = 32 + Width = 141 + BorderSpacing.Around = 2 + Caption = 'SearchPkgsCheckBox' + OnChange = SearchPkgsCheckBoxChange + TabOrder = 3 + end + object SearchSrcEditCheckBox: TCheckBox + AnchorSideLeft.Control = SearchPkgsCheckBox + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = SearchPkgsCheckBox + AnchorSideTop.Side = asrCenter + Left = 161 + Height = 24 + Top = 32 + Width = 156 + BorderSpacing.Left = 15 + BorderSpacing.Around = 2 + Caption = 'SearchSrcEditCheckBox' + OnChange = SearchSrcEditCheckBoxChange + TabOrder = 4 end end object AllUnitsGroupBox: TGroupBox Left = 0 - Height = 356 - Top = 33 + Height = 330 + Top = 59 Width = 248 Align = alLeft Caption = 'AllUnitsGroupBox' - ClientHeight = 339 + ClientHeight = 313 ClientWidth = 244 TabOrder = 1 object AllUnitsShowGroupNodesSpeedButton: TSpeedButton @@ -158,7 +186,7 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideRight.Control = AllUnitsSearchPrevSpeedButton Left = 198 Height = 22 - Top = 315 + Top = 289 Width = 23 Anchors = [akTop, akRight] ShowHint = True @@ -171,7 +199,7 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideRight.Side = asrBottom Left = 221 Height = 22 - Top = 315 + Top = 289 Width = 23 Anchors = [akTop, akRight] ShowHint = True @@ -185,7 +213,7 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = AllUnitsSearchEdit Left = 0 - Height = 289 + Height = 263 Top = 25 Width = 244 Anchors = [akTop, akLeft, akRight, akBottom] @@ -201,7 +229,7 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideBottom.Side = asrBottom Left = 0 Height = 25 - Top = 314 + Top = 288 Width = 198 Anchors = [akLeft, akRight, akBottom] TabOrder = 2 @@ -225,18 +253,18 @@ object UnitDependenciesWindow: TUnitDependenciesWindow end object UnitsSplitter: TSplitter Left = 248 - Height = 356 - Top = 33 + Height = 330 + Top = 59 Width = 5 end object SelectedUnitsGroupBox: TGroupBox Left = 253 - Height = 356 - Top = 33 + Height = 330 + Top = 59 Width = 363 Align = alClient Caption = 'SelectedUnitsGroupBox' - ClientHeight = 339 + ClientHeight = 313 ClientWidth = 359 TabOrder = 3 object SelUnitsSearchNextSpeedButton: TSpeedButton @@ -245,7 +273,7 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideRight.Control = SelUnitsSearchPrevSpeedButton Left = 313 Height = 22 - Top = 315 + Top = 289 Width = 23 Anchors = [akTop, akRight] ShowHint = True @@ -258,7 +286,7 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideRight.Side = asrBottom Left = 336 Height = 22 - Top = 315 + Top = 289 Width = 23 Anchors = [akTop, akRight] ShowHint = True @@ -271,7 +299,7 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideBottom.Side = asrBottom Left = 0 Height = 25 - Top = 314 + Top = 288 Width = 313 Anchors = [akLeft, akRight, akBottom] TabOrder = 0 @@ -284,7 +312,7 @@ object UnitDependenciesWindow: TUnitDependenciesWindow AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = SelUnitsSearchEdit Left = 0 - Height = 314 + Height = 288 Top = 0 Width = 359 Anchors = [akTop, akLeft, akRight, akBottom] diff --git a/components/codetools/ide/codyunitdepwnd.pas b/components/codetools/ide/codyunitdepwnd.pas index 53765864b5..a9388c1040 100644 --- a/components/codetools/ide/codyunitdepwnd.pas +++ b/components/codetools/ide/codyunitdepwnd.pas @@ -80,15 +80,17 @@ type ProgressBar1: TProgressBar; GroupsTabSheet: TTabSheet; GroupsSplitter: TSplitter; + SearchPkgsCheckBox: TCheckBox; + SearchSrcEditCheckBox: TCheckBox; SelectedUnitsGroupBox: TGroupBox; SelUnitsSearchEdit: TEdit; SelUnitsSearchNextSpeedButton: TSpeedButton; SelUnitsSearchPrevSpeedButton: TSpeedButton; SelUnitsTreeView: TTreeView; - UnitScopeAddFilesButton: TButton; - UnitScopeAddFilesCheckBox: TCheckBox; + SearchCustomFilesBrowseButton: TButton; + SearchCustomFilesCheckBox: TCheckBox; ScopePanel: TPanel; - UnitScopeAddFilesComboBox: TComboBox; + SearchCustomFilesComboBox: TComboBox; UnitsSplitter: TSplitter; UnitsTabSheet: TTabSheet; Timer1: TTimer; @@ -97,10 +99,12 @@ type procedure FormDestroy(Sender: TObject); procedure GroupsLvlGraphSelectionChanged(Sender: TObject); procedure OnIdle(Sender: TObject; var {%H-}Done: Boolean); + procedure SearchPkgsCheckBoxChange(Sender: TObject); + procedure SearchSrcEditCheckBoxChange(Sender: TObject); procedure Timer1Timer(Sender: TObject); - procedure UnitScopeAddFilesButtonClick(Sender: TObject); - procedure UnitScopeAddFilesCheckBoxChange(Sender: TObject); - procedure UnitScopeAddFilesComboBoxChange(Sender: TObject); + procedure SearchCustomFilesBrowseButtonClick(Sender: TObject); + procedure SearchCustomFilesCheckBoxChange(Sender: TObject); + procedure SearchCustomFilesComboBoxChange(Sender: TObject); private FAllUnitsMultiSelect: boolean; FCurrentUnit: TUGUnit; @@ -216,12 +220,22 @@ begin end; end; +procedure TUnitDependenciesWindow.SearchPkgsCheckBoxChange(Sender: TObject); +begin + IdleConnected:=true; +end; + +procedure TUnitDependenciesWindow.SearchSrcEditCheckBoxChange(Sender: TObject); +begin + IdleConnected:=true; +end; + procedure TUnitDependenciesWindow.Timer1Timer(Sender: TObject); begin end; -procedure TUnitDependenciesWindow.UnitScopeAddFilesButtonClick(Sender: TObject); +procedure TUnitDependenciesWindow.SearchCustomFilesBrowseButtonClick(Sender: TObject); var Dlg: TSelectDirectoryDialog; s: TCaption; @@ -234,26 +248,26 @@ begin Dlg.Options:=Dlg.Options+[ofPathMustExist]; if not Dlg.Execute then exit; aFilename:=TrimFilename(Dlg.FileName); - s:=UnitScopeAddFilesComboBox.Text; + s:=SearchCustomFilesComboBox.Text; p:=1; if FindNextDelimitedItem(s,';',p,aFilename)<>'' then exit; if s<>'' then s+=';'; s+=aFilename; - UnitScopeAddFilesComboBox.Text:=s; + SearchCustomFilesComboBox.Text:=s; IdleConnected:=true; finally Dlg.Free; end; end; -procedure TUnitDependenciesWindow.UnitScopeAddFilesCheckBoxChange( +procedure TUnitDependenciesWindow.SearchCustomFilesCheckBoxChange( Sender: TObject); begin UpdateAddFiles; IdleConnected:=true; end; -procedure TUnitDependenciesWindow.UnitScopeAddFilesComboBoxChange( +procedure TUnitDependenciesWindow.SearchCustomFilesComboBoxChange( Sender: TObject); begin IdleConnected:=true; @@ -460,29 +474,34 @@ begin if (aProject<>nil) and (aProject.MainFile<>nil) then UsesGraph.AddStartUnit(aProject.MainFile.Filename); - // ToDo: add all open packages - for i:=0 to PackageEditingInterface.GetPackageCount-1 do begin - Pkg:=PackageEditingInterface.GetPackages(i); - if not FilenameIsAbsolute(Pkg.Filename) then continue; - for j:=0 to Pkg.FileCount-1 do begin - PkgFile:=Pkg.Files[j]; - if PkgFile.Removed then continue; - aFilename:=PkgFile.GetFullFilename; + // add all open packages + if SearchPkgsCheckBox.Checked then begin + for i:=0 to PackageEditingInterface.GetPackageCount-1 do begin + Pkg:=PackageEditingInterface.GetPackages(i); + if not FilenameIsAbsolute(Pkg.Filename) then continue; + for j:=0 to Pkg.FileCount-1 do begin + PkgFile:=Pkg.Files[j]; + if PkgFile.Removed then continue; + aFilename:=PkgFile.GetFullFilename; + if FilenameIsPascalUnit(AFilename) then + UsesGraph.AddStartUnit(AFilename); + end; + end; + end; + + // add all source editor files + if SearchSrcEditCheckBox.Checked then begin + for i:=0 to SourceEditorManagerIntf.SourceEditorCount-1 do begin + SrcEdit:=SourceEditorManagerIntf.SourceEditors[i]; + AFilename:=SrcEdit.FileName; if FilenameIsPascalUnit(AFilename) then UsesGraph.AddStartUnit(AFilename); end; end; - // 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; + if SearchCustomFilesCheckBox.Checked then + AddAdditionalFilesAsStartUnits; end; procedure TUnitDependenciesWindow.AddAdditionalFilesAsStartUnits; @@ -493,7 +512,7 @@ var i: Integer; p: Integer; begin - List:=UnitScopeAddFilesComboBox.Text; + List:=SearchCustomFilesComboBox.Text; p:=1; while p<=length(List) do begin aFilename:=TrimAndExpandFilename(GetNextDelimitedItem(List,';',p)); @@ -555,10 +574,13 @@ 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'; + SearchCustomFilesCheckBox.Caption:='Additional directories:'; + SearchCustomFilesCheckBox.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.'; + SearchCustomFilesComboBox.Text:=''; + SearchCustomFilesBrowseButton.Caption:='Browse'; + + SearchPkgsCheckBox.Caption:='All package units'; + SearchSrcEditCheckBox.Caption:='All source editor units'; // view all units AllUnitsGroupBox.Caption:='All units'; @@ -589,8 +611,8 @@ end; procedure TUnitDependenciesWindow.UpdateAddFiles; begin - UnitScopeAddFilesComboBox.Enabled:=UnitScopeAddFilesCheckBox.Checked; - UnitScopeAddFilesButton.Enabled:=UnitScopeAddFilesCheckBox.Checked; + SearchCustomFilesComboBox.Enabled:=SearchCustomFilesCheckBox.Checked; + SearchCustomFilesBrowseButton.Enabled:=SearchCustomFilesCheckBox.Checked; end; procedure TUnitDependenciesWindow.UpdateAll;