-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathOTA.SearchProject.pas
More file actions
76 lines (65 loc) · 2.65 KB
/
OTA.SearchProject.pas
File metadata and controls
76 lines (65 loc) · 2.65 KB
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
73
74
75
76
unit OTA.SearchProject;
interface
uses
System.Classes, System.SysUtils, Vcl.Menus, ToolsAPI;
type
TSearchProject = class(TNotifierObject, IOTAProjectMenuItemCreatorNotifier,
TFunc<IOTAProjectMenuItemCreatorNotifier>, TFunc<IOTAKeyboardBinding>)
private
FText: string;
procedure DoExecute(const aMenuContextList: IInterfaceList);
function FindActiveProjectIndex: Integer;
protected
procedure AddMenu(const Project: IOTAProject; const IdentList: TStrings; const
ProjectManagerMenuList: IInterfaceList; IsMultiSelect: Boolean);
function TFunc<IOTAKeyboardBinding>.Invoke = Invoke_IOTAKeyboardBinding;
function TFunc<IOTAProjectMenuItemCreatorNotifier>.Invoke = Invoke_IOTAProjectMenuItemCreatorNotifier;
function Invoke_IOTAKeyboardBinding: IOTAKeyboardBinding;
function Invoke_IOTAProjectMenuItemCreatorNotifier: IOTAProjectMenuItemCreatorNotifier;
end;
implementation
uses
Winapi.Windows, Vcl.Dialogs,
OTA.KeyboardBinding, OTA.ProjectManagerMenu;
procedure TSearchProject.AddMenu(const Project: IOTAProject;
const IdentList: TStrings; const ProjectManagerMenuList: IInterfaceList;
IsMultiSelect: Boolean);
begin
if Assigned(Project) and (IdentList.Contains(sProjectContainer) or IdentList.Contains(sProjectGroupContainer)) then
ProjectManagerMenuList.Add(TNotifierObject_ProjectManagerMenu.Create('Search Project', '', pmmpUserReorder, DoExecute, ClassName) as IOTAProjectManagerMenu);
end;
procedure TSearchProject.DoExecute(const aMenuContextList: IInterfaceList);
begin
if InputQuery('Find Project', 'Name:', FText) then begin
var G := (BorlandIDEServices as IOTAModuleServices).MainProjectGroup;
var iActive := FindActiveProjectIndex + 1;
if iActive >= G.ProjectCount then
iActive := 0; //start from first
for var i := iActive to G.ProjectCount - 1 do begin
if G.Projects[i].ProjectOptions.TargetName.ToLower.Contains(FText.ToLower) then begin
G.ActiveProject := G.Projects[i];
Break;
end;
end;
end;
end;
function TSearchProject.FindActiveProjectIndex: Integer;
begin
Result := -1;
var G := (BorlandIDEServices as IOTAModuleServices).MainProjectGroup;
for var i := 0 to G.ProjectCount - 1 do begin
if G.Projects[i] = G.ActiveProject then begin
Result := i;
Break;
end;
end;
end;
function TSearchProject.Invoke_IOTAKeyboardBinding: IOTAKeyboardBinding;
begin
Result := TOTA_KeyboardBinding.Create(ClassName, '', [ShortCut(VK_F3, [])]) as IOTAKeyboardBinding;
end;
function TSearchProject.Invoke_IOTAProjectMenuItemCreatorNotifier: IOTAProjectMenuItemCreatorNotifier;
begin
Result := Self as IOTAProjectMenuItemCreatorNotifier;
end;
end.