2006-01-07 19:56:40 +00:00
|
|
|
{: Implements unit filtering visitors.
|
|
|
|
|
|
|
|
Last changed: $Date$
|
|
|
|
Revision: $Rev$
|
|
|
|
Author: $Author$
|
|
|
|
}
|
2006-01-05 21:04:59 +00:00
|
|
|
unit UnSwFilters;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
UnSwObjects;
|
|
|
|
|
|
|
|
type
|
2006-01-06 05:57:45 +00:00
|
|
|
TUnSwUnitFilter = class(TUnSwNoRefIntfObject, IUnSwVisitor)
|
2006-01-05 21:04:59 +00:00
|
|
|
private
|
|
|
|
FList: TUnSwUnitList;
|
|
|
|
protected
|
|
|
|
// Called by default by all other Visit methods
|
|
|
|
procedure VisitUnit(const AUnit: TUnSwUnit); virtual;
|
|
|
|
|
|
|
|
procedure VisitModule(const AUnit: TUnSwModuleUnit); virtual;
|
|
|
|
procedure VisitProject(const AUnit: TUnSwProjectUnit); virtual;
|
|
|
|
|
|
|
|
procedure FilterUnit(const AUnit: TUnSwUnit); virtual;
|
|
|
|
public
|
2007-02-09 13:58:37 +00:00
|
|
|
procedure FilterList(AList: TUnSwUnitList);
|
2006-01-05 21:04:59 +00:00
|
|
|
end;
|
|
|
|
|
2006-01-06 05:57:45 +00:00
|
|
|
TUnSwUnitSimpleFilter = class(TUnSwUnitFilter)
|
2006-01-05 21:04:59 +00:00
|
|
|
private
|
|
|
|
FFilter: String;
|
|
|
|
|
|
|
|
procedure SetFilter(const Value: String);
|
|
|
|
public
|
|
|
|
property Filter: String read FFilter write SetFilter;
|
|
|
|
end;
|
|
|
|
|
2006-01-06 05:57:45 +00:00
|
|
|
TUnSwUnitSimpleNameFilter = class(TUnSwUnitSimpleFilter)
|
|
|
|
protected
|
|
|
|
procedure VisitUnit(const AUnit: TUnSwUnit); override;
|
|
|
|
end;
|
|
|
|
|
|
|
|
TUnSwUnitSimpleFormNameFilter = class(TUnSwUnitSimpleNameFilter)
|
|
|
|
protected
|
|
|
|
procedure VisitModule(const AUnit: TUnSwModuleUnit); override;
|
|
|
|
end;
|
|
|
|
|
|
|
|
TUnSwUnitTypeFilter = class(TUnSwUnitFilter)
|
2006-01-05 21:04:59 +00:00
|
|
|
private
|
|
|
|
FIncludeDataModules: Boolean;
|
|
|
|
FIncludeForms: Boolean;
|
|
|
|
FIncludeProjectSource: Boolean;
|
|
|
|
FIncludeUnits: Boolean;
|
|
|
|
protected
|
|
|
|
procedure VisitModule(const AUnit: TUnSwModuleUnit); override;
|
|
|
|
procedure VisitProject(const AUnit: TUnSwProjectUnit); override;
|
|
|
|
public
|
2007-02-09 13:58:37 +00:00
|
|
|
constructor Create;
|
2006-01-05 21:04:59 +00:00
|
|
|
|
|
|
|
property IncludeDataModules: Boolean read FIncludeDataModules write FIncludeDataModules;
|
|
|
|
property IncludeForms: Boolean read FIncludeForms write FIncludeForms;
|
|
|
|
property IncludeProjectSource: Boolean read FIncludeProjectSource write FIncludeProjectSource;
|
|
|
|
property IncludeUnits: Boolean read FIncludeUnits write FIncludeUnits;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
|
|
SysUtils;
|
|
|
|
|
|
|
|
|
|
|
|
{ TUnSwUnitFilter }
|
2007-02-09 13:58:37 +00:00
|
|
|
procedure TUnSwUnitFilter.FilterList(AList: TUnSwUnitList);
|
2006-01-05 21:04:59 +00:00
|
|
|
begin
|
|
|
|
FList := AList;
|
2007-02-09 13:58:37 +00:00
|
|
|
try
|
|
|
|
FList.AcceptVisitor(Self);
|
|
|
|
finally
|
|
|
|
FList := nil;
|
|
|
|
end;
|
2006-01-05 21:04:59 +00:00
|
|
|
end;
|
|
|
|
|
2007-02-09 13:58:37 +00:00
|
|
|
|
2006-01-05 21:04:59 +00:00
|
|
|
procedure TUnSwUnitFilter.VisitUnit(const AUnit: TUnSwUnit);
|
|
|
|
begin
|
|
|
|
end;
|
|
|
|
|
2007-02-09 13:58:37 +00:00
|
|
|
|
2006-01-05 21:04:59 +00:00
|
|
|
procedure TUnSwUnitFilter.VisitModule(const AUnit: TUnSwModuleUnit);
|
|
|
|
begin
|
|
|
|
VisitUnit(AUnit);
|
|
|
|
end;
|
|
|
|
|
2007-02-09 13:58:37 +00:00
|
|
|
|
2006-01-05 21:04:59 +00:00
|
|
|
procedure TUnSwUnitFilter.VisitProject(const AUnit: TUnSwProjectUnit);
|
|
|
|
begin
|
|
|
|
VisitUnit(AUnit);
|
|
|
|
end;
|
|
|
|
|
2007-02-09 13:58:37 +00:00
|
|
|
|
2006-01-05 21:04:59 +00:00
|
|
|
procedure TUnSwUnitFilter.FilterUnit(const AUnit: TUnSwUnit);
|
|
|
|
begin
|
|
|
|
FList.Remove(AUnit);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{ TUnSwUnitSimpleFilter }
|
2006-01-06 05:57:45 +00:00
|
|
|
procedure TUnSwUnitSimpleFilter.SetFilter(const Value: String);
|
|
|
|
begin
|
|
|
|
FFilter := LowerCase(Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{ TUnSwUnitSimpleNameFilter }
|
|
|
|
procedure TUnSwUnitSimpleNameFilter.VisitUnit(const AUnit: TUnSwUnit);
|
2006-01-05 21:04:59 +00:00
|
|
|
begin
|
2006-01-06 05:57:45 +00:00
|
|
|
if (Length(Filter) > 0) and
|
|
|
|
(AnsiPos(Filter, LowerCase(AUnit.Name)) = 0) then
|
2006-01-05 21:04:59 +00:00
|
|
|
FilterUnit(AUnit);
|
|
|
|
end;
|
|
|
|
|
2006-01-06 05:57:45 +00:00
|
|
|
|
|
|
|
{ TUnSwUnitSimpleFormNameFilter }
|
|
|
|
procedure TUnSwUnitSimpleFormNameFilter.VisitModule(const AUnit: TUnSwModuleUnit);
|
2006-01-05 21:04:59 +00:00
|
|
|
begin
|
2006-01-06 05:57:45 +00:00
|
|
|
if (Length(Filter) > 0) and
|
|
|
|
(AnsiPos(Filter, LowerCase(AUnit.FormName)) = 0) then
|
|
|
|
FilterUnit(AUnit);
|
2006-01-05 21:04:59 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{ TUnSwUnitTypeFilter }
|
2007-02-09 13:58:37 +00:00
|
|
|
constructor TUnSwUnitTypeFilter.Create;
|
2006-01-05 21:04:59 +00:00
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
FIncludeDataModules := True;
|
|
|
|
FIncludeForms := True;
|
|
|
|
FIncludeProjectSource := True;
|
|
|
|
FIncludeUnits := True;
|
|
|
|
end;
|
|
|
|
|
2007-02-09 13:58:37 +00:00
|
|
|
|
2006-01-05 21:04:59 +00:00
|
|
|
procedure TUnSwUnitTypeFilter.VisitModule(const AUnit: TUnSwModuleUnit);
|
|
|
|
var
|
2006-01-07 19:56:40 +00:00
|
|
|
validTypes: TUnSwUnitTypes;
|
2006-01-05 21:04:59 +00:00
|
|
|
|
|
|
|
begin
|
2006-01-07 19:56:40 +00:00
|
|
|
validTypes := [];
|
2006-01-05 21:04:59 +00:00
|
|
|
|
|
|
|
if FIncludeDataModules then
|
2006-01-07 19:56:40 +00:00
|
|
|
Include(validTypes, swutDataModule);
|
2006-01-05 21:04:59 +00:00
|
|
|
|
|
|
|
if FIncludeForms then
|
2006-01-07 19:56:40 +00:00
|
|
|
Include(validTypes, swutForm);
|
2006-01-05 21:04:59 +00:00
|
|
|
|
|
|
|
if FIncludeUnits then
|
2006-01-07 19:56:40 +00:00
|
|
|
Include(validTypes, swutUnit);
|
2006-01-05 21:04:59 +00:00
|
|
|
|
2006-01-07 19:56:40 +00:00
|
|
|
if not (AUnit.UnitType in validTypes) then
|
2006-01-05 21:04:59 +00:00
|
|
|
FilterUnit(AUnit);
|
|
|
|
end;
|
|
|
|
|
2007-02-09 13:58:37 +00:00
|
|
|
|
2006-01-05 21:04:59 +00:00
|
|
|
procedure TUnSwUnitTypeFilter.VisitProject(const AUnit: TUnSwProjectUnit);
|
|
|
|
begin
|
|
|
|
if not FIncludeProjectSource then
|
|
|
|
FilterUnit(AUnit);
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|