IDE: unit deps: resourcestrings

git-svn-id: trunk@41785 -
This commit is contained in:
mattias 2013-06-22 07:12:56 +00:00
parent 04269eb231
commit b9e87a8452
4 changed files with 102 additions and 42 deletions

View File

@ -343,7 +343,7 @@ resourcestring
lisMenuJumpToImplementation = 'Jump to Implementation'; lisMenuJumpToImplementation = 'Jump to Implementation';
lisMenuViewUnits = 'Units ...'; lisMenuViewUnits = 'Units ...';
lisMenuViewForms = 'Forms ...'; lisMenuViewForms = 'Forms ...';
lisMenuViewUnitDependencies = 'Unit Dependencies ...'; lisMenuViewUnitDependencies = 'Unit Dependencies';
lisKMViewUnitInfo = 'View Unit Info'; lisKMViewUnitInfo = 'View Unit Info';
lisMenuViewUnitInfo = 'Unit Information ...'; lisMenuViewUnitInfo = 'Unit Information ...';
lisMenuViewToggleFormUnit = 'Toggle Form/Unit View'; lisMenuViewToggleFormUnit = 'Toggle Form/Unit View';
@ -5749,6 +5749,39 @@ resourcestring
lisMMIDEMacro = 'IDE Macro'; lisMMIDEMacro = 'IDE Macro';
lisMMOverrideOutputDirectory = 'Override output directory (-FU)'; lisMMOverrideOutputDirectory = 'Override output directory (-FU)';
lisPriority = 'Priority'; lisPriority = 'Priority';
lisUDScanningUnits = 'Scanning: %s units ...';
lisUDFile = 'File: %s';
lisUDInterfaceUses = 'Interface Uses: %s';
lisUDImplementationUses = 'Implementation Uses: %s';
lisUDUsedByInterfaces = 'Used by Interfaces: %s';
lisUDUsedByImplementations = 'Used by Implementations: %s';
lisUDScanning = 'Scanning ...';
lisUDInterfaceUses2 = 'interface uses: %s';
lisUDImplementationUses2 = 'implementation uses: %s';
lisUDUsedByInterfaces2 = 'used by interfaces: %s';
lisUDUsedByImplementations2 = 'used by implementations: %s';
lisUDProjectsAndPackages = 'Projects and packages';
lisUDUnits = 'Units';
lisUDAdditionalDirectories = 'Additional directories:';
lisUDByDefaultOnlyTheProjectUnitsAndTheSourceEditorUnit = '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.';
lisUDAllPackageUnits = 'All package units';
lisUDAllSourceEditorUnits = 'All source editor units';
lisUDAllUnits = 'All units';
lisUDShowNodesForDirectories = 'Show nodes for directories';
lisUDShowNodesForProjectAndPackages = 'Show nodes for project and packages';
lisUDSearchNextOccurenceOfThisPhrase = 'Search next occurence of this phrase';
lisUDSearchPreviousOccurenceOfThisPhrase = 'Search previous occurence of '
+'this phrase';
lisUDSelectedUnits = 'Selected units';
lisUDSearchNextUnitOfThisPhrase = 'Search next unit of this phrase';
lisUDSearchPreviousUnitOfThisPhrase = 'Search previous unit of this phrase';
lisUDExpandAllNodes = 'Expand all nodes';
lisUDCollapseAllNodes = 'Collapse all nodes';
lisUDFilter = '(Filter)';
lisUDSearch = '(Search)';
lisUDUnits2 = 'Units: %s';
implementation implementation

View File

@ -2,8 +2,8 @@
/*************************************************************************** /***************************************************************************
mainbar.pp - Toolbar mainbar.pp - Toolbar
---------------------- ----------------------
TMainIDEBar is main window of the IDE, containing the menu and the component TMainIDEBar is the main window of the IDE, containing the menu and the
palette. component palette.
***************************************************************************/ ***************************************************************************/
@ -170,6 +170,7 @@ type
itmViewCodeExplorer: TIDEMenuCommand; itmViewCodeExplorer: TIDEMenuCommand;
itmViewFPDocEditor: TIDEMenuCommand; itmViewFPDocEditor: TIDEMenuCommand;
itmViewCodeBrowser: TIDEMenuCommand; itmViewCodeBrowser: TIDEMenuCommand;
itmSourceUnitDependencies: TIDEMenuCommand;
itmViewRestrictionBrowser: TIDEMenuCommand; itmViewRestrictionBrowser: TIDEMenuCommand;
itmViewComponents: TIDEMenuCommand; itmViewComponents: TIDEMenuCommand;
itmJumpHistory: TIDEMenuCommand; itmJumpHistory: TIDEMenuCommand;
@ -235,7 +236,6 @@ type
itmSourceInsertFilename: TIDEMenuCommand; itmSourceInsertFilename: TIDEMenuCommand;
// itmSourceTools // itmSourceTools
itmSourceUnitInfo: TIDEMenuCommand; itmSourceUnitInfo: TIDEMenuCommand;
itmSourceUnitDependencies: TIDEMenuCommand;
// refactor menu // refactor menu
//mnuRefactor: TIDEMenuSection; //mnuRefactor: TIDEMenuSection;

View File

@ -409,4 +409,9 @@ object UnitDependenciesWindow: TUnitDependenciesWindow
OnClick = UnitsTVCollapseAllMenuItemClick OnClick = UnitsTVCollapseAllMenuItemClick
end end
end end
object Timer1: TTimer
OnTimer = Timer1Timer
left = 465
top = 175
end
end end

View File

@ -34,11 +34,14 @@ unit UnitDependencies;
interface interface
uses uses
Classes, SysUtils, types, AVL_Tree, LazLogger, LazFileUtils, LazUTF8, Forms, Classes, SysUtils, types, AVL_Tree, LazLogger, LazFileUtils, LazUTF8,
Controls, ExtCtrls, ComCtrls, StdCtrls, Buttons, Dialogs, Menus, Clipbrd, Forms, Controls, ExtCtrls, ComCtrls, StdCtrls, Buttons, Dialogs, Menus, Clipbrd,
LvlGraphCtrl, LazIDEIntf, ProjectIntf, IDEWindowIntf, PackageIntf, LvlGraphCtrl,
SrcEditorIntf, IDEDialogs, IDEImagesIntf, IDECommands, CodeToolManager, LazIDEIntf, ProjectIntf, IDEWindowIntf, PackageIntf, SrcEditorIntf,
DefineTemplates, CodeToolsStructs, CTUnitGraph, CTUnitGroupGraph, FileProcs; IDEImagesIntf, IDECommands, IDEDialogs,
CodeToolManager, DefineTemplates, CodeToolsStructs,
CTUnitGraph, CTUnitGroupGraph, FileProcs,
LazarusIDEStrConsts;
const const
GroupPrefixProject = '-Project-'; GroupPrefixProject = '-Project-';
@ -109,6 +112,7 @@ type
RefreshButton: TButton; RefreshButton: TButton;
StatsLabel: TLabel; StatsLabel: TLabel;
StatusPanel: TPanel; StatusPanel: TPanel;
Timer1: TTimer;
UnitsTVCopyFilenameMenuItem: TMenuItem; UnitsTVCopyFilenameMenuItem: TMenuItem;
UnitsTVCollapseAllMenuItem: TMenuItem; UnitsTVCollapseAllMenuItem: TMenuItem;
UnitsTVExpandAllMenuItem: TMenuItem; UnitsTVExpandAllMenuItem: TMenuItem;
@ -145,6 +149,7 @@ type
procedure RefreshButtonClick(Sender: TObject); procedure RefreshButtonClick(Sender: TObject);
procedure SelUnitsTreeViewExpanding(Sender: TObject; Node: TTreeNode; procedure SelUnitsTreeViewExpanding(Sender: TObject; Node: TTreeNode;
var AllowExpansion: Boolean); var AllowExpansion: Boolean);
procedure Timer1Timer(Sender: TObject);
procedure UnitsTreeViewShowHint(Sender: TObject; HintInfo: PHintInfo); procedure UnitsTreeViewShowHint(Sender: TObject; HintInfo: PHintInfo);
procedure UnitsTreeViewMouseDown(Sender: TObject; Button: TMouseButton; procedure UnitsTreeViewMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); Shift: TShiftState; X, Y: Integer);
@ -340,8 +345,8 @@ begin
AllUnitsTreeView.Images:=IDEImages.Images_16; AllUnitsTreeView.Images:=IDEImages.Images_16;
SelUnitsTreeView.Images:=IDEImages.Images_16; SelUnitsTreeView.Images:=IDEImages.Images_16;
Caption:='Unit Dependencies'; Caption:=lisMenuViewUnitDependencies;
RefreshButton.Caption:='Refresh'; RefreshButton.Caption:=dlgUnitDepRefresh;
MainPageControl.ActivePage:=UnitsTabSheet; MainPageControl.ActivePage:=UnitsTabSheet;
@ -452,6 +457,17 @@ begin
end; end;
end; end;
procedure TUnitDependenciesWindow.Timer1Timer(Sender: TObject);
var
Cnt: Integer;
begin
if (FNewUsesGraph=nil) then exit;
Cnt:=0;
if FNewUsesGraph.FilesTree<>nil then
Cnt:=FNewUsesGraph.FilesTree.Count;
StatsLabel.Caption:=Format(lisUDScanningUnits, [IntToStr(Cnt)]);
end;
procedure TUnitDependenciesWindow.UnitsTreeViewShowHint(Sender: TObject; procedure TUnitDependenciesWindow.UnitsTreeViewShowHint(Sender: TObject;
HintInfo: PHintInfo); HintInfo: PHintInfo);
@ -489,20 +505,21 @@ begin
UDNode:=TUDNode(TVNode.Data); UDNode:=TUDNode(TVNode.Data);
Filename:=GetFilename(UDNode); Filename:=GetFilename(UDNode);
if Filename='' then exit; if Filename='' then exit;
s:='File: '+Filename; s:=Format(lisUDFile, [Filename]);
if UDNode.Typ=udnUnit then begin if UDNode.Typ=udnUnit then begin
UGUnit:=UsesGraph.GetUnit(Filename,false); UGUnit:=UsesGraph.GetUnit(Filename,false);
if UGUnit<>nil then begin if UGUnit<>nil then begin
CountUses(UGUnit.UsesUnits,UsesIntf,UsesImpl); CountUses(UGUnit.UsesUnits,UsesIntf,UsesImpl);
CountUses(UGUnit.UsedByUnits,UsedByIntf,UsedByImpl); CountUses(UGUnit.UsedByUnits,UsedByIntf,UsedByImpl);
if UsesIntf>0 then if UsesIntf>0 then
s+=LineEnding+'Interface Uses: '+IntToStr(UsesIntf); s+=LineEnding+Format(lisUDInterfaceUses, [IntToStr(UsesIntf)]);
if UsesImpl>0 then if UsesImpl>0 then
s+=LineEnding+'Implementation Uses: '+IntToStr(UsesImpl); s+=LineEnding+Format(lisUDImplementationUses, [IntToStr(UsesImpl)]);
if UsedByIntf>0 then if UsedByIntf>0 then
s+=LineEnding+'Used by Interfaces: '+IntToStr(UsedByIntf); s+=LineEnding+Format(lisUDUsedByInterfaces, [IntToStr(UsedByIntf)]);
if UsedByImpl>0 then if UsedByImpl>0 then
s+=LineEnding+'Used by Implementations: '+IntToStr(UsedByImpl); s+=LineEnding+Format(lisUDUsedByImplementations, [IntToStr(UsedByImpl)]
);
end; end;
end; end;
HintInfo^.HintStr:=s; HintInfo^.HintStr:=s;
@ -600,8 +617,10 @@ begin
// hide progress bar and update stats // hide progress bar and update stats
ProgressBar1.Visible:=false; ProgressBar1.Visible:=false;
ProgressBar1.Style:=pbstNormal; ProgressBar1.Style:=pbstNormal;
StatsLabel.Caption:='Units: '+IntToStr(UsesGraph.FilesTree.Count);
RefreshButton.Enabled:=true; RefreshButton.Enabled:=true;
Timer1.Enabled:=false;
StatsLabel.Caption:=Format(lisUDUnits2, [IntToStr(
FUsesGraph.FilesTree.Count)]);
// update controls // update controls
UpdateAll; UpdateAll;
end; end;
@ -940,7 +959,8 @@ begin
ProgressBar1.Visible:=true; ProgressBar1.Visible:=true;
ProgressBar1.Style:=pbstMarquee; ProgressBar1.Style:=pbstMarquee;
StatsLabel.Caption:='Scanning ...'; StatsLabel.Caption:=lisUDScanning;
Timer1.Enabled:=true;
RefreshButton.Enabled:=false; RefreshButton.Enabled:=false;
FNewUsesGraph:=CodeToolBoss.CreateUsesGraph; FNewUsesGraph:=CodeToolBoss.CreateUsesGraph;
@ -1105,10 +1125,11 @@ procedure TUnitDependenciesWindow.AddUsesSubNodes(UDNode: TUDNode);
// create a section node // create a section node
NodeText:=IntToStr(Cnt); NodeText:=IntToStr(Cnt);
case NodeTyp of case NodeTyp of
udnInterface: NodeText:=Format('interface uses: %s',[NodeText]); udnInterface: NodeText:=Format(lisUDInterfaceUses2, [NodeText]);
udnImplementation: NodeText:=Format('implementation uses: %s',[NodeText]); udnImplementation: NodeText:=Format(lisUDImplementationUses2, [NodeText]);
udnUsedByInterface: NodeText:=Format('used by interfaces: %s',[NodeText]); udnUsedByInterface: NodeText:=Format(lisUDUsedByInterfaces2, [NodeText]);
udnUsedByImplementation: NodeText:=Format('used by implementations: %s',[NodeText]); udnUsedByImplementation: NodeText:=Format(lisUDUsedByImplementations2, [
NodeText]);
else exit; else exit;
end; end;
SectionUDNode:=ParentUDNode.GetNode(NodeTyp,NodeText,true); SectionUDNode:=ParentUDNode.GetNode(NodeTyp,NodeText,true);
@ -1287,7 +1308,7 @@ end;
procedure TUnitDependenciesWindow.SetupGroupsTabSheet; procedure TUnitDependenciesWindow.SetupGroupsTabSheet;
begin begin
GroupsTabSheet.Caption:='Projects and packages'; GroupsTabSheet.Caption:=lisUDProjectsAndPackages;
GroupsLvlGraph:=TLvlGraphControl.Create(Self); GroupsLvlGraph:=TLvlGraphControl.Create(Self);
with GroupsLvlGraph do with GroupsLvlGraph do
@ -1316,46 +1337,47 @@ end;
procedure TUnitDependenciesWindow.SetupUnitsTabSheet; procedure TUnitDependenciesWindow.SetupUnitsTabSheet;
begin begin
UnitsTabSheet.Caption:='Units'; UnitsTabSheet.Caption:=lisUDUnits;
// start searching // start searching
SearchCustomFilesCheckBox.Caption:='Additional directories:'; SearchCustomFilesCheckBox.Caption:=lisUDAdditionalDirectories;
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.'; SearchCustomFilesCheckBox.Hint:=
lisUDByDefaultOnlyTheProjectUnitsAndTheSourceEditorUnit;
SearchCustomFilesComboBox.Text:=''; SearchCustomFilesComboBox.Text:='';
SearchCustomFilesBrowseButton.Caption:='Browse'; SearchCustomFilesBrowseButton.Caption:=lisPathEditBrowse;
SearchPkgsCheckBox.Caption:='All package units'; SearchPkgsCheckBox.Caption:=lisUDAllPackageUnits;
SearchSrcEditCheckBox.Caption:='All source editor units'; SearchSrcEditCheckBox.Caption:=lisUDAllSourceEditorUnits;
// view all units // view all units
AllUnitsGroupBox.Caption:='All units'; AllUnitsGroupBox.Caption:=lisUDAllUnits;
AllUnitsFilterEdit.Text:=ResStrFilter; AllUnitsFilterEdit.Text:=ResStrFilter;
AllUnitsShowDirsSpeedButton.Hint:='Show nodes for directories'; AllUnitsShowDirsSpeedButton.Hint:=lisUDShowNodesForDirectories;
AllUnitsShowDirsSpeedButton.LoadGlyphFromLazarusResource('pkg_hierarchical'); AllUnitsShowDirsSpeedButton.LoadGlyphFromLazarusResource('pkg_hierarchical');
AllUnitsShowDirsSpeedButton.Down:=true; AllUnitsShowDirsSpeedButton.Down:=true;
AllUnitsShowGroupNodesSpeedButton.Hint:='Show nodes for project and packages'; AllUnitsShowGroupNodesSpeedButton.Hint:=lisUDShowNodesForProjectAndPackages;
AllUnitsShowGroupNodesSpeedButton.LoadGlyphFromLazarusResource('pkg_hierarchical'); AllUnitsShowGroupNodesSpeedButton.LoadGlyphFromLazarusResource('pkg_hierarchical');
AllUnitsShowGroupNodesSpeedButton.Down:=true; AllUnitsShowGroupNodesSpeedButton.Down:=true;
AllUnitsSearchEdit.Text:=ResStrSearch; AllUnitsSearchEdit.Text:=ResStrSearch;
AllUnitsSearchNextSpeedButton.Hint:='Search next occurence of this phrase'; AllUnitsSearchNextSpeedButton.Hint:=lisUDSearchNextOccurenceOfThisPhrase;
AllUnitsSearchNextSpeedButton.LoadGlyphFromLazarusResource('arrow_down'); AllUnitsSearchNextSpeedButton.LoadGlyphFromLazarusResource('arrow_down');
AllUnitsSearchPrevSpeedButton.Hint:='Search previous occurence of this phrase'; AllUnitsSearchPrevSpeedButton.Hint:=lisUDSearchPreviousOccurenceOfThisPhrase;
AllUnitsSearchPrevSpeedButton.LoadGlyphFromLazarusResource('arrow_up'); AllUnitsSearchPrevSpeedButton.LoadGlyphFromLazarusResource('arrow_up');
// selected units // selected units
SelectedUnitsGroupBox.Caption:='Selected units'; SelectedUnitsGroupBox.Caption:=lisUDSelectedUnits;
SelUnitsSearchEdit.Text:=ResStrSearch; SelUnitsSearchEdit.Text:=ResStrSearch;
SelUnitsSearchNextSpeedButton.Hint:='Search next unit of this phrase'; SelUnitsSearchNextSpeedButton.Hint:=lisUDSearchNextUnitOfThisPhrase;
SelUnitsSearchNextSpeedButton.LoadGlyphFromLazarusResource('arrow_down'); SelUnitsSearchNextSpeedButton.LoadGlyphFromLazarusResource('arrow_down');
SelUnitsSearchPrevSpeedButton.Hint:='Search previous unit of this phrase'; SelUnitsSearchPrevSpeedButton.Hint:=lisUDSearchPreviousUnitOfThisPhrase;
SelUnitsSearchPrevSpeedButton.LoadGlyphFromLazarusResource('arrow_up'); SelUnitsSearchPrevSpeedButton.LoadGlyphFromLazarusResource('arrow_up');
// popup menu // popup menu
UnitsTVCopyFilenameMenuItem.Caption:='Copy Filename'; UnitsTVCopyFilenameMenuItem.Caption:=uemCopyFilename;
UnitsTVExpandAllMenuItem.Caption:='Expand all nodes'; UnitsTVExpandAllMenuItem.Caption:=lisUDExpandAllNodes;
UnitsTVCollapseAllMenuItem.Caption:='Collapse all nodes'; UnitsTVCollapseAllMenuItem.Caption:=lisUDCollapseAllNodes;
UpdateUnitsButtons; UpdateUnitsButtons;
end; end;
@ -1776,12 +1798,12 @@ end;
function TUnitDependenciesWindow.ResStrFilter: string; function TUnitDependenciesWindow.ResStrFilter: string;
begin begin
Result:='(Filter)'; Result:=lisUDFilter;
end; end;
function TUnitDependenciesWindow.ResStrSearch: string; function TUnitDependenciesWindow.ResStrSearch: string;
begin begin
Result:='(Search)'; Result:=lisUDSearch;
end; end;
function TUnitDependenciesWindow.NodeTextFitsFilter(const NodeText, function TUnitDependenciesWindow.NodeTextFitsFilter(const NodeText,