-
Notifications
You must be signed in to change notification settings - Fork 10
/
DW.DESIGN.UserSessionWizard.pas
201 lines (159 loc) · 4.8 KB
/
DW.DESIGN.UserSessionWizard.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
unit DW.DESIGN.UserSessionWizard;
interface
uses Classes, Winapi.Windows, Vcl.Dialogs, DesignIntf, ToolsAPI, TypInfo;
type
TDWUserSessionModuleCreator = class(TInterfacedObject, IOTACreator, IOTAModuleCreator)
private
FOwner: IOTAModule;
FImplFileName: string;
FFormName: string;
public
constructor Create(AOwner: IOTAModule); overload;
constructor Create; overload;
// IOTACreator
function GetCreatorType: string;
function GetExisting: Boolean;
function GetFileSystem: string;
function GetOwner: IOTAModule;
function GetUnnamed: Boolean;
// IOTAModuleCreator
function GetAncestorName: string;
function GetImplFileName: string;
function GetIntfFileName: string;
function GetFormName: string;
function GetMainForm: Boolean;
function GetShowForm: Boolean;
function GetShowSource: Boolean;
function NewFormFile(const FormIdent, AncestorIdent: string): IOTAFile;
function NewImplSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile;
function NewIntfSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile;
procedure FormCreated(const FormEditor: IOTAFormEditor);
end;
TDWUserSessionModuleSource = class(TInterfacedObject, IOTAFile)
private
FModuleIdent: string;
FFormIdent: string;
FAncestorIdent: string;
public
constructor Create(const ModuleIdent, FormIdent, AncestorIdent: string);
// IOTAFile
function GetSource: string;
function GetAge: TDateTime;
end;
const
CrLf2 = #13#10#13#10;
CrLf = #13#10;
implementation
uses
SysUtils, System.Win.ComObj, DWForm, DW.Vcl.Labels, DW.CORE.UserSession;
procedure DebugMsg(const Msg: String);
begin
// ShowMessage(Msg);
end;
constructor TDWUserSessionModuleCreator.Create;
begin
Create(nil);
end;
constructor TDWUserSessionModuleCreator.Create(AOwner: IOTAModule);
begin
inherited Create;
FOwner := AOwner;
end;
procedure TDWUserSessionModuleCreator.FormCreated(const FormEditor: IOTAFormEditor);
begin
end;
function TDWUserSessionModuleCreator.GetAncestorName: string;
begin
Result := 'DWUserSession';
end;
function TDWUserSessionModuleCreator.GetCreatorType: string;
begin
Result := sForm;
end;
function TDWUserSessionModuleCreator.GetExisting: Boolean;
begin
Result := False;
end;
function TDWUserSessionModuleCreator.GetFileSystem: string;
begin
Result := '';
end;
function TDWUserSessionModuleCreator.GetFormName: string;
begin
Result := 'DWSessionData';
end;
function TDWUserSessionModuleCreator.GetImplFileName: string;
begin
Result := GetCurrentDir + '\uDWSessionData.pas';
end;
function TDWUserSessionModuleCreator.GetIntfFileName: string;
begin
Result := '';
end;
function TDWUserSessionModuleCreator.GetMainForm: Boolean;
begin
Result := False;
end;
function TDWUserSessionModuleCreator.GetOwner: IOTAModule;
begin
if FOwner <> nil then
Result := FOwner
else
Result := GetActiveProject;
end;
function TDWUserSessionModuleCreator.GetShowForm: Boolean;
begin
Result := True;
end;
function TDWUserSessionModuleCreator.GetShowSource: Boolean;
begin
Result := True;
end;
function TDWUserSessionModuleCreator.GetUnnamed: Boolean;
begin
Result := True;
end;
function TDWUserSessionModuleCreator.NewFormFile(const FormIdent, AncestorIdent: string): IOTAFile;
begin
Result := nil;
end;
function TDWUserSessionModuleCreator.NewImplSource(const ModuleIdent, FormIdent,
AncestorIdent: string): IOTAFile;
begin
Result := TDWUserSessionModuleSource.Create(ModuleIdent, FormIdent, AncestorIdent);
end;
function TDWUserSessionModuleCreator.NewIntfSource(const ModuleIdent, FormIdent,
AncestorIdent: string): IOTAFile;
begin
Result := nil;
end;
constructor TDWUserSessionModuleSource.Create(Const ModuleIdent, FormIdent, AncestorIdent: string);
begin
inherited Create;
FModuleIdent := ModuleIdent;
FFormIdent := FormIdent; // Copy(FormIdent, 2, MaxInt);
FAncestorIdent := AncestorIdent; // Copy(AncestorIdent, 2,MaxInt);
end;
function TDWUserSessionModuleSource.GetAge: TDateTime;
begin
Result := -1;
end;
function TDWUserSessionModuleSource.GetSource: string;
const
cSource = 'unit %0:s;' + CrLf2 +
'interface' + CrLf2 +
'uses' + CrLf + ' DW.CORE.UserSession;' + CrLf +
'type' + CrLf +
' T%1:s = class(T%2:s)' + CrLf + ' private' + CrLf + ' { private declarations }' + CrLf +
' public' + CrLf + ' { public declarations }' + CrLf + ' end;' + CrLf2 +
'{ !!! Do Not Declare Global Variables !!! }' + CrLf2 +
'implementation' + CrLf2 +
' uses' + CrLf + ' DWGlobal;' + CrLf2 +
// '{'#9'%CLASSGROUP ''Vcl.Controls.TControl''}' + CrLf2 +
'{$R *.dfm}' + CrLf2 + CrLf2 +
'initialization' + CrLf + ' gUserSessionClass := T%1:s;' + CrLf2 +
'end.';
begin
Result := Format(cSource, [FModuleIdent, FFormIdent, FAncestorIdent]);
end;
end.