forked from Sovos-Compliance/convey-public-libs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
kbmMemTableReg.pas
401 lines (355 loc) · 11.4 KB
/
kbmMemTableReg.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
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
unit kbmMemTableReg;
interface
{$I kbmMemTable.inc}
uses Classes
{$ifdef LEVEL6}
{$ifndef LINUX}
,PropertyCategories
{$endif}
{$else}
,DsgnIntf
{$endif}
{$ifdef LEVEL5}
{$ifndef LINUX}
,FldLinks
{$endif}
,DB,Sysutils
{$endif};
procedure Register;
// =========================================================================
// Registration for kbmMemTable extended by Chris G. Royle to support
// Delphi 5 Categories.
//
// Between versions 1.37 and the current version, many new features / properties have
// been added. Categorisation helps newbies & upgraders make the transition.
//
// Note that the Advanced, and File Categories default to being non-visible after a build.
// =========================================================================
implementation
uses
kbmMemTable,kbmMemBinaryStreamFormat,kbmMemCSVStreamFormat
{$ifdef LEVEL5}
,kbmMemTableDesigner
{$endif}
{$ifdef LEVEL6}
{$ifndef LINUX}
,DesignEditors
,DesignIntf
{$endif}
{$endif}
;
{$ifdef LEVEL5}
type
T__Dummy = class(TObject); // To make sure compilation will be ok even if all ifdefs fail.
{$ifndef LINUX}
TkbmMemTableLocaleIDProperty = class(TIntegerProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const Value: string); override;
end;
{$ifndef LEVEL6}
TkbmMemTableBasicCategory = class(TPropertyCategory)
public
class function Name: string; override;
class function Description: string; override;
end;
TkbmMemTableAdvancedCategory = class(TPropertyCategory)
public
class function Name: string; override;
class function Description: string; override;
procedure AfterConstruction; override;
end;
TkbmMemTableIndexCategory = class(TPropertyCategory)
public
class function Name: string; override;
class function Description: string; override;
end;
TkbmMemTableFileCategory = class(TPropertyCategory)
public
class function Name: string; override;
class function Description: string; override;
procedure AfterConstruction; override;
end;
TkbmMemTableLocaleCategory = class(TPropertyCategory)
public
class function Name: string; override;
class function Description: string; override;
procedure AfterConstruction; override;
end;
{$endif}
{ TkbmMemTableFieldLinkProperty }
TkbmMemTableFieldLinkProperty = class(TFieldLinkProperty)
private
FTable: TkbmCustomMemTable;
protected
procedure GetFieldNamesForIndex(List: TStrings); override;
function GetIndexBased: Boolean; override;
function GetIndexDefs: TIndexDefs; override;
function GetIndexFieldNames: string; override;
function GetIndexName: string; override;
function GetMasterFields: string; override;
procedure SetIndexFieldNames(const Value: string); override;
procedure SetIndexName(const Value: string); override;
procedure SetMasterFields(const Value: string); override;
public
property IndexBased: Boolean read GetIndexBased;
property IndexDefs: TIndexDefs read GetIndexDefs;
property IndexFieldNames: string read GetIndexFieldNames write SetIndexFieldNames;
property IndexName: string read GetIndexName write SetIndexName;
property MasterFields: string read GetMasterFields write SetMasterFields;
procedure Edit; override;
end;
{$endif}
const
CBasicName = 'Basic';
CBasicDesc = 'TkbmMemTable Basic';
CFileName = 'File Access';
CFileDesc = 'TkbmMemTable File Access';
CIndexName = 'Indexing';
CIndexDesc = 'TkbmMemTable Indexing';
CAdvancedName = 'Advanced';
CAdvancedDesc = 'TkbmMemTable Advanced';
CLocaleName = 'Locale';
CLocaleDesc = 'TkbmMemTable Locale';
{$endif}
procedure Register;
begin
RegisterComponents('kbmMemTable', [TkbmMemTable,{$ifndef LINUX}TkbmThreadDataSet,{$endif}TkbmBinaryStreamFormat,TkbmCSVStreamFormat]);
{$ifndef LINUX}
{$ifdef LEVEL5}
RegisterComponentEditor(TkbmMemTable, TkbmMemTableDesigner);
RegisterPropertyEditor(TypeInfo(string), TkbmCustomMemTable, 'MasterFields', TkbmMemTableFieldLinkProperty);
RegisterPropertyEditor(TypeInfo(TkbmLocaleID), TkbmCustomMemTable, 'LocaleID', TkbmMemTableLocaleIDProperty);
{$ifdef LEVEL6}
RegisterPropertiesInCategory(CBasicName, TkbmMemTable,
['Active','DesignActivation',
'FieldDefs',
'EnableIndexes', 'IndexDefs', 'IndexFieldNames', 'IndexName', 'AutoReposition',
'Filter', 'Filtered', 'FilterOptions',
'Persistent', 'PersistentFile','PersistentFormat','CommaTextFormat','DefaultFormat',
'ProgressFlags',
'MasterFields', 'MasterSource', 'DetailFields', 'Name',
'ReadOnly', 'SortFields', 'SortOptions',
'Tag', 'Version',
'OnFilterRecord', 'OnCalcFields', 'OnProgress']);
RegisterPropertiesInCategory(CFileName, TkbmMemTable,
['Persistent', 'PersistentFile', 'PersistentSaveFormat', 'PersistentSaveOptions',
'PersistentBackup', 'PersistentBackupExt',
'PersistentFormat', 'CommaTextFormat', 'DefaultFormat',
'OnLoad', 'OnLoadRecord', 'OnSave', 'OnSaveRecord']);
RegisterPropertiesInCategory(CIndexName, TkbmMemTable,
['EnableIndexes', 'IndexDefs', 'IndexFieldNames', 'IndexName', 'OnFilterIndex']);
RegisterPropertiesInCategory(CAdvancedName, TkbmMemTable,
['AllDataOptions',
'AttachedAutoRefresh', 'AttachedTo',
'AutoIncMinValue', 'EnableJournal',
'EnableVersioning',
'DeltaHandler',
'LoadLimit',
'RecalcOnFetch', 'RecalcOnIndex', 'StoreDataOnForm', 'FormFormat',
'Performance', 'Standalone',
'VersioningMode',
'OnLoadField', 'OnSaveField', 'OnCompareFields',
'OnCompressBlobStream', 'OnDecompressBlobStream',
'OnCompressField','OnDecompressField','OnSetupField']);
RegisterPropertiesInCategory(CLocaleName, TkbmMemTable,
['LocaleID',
'LanguageID', 'SubLanguageID',
'SortID']);
{$else}
RegisterPropertiesInCategory(TkbmMemTableBasicCategory, TkbmMemTable,
['Active','DesignActivation',
'FieldDefs',
'EnableIndexes', 'IndexDefs', 'IndexFieldNames', 'IndexName', 'AutoReposition',
'Filter', 'Filtered', 'FilterOptions',
'Persistent', 'PersistentFile','PersistentFormat','CommaTextFormat','DefaultFormat',
'ProgressFlags',
'MasterFields', 'MasterSource', 'DetailFields', 'Name',
'ReadOnly', 'SortFields', 'SortOptions',
'Tag', 'Version',
'OnFilterRecord', 'OnCalcFields', 'OnProgress']);
RegisterPropertiesInCategory(TkbmMemTableFileCategory, TkbmMemTable,
['Persistent', 'PersistentFile', 'PersistentSaveFormat', 'PersistentSaveOptions',
'PersistentBackup', 'PersistentBackupExt',
'PersistentFormat', 'CommaTextFormat', 'DefaultFormat',
'OnLoad', 'OnLoadRecord', 'OnSave', 'OnSaveRecord']);
RegisterPropertiesInCategory(TkbmMemTableIndexCategory, TkbmMemTable,
['EnableIndexes', 'IndexDefs', 'IndexFieldNames', 'IndexName', 'OnFilterIndex']);
RegisterPropertiesInCategory(TkbmMemTableAdvancedCategory, TkbmMemTable,
['AllDataOptions',
'AttachedAutoRefresh', 'AttachedTo',
'AutoIncMinValue', 'EnableJournal',
'EnableVersioning',
'DeltaHandler',
'LoadLimit',
'RecalcOnFetch', 'RecalcOnIndex', 'StoreDataOnForm', 'FormFormat',
'Performance', 'Standalone',
'VersioningMode',
'OnLoadField', 'OnSaveField', 'OnCompareFields',
'OnCompressBlobStream', 'OnDecompressBlobStream',
'OnCompressField','OnDecompressField','OnSetupField']);
RegisterPropertiesInCategory(TkbmMemTableLocaleCategory, TkbmMemTable,
['LocaleID',
'LanguageID', 'SubLanguageID',
'SortID']);
{$endif}
{$endif}
{$endif}
end;
{$ifndef LINUX}
{$ifdef LEVEL5}
function TkbmMemTableLocaleIDProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paValueList, paSortList, paRevertable];
end;
procedure TkbmMemTableLocaleIDProperty.GetValues(Proc: TGetStrProc);
var
l:TLanguages;
i:integer;
begin
l:=Languages;
for i:=0 to l.Count-1 do Proc(l.Name[i]);
end;
procedure TkbmMemTableLocaleIDProperty.SetValue(const Value: string);
var
l:TLanguages;
i:integer;
begin
l:=Languages;
for i:=0 to l.Count-1 do
if l.Name[i]=Value then
begin
SetOrdValue(l.LocaleID[i]);
break;
end;
end;
{$endif}
{$ifndef LEVEL6}
class function TkbmMemTableBasicCategory.Name: string;
begin
Result := CBasicName;
end;
class function TkbmMemTableBasicCategory.Description: string;
begin
Result := CBasicDesc;
end;
class function TkbmMemTableFileCategory.Name: string;
begin
Result := CFileName;
end;
class function TkbmMemTableFileCategory.Description: string;
begin
Result := CFileDesc;
end;
procedure TkbmMemTableFileCategory.AfterConstruction;
begin
inherited;
Visible:= False;
end;
class function TkbmMemTableIndexCategory.Name: string;
begin
Result := CIndexName;
end;
class function TkbmMemTableIndexCategory.Description: string;
begin
Result := CIndexDesc;
end;
class function TkbmMemTableAdvancedCategory.Name: string;
begin
Result := CAdvancedName;
end;
procedure TkbmMemTableAdvancedCategory.AfterConstruction;
begin
inherited;
Visible:= False;
end;
class function TkbmMemTableAdvancedCategory.Description: string;
begin
Result := CAdvancedDesc;
end;
class function TkbmMemTableLocaleCategory.Name: string;
begin
Result := CLocaleName;
end;
class function TkbmMemTableLocaleCategory.Description: string;
begin
Result := CLocaleDesc;
end;
procedure TkbmMemTableLocaleCategory.AfterConstruction;
begin
inherited;
Visible:= False;
end;
{$endif} // LEVEL6
{ TkbmMemTableFieldLinkProperty }
procedure TkbmMemTableFieldLinkProperty.Edit;
var
Table: TkbmCustomMemTable;
begin
Table := TkbmCustomMemTable(DataSet);
FTable := TkbmCustomMemTable.Create(nil);
FTable.Name:='__PROXY_MT';
try
FTable.CreateTableAs(Table,[]);
FTable.IndexDefs.assign(Table.IndexDefs);
FTable.MasterFields := Table.MasterFields;
if Table.IndexFieldNames <> '' then
FTable.IndexFieldNames := Table.IndexFieldNames
else
FTable.IndexName := Table.IndexName;
FTable.Open;
inherited Edit;
if Changed then
begin
Table.MasterFields := FTable.MasterFields;
if FTable.IndexFieldNames <> '' then
Table.IndexFieldNames := FTable.IndexFieldNames
else
Table.IndexName := FTable.IndexName;
end;
finally
FTable.Free;
end;
end;
procedure TkbmMemTableFieldLinkProperty.GetFieldNamesForIndex(List: TStrings);
var
i: Integer;
begin
for i := 0 to FTable.IndexFieldCount - 1 do
List.Add(FTable.IndexFields[i].FieldName);
end;
function TkbmMemTableFieldLinkProperty.GetIndexBased: Boolean;
begin
Result := not IProviderSupport(FTable).PSIsSQLBased;
end;
function TkbmMemTableFieldLinkProperty.GetIndexDefs: TIndexDefs;
begin
Result := FTable.IndexDefs;
end;
function TkbmMemTableFieldLinkProperty.GetIndexFieldNames: string;
begin
Result := FTable.IndexFieldNames;
end;
function TkbmMemTableFieldLinkProperty.GetIndexName: string;
begin
Result := FTable.IndexName;
end;
function TkbmMemTableFieldLinkProperty.GetMasterFields: string;
begin
Result := FTable.MasterFields;
end;
procedure TkbmMemTableFieldLinkProperty.SetIndexFieldNames(const Value: string);
begin
FTable.IndexFieldNames := Value;
end;
procedure TkbmMemTableFieldLinkProperty.SetIndexName(const Value: string);
begin
FTable.IndexName := Value;
end;
procedure TkbmMemTableFieldLinkProperty.SetMasterFields(const Value: string);
begin
FTable.MasterFields := Value;
end;
{$endif}
end.