-
Notifications
You must be signed in to change notification settings - Fork 2
/
OTA.SearchMissingFile.pas
72 lines (62 loc) · 2.13 KB
/
OTA.SearchMissingFile.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
unit OTA.SearchMissingFile;
interface
uses
Vcl.Menus, ToolsAPI;
type
TSearchMissingFile = class(TNotifierObject, INTAProjectMenuCreatorNotifier)
private
FText: string;
procedure OnMenuClick(Sender: TObject);
protected
function AddMenu(const Ident: string): TMenuItem;
function CanHandle(const Ident: string): Boolean;
public
procedure AfterConstruction; override;
end;
implementation
uses
System.SysUtils, Vcl.Dialogs;
function TSearchMissingFile.AddMenu(const Ident: string): TMenuItem;
begin
Result := TMenuItem.Create(nil);
Result.Caption := 'Search Missing File';
Result.OnClick := OnMenuClick;
end;
procedure TSearchMissingFile.AfterConstruction;
begin
inherited;
FText := 'Library.rc'; //by default search Library.rc
end;
function TSearchMissingFile.CanHandle(const Ident: string): Boolean;
begin
Result := SameText(Ident, {$if CompilerVersion < 21}sProjectContainer{$else}sProjectGroupContainer{$ifend});
end;
procedure TSearchMissingFile.OnMenuClick(Sender: TObject);
var i, j, lCount: integer;
bFound: boolean;
G: IOTAProjectGroup;
M: IOTAMessageGroup;
begin
if InputQuery('Search Missing File', 'Please enter file name', FText) then begin
lCount := 0;
M := (BorlandIDEServices as IOTAMessageServices).AddMessageGroup(Format('Missing "%s" Projects', [FText]));
(BorlandIDEServices as IOTAMessageServices).ClearMessageGroup(M);
G := (BorlandIDEServices as IOTAModuleServices).MainProjectGroup;
for i := 0 to G.ProjectCount - 1 do begin
if not SameText(ExtractFileExt(G.Projects[i].ProjectOptions.TargetName), '.BPL') then Continue;
bFound := False;
for j := 0 to G.Projects[i].GetModuleCount - 1 do begin
bFound := SameText(G.Projects[i].GetModule(j).Name, FText);
if bFound then
Break;
end;
if not bFound then begin
(BorlandIDEServices as IOTAMessageServices).AddTitleMessage(ExtractFileName(G.Projects[i].ProjectOptions.TargetName), M);
Inc(lCount);
end;
end;
ShowMessageFmt('%d projects found.', [lCount]);
(BorlandIDEServices as IOTAMessageServices).ShowMessageView(M);
end;
end;
end.