Initial commit

This commit is contained in:
Mark van Renswoude 2006-01-05 06:03:24 +00:00
parent 80459e91de
commit 4e7456ac74
12 changed files with 1316 additions and 0 deletions

View File

@ -0,0 +1,172 @@
<?xml version="1.0" encoding="utf-8"?>
<BorlandProject>
<PersonalityInfo>
<Option>
<Option Name="Personality">Delphi.Personality</Option>
<Option Name="ProjectType"></Option>
<Option Name="Version">1.0</Option>
<Option Name="GUID">{9DCE4F2A-AAF1-4F8E-ACA7-C36AFC829E47}</Option>
</Option>
</PersonalityInfo>
<Delphi.Personality>
<Source>
<Source Name="MainSource">UnitSwitcher.dpk</Source>
</Source>
<FileVersion>
<FileVersion Name="Version">7.0</FileVersion>
</FileVersion>
<Compiler>
<Compiler Name="A">8</Compiler>
<Compiler Name="B">0</Compiler>
<Compiler Name="C">1</Compiler>
<Compiler Name="D">1</Compiler>
<Compiler Name="E">0</Compiler>
<Compiler Name="F">0</Compiler>
<Compiler Name="G">1</Compiler>
<Compiler Name="H">1</Compiler>
<Compiler Name="I">1</Compiler>
<Compiler Name="J">0</Compiler>
<Compiler Name="K">0</Compiler>
<Compiler Name="L">1</Compiler>
<Compiler Name="M">0</Compiler>
<Compiler Name="N">1</Compiler>
<Compiler Name="O">1</Compiler>
<Compiler Name="P">1</Compiler>
<Compiler Name="Q">0</Compiler>
<Compiler Name="R">0</Compiler>
<Compiler Name="S">0</Compiler>
<Compiler Name="T">0</Compiler>
<Compiler Name="U">0</Compiler>
<Compiler Name="V">1</Compiler>
<Compiler Name="W">0</Compiler>
<Compiler Name="X">1</Compiler>
<Compiler Name="Y">1</Compiler>
<Compiler Name="Z">1</Compiler>
<Compiler Name="ShowHints">True</Compiler>
<Compiler Name="ShowWarnings">True</Compiler>
<Compiler Name="UnitAliases">WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;</Compiler>
<Compiler Name="NamespacePrefix"></Compiler>
<Compiler Name="GenerateDocumentation">False</Compiler>
<Compiler Name="DefaultNamespace"></Compiler>
<Compiler Name="SymbolDeprecated">True</Compiler>
<Compiler Name="SymbolLibrary">True</Compiler>
<Compiler Name="SymbolPlatform">True</Compiler>
<Compiler Name="SymbolExperimental">True</Compiler>
<Compiler Name="UnitLibrary">True</Compiler>
<Compiler Name="UnitPlatform">True</Compiler>
<Compiler Name="UnitDeprecated">True</Compiler>
<Compiler Name="UnitExperimental">True</Compiler>
<Compiler Name="HResultCompat">True</Compiler>
<Compiler Name="HidingMember">True</Compiler>
<Compiler Name="HiddenVirtual">True</Compiler>
<Compiler Name="Garbage">True</Compiler>
<Compiler Name="BoundsError">True</Compiler>
<Compiler Name="ZeroNilCompat">True</Compiler>
<Compiler Name="StringConstTruncated">True</Compiler>
<Compiler Name="ForLoopVarVarPar">True</Compiler>
<Compiler Name="TypedConstVarPar">True</Compiler>
<Compiler Name="AsgToTypedConst">True</Compiler>
<Compiler Name="CaseLabelRange">True</Compiler>
<Compiler Name="ForVariable">True</Compiler>
<Compiler Name="ConstructingAbstract">True</Compiler>
<Compiler Name="ComparisonFalse">True</Compiler>
<Compiler Name="ComparisonTrue">True</Compiler>
<Compiler Name="ComparingSignedUnsigned">True</Compiler>
<Compiler Name="CombiningSignedUnsigned">True</Compiler>
<Compiler Name="UnsupportedConstruct">True</Compiler>
<Compiler Name="FileOpen">True</Compiler>
<Compiler Name="FileOpenUnitSrc">True</Compiler>
<Compiler Name="BadGlobalSymbol">True</Compiler>
<Compiler Name="DuplicateConstructorDestructor">True</Compiler>
<Compiler Name="InvalidDirective">True</Compiler>
<Compiler Name="PackageNoLink">True</Compiler>
<Compiler Name="PackageThreadVar">True</Compiler>
<Compiler Name="ImplicitImport">True</Compiler>
<Compiler Name="HPPEMITIgnored">True</Compiler>
<Compiler Name="NoRetVal">True</Compiler>
<Compiler Name="UseBeforeDef">True</Compiler>
<Compiler Name="ForLoopVarUndef">True</Compiler>
<Compiler Name="UnitNameMismatch">True</Compiler>
<Compiler Name="NoCFGFileFound">True</Compiler>
<Compiler Name="ImplicitVariants">True</Compiler>
<Compiler Name="UnicodeToLocale">True</Compiler>
<Compiler Name="LocaleToUnicode">True</Compiler>
<Compiler Name="ImagebaseMultiple">True</Compiler>
<Compiler Name="SuspiciousTypecast">True</Compiler>
<Compiler Name="PrivatePropAccessor">True</Compiler>
<Compiler Name="UnsafeType">False</Compiler>
<Compiler Name="UnsafeCode">False</Compiler>
<Compiler Name="UnsafeCast">False</Compiler>
<Compiler Name="OptionTruncated">True</Compiler>
<Compiler Name="WideCharReduced">True</Compiler>
<Compiler Name="DuplicatesIgnored">True</Compiler>
<Compiler Name="UnitInitSeq">True</Compiler>
<Compiler Name="LocalPInvoke">True</Compiler>
<Compiler Name="MessageDirective">True</Compiler>
<Compiler Name="CodePage"></Compiler>
</Compiler>
<Linker>
<Linker Name="MapFile">0</Linker>
<Linker Name="OutputObjs">0</Linker>
<Linker Name="GenerateHpps">False</Linker>
<Linker Name="ConsoleApp">1</Linker>
<Linker Name="DebugInfo">False</Linker>
<Linker Name="RemoteSymbols">False</Linker>
<Linker Name="GenerateDRC">False</Linker>
<Linker Name="MinStackSize">16384</Linker>
<Linker Name="MaxStackSize">1048576</Linker>
<Linker Name="ImageBase">4194304</Linker>
<Linker Name="ExeDescription">UnitSwitcher</Linker>
</Linker>
<Directories>
<Directories Name="OutputDir"></Directories>
<Directories Name="UnitOutputDir"></Directories>
<Directories Name="PackageDLLOutputDir"></Directories>
<Directories Name="PackageDCPOutputDir"></Directories>
<Directories Name="SearchPath"></Directories>
<Directories Name="Packages"></Directories>
<Directories Name="Conditionals"></Directories>
<Directories Name="DebugSourceDirs"></Directories>
<Directories Name="UsePackages">False</Directories>
</Directories>
<Parameters>
<Parameters Name="RunParams"></Parameters>
<Parameters Name="HostApplication"></Parameters>
<Parameters Name="Launcher"></Parameters>
<Parameters Name="UseLauncher">False</Parameters>
<Parameters Name="DebugCWD"></Parameters>
<Parameters Name="Debug Symbols Search Path"></Parameters>
<Parameters Name="LoadAllSymbols">True</Parameters>
<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
</Parameters>
<VersionInfo>
<VersionInfo Name="IncludeVerInfo">True</VersionInfo>
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">0</VersionInfo>
<VersionInfo Name="Release">0</VersionInfo>
<VersionInfo Name="Build">0</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
<VersionInfo Name="Special">False</VersionInfo>
<VersionInfo Name="Private">False</VersionInfo>
<VersionInfo Name="DLL">False</VersionInfo>
<VersionInfo Name="Locale">1043</VersionInfo>
<VersionInfo Name="CodePage">1252</VersionInfo>
</VersionInfo>
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName"></VersionInfoKeys>
<VersionInfoKeys Name="FileDescription"></VersionInfoKeys>
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="InternalName"></VersionInfoKeys>
<VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys>
<VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys>
<VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys>
<VersionInfoKeys Name="ProductName"></VersionInfoKeys>
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="Comments"></VersionInfoKeys>
</VersionInfoKeys>
</Delphi.Personality>
<StarTeamAssociation></StarTeamAssociation>
<StarTeamNonRelativeFiles></StarTeamNonRelativeFiles>
</BorlandProject>

View File

@ -0,0 +1,39 @@
-$A8
-$B-
-$C+
-$D+
-$E-
-$F-
-$G+
-$H+
-$I+
-$J-
-$K-
-$L+
-$M-
-$N+
-$O+
-$P+
-$Q-
-$R-
-$S-
-$T-
-$U-
-$V+
-$W-
-$X+
-$YD
-$Z1
-cg
-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-H+
-W+
-M
-$M16384,1048576
-K$00400000
-LE"C:\Documents and Settings\PsychoMark\My Documents\Borland Studio Projects\Bpl"
-LN"C:\Documents and Settings\PsychoMark\My Documents\Borland Studio Projects\Bpl"
-Z
-w-UNSAFE_TYPE
-w-UNSAFE_CODE
-w-UNSAFE_CAST

View File

@ -0,0 +1,39 @@
package UnitSwitcher;
{$R *.res}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO ON}
{$SAFEDIVIDE OFF}
{$STACKFRAMES OFF}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DESCRIPTION 'UnitSwitcher'}
{$LIBSUFFIX 'D2006'}
{$DESIGNONLY}
{$IMPLICITBUILD OFF}
requires
rtl,
designide;
contains
UnSwClient in '..\..\Source\UnSwClient.pas',
UnSwObjects in '..\..\Source\UnSwObjects.pas',
UnSwDialog in '..\..\Source\UnSwDialog.pas' {frmUnSwDialog};
end.

Binary file not shown.

BIN
Resources/DataModule.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
Resources/Form.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
Resources/Project.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
Resources/Unit.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

107
Source/UnSwClient.pas Normal file
View File

@ -0,0 +1,107 @@
{$ASSERTIONS ON}
unit UnSwClient;
interface
implementation
uses
ActnList,
Classes,
Dialogs,
SysUtils,
ToolsAPI,
UnSwDialog,
UnSwObjects;
type
TUnitSwitcherHook = class(TObject)
private
FOldExecute: TNotifyEvent;
FViewUnitAction: TContainedAction;
protected
procedure NewExecute(Sender: TObject); virtual;
public
constructor Create();
destructor Destroy(); override;
end;
{ TUnitSwitcherHook}
constructor TUnitSwitcherHook.Create();
var
iAction: Integer;
ifNTA: INTAServices;
pAction: TContainedAction;
begin
try
Assert(Assigned(BorlandIDEServices), 'BorlandIDEServices not available.');
Assert(Supports(BorlandIDEServices, INTAServices, ifNTA),
'BorlandIDEServices does not support the ' +
'INTAServices interface.');
Assert(Supports(BorlandIDEServices, IOTAModuleServices),
'BorlandIDEServices does not support the ' +
'IOTAModuleServices interface.');
for iAction := 0 to Pred(ifNTA.ActionList.ActionCount) do
begin
pAction := ifNTA.ActionList.Actions[iAction];
if pAction.Name = 'ViewUnitCommand' then
begin
FOldExecute := pAction.OnExecute;
pAction.OnExecute := NewExecute;
FViewUnitAction := pAction;
break;
end;
end;
Assert(Assigned(FViewUnitAction), 'ViewUnitCommand action is not' +
'available in the IDE.');
except
on E:EAssertionFailed do
ShowMessage('Error while loading UnitSwitcher: ' + E.Message);
end;
end;
destructor TUnitSwitcherHook.Destroy();
begin
if Assigned(FViewUnitAction) then
FViewUnitAction.OnExecute := FOldExecute;
inherited;
end;
procedure TUnitSwitcherHook.NewExecute(Sender: TObject);
var
iModule: Integer;
pProject: IOTAProject;
pUnits: TUnSwUnitList;
begin
pProject := (BorlandIDEServices as IOTAModuleServices).GetActiveProject;
if not Assigned(pProject) then
exit;
pUnits := TUnSwUnitList.Create();
try
for iModule := 0 to Pred(pProject.GetModuleCount) do
pUnits.Add(TUnSwUnit.Create(pProject.GetModule(iModule)));
TfrmUnSwDialog.Execute(pUnits);
finally
FreeAndNil(pUnits);
end;
end;
var
GUnitSwitcher: TUnitSwitcherHook;
initialization
GUnitSwitcher := TUnitSwitcherHook.Create();
finalization
FreeAndNil(GUnitSwitcher);
end.

512
Source/UnSwDialog.dfm Normal file
View File

@ -0,0 +1,512 @@
object frmUnSwDialog: TfrmUnSwDialog
Left = 187
Top = 83
BorderIcons = [biSystemMenu]
Caption = 'UnitSwitcher - it almosts makes coffee.'
ClientHeight = 387
ClientWidth = 299
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
PixelsPerInch = 96
TextHeight = 13
object sbStatus: TStatusBar
Left = 0
Top = 368
Width = 299
Height = 19
Panels = <
item
Width = 50
end>
end
object pnlMain: TPanel
Left = 0
Top = 0
Width = 299
Height = 334
Align = alClient
BevelOuter = bvNone
BorderWidth = 4
TabOrder = 1
ExplicitWidth = 297
ExplicitHeight = 368
object pnlSearch: TPanel
Left = 4
Top = 4
Width = 291
Height = 25
Align = alTop
BevelOuter = bvNone
TabOrder = 0
object edtSearch: TEdit
Left = 0
Top = 0
Width = 291
Height = 21
Align = alTop
TabOrder = 0
OnChange = edtSearchChange
OnKeyDown = edtSearchKeyDown
end
end
object lstUnits: TListBox
Left = 4
Top = 29
Width = 291
Height = 301
Style = lbVirtualOwnerDraw
Align = alClient
ItemHeight = 20
TabOrder = 1
OnData = lstUnitsData
OnDrawItem = lstUnitsDrawItem
end
end
object Panel1: TPanel
Left = 0
Top = 334
Width = 299
Height = 34
Align = alBottom
BevelOuter = bvNone
TabOrder = 2
DesignSize = (
299
34)
object btnCancel: TButton
Left = 220
Top = 2
Width = 75
Height = 25
Anchors = [akTop, akRight]
Cancel = True
Caption = 'Cancel'
ModalResult = 2
TabOrder = 0
end
object btnOK: TButton
Left = 139
Top = 2
Width = 75
Height = 25
Anchors = [akTop, akRight]
Caption = 'OK'
Default = True
ModalResult = 1
TabOrder = 1
end
end
object ilsTypes: TImageList
Left = 8
Top = 32
Bitmap = {
494C010104000900040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000003000000001002000000000000030
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000008000
0000000000000000000080808000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000FFFFFF008080800080808000808080008080800080808000808080008080
8000808080008080800080808000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000080000000800000008000
0000800000000000000080808000C0C0C000C0C0C000C0C0C000C0C0C0000000
00000000000000000000000000000000000000000000FFFFFF00808080008080
8000808080008080800080808000808080008080800080808000808080008080
8000808080000000000000000000000000000000000000000000000000000000
0000FFFFFF00FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF0080808000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000080000000000000008000
0000000000000000000080808000808080008080800000000000808080008080
80000000000000000000000000000000000000000000FFFFFF00FFFFFF00C0C0
C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0
C000808080000000000000000000000000000000000000000000000000000000
0000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0
C000FFFFFF00C0C0C000808080000000000000000000FFFFFF00808080008080
8000808080008080800080808000808080008080800080808000808080008080
8000808080008080800080808000000000000000000080000000000000000000
0000000000000000000000000000000000008080800000000000000000000000
00000000000000000000000000000000000000000000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF00C0C0C000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000FFFFFF00FFFFFF0000000000000000000000000000000000000000000000
000000000000FFFFFF00808080000000000000000000FFFFFF00FFFFFF00C0C0
C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0
C000FFFFFF00C0C0C00080808000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000FFFFFF00FFFFFF00C0C0
C000FFFFFF00C0C0C000FFFFFF0000000000FFFFFF0080808000808080008080
8000808080008080800080808000000000000000000000000000000000000000
0000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0
C000FFFFFF00C0C0C000808080000000000000000000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF0080808000000000008080800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF00C0C0C00000000000FFFFFF00FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF0080808000000000000000000000000000000000000000
0000FFFFFF000000FF000000FF000000FF000000FF000000FF000000FF000000
FF000000FF000000FF00808080000000000000000000FFFFFF00FFFFFF00C0C0
C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0
C000FFFFFF00C0C0C00080808000000000008080800080808000000000000000
000000000000FFFFFF0080808000808080008080800080808000808080008080
80008080800080808000808080000000000000000000FFFFFF00FFFFFF00C0C0
C000FFFFFF00C0C0C000FFFFFF0000000000FFFFFF00C0C0C000FFFFFF00C0C0
C000FFFFFF00C0C0C00080808000000000000000000080000000000000000000
0000FFFFFF000000FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF000000FF00808080000000000000000000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF0080808000000000000000000000000000000000000000
000000000000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF00808080000000000000000000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF00C0C0C00000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00000000000000000000000000000000000000
0000FFFFFF000000FF000000FF000000FF000000FF000000FF000000FF000000
FF000000FF000000FF00808080000000000000000000FFFFFF00FFFFFF00C0C0
C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0
C000FFFFFF00C0C0C00080808000000000000000000000000000000000000000
000000000000FFFFFF00FFFFFF00C0C0C0000000FF000000FF000000FF00C0C0
C000FFFFFF00C0C0C000808080000000000000000000FFFFFF00FFFFFF00C0C0
C000FFFFFF00C0C0C000FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0
C000FFFFFF00C0C0C000808080000000000000000000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF0080808000000000000000000000000000000000000000
000000000000FFFFFF00C0C0C000FFFFFF000000FF000000FF00C0C0C000FFFF
FF00C0C0C000FFFFFF00808080000000000000000000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF00C0C0C00000000000FF000000FF000000FF000000FF00
0000FF00000000000000C0C0C000000000000000000000000000000000000000
0000FFFFFF00FFFFFF0000000000000000000000000000000000000000000000
0000C0C0C000FFFFFF00808080000000000000000000FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00000000000000000000000000000000000000
000000000000FFFFFF00FFFFFF00C0C0C0000000FF00C0C0C0000000FF000000
FF00FFFFFF00C0C0C000808080000000000000000000FFFFFF00FFFFFF00C0C0
C000FFFFFF00C0C0C000FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0
C000FFFFFF008080800080808000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF00808080000000000000000000FFFFFF00C0C0C000FFFF
FF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF
FF00808080000000000000000000000000000000000000000000000000000000
0000FFFFFF00FFFFFF0000000000000000000000000000000000C0C0C000FFFF
FF000000000000000000000000000000000000000000FF000000FF000000FF00
0000FF000000FF000000FF000000FF000000FF00000000000000C0C0C0000000
0000C0C0C00000000000C0C0C000000000000000000000000000000000000000
000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF000000000000000000FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF000000000000000000000000000000000000000000000000000000
0000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0
C00000000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000FF000000FF000000FF000000FF00000000000000C0C0C0000000
0000C0C0C00000000000C0C0C0000000000000000000FF000000FF000000FF00
0000FF000000FF000000FF00000000000000C0C0C00000000000C0C0C0000000
0000C0C0C0000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000424D3E000000000000003E000000
2800000040000000300000000100010000000000800100000000000000000000
000000000000000000000000FFFFFF0000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000E000FFFFEC0F0003E000FFFF840F0003
E0000000AC0F0003E0000000BF3F0000E0000000FFFF00006000000010000000
200000001000000000000000B000000020000000F000000060000000F0000000
E0000000F0000000E0000000F0000003E0000000F0000003E0010000F0000003
E003FFFFF0000003E007FFFFF000000300000000000000000000000000000000
000000000000}
end
end

191
Source/UnSwDialog.pas Normal file
View File

@ -0,0 +1,191 @@
unit UnSwDialog;
interface
uses
Classes,
ComCtrls,
Controls,
ExtCtrls,
Forms,
ImgList,
StdCtrls,
Windows,
UnSwObjects;
type
TfrmUnSwDialog = class(TForm)
edtSearch: TEdit;
ilsTypes: TImageList;
lstUnits: TListBox;
pnlMain: TPanel;
pnlSearch: TPanel;
sbStatus: TStatusBar;
Panel1: TPanel;
btnCancel: TButton;
btnOK: TButton;
procedure edtSearchChange(Sender: TObject);
procedure edtSearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure lstUnitsData(Control: TWinControl; Index: Integer; var Data: string);
procedure lstUnitsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
private
FUnitList: TUnSwUnitList;
FTypeFilteredList: TUnSwUnitList;
FInputFilteredList: TUnSwUnitList;
FTypeFilter: TUnSwUnitTypeFilter;
FInputFilter: TUnSwUnitSimpleFilter;
function InternalExecute(const AUnits: TUnSwUnitList): Integer;
procedure UpdateList();
function GetActiveUnit(): TUnSwUnit;
public
class function Execute(const AUnits: TUnSwUnitList): Integer;
end;
implementation
uses
SysUtils,
Graphics;
{$R *.dfm}
{ TfrmUnSwDialog }
class function TfrmUnSwDialog.Execute(const AUnits: TUnSwUnitList): Integer;
begin
with Self.Create(nil) do
try
Result := InternalExecute(AUnits);
finally
Free();
end;
end;
function SortByName(Item1, Item2: Pointer): Integer;
begin
Result := CompareText(TUnSwUnit(Item1).Name, TUnSwUnit(Item2).Name)
end;
function TfrmUnSwDialog.InternalExecute(const AUnits: TUnSwUnitList): Integer;
begin
Result := -1;
FUnitList := AUnits;
FTypeFilteredList := TUnSwUnitList.Create();
FInputFilteredList := TUnSwUnitList.Create();
FTypeFilter := TUnSwUnitTypeFilter.Create();
FInputFilter := TUnSwUnitSimpleFilter.Create();
try
FTypeFilteredList.Clone(FUnitList);
FTypeFilteredList.ApplyFilter(FTypeFilter);
FTypeFilteredList.Sort(SortByName);
UpdateList();
Self.ShowModal();
finally
FreeAndNil(FInputFilter);
FreeAndNil(FTypeFilter);
FreeAndNil(FInputFilteredList);
FreeAndNil(FTypeFilteredList);
end;
end;
procedure TfrmUnSwDialog.UpdateList();
var
pActive: TUnSwUnit;
begin
pActive := GetActiveUnit();
// #ToDo1 Try to select the previous unit, otherwise select the first
FInputFilteredList.Clone(FTypeFilteredList);
FInputFilteredList.ApplyFilter(FInputFilter);
lstUnits.Count := FInputFilteredList.Count;
if FInputFilteredList.Count > 0 then
begin
if Assigned(pActive) then
lstUnits.ItemIndex := FInputFilteredList.IndexOf(pActive);
if lstUnits.ItemIndex = -1 then
lstUnits.ItemIndex := 0;
end;
end;
function TfrmUnSwDialog.GetActiveUnit(): TUnSwUnit;
begin
Result := nil;
if lstUnits.ItemIndex > -1 then
Result := FInputFilteredList[lstUnits.ItemIndex];
end;
procedure TfrmUnSwDialog.edtSearchChange(Sender: TObject);
begin
FInputFilter.Filter := edtSearch.Text;
UpdateList();
end;
procedure TfrmUnSwDialog.edtSearchKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Shift = [] then
case Key of
VK_UP:
if lstUnits.ItemIndex > 0 then
lstUnits.ItemIndex := Pred(lstUnits.ItemIndex);
VK_DOWN:
if lstUnits.ItemIndex < Pred(lstUnits.Items.Count) then
lstUnits.ItemIndex := Succ(lstUnits.ItemIndex);
end;
end;
procedure TfrmUnSwDialog.lstUnitsData(Control: TWinControl; Index: Integer;
var Data: string);
begin
Data := FInputFilteredList[Index].Name;
end;
procedure TfrmUnSwDialog.lstUnitsDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
iIcon: Integer;
rText: TRect;
sText: String;
begin
with TListBox(Control) do
begin
if odSelected in State then
begin
Canvas.Brush.Color := clHighlight;
Canvas.Font.Color := clHighlightText;
end else
begin
Canvas.Brush.Color := clWindow;
Canvas.Font.Color := clWindowText;
end;
Canvas.FillRect(Rect);
rText := Rect;
InflateRect(rText, -2, -2);
iIcon := 0;
case FInputFilteredList[Index].UnitType of
swutForm: iIcon := 1;
swutDataModule: iIcon := 2;
swutProjUnit: iIcon := 3;
end;
ilsTypes.Draw(Canvas, rText.Left, rText.Top, iIcon);
Inc(rText.Left, ilsTypes.Width + 4);
sText := FInputFilteredList[Index].Name;
DrawText(Canvas.Handle, PChar(sText), Length(sText), rText, DT_SINGLELINE or
DT_LEFT or DT_VCENTER or DT_END_ELLIPSIS);
end;
end;
end.

256
Source/UnSwObjects.pas Normal file
View File

@ -0,0 +1,256 @@
unit UnSwObjects;
interface
uses
Classes,
Contnrs,
ToolsAPI;
type
// Forward declarations
TUnSwUnitFilter = class;
TUnSwUnitType = (
swutForm = 0,
swutDataModule = 1,
swutProjUnit = 2,
swutUnit = 3,
swutRc = 4,
swutAsm = 5,
swutDef = 6,
swutObj = 7,
swutRes = 8,
swutLib = 9,
swutTypeLib = 10,
swutPackageImport = 11,
swutFormResource = 12,
swutCustom = 13,
swutIDL = 14
);
TUnSwUnitTypes = set of TUnSwUnitType;
TUnSwUnit = class(TPersistent)
private
FModule: IOTAModuleInfo;
function GetName(): String;
function GetFileName(): String;
function GetUnitType(): TUnSwUnitType;
public
constructor Create(const AModule: IOTAModuleInfo); virtual;
property Name: String read GetName;
property FileName: String read GetFileName;
property UnitType: TUnSwUnitType read GetUnitType;
end;
TUnSwUnitList = class(TPersistent)
private
FItems: TObjectList;
function GetCount(): Integer;
function GetItem(Index: Integer): TUnSwUnit;
procedure SetItem(Index: Integer; Value: TUnSwUnit);
public
constructor Create();
destructor Destroy(); override;
function Add(const AUnit: TUnSwUnit): Integer; virtual;
function IndexOf(const AUnit: TUnSwUnit): Integer;
procedure Sort(Compare: TListSortCompare);
procedure Clone(const ASource: TUnSwUnitList); virtual;
procedure ApplyFilter(const AFilter: TUnSwUnitFilter); virtual;
property Count: Integer read GetCount;
property Items[Index: Integer]: TUnSwUnit read GetItem
write SetItem; default;
end;
TUnSwUnitFilter = class(TObject)
protected
function IsFiltered(const AUnit: TUnSwUnit): Boolean; virtual; abstract;
public
constructor Create(); virtual;
end;
TUnSwUnitSimpleFilter = class(TUnSwUnitFilter)
private
FFilter: String;
procedure SetFilter(const Value: String);
protected
function IsFiltered(const AUnit: TUnSwUnit): Boolean; override;
public
property Filter: String read FFilter write SetFilter;
end;
TUnSwUnitTypeFilter = class(TUnSwUnitFilter)
private
FIncludeDataModules: Boolean;
FIncludeForms: Boolean;
FIncludeProjectSource: Boolean;
protected
function IsFiltered(const AUnit: TUnSwUnit): Boolean; override;
public
constructor Create(); override;
property IncludeDataModules: Boolean read FIncludeDataModules write FIncludeDataModules;
property IncludeForms: Boolean read FIncludeForms write FIncludeForms;
property IncludeProjectSource: Boolean read FIncludeProjectSource write FIncludeProjectSource;
end;
implementation
uses
SysUtils;
{ TUnSwUnit }
constructor TUnSwUnit.Create(const AModule: IOTAModuleInfo);
begin
inherited Create();
FModule := AModule;
end;
function TUnSwUnit.GetName(): String;
begin
Result := FModule.Name;
end;
function TUnSwUnit.GetFileName(): String;
begin
Result := FModule.FileName;
end;
function TUnSwUnit.GetUnitType(): TUnSwUnitType;
begin
Result := TUnSwUnitType(FModule.ModuleType);
if (Result = swutForm) and (Length(FModule.FormName) = 0) then
Result := swutUnit;
end;
{ TUnSwUnitList}
constructor TUnSwUnitList.Create();
begin
inherited Create();
FItems := TObjectList.Create(True);
end;
destructor TUnSwUnitList.Destroy();
begin
FreeAndNil(FItems);
inherited;
end;
function TUnSwUnitList.Add(const AUnit: TUnSwUnit): Integer;
begin
Result := FItems.Add(AUnit);
end;
function TUnSwUnitList.IndexOf(const AUnit: TUnSwUnit): Integer;
begin
Result := FItems.IndexOf(AUnit);
end;
procedure TUnSwUnitList.Sort(Compare: TListSortCompare);
begin
FItems.Sort(Compare);
end;
procedure TUnSwUnitList.ApplyFilter(const AFilter: TUnSwUnitFilter);
var
iItem: Integer;
begin
for iItem := Pred(Count) downto 0 do
if AFilter.IsFiltered(Items[iItem]) then
FItems.Delete(iItem);
end;
procedure TUnSwUnitList.Clone(const ASource: TUnSwUnitList);
var
iItem: Integer;
begin
FItems.Clear();
FItems.OwnsObjects := False;
for iItem := 0 to Pred(ASource.Count) do
FItems.Add(ASource[iItem]);
end;
function TUnSwUnitList.GetCount(): Integer;
begin
Result := FItems.Count;
end;
function TUnSwUnitList.GetItem(Index: Integer): TUnSwUnit;
begin
Result := TUnSwUnit(FItems[Index]);
end;
procedure TUnSwUnitList.SetItem(Index: Integer; Value: TUnSwUnit);
begin
FItems[Index] := Value;
end;
{ TUnSwUnitFilter }
constructor TUnSwUnitFilter.Create();
begin
inherited Create();
end;
{ TUnSwUnitSimpleFilter }
function TUnSwUnitSimpleFilter.IsFiltered(const AUnit: TUnSwUnit): Boolean;
begin
Result := (Length(FFilter) > 0) and
(AnsiPos(FFilter, LowerCase(AUnit.Name)) = 0);
end;
procedure TUnSwUnitSimpleFilter.SetFilter(const Value: String);
begin
FFilter := LowerCase(Value);
end;
{ TUnSwUnitTypeFilter }
constructor TUnSwUnitTypeFilter.Create();
begin
inherited;
FIncludeDataModules := True;
FIncludeForms := True;
FIncludeProjectSource := True;
end;
function TUnSwUnitTypeFilter.IsFiltered(const AUnit: TUnSwUnit): Boolean;
var
eValidTypes: TUnSwUnitTypes;
begin
eValidTypes := [swutUnit];
if FIncludeDataModules then
Include(eValidTypes, swutDataModule);
if FIncludeForms then
Include(eValidTypes, swutForm);
if FIncludeProjectSource then
Include(eValidTypes, swutProjUnit);
Result := not (AUnit.UnitType in eValidTypes);
end;
end.