-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDW.OTA.ProjectManagerMenu.pas
More file actions
302 lines (252 loc) · 8.37 KB
/
DW.OTA.ProjectManagerMenu.pas
File metadata and controls
302 lines (252 loc) · 8.37 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
unit DW.OTA.ProjectManagerMenu;
{*******************************************************}
{ }
{ TOTAL - Terrific Open Tools API Library }
{ }
{*******************************************************}
interface
uses
// RTL
System.Classes, System.SysUtils,
// Design
ToolsAPI,
// TOTAL
DW.OTA.Notifiers;
type
TProjectManagerMenu = class;
TProjectManagerMenuNotifier = class(TTOTALNotifier, IUnknown, IOTANotifier, IOTAProjectMenuItemCreatorNotifier)
protected
procedure AddMenuItem(const AItem: TProjectManagerMenu; const APosition: Integer);
procedure DoAddMenu(const AProject: IOTAProject; const AIdentList: TStrings; const AProjectManagerMenuList: IInterfaceList;
AIsMultiSelect: Boolean); virtual;
procedure DoAddGroupMenu(const AProject: IOTAProject; const AIdentList: TStrings; const AProjectManagerMenuList: IInterfaceList;
AIsMultiSelect: Boolean); virtual;
function FindItem(const AProjectManagerMenuList: IInterfaceList; const AVerb: string): Integer;
public
{ IOTANotifier }
procedure AfterSave;
procedure BeforeSave;
procedure Destroyed;
procedure Modified;
{ IOTAProjectMenuItemCreatorNotifier }
procedure AddMenu(const AProject: IOTAProject; const AIdentList: TStrings; const AProjectManagerMenuList: IInterfaceList;
AIsMultiSelect: Boolean);
public
constructor Create;
destructor Destroy; override;
procedure AddNotifier; override;
procedure RemoveNotifier; override;
end;
TProjectManagerMenu = class(TNotifierObject, IOTALocalMenu, IOTAProjectManagerMenu)
private
FCaption: string;
FExecuteProc: TProc;
FName: string;
FParent: string;
FPosition: Integer;
FVerb: string;
public
{ IOTALocalMenu }
function GetCaption: string; virtual;
function GetChecked: Boolean; virtual;
function GetEnabled: Boolean; virtual;
function GetHelpContext: Integer;
function GetName: string;
function GetParent: string;
function GetPosition: Integer;
function GetVerb: string;
procedure SetCaption(const Value: string);
procedure SetChecked(Value: Boolean);
procedure SetEnabled(Value: Boolean);
procedure SetHelpContext(Value: Integer);
procedure SetName(const Value: string);
procedure SetParent(const Value: string);
procedure SetPosition(Value: Integer);
procedure SetVerb(const Value: string);
{ IOTAProjectManagerMenu }
function GetIsMultiSelectable: Boolean;
procedure Execute(const MenuContextList: IInterfaceList); overload;
function PostExecute(const MenuContextList: IInterfaceList): Boolean;
function PreExecute(const MenuContextList: IInterfaceList): Boolean;
procedure SetIsMultiSelectable(Value: Boolean);
public
constructor Create(const ACaption, AVerb: string; const APosition: Integer; const AExecuteProc: TProc = nil;
const AName: string = ''; const AParent: string = '');
end;
TProjectManagerMenuSeparator = class(TProjectManagerMenu, IOTAProjectManagerMenu)
public
constructor Create(APosition: Integer; const AParent: string = '');
end;
implementation
uses
DW.OTA.Helpers;
{ TProjectManagerMenuNotifier }
constructor TProjectManagerMenuNotifier.Create;
begin
inherited;
// FIndex := (BorlandIDEServices as IOTAProjectManager).AddMenuItemCreatorNotifier(Self);
end;
destructor TProjectManagerMenuNotifier.Destroy;
begin
// (BorlandIDEServices as IOTAProjectManager).RemoveMenuItemCreatorNotifier(FIndex);
inherited;
end;
procedure TProjectManagerMenuNotifier.AddNotifier;
begin
Index := (BorlandIDEServices as IOTAProjectManager).AddMenuItemCreatorNotifier(Self);
end;
procedure TProjectManagerMenuNotifier.RemoveNotifier;
begin
(BorlandIDEServices as IOTAProjectManager).RemoveMenuItemCreatorNotifier(Index);
end;
procedure TProjectManagerMenuNotifier.DoAddMenu(const AProject: IOTAProject; const AIdentList: TStrings;
const AProjectManagerMenuList: IInterfaceList; AIsMultiSelect: Boolean);
begin
//
end;
procedure TProjectManagerMenuNotifier.DoAddGroupMenu(const AProject: IOTAProject; const AIdentList: TStrings;
const AProjectManagerMenuList: IInterfaceList; AIsMultiSelect: Boolean);
begin
//
end;
procedure TProjectManagerMenuNotifier.AddMenu(const AProject: IOTAProject; const AIdentList: TStrings; const AProjectManagerMenuList: IInterfaceList;
AIsMultiSelect: Boolean);
begin
if AIdentList.IndexOf(sProjectContainer) > -1 then
DoAddMenu(AProject, AIdentList, AProjectManagerMenuList, AIsMultiSelect)
else if AIdentList.IndexOf(sProjectGroupContainer) > -1 then
DoAddGroupMenu(AProject, AIdentList, AProjectManagerMenuList, AIsMultiSelect);
end;
procedure TProjectManagerMenuNotifier.AddMenuItem(const AItem: TProjectManagerMenu; const APosition: Integer);
begin
end;
function TProjectManagerMenuNotifier.FindItem(const AProjectManagerMenuList: IInterfaceList; const AVerb: string): Integer;
var
I: Integer;
begin
Result := -1;
for I := 0 To AProjectManagerMenuList.Count - 1 Do
begin
if CompareText((AProjectManagerMenuList[I] as IOTAProjectManagerMenu).Verb, AVerb) = 0 Then
Exit(I);
end;
end;
procedure TProjectManagerMenuNotifier.AfterSave;
begin
//
end;
procedure TProjectManagerMenuNotifier.BeforeSave;
begin
//
end;
procedure TProjectManagerMenuNotifier.Destroyed;
begin
//
end;
procedure TProjectManagerMenuNotifier.Modified;
begin
//
end;
{ TProjectManagerMenu }
constructor TProjectManagerMenu.Create(const ACaption, AVerb: string; const APosition: Integer; const AExecuteProc: TProc = nil;
const AName: string = ''; const AParent: string = '');
begin
inherited Create;
FCaption := ACaption;
FName := AName;
FParent := AParent;
FPosition := APosition;
FVerb := AVerb;
FExecuteProc := AExecuteProc;
end;
procedure TProjectManagerMenu.Execute(const MenuContextList: IInterfaceList);
begin
if Assigned(FExecuteProc) then
FExecuteProc;
end;
function TProjectManagerMenu.GetCaption: string;
begin
Result := FCaption;
end;
function TProjectManagerMenu.GetChecked: Boolean;
begin
Result := False;
end;
function TProjectManagerMenu.GetEnabled: Boolean;
begin
Result := True;
end;
function TProjectManagerMenu.GetHelpContext: Integer;
begin
Result := 0;
end;
function TProjectManagerMenu.GetIsMultiSelectable: Boolean;
begin
Result := False;
end;
function TProjectManagerMenu.GetName: string;
begin
Result := FName;
end;
function TProjectManagerMenu.GetParent: string;
begin
Result := FParent;
end;
function TProjectManagerMenu.GetPosition: Integer;
begin
Result := FPosition;
end;
function TProjectManagerMenu.GetVerb: string;
begin
Result := FVerb;
end;
function TProjectManagerMenu.PostExecute(const MenuContextList: IInterfaceList): Boolean;
begin
Result := False;
end;
function TProjectManagerMenu.PreExecute(const MenuContextList: IInterfaceList): Boolean;
begin
Result := False;
end;
procedure TProjectManagerMenu.SetCaption(const Value: string);
begin
FCaption := Value;
end;
procedure TProjectManagerMenu.SetChecked(Value: Boolean);
begin
// Override GetChecked instead
end;
procedure TProjectManagerMenu.SetEnabled(Value: Boolean);
begin
// Override GetEnabled instead
end;
procedure TProjectManagerMenu.SetHelpContext(Value: Integer);
begin
// Override GetHelpContext instead
end;
procedure TProjectManagerMenu.SetIsMultiSelectable(Value: Boolean);
begin
// Override GetIsMultiSelectable instead
end;
procedure TProjectManagerMenu.SetName(const Value: string);
begin
// Why would you change the name, after creation? :-)
end;
procedure TProjectManagerMenu.SetParent(const Value: string);
begin
// Override GetParent instead
end;
procedure TProjectManagerMenu.SetPosition(Value: Integer);
begin
// Not sure why you would change the position after creation
end;
procedure TProjectManagerMenu.SetVerb(const Value: string);
begin
// Why would you change the verb, after creation? :-)
end;
{ TProjectManagerMenuSeparator }
constructor TProjectManagerMenuSeparator.Create(APosition: Integer; const AParent: string);
begin
inherited Create('-', '', APosition, nil, '', AParent);
end;
end.