forked from Sovos-Compliance/convey-public-libs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
kbmMemTableDesigner.pas
149 lines (134 loc) · 3.4 KB
/
kbmMemTableDesigner.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
unit kbmMemTableDesigner;
interface
{$I kbmMemTable.inc}
uses
{$ifdef LEVEL6}
{$ifndef LINUX}
DesignEditors,
{$endif}
{$else}
Dsgnintf,
{$endif}
db;
{$ifndef LINUX}
type
TkbmMemTableDesigner = class(TComponentEditor)
private
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
procedure TableDesigner;
procedure LoadPersistentFileBinary;
procedure LoadPersistentFileNormal;
procedure EmptyTable;
end;
{$endif}
implementation
{$ifndef LINUX}
uses
{$ifndef LINUX}
DSDesign,
{$else}
DBDesign,
{$endif}
kbmMemTable,
kbmMemCSVStreamFormat,
kbmMemBinaryStreamFormat,
kbmMemTableDesForm;
procedure TkbmMemTableDesigner.EmptyTable;
begin
TkbmMemTable(Component).Active := True;
TkbmMemTable(Component).EmptyTable;
end;
procedure TkbmMemTableDesigner.ExecuteVerb(Index: Integer);
begin
{$ifndef LEVEL5}
inc(Index);
{$endif}
case Index of
{$ifdef LEVEL5}
0: DSDesign.ShowFieldsEditor(Designer, TDataSet(Component),TDSDesigner);
{$endif}
1: TableDesigner;
2: LoadPersistentFileBinary;
3: LoadPersistentFileNormal;
4: EmptyTable;
end;
end;
function TkbmMemTableDesigner.GetVerb(Index: Integer): String;
begin
{$ifndef LEVEL5}
inc(Index);
{$endif}
case Index of
{$ifdef LEVEL5}
0: Result:= '&Fields Editor';
{$endif}
1: Result:= '&Table Designer';
2: Result:= '&Load Persistent File (Binary)';
3: Result:= '&Load Persistent File (Normal)';
4: Result:= '&Empty Table';
end;
end;
function TkbmMemTableDesigner.GetVerbCount: Integer;
begin
{$ifdef LEVEL5}
Result:=5;
{$else}
Result:=4;
{$endif}
end;
procedure TkbmMemTableDesigner.LoadPersistentFileBinary;
var
DummyTable:TkbmMemTable;
Fmt:TkbmCustomStreamFormat;
begin
DummyTable:=TkbmMemTable.Create(nil);
Fmt:=TkbmBinaryStreamFormat.Create(nil);
try
DummyTable.LoadFromFileViaFormat(TkbmMemTable(Component).PersistentFile,Fmt);
DummyTable.Active:=True;
TkbmMemTable(Component).Active:=True;
TkbmMemTable(Component).EmptyTable;
frmKbmMemTableDesigner.CopyDataSet(DummyTable,TDataSet(Component),False);
DummyTable.Active:=False;
finally
Fmt.Free;
DummyTable.Free;
end;
end;
procedure TkbmMemTableDesigner.LoadPersistentFileNormal;
var
DummyTable:TkbmMemTable;
Fmt:TkbmCustomStreamFormat;
begin
DummyTable:=TkbmMemTable.Create(nil);
Fmt:=TkbmCSVStreamFormat.Create(nil);
try
DummyTable.LoadFromFileViaFormat(TkbmMemTable(Component).PersistentFile,Fmt);
DummyTable.Active := True;
TkbmMemTable(Component).Active:=True;
TkbmMemTable(Component).EmptyTable;
frmKbmMemTableDesigner.CopyDataSet(DummyTable,TDataSet(Component),False);
DummyTable.Active := False;
finally
Fmt.Free;
DummyTable.Free;
end;
end;
procedure TkbmMemTableDesigner.TableDesigner;
var
frmKbmMemTableDesigner:TfrmKbmMemTableDesigner;
begin
frmKbmMemTableDesigner:=TfrmKbmMemTableDesigner.Create(nil);
try
frmkbmMemTableDesigner.Designer := Designer;
frmKbmMemTableDesigner.MemTable:=TkbmMemTable(Component);
frmKbmMemTableDesigner.ShowModal;
finally
// frmKbmMemTableDesigner.Free;
end;
end;
{$endif}
end.