cody: unit deps: pkg files

git-svn-id: trunk@41732 -
This commit is contained in:
mattias 2013-06-16 19:34:54 +00:00
parent c1636ed4e7
commit 8c8d0e7028
2 changed files with 77 additions and 6 deletions

View File

@ -61,6 +61,7 @@ object UnitDependenciesWindow: TUnitDependenciesWindow
Width = 111 Width = 111
BorderSpacing.Around = 2 BorderSpacing.Around = 2
Caption = 'Additional files:' Caption = 'Additional files:'
OnChange = UnitScopeAddFilesCheckBoxChange
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 0 TabOrder = 0
@ -78,6 +79,7 @@ object UnitDependenciesWindow: TUnitDependenciesWindow
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
AutoSize = True AutoSize = True
Caption = 'Browse' Caption = 'Browse'
OnClick = UnitScopeAddFilesButtonClick
TabOrder = 1 TabOrder = 1
end end
object UnitScopeAddFilesComboBox: TComboBox object UnitScopeAddFilesComboBox: TComboBox
@ -92,6 +94,7 @@ object UnitDependenciesWindow: TUnitDependenciesWindow
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 2 BorderSpacing.Around = 2
ItemHeight = 0 ItemHeight = 0
OnChange = UnitScopeAddFilesComboBoxChange
TabOrder = 2 TabOrder = 2
Text = 'UnitScopeAddFilesComboBox' Text = 'UnitScopeAddFilesComboBox'
end end

View File

@ -51,11 +51,11 @@ unit CodyUnitDepWnd;
interface interface
uses uses
Classes, SysUtils, AVL_Tree, LazLogger, LazFileUtils, Classes, SysUtils, AVL_Tree, LazLogger, LazFileUtils, Forms, Controls,
Forms, Controls, ExtCtrls, ComCtrls, StdCtrls, Buttons, LvlGraphCtrl, ExtCtrls, ComCtrls, StdCtrls, Buttons, Dialogs, LvlGraphCtrl, LazIDEIntf,
LazIDEIntf, ProjectIntf, IDEWindowIntf, PackageIntf, SrcEditorIntf, ProjectIntf, IDEWindowIntf, PackageIntf, SrcEditorIntf, IDEDialogs,
CodeToolManager, DefineTemplates, CodeToolsStructs, CodeToolManager, DefineTemplates, CodeToolsStructs, CTUnitGraph,
CTUnitGraph, CTUnitGroupGraph, FileProcs; CTUnitGroupGraph, FileProcs;
const const
GroupPrefixProject = '-Project-'; GroupPrefixProject = '-Project-';
@ -98,6 +98,9 @@ type
procedure GroupsLvlGraphSelectionChanged(Sender: TObject); procedure GroupsLvlGraphSelectionChanged(Sender: TObject);
procedure OnIdle(Sender: TObject; var {%H-}Done: Boolean); procedure OnIdle(Sender: TObject; var {%H-}Done: Boolean);
procedure Timer1Timer(Sender: TObject); procedure Timer1Timer(Sender: TObject);
procedure UnitScopeAddFilesButtonClick(Sender: TObject);
procedure UnitScopeAddFilesCheckBoxChange(Sender: TObject);
procedure UnitScopeAddFilesComboBoxChange(Sender: TObject);
private private
FAllUnitsMultiSelect: boolean; FAllUnitsMultiSelect: boolean;
FCurrentUnit: TUGUnit; FCurrentUnit: TUGUnit;
@ -116,6 +119,7 @@ type
procedure AddAdditionalFilesAsStartUnits; procedure AddAdditionalFilesAsStartUnits;
procedure SetupGroupsTabSheet; procedure SetupGroupsTabSheet;
procedure SetupUnitsTabSheet; procedure SetupUnitsTabSheet;
procedure UpdateAddFiles;
procedure UpdateAll; procedure UpdateAll;
procedure UpdateGroupsLvlGraph; procedure UpdateGroupsLvlGraph;
procedure UpdateUnitsLvlGraph; procedure UpdateUnitsLvlGraph;
@ -214,7 +218,45 @@ end;
procedure TUnitDependenciesWindow.Timer1Timer(Sender: TObject); procedure TUnitDependenciesWindow.Timer1Timer(Sender: TObject);
begin begin
UpdateAll;
end;
procedure TUnitDependenciesWindow.UnitScopeAddFilesButtonClick(Sender: TObject);
var
Dlg: TSelectDirectoryDialog;
s: TCaption;
aFilename: String;
p: Integer;
begin
Dlg:=TSelectDirectoryDialog.Create(nil);
try
InitIDEFileDialog(Dlg);
Dlg.Options:=Dlg.Options+[ofPathMustExist];
if not Dlg.Execute then exit;
aFilename:=TrimFilename(Dlg.FileName);
s:=UnitScopeAddFilesComboBox.Text;
p:=1;
if FindNextDelimitedItem(s,';',p,aFilename)<>'' then exit;
if s<>'' then s+=';';
s+=aFilename;
UnitScopeAddFilesComboBox.Text:=s;
IdleConnected:=true;
finally
Dlg.Free;
end;
end;
procedure TUnitDependenciesWindow.UnitScopeAddFilesCheckBoxChange(
Sender: TObject);
begin
UpdateAddFiles;
IdleConnected:=true;
end;
procedure TUnitDependenciesWindow.UnitScopeAddFilesComboBoxChange(
Sender: TObject);
begin
IdleConnected:=true;
end; end;
procedure TUnitDependenciesWindow.SetIdleConnected(AValue: boolean); procedure TUnitDependenciesWindow.SetIdleConnected(AValue: boolean);
@ -407,6 +449,9 @@ var
i: Integer; i: Integer;
SrcEdit: TSourceEditorInterface; SrcEdit: TSourceEditorInterface;
AFilename: String; AFilename: String;
Pkg: TIDEPackage;
j: Integer;
PkgFile: TLazPackageFile;
begin begin
UsesGraph.TargetAll:=true; UsesGraph.TargetAll:=true;
@ -416,6 +461,17 @@ begin
UsesGraph.AddStartUnit(aProject.MainFile.Filename); UsesGraph.AddStartUnit(aProject.MainFile.Filename);
// ToDo: add all open packages // 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;
if FilenameIsPascalUnit(AFilename) then
UsesGraph.AddStartUnit(AFilename);
end;
end;
// add all source editor files // add all source editor files
for i:=0 to SourceEditorManagerIntf.SourceEditorCount-1 do begin for i:=0 to SourceEditorManagerIntf.SourceEditorCount-1 do begin
@ -505,6 +561,8 @@ begin
UnitScopeAddFilesButton.Caption:='Browse'; UnitScopeAddFilesButton.Caption:='Browse';
// view all units // view all units
AllUnitsGroupBox.Caption:='All units';
AllUnitsFilterEdit.Text:='(Filter)'; AllUnitsFilterEdit.Text:='(Filter)';
AllUnitsMultiselectSpeedButton.Hint:='Allow to select multiple units'; AllUnitsMultiselectSpeedButton.Hint:='Allow to select multiple units';
AllUnitsShowDirsSpeedButton.Hint:='Show nodes for directories'; AllUnitsShowDirsSpeedButton.Hint:='Show nodes for directories';
@ -519,15 +577,25 @@ begin
AllUnitsSearchPrevSpeedButton.LoadGlyphFromLazarusResource('arrow_up'); AllUnitsSearchPrevSpeedButton.LoadGlyphFromLazarusResource('arrow_up');
// selected units // selected units
SelectedUnitsGroupBox.Caption:='Selected units';
SelUnitsSearchEdit.Text:='(Filter)'; SelUnitsSearchEdit.Text:='(Filter)';
SelUnitsSearchNextSpeedButton.Hint:='Search next unit of this phrase'; SelUnitsSearchNextSpeedButton.Hint:='Search next unit of this phrase';
SelUnitsSearchNextSpeedButton.LoadGlyphFromLazarusResource('arrow_down'); SelUnitsSearchNextSpeedButton.LoadGlyphFromLazarusResource('arrow_down');
SelUnitsSearchPrevSpeedButton.Hint:='Search previous unit of this phrase'; SelUnitsSearchPrevSpeedButton.Hint:='Search previous unit of this phrase';
SelUnitsSearchPrevSpeedButton.LoadGlyphFromLazarusResource('arrow_up'); SelUnitsSearchPrevSpeedButton.LoadGlyphFromLazarusResource('arrow_up');
UpdateAddFiles;
end;
procedure TUnitDependenciesWindow.UpdateAddFiles;
begin
UnitScopeAddFilesComboBox.Enabled:=UnitScopeAddFilesCheckBox.Checked;
UnitScopeAddFilesButton.Enabled:=UnitScopeAddFilesCheckBox.Checked;
end; end;
procedure TUnitDependenciesWindow.UpdateAll; procedure TUnitDependenciesWindow.UpdateAll;
begin begin
UpdateAddFiles;
UpdateGroupsLvlGraph; UpdateGroupsLvlGraph;
UpdateUnitsLvlGraph; UpdateUnitsLvlGraph;
end; end;