1+ unit DelphiDocker.LocalMenuItem;
2+
3+ interface
4+
5+ uses
6+ ToolsAPI, Vcl.ActnList, System.Classes, Dialogs;
7+
8+ type
9+ TNotifierLocalMenuItem = class (TNotifierObject, IOTANotifier, IOTAProjectMenuItemCreatorNotifier)
10+ public
11+ function IsProject (const AIdent: string): Boolean;
12+ procedure AddMenu (const AProject: IOTAProject; const AIdentList: TStrings;
13+ const AProjectManagerMenuList: IInterfaceList; AIsMultiSelect: Boolean);
14+ end ;
15+
16+ TLocalMenuItem = class (TNotifierObject, IOTALocalMenu, IOTAProjectManagerMenu)
17+ private
18+ FCaption: string;
19+ FChecked: Boolean;
20+ FEnabled: Boolean;
21+ FHelpContext: Integer;
22+ FName: string;
23+ FParent: string;
24+ FPosition: Integer;
25+ FVerb: string;
26+ FOnExecute: TNotifyEvent;
27+ public
28+ function GetCaption : string;
29+ function GetChecked : Boolean;
30+ function GetEnabled : Boolean;
31+ function GetHelpContext : Integer;
32+ function GetName : string;
33+ function GetParent : string;
34+ function GetPosition : Integer;
35+ function GetVerb : string;
36+ procedure SetCaption (const Value : string);
37+ procedure SetChecked (Value : Boolean);
38+ procedure SetEnabled (Value : Boolean);
39+ procedure SetHelpContext (Value : Integer);
40+ procedure SetName (const Value : string);
41+ procedure SetParent (const Value : string);
42+ procedure SetPosition (Value : Integer);
43+ procedure SetVerb (const Value : string);
44+ property Caption: string read GetCaption write SetCaption;
45+ property Checked: Boolean read GetChecked write SetChecked;
46+ property Enabled: Boolean read GetEnabled write SetEnabled;
47+ property HelpContext: Integer read GetHelpContext write SetHelpContext;
48+ property Name : string read GetName write SetName;
49+ property Parent: string read GetParent write SetParent;
50+ property Position: Integer read GetPosition write SetPosition;
51+ property Verb: string read GetVerb write SetVerb;
52+ property OnExecute: TNotifyEvent read FOnExecute write FOnExecute;
53+ function GetIsMultiSelectable : Boolean;
54+ procedure SetIsMultiSelectable (Value : Boolean);
55+ procedure Execute (const MenuContextList: IInterfaceList); overload;
56+ function PreExecute (const MenuContextList: IInterfaceList): Boolean;
57+ function PostExecute (const MenuContextList: IInterfaceList): Boolean;
58+ property IsMultiSelectable: Boolean read GetIsMultiSelectable write SetIsMultiSelectable;
59+ constructor Create;
60+ end ;
61+
62+ implementation
63+
64+ constructor TLocalMenuItem.Create;
65+ begin
66+ FCaption := ' Run With Docker' ;
67+ FEnabled := True;
68+ FPosition := pmmpRunNoDebug + 10 ;
69+ end ;
70+
71+ procedure TLocalMenuItem.Execute (const MenuContextList: IInterfaceList);
72+ begin
73+ ShowMessage(' teste' );
74+ end ;
75+
76+ function TLocalMenuItem.GetCaption : string;
77+ begin
78+ Result := FCaption;
79+ end ;
80+
81+ function TLocalMenuItem.GetChecked : Boolean;
82+ begin
83+ Result := FChecked;
84+ end ;
85+
86+ function TLocalMenuItem.GetEnabled : Boolean;
87+ begin
88+ Result := FEnabled;
89+ end ;
90+
91+ function TLocalMenuItem.GetHelpContext : Integer;
92+ begin
93+ Result := FHelpContext;
94+ end ;
95+
96+ function TLocalMenuItem.GetIsMultiSelectable : Boolean;
97+ begin
98+
99+ end ;
100+
101+ function TLocalMenuItem.GetName : string;
102+ begin
103+ Result := FName;
104+ end ;
105+
106+ function TLocalMenuItem.GetParent : string;
107+ begin
108+ Result := FParent;
109+ end ;
110+
111+ function TLocalMenuItem.GetPosition : Integer;
112+ begin
113+ Result := FPosition;
114+ end ;
115+
116+ function TLocalMenuItem.GetVerb : string;
117+ begin
118+ Result := FVerb;
119+ end ;
120+
121+ function TLocalMenuItem.PostExecute (const MenuContextList: IInterfaceList): Boolean;
122+ begin
123+
124+ end ;
125+
126+ function TLocalMenuItem.PreExecute (const MenuContextList: IInterfaceList): Boolean;
127+ begin
128+
129+ end ;
130+
131+ procedure TLocalMenuItem.SetCaption (const Value : string);
132+ begin
133+ FCaption := Value ;
134+ end ;
135+
136+ procedure TLocalMenuItem.SetChecked (Value : Boolean);
137+ begin
138+ FChecked := Value ;
139+ end ;
140+
141+ procedure TLocalMenuItem.SetEnabled (Value : Boolean);
142+ begin
143+ FEnabled := Value ;
144+ end ;
145+
146+ procedure TLocalMenuItem.SetHelpContext (Value : Integer);
147+ begin
148+ FHelpContext := Value ;
149+ end ;
150+
151+ procedure TLocalMenuItem.SetIsMultiSelectable (Value : Boolean);
152+ begin
153+
154+ end ;
155+
156+ procedure TLocalMenuItem.SetName (const Value : string);
157+ begin
158+ FName := Value ;
159+ end ;
160+
161+ procedure TLocalMenuItem.SetParent (const Value : string);
162+ begin
163+ FParent := Value ;
164+ end ;
165+
166+ procedure TLocalMenuItem.SetPosition (Value : Integer);
167+ begin
168+ FPosition := Value ;
169+ end ;
170+
171+ procedure TLocalMenuItem.SetVerb (const Value : string);
172+ begin
173+ FVerb := Value ;
174+ end ;
175+
176+ { TNotifierLocalMenu }
177+
178+ procedure TNotifierLocalMenuItem.AddMenu (const AProject: IOTAProject; const AIdentList: TStrings;
179+ const AProjectManagerMenuList: IInterfaceList; AIsMultiSelect: Boolean);
180+ begin
181+ if IsProject(AProject.ApplicationType) and (not AIsMultiSelect) and Assigned(AProject) and
182+ (AIdentList.IndexOf(sProjectContainer) <> -1 ) and Assigned(AProjectManagerMenuList) then
183+ begin
184+ AProjectManagerMenuList.Add(TLocalMenuItem.Create);
185+ end ;
186+ end ;
187+
188+ function TNotifierLocalMenuItem.IsProject (const AIdent: string): Boolean;
189+ begin
190+ Result := (AIdent = sApplication) or (AIdent = sConsole) or (AIdent = sPackage);
191+ end ;
192+
193+ end .
194+
0 commit comments