-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathUJUnitTest.pas
More file actions
241 lines (214 loc) · 6.01 KB
/
UJUnitTest.pas
File metadata and controls
241 lines (214 loc) · 6.01 KB
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
unit UJUnitTest;
interface
uses
Classes,
Controls,
Forms,
ComCtrls,
ExtCtrls,
Menus,
TB2Item,
SpTBXItem,
System.ImageList,
Vcl.ImgList,
Vcl.VirtualImageList,
Vcl.BaseImageCollection,
SVGIconImageCollection,
UDockForm;
type
TFJUnitTests = class(TDockableForm)
PJUnit: TPanel;
TVJUnitTests: TTreeView;
PMJUnitTests: TSpTBXPopupMenu;
MIFont: TSpTBXItem;
MIDefaulLayout: TSpTBXItem;
MIClose: TSpTBXItem;
icJUnit: TSVGIconImageCollection;
vilJUnitLight: TVirtualImageList;
vilJUnitDark: TVirtualImageList;
procedure TVJUnitTestsChange(Sender: TObject; Node: TTreeNode);
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure MIFontClick(Sender: TObject);
procedure MIDefaulLayoutClick(Sender: TObject);
procedure MICloseClick(Sender: TObject);
procedure TVJUnitTestsMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
private
FPathname: string;
FUndockLeft: Integer;
FUndockTop: Integer;
FWindowOpened: Boolean;
procedure SaveWindow;
procedure OpenWindow;
public
procedure ShowIt;
procedure HideIt;
procedure DeleteData;
procedure ChangeStyle;
property Pathname: string read FPathname write FPathname;
property UndockLeft: Integer read FUndockLeft write FUndockLeft;
property UndockTop: Integer read FUndockTop write FUndockTop;
end;
var
FJUnitTests: TFJUnitTests;
implementation
uses
SysUtils,
Math,
JvGnugettext,
UConfiguration,
UUtils,
UBaseForm,
UJava,
UEditorForm;
{$R *.dfm}
procedure TFJUnitTests.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
FWindowOpened := False;
end;
procedure TFJUnitTests.FormShow(Sender: TObject);
begin
if not FWindowOpened then
begin
OpenWindow;
FWindowOpened := True;
end;
end;
procedure TFJUnitTests.TVJUnitTestsChange(Sender: TObject; Node: TTreeNode);
var
Line: Integer;
EditForm: TFEditForm;
AForm: TFForm;
IsWrapping: Boolean;
begin
FJava.SwitchWindowWithSearch(FPathname);
if FJava.WindowOpened(FPathname, AForm) then
begin
EditForm := TFEditForm(AForm);
FJava.SwitchToWindow(EditForm);
Line := TInteger(Node.Data).Int;
IsWrapping := EditForm.Editor.WordWrap;
with EditForm.Editor do
begin
if IsWrapping then
EditForm.SBWordWrapClick(nil);
TopLine := Line;
CaretY := Line;
CaretX := 1; // Length(Lines[Line-1]) + 1;
EnsureCursorPosVisible;
if IsWrapping then
EditForm.SBWordWrapClick(nil);
end;
if EditForm.CanFocus then
EditForm.SetFocus;
end;
end;
procedure TFJUnitTests.TVJUnitTestsMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight then
PMJUnitTests.Popup(X + TTreeView(Sender).ClientOrigin.X - 40,
Y + TTreeView (Sender).ClientOrigin.Y - 5);
end;
procedure TFJUnitTests.OpenWindow;
begin
UndockLeft := PPIScale(FConfiguration.ReadIntegerU('JUnitTest',
'UndockLeft', 400));
UndockTop := PPIScale(FConfiguration.ReadIntegerU('JUnitTest',
'UndockTop', 100));
UndockWidth := PPIScale(FConfiguration.ReadIntegerU('JUnitTest',
'UndockWidth', 200));
UndockHeight := PPIScale(FConfiguration.ReadIntegerU('JUnitTest',
'UndockHeight', 200));
UndockLeft := Min(UndockLeft, Screen.DesktopWidth - 50);
UndockTop := Min(UndockTop, Screen.DesktopHeight - 50);
ManualFloat(Rect(UndockLeft, UndockTop, UndockLeft + UndockWidth,
UndockTop + UndockHeight));
Font.Name := FConfiguration.ReadStringU('JUnitTest', 'Fontname', 'Segoe UI');
Font.Size := PPIScale(FConfiguration.ReadIntegerU('JUnitTest',
'Fontsize', 10));
end;
procedure TFJUnitTests.SaveWindow;
begin
FConfiguration.WriteBoolU('JUnitTest', 'Visible', Visible);
FConfiguration.WriteBoolU('JUnitTest', 'Floating', Floating);
if Floating then
begin
FConfiguration.WriteIntegerU('JUnitTest', 'UndockLeft', PPIUnScale(Left));
FConfiguration.WriteIntegerU('JUnitTest', 'UndockTop', PPIUnScale(Top));
FConfiguration.WriteIntegerU('JUnitTest', 'UndockWidth', PPIUnScale(Width));
FConfiguration.WriteIntegerU('JUnitTest', 'UndockHeight',
PPIUnScale(Height));
end
else
begin
FConfiguration.WriteIntegerU('JUnitTest', 'UndockLeft',
PPIUnScale(UndockLeft));
FConfiguration.WriteIntegerU('JUnitTest', 'UndockTop',
PPIUnScale(UndockTop));
FConfiguration.WriteIntegerU('JUnitTest', 'UndockWidth',
PPIUnScale(UndockWidth));
FConfiguration.WriteIntegerU('JUnitTest', 'UndockHeight',
PPIUnScale(UndockHeight));
end;
FConfiguration.WriteStringU('JUnitTest', 'Fontname', Font.Name);
FConfiguration.WriteIntegerU('JUnitTest', 'Fontsize', PPIUnScale(Font.Size));
end;
procedure TFJUnitTests.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
SaveWindow;
DeleteData;
end;
procedure TFJUnitTests.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
SaveWindow;
end;
procedure TFJUnitTests.DeleteData;
var
TInt: TInteger;
begin
for var I := 0 to TVJUnitTests.Items.Count - 1 do
begin
TInt := TInteger(TVJUnitTests.Items[I].Data);
FreeAndNil(TInt);
end;
TVJUnitTests.Items.Clear;
end;
procedure TFJUnitTests.MICloseClick(Sender: TObject);
begin
HideIt;
end;
procedure TFJUnitTests.MIDefaulLayoutClick(Sender: TObject);
begin
FJava.MIDefaultLayoutClick(Self);
end;
procedure TFJUnitTests.MIFontClick(Sender: TObject);
begin
FJava.FDFont.Font.Assign(Font);
FJava.FDFont.Options := [];
if FJava.FDFont.Execute then
Font.Assign(FJava.FDFont.Font);
end;
procedure TFJUnitTests.ShowIt;
begin
FJava.ShowDockableForm(Self);
end;
procedure TFJUnitTests.HideIt;
begin
Close;
end;
procedure TFJUnitTests.ChangeStyle;
begin
if FConfiguration.IsDark then
PMJUnitTests.Images := vilJUnitDark
else
PMJUnitTests.Images := vilJUnitLight;
end;
initialization
FJUnitTests := nil;
end.