-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathMVCBr.FrameView.pas
249 lines (206 loc) · 5.57 KB
/
MVCBr.FrameView.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
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
unit MVCBr.FrameView;
interface
uses System.Classes, Forms, System.SysUtils,
System.JSON, System.RTTI,
MVCBr.Interf;
Type
IFrameView = interface(IView)
['{97C0656C-FD84-4E9E-985B-03614FA19D15}']
end;
TFrameFactory = class(TFrame, IFrameView, IView)
private
FID, FTitle: string;
FViewModel: IViewModel;
FController: IController;
protected
function RefCount:Integer;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function This: TObject;
procedure Release; virtual;
[weak]
Function Controller(const AController: IController): IView; virtual;
[weak]
function GetController: IController; virtual;
procedure SetController(Const AController: IController); virtual;
[weak]
function ShowView(): IView; overload; virtual;
[weak]
function UpdateView: IView; virtual;
procedure Update(AJsonValue: TJsonValue; var AHandled: boolean);
overload; virtual;
[weak]
function ViewEvent(AMessage: string; var AHandled: boolean): IView;
overload; virtual;
[weak]
function ViewEvent(AMessage: TJsonValue; var AHandled: boolean): IView;
overload; virtual;
[weak]
function GetModel(AII: TGuid): IModel;
[weak]
function GetViewModel: IViewModel; virtual;
procedure SetViewModel(const AViewModel: IViewModel); virtual;
function GetID: string; virtual;
function GetTitle: String; virtual;
procedure SetTitle(Const AText: String); virtual;
property Title: string read GetTitle write SetTitle;
Procedure DoCommand(ACommand: string;
const AArgs: array of TValue); virtual;
function ShowView(const AProcBeforeShow: TProc<IView>): integer; overload;
[weak]
function ShowView(const AProcBeforeShow: TProc<IView>; AShowModal: boolean)
: IView; overload;
[weak]
function ShowView(const AProcBeforeShow: TProc<IView>;
const AProcOnClose: TProc<IView>): IView; overload; virtual;
procedure UpdateObserver(AJson: TJsonValue); overload; virtual;
procedure UpdateObserver(AName: string; AJson: TJsonValue);
overload; virtual;
procedure Init; virtual;
[weak]
function ApplicationControllerInternal: IApplicationController;
function GetPropertyValue(ANome: string): TValue;
procedure SetPropertyValue(ANome: string; const Value: TValue);
property PropertyValue[ANome: string]: TValue read GetPropertyValue
write SetPropertyValue;
function GetGuid(AII: IInterface): TGuid;
end;
implementation
uses MVCBr.ApplicationController, MVCBr.MiddlewareFactory;
{ TFrameFactory }
function TFrameFactory.ApplicationControllerInternal: IApplicationController;
begin
result := ApplicationController;
end;
function TFrameFactory.Controller(const AController: IController): IView;
begin
result := self;
FController := AController;
end;
constructor TFrameFactory.Create(AOwner: TComponent);
begin
inherited;
TMVCBrMiddlewareFactory.SendBeforeEvent(middFrame, self);
end;
destructor TFrameFactory.Destroy;
begin
TMVCBrMiddlewareFactory.SendAfterEvent(middFrame, self);
inherited;
end;
procedure TFrameFactory.DoCommand(ACommand: string;
const AArgs: array of TValue);
begin
end;
function TFrameFactory.GetController: IController;
begin
result := FController;
end;
function TFrameFactory.GetGuid(AII: IInterface): TGuid;
begin
result := TMVCBr.GetGuid(AII);
end;
function TFrameFactory.GetID: string;
begin
result := FID;
end;
function TFrameFactory.GetModel(AII: TGuid): IModel;
begin
result := FController.GetModel(AII);
end;
function TFrameFactory.GetPropertyValue(ANome: string): TValue;
begin
result := TMVCBr.GetProperty(self, ANome);
end;
function TFrameFactory.GetTitle: String;
begin
result := FTitle;
end;
function TFrameFactory.GetViewModel: IViewModel;
begin
result := FViewModel;
end;
procedure TFrameFactory.Init;
begin
// abstract;
end;
function TFrameFactory.RefCount: Integer;
begin
result := _AddRef;
_Release;
end;
procedure TFrameFactory.Release;
begin
FViewModel := nil;
FController := nil;
end;
procedure TFrameFactory.SetController(const AController: IController);
begin
FController := AController;
end;
procedure TFrameFactory.SetPropertyValue(ANome: string; const Value: TValue);
begin
TMVCBr.SetProperty(self, ANome, Value);
end;
procedure TFrameFactory.SetTitle(const AText: String);
begin
FTitle := AText;
end;
procedure TFrameFactory.SetViewModel(const AViewModel: IViewModel);
begin
FViewModel := AViewModel;
end;
function TFrameFactory.ShowView(const AProcBeforeShow,
AProcOnClose: TProc<IView>): IView;
begin
result := self;
show;
end;
function TFrameFactory.ShowView: IView;
begin
result := self;
show;
end;
function TFrameFactory.This: TObject;
begin
result := self;
end;
function TFrameFactory.ShowView(const AProcBeforeShow: TProc<IView>): integer;
begin
result := 0;
show;
result := 1;
end;
function TFrameFactory.ShowView(const AProcBeforeShow: TProc<IView>;
AShowModal: boolean): IView;
begin
result := self;
show;
end;
procedure TFrameFactory.UpdateObserver(AJson: TJsonValue);
begin
// abstract;
end;
procedure TFrameFactory.Update(AJsonValue: TJsonValue; var AHandled: boolean);
begin
AHandled := false;
end;
procedure TFrameFactory.UpdateObserver(AName: string; AJson: TJsonValue);
begin
// abstract;
end;
function TFrameFactory.UpdateView: IView;
begin
result := self;
end;
function TFrameFactory.ViewEvent(AMessage: string;
var AHandled: boolean): IView;
begin
// abstract;
end;
function TFrameFactory.ViewEvent(AMessage: TJsonValue;
var AHandled: boolean): IView;
begin
// abstract;
end;
end.