-
Notifications
You must be signed in to change notification settings - Fork 8
/
MainForm.pas
1635 lines (1449 loc) · 50.7 KB
/
MainForm.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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{*****************************************************************************
The Delphi Code Coverage Wizzard team (see file NOTICE.txt) licenses this file
to you under the Mozilla public License 1.1 (the
"License"); you may not use this file except in compliance
with the License. A copy of this licence is found in the root directory
of this project in the file LICENCE.txt.
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*****************************************************************************}
/// <summary>
/// User interface of the application
/// </summary>
unit MainForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, System.ImageList, Vcl.ImgList,
Vcl.VirtualImageList, Vcl.StdCtrls, Vcl.WinXPanels, Vcl.ExtCtrls,
Vcl.BaseImageCollection, Vcl.ImageCollection, Vcl.ComCtrls, Vcl.ButtonGroup,
Vcl.CheckLst, USettings, UDataModuleIcons, Vcl.WinXCtrls, Vcl.Menus,
Winapi.WebView2, Winapi.ActiveX, Vcl.Edge, Vcl.OleCtrls, SHDocVw,
MainFormLogic, UProjectSettings, UProjectSettingsInterface, Vcl.NumberBox;
type
/// <summary>
/// Main form with all GUI elements
/// </summary>
TFormMain = class(TForm)
cp_Main: TCardPanel;
crd_Start: TCard;
ButtonNew: TButton;
VirtualImageListButtons32: TVirtualImageList;
ButtonOpen: TButton;
ButtonRun: TButton;
ButtonAbout: TButton;
ListViewProjects: TListView;
LabelRecentProjectsCaption: TLabel;
ButtonOpenRecent: TButton;
ButtonRunRecent: TButton;
ButtonDeleteSelected: TButton;
crd_EditSettings: TCard;
cp_Wizard: TCardPanel;
crd_UnitTestExecutable: TCard;
p_WizardNavigation: TPanel;
ButtonGroup1: TButtonGroup;
PanelHeader: TPanel;
PanelBottomNavigation: TPanel;
LabelTop: TLabel;
ButtonPrevious: TButton;
ButtonNext: TButton;
LabelUnitTestExe: TLabel;
LabelUnitTestMap: TLabel;
EditExeFile: TEdit;
EditMapFile: TEdit;
ButtonOpenExe: TButton;
VirtualImageListButtons16: TVirtualImageList;
ButtonOpenMap: TButton;
ButtonCancel: TButton;
crd_Source: TCard;
LabelSourceFilesPath: TLabel;
EditSourcePath: TEdit;
ButtonSourcePath: TButton;
CheckListBoxSource: TCheckListBox;
crd_Output: TCard;
LabelScriptOutputPath: TLabel;
EditScriptOutputFolder: TEdit;
ButtonScriptOutputFolder: TButton;
EditReportOutputFolder: TEdit;
ButtonReportOutputFolder: TButton;
LabelReportOutputPath: TLabel;
CheckBoxEMMA: TCheckBox;
CheckBoxMeta: TCheckBox;
CheckBoxXML: TCheckBox;
CheckBoxHTML: TCheckBox;
LabelOutputFormatsCaption: TLabel;
Bevel1: TBevel;
crd_MiscSettings: TCard;
LabelMiscSettingsNote: TLabel;
CheckBoxRelativePaths: TCheckBox;
LabelPath: TLabel;
MemoScriptPreview: TMemo;
LabelScriptPreviewCaption: TLabel;
crd_SaveAndRun: TCard;
ButtonSave: TButton;
ButtonWizardRun: TButton;
FileOpenDialogProject: TFileOpenDialog;
FileOpenDialogExe: TFileOpenDialog;
FileOpenDialogMap: TFileOpenDialog;
FileSaveDialogProject: TFileSaveDialog;
FolderOpenDialog: TFileOpenDialog;
LabelSourceFilesCaption: TLabel;
b_SelectAll: TButton;
b_DeselectAll: TButton;
b_RefreshSourceFiles: TButton;
LabelCodeCoveragePath: TLabel;
EditCodeCoverageExe: TEdit;
ButtonOpenCodeCoverage: TButton;
FileOpenDialogCoverage: TFileOpenDialog;
ButtonHome: TButton;
FolderOpenDialogReport: TFileOpenDialog;
FolderOpenDialogSource: TFileOpenDialog;
crd_Run: TCard;
LabelRunDescription: TLabel;
ActivityIndicator: TActivityIndicator;
crd_Finished: TCard;
ButtonHomeAfterRun: TButton;
ButtonBrowserBack: TButton;
ButtonBrowserNext: TButton;
EdgeBrowser: TEdgeBrowser;
PopupMenuRecentProjects: TPopupMenu;
PMOpenSelected: TMenuItem;
PMRunselected: TMenuItem;
PMRemoveselected: TMenuItem;
ScrollBoxOutputSettings: TScrollBox;
CheckBoxEMMA21: TCheckBox;
CheckBoxOpenEMMAFileExtern: TCheckBox;
CheckBoxOpenXMLFileExtern: TCheckBox;
CheckBoxOpenHTMLFileExtern: TCheckBox;
CheckBoxXMLLines: TCheckBox;
CheckBoxXMLCombineMultiple: TCheckBox;
LabelAdditioalParams: TLabel;
EditAdditionalParameter: TEdit;
CheckBoxXMLJacocoFormat: TCheckBox;
ScrollBoxMisc: TScrollBox;
Label1: TLabel;
CheckBoxLogToFile: TCheckBox;
CheckBoxLogPerAPI: TCheckBox;
CheckBoxPassThroughExitCode: TCheckBox;
CheckBoxUseApplicationWorkingDir: TCheckBox;
Label2: TLabel;
EditCommandLineParams: TEdit;
ScrollBoxUnitTestExecutable: TScrollBox;
ButtonSaveAs: TButton;
LabelCodePage: TLabel;
EditCodePage: TEdit;
PMRemoveInexisting: TMenuItem;
TimerSourcePath: TTimer;
Label3AdditionalParamIndex: TLabel;
EditAdditionalParamIndex: TEdit;
BalloonHintMap: TBalloonHint;
LabelEdgeSDK: TLabel;
ButtonBackToProject: TButton;
ButtonRunAgain: TButton;
CheckBoxLimitNumberOfExecutionTime: TCheckBox;
Label3: TLabel;
NumberBoxLineExecutionCount: TNumberBox;
crd_ClassPrefixExcludes: TCard;
b_SelectAllClassPrefixExcluded: TButton;
b_DeselectAllClassPrefixExcluded: TButton;
b_DeleteSelectedClassExclusionMasks: TButton;
MemoClassPrefixExcluded: TMemo;
CheckBoxIncludeFileExtension: TCheckBox;
procedure ButtonAboutClick(Sender: TObject);
procedure ButtonNewClick(Sender: TObject);
procedure ButtonCancelClick(Sender: TObject);
procedure ButtonNextClick(Sender: TObject);
procedure ButtonPreviousClick(Sender: TObject);
procedure ButtonOpenExeClick(Sender: TObject);
procedure ButtonOpenMapClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ButtonOpenClick(Sender: TObject);
procedure ButtonRunClick(Sender: TObject);
procedure ButtonSourcePathClick(Sender: TObject);
procedure ButtonScriptOutputFolderClick(Sender: TObject);
procedure ButtonReportOutputFolderClick(Sender: TObject);
procedure EditSourcePathChange(Sender: TObject);
procedure ButtonSaveClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ButtonDeleteSelectedClick(Sender: TObject);
procedure CheckBoxEMMAClick(Sender: TObject);
procedure EditMapFileChange(Sender: TObject);
procedure EditExeFileChange(Sender: TObject);
procedure crd_UnitTestExecutableEnter(Sender: TObject);
procedure crd_SourceEnter(Sender: TObject);
procedure crd_OutputEnter(Sender: TObject);
procedure crd_MiscSettingsEnter(Sender: TObject);
procedure crd_SaveAndRunEnter(Sender: TObject);
procedure CheckListBoxSourceClickCheck(Sender: TObject);
procedure b_SelectAllClick(Sender: TObject);
procedure b_DeselectAllClick(Sender: TObject);
procedure b_RefreshSourceFilesClick(Sender: TObject);
procedure ButtonScriptOutputFolderExit(Sender: TObject);
procedure EditReportOutputFolderExit(Sender: TObject);
procedure CheckBoxXMLClick(Sender: TObject);
procedure CheckBoxHTMLClick(Sender: TObject);
procedure CheckBoxMetaClick(Sender: TObject);
procedure CheckBoxRelativePathsClick(Sender: TObject);
procedure ButtonOpenCodeCoverageClick(Sender: TObject);
procedure EditCodeCoverageExeChange(Sender: TObject);
procedure EditScriptOutputFolderExit(Sender: TObject);
procedure ButtonHomeClick(Sender: TObject);
procedure ButtonWizardRunClick(Sender: TObject);
procedure ButtonGroup1ButtonClicked(Sender: TObject; Index: Integer);
procedure ButtonOpenRecentClick(Sender: TObject);
procedure ListViewProjectsDblClick(Sender: TObject);
procedure ButtonRunRecentClick(Sender: TObject);
procedure ButtonBrowserBackClick(Sender: TObject);
procedure ButtonBrowserNextClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure EdgeBrowserCreateWebViewCompleted(Sender: TCustomEdgeBrowser;
AResult: HRESULT);
procedure EdgeBrowserHistoryChanged(Sender: TCustomEdgeBrowser);
procedure CheckBoxOpenXMLFileExternClick(Sender: TObject);
procedure CheckBoxOpenHTMLFileExternClick(Sender: TObject);
procedure CheckBoxOpenEMMAFileExternClick(Sender: TObject);
procedure CheckBoxEMMA21Click(Sender: TObject);
procedure EditAdditionalParameterChange(Sender: TObject);
procedure CheckBoxXMLLinesClick(Sender: TObject);
procedure CheckBoxXMLCombineMultipleClick(Sender: TObject);
procedure CheckBoxXMLJacocoFormatClick(Sender: TObject);
procedure CheckBoxLogToFileClick(Sender: TObject);
procedure CheckBoxLogPerAPIClick(Sender: TObject);
procedure CheckBoxPassThroughExitCodeClick(Sender: TObject);
procedure CheckBoxUseApplicationWorkingDirClick(Sender: TObject);
procedure EditCommandLineParamsChange(Sender: TObject);
procedure ButtonSaveAsClick(Sender: TObject);
procedure EditCodePageChange(Sender: TObject);
procedure PMRemoveInexistingClick(Sender: TObject);
procedure TimerSourcePathTimer(Sender: TObject);
procedure EditAdditionalParamIndexChange(Sender: TObject);
procedure ButtonBackToProjectClick(Sender: TObject);
procedure CheckBoxLimitNumberOfExecutionTimeClick(Sender: TObject);
procedure NumberBoxLineExecutionCountChangeValue(Sender: TObject);
procedure b_SelectAllClassPrefixExcludedClick(Sender: TObject);
procedure b_DeselectAllClassPrefixExcludedClick(Sender: TObject);
procedure b_DeleteSelectedClassExclusionMasksClick(Sender: TObject);
procedure MemoClassPrefixExcludedChange(Sender: TObject);
procedure crd_ClassPrefixExcludesEnter(Sender: TObject);
procedure CheckBoxIncludeFileExtensionClick(Sender: TObject);
private
/// <summary>
/// Manages application settings
/// </summary>
FSettings : TSettings;
/// <summary>
/// Manages project settings and loading/saving these from/to a file
/// </summary>
FProject : IProjectSettings;
/// <summary>
/// Buisiness logic for the main form
/// </summary>
FLogic : TMainFormLogic;
/// <summary>
/// Buffered entered new source file base path. Needed because processing
/// has been deferred via some timer.
/// </summary>
FNewSourcePath : string;
/// <summary>
/// Checks whether both file names have been filled in and depending on the
/// outcome sets the tag of the exe file card to the index of the check
/// icon or to -1. Means: displays a check or no icon, depending on whether
/// both values are set or at least one is missing
/// </summary>
procedure DisplayExeMapInputStatus;
/// <summary>
/// Positions the form as defined in the settings
/// </summary>
procedure SetFormPos;
/// <summary>
/// Fills the list of recent projects with the data from settings. Clears
/// the list first.
/// </summary>
procedure DisplayRecentProjects;
/// <summary>
/// Displays the dialog for adding this tool to Delphi's Tools menu
/// </summary>
procedure DisplayAddToToolsMenu;
/// <summary>
/// Sets the focus on the first WinControl on the active card of the new
/// project wizard.
/// </summary>
procedure SetFocusToFirstProjectCardControl;
/// <summary>
/// Selects or deselects all files in the source file list box.
/// </summary>
procedure SelectDeselectAllSourceFIles(Selected: Boolean);
/// <summary>
/// Displays all source files in the project's list of source files along
/// with their selection status in the checkbox list
/// </summary>
procedure DisplaySourceFiles;
/// <summary>
/// Checks whether all required fields on the output settings screen have
/// been filled in and if yes displays the check icon on the menu item.
/// </summary>
procedure DisplayOutputSettingsStatus;
/// <summary>
/// Sets the image index of the active card.
/// </summary>
/// <param name="ImageIndex">
/// Index of the image to display on the menu button for the currently
/// active card
/// </param>
procedure SetActiveWizardCardImageIndex(ImageIndex: Integer);
/// <summary>
/// Checks whether the currently active wizard page is the one for the
/// misc settings and if, sets the check icon for that menu button since
/// there is no mandatory control on this page
/// </summary>
procedure SetMiscSettingsCheckIfActive;
/// <summary>
/// Changes the set of selected output formats. Either adds the format
/// specified or removes it.
/// </summary>
/// <param name="Checked">
/// When true the format will be added as output format, otherwise it will
/// be removed.
/// </param>
/// <param name="OutputFormat">
/// Format to be added or removed.
/// </param>
procedure OutputFormatCheckStatusChanged(Checked : Boolean;
OutputFormat : TOutputFormat);
/// <summary>
/// Loads the specified project file, displays its contents and jumps into
/// edit mode's save and run section.
/// </summary>
/// <param name="FileName">
/// Path and name of the file to load
/// </param>
procedure LoadProjectFile(const FileName: string);
/// <summary>
/// Loads the file selected in the listview
/// </summary>
procedure LoadSelectedFileFromListView;
/// <summary>
/// Updates all icons for all buttons in the left hand wizard navigation
/// with the image index stored in their CardPanel Card.
/// </summary>
procedure DisplayButtonIcons;
/// <summary>
/// Displays the check icon on the left hand side button menu if the
/// fields on the source files card are properly filled.
/// </summary>
procedure DisplaySourceFilesStatus;
/// <summary>
/// Runs the specified script as defined in the project settings
/// </summary>
procedure RunScript;
/// <summary>
/// Event which is being called when a coverage test run has been finished
/// </summary>
/// <param name="CallResult">
/// Result code of the external program called
/// </param>
procedure OnTestRunFinished(CallResult: UInt32);
/// <summary>
/// Displays the paths used in the generated script in the memo
/// </summary>
procedure DisplayScriptOutputPaths;
/// <summary>
/// Prepare display of all dynamic contents on the misc. settings page
/// </summary>
procedure PrepareScriptOutputPathDisplay;
/// <summary>
/// Preinitializes the path to the code coverage command line tool with the
/// one shipping with this wizard.
/// </summary>
procedure PreInitCodeCoverageExe;
/// <summary>
/// Resets all wizard fields to initial or empty values
/// </summary>
procedure ClearWizardFields;
/// <summary>
/// Sets the value of the source path edit without automatically updating
/// the list of source files.
/// </summary>
/// <param name="ANewPath">
/// New value for the source path edit
/// </param>
procedure SetSourcePathWithoutFileList(const ANewPath: string);
/// <summary>
/// Processes the command line params
/// </summary>
procedure ProcessCmdLineParams;
/// <summary>
/// Updates enabled state of the forward/back buttons for the integrated
// HTML view
/// </summary>
procedure UpdateBrowserNavigationButtons;
/// <summary>
/// Changes enabled state of the EMMA specific checkboxes (meta data and
/// display in external viewer) based on whether the format is enabled or not
/// </summary>
procedure UpdateEMMACheckBoxEnableStates;
/// <summary>
/// Changes enabled state of the XML specific checkboxes (lines, display in
/// external viewer and combine) based on whether the format is enabled or not
/// </summary>
procedure UpdateXMLCheckBoxEnableStates;
/// <summary>
/// Changes enabled state of the HTML specific checkboxes (display in
/// external viewer) based on whether the format is enabled or not
/// </summary>
procedure UpdateHTMLCheckBoxEnableStates;
/// <summary>
/// Displays the Save and Run card of the wizard and disables the next button
/// </summary>
procedure DisplaySaveAndRunScreen;
/// <summary>
/// Initializes the project data management instance
/// </summary>
procedure CreateProjectSettings;
/// <summary>
/// Generates the directories, the lst files and the batch file to run
/// CodeCoverage.exe
/// </summary>
procedure GenerateDirectoriesAndBatchFile;
/// <summary>
/// Adds a project to the list of recent projects, if it's not already in
/// that list and refreshes list display
/// </summary>
/// <param name="FileName">
/// Path and name of the file to add
/// </param>
procedure AddAndUpdateRecentProjects(const FileName: string);
/// <summary>
/// Asks if the file list may be changed if its not empty or the source
/// path should be reverted to the old path and if it shall be changed
/// updates the file list
/// </summary>
/// <param name="NewSourcePath">
/// New source file base path
/// </param>
procedure DoSourcePathChange(const NewSourcePath: string);
/// <summary>
/// Checks if the question about registering the DCCP file extension has
/// already been asked and if not asks it and adds the extension if requested
/// </summary>
procedure DisplayAddFileExtension;
public
end;
var
FormMain: TFormMain;
implementation
uses
System.UITypes,
System.IOUtils,
System.TypInfo,
System.Threading,
UScriptsGenerator,
UScriptRunner,
UManageToolsMenu,
UUtils,
MainFormTexts,
AboutForm;
{$R *.dfm}
const
/// <summary>
/// Index of the icon for the currently active wizzard page
/// </summary>
cImgActivePage = 7;
/// <summary>
/// Index of the icon for a completely filled in wizzard page
/// </summary>
cImgCompletedPage = 8;
procedure TFormMain.ButtonSaveAsClick(Sender: TObject);
begin
FileSaveDialogProject.FileName := FProject.FileName;
if FileSaveDialogProject.Execute then
begin
try
FProject.SaveToXML(FileSaveDialogProject.FileName);
AddAndUpdateRecentProjects(FileSaveDialogProject.FileName);
crd_SaveAndRun.Tag := cImgCompletedPage;
GenerateDirectoriesAndBatchFile;
except
on e:exception do
MessageDlg(Format(rSaveFileError,
[e.Message, FileSaveDialogProject.FileName]),
mtError, [mbOK], -1);
end;
end;
end;
procedure TFormMain.ButtonSaveClick(Sender: TObject);
begin
try
if TFile.Exists(FProject.FileName) then
begin
FProject.SaveToXML(FProject.FileName);
crd_SaveAndRun.Tag := cImgCompletedPage;
GenerateDirectoriesAndBatchFile;
end
else
ButtonSaveAsClick(Sender);
except
on e:exception do
MessageDlg(Format(rSaveFileError,
[e.Message, FProject.FileName]),
mtError, [mbOK], -1);
end;
end;
procedure TFormMain.AddAndUpdateRecentProjects(const FileName: string);
begin
FSettings.AddRecentProject(FileName);
ListViewProjects.Items.Clear;
DisplayRecentProjects;
end;
procedure TFormMain.GenerateDirectoriesAndBatchFile;
var
ScriptGenerator : TScriptsGenerator;
begin
try
FLogic.ForceDirectories(FProject);
except
on e:exception do
MessageDlg(e.Message, mtError, [mbOK], -1);
end;
ScriptGenerator := TScriptsGenerator.Create(FProject,
FProject.FileName);
try
ScriptGenerator.Generate;
finally
ScriptGenerator.Free;
end;
end;
procedure TFormMain.SetActiveWizardCardImageIndex(ImageIndex : Integer);
begin
ButtonGroup1.Items[cp_Wizard.ActiveCardIndex].ImageIndex := ImageIndex;
end;
procedure TFormMain.ButtonScriptOutputFolderClick(Sender: TObject);
begin
if EditScriptOutputFolder.Text <> '' then
FolderOpenDialog.FileName := EditScriptOutputFolder.Text;
if FolderOpenDialog.Execute then
EditScriptOutputFolder.Text := FolderOpenDialog.FileName;
end;
procedure TFormMain.ButtonScriptOutputFolderExit(Sender: TObject);
begin
FProject.ScriptsOutputPath := EditScriptOutputFolder.Text;
end;
procedure TFormMain.ButtonSourcePathClick(Sender: TObject);
begin
if EditSourcePath.Text <> '' then
FolderOpenDialogSource.FileName := EditSourcePath.Text;
if FolderOpenDialogSource.Execute then
EditSourcePath.Text := FolderOpenDialogSource.FileName;
end;
procedure TFormMain.ButtonWizardRunClick(Sender: TObject);
begin
crd_SaveAndRun.Tag := cImgCompletedPage;
RunScript;
end;
procedure TFormMain.b_SelectAllClassPrefixExcludedClick(Sender: TObject);
begin
MemoClassPrefixExcluded.SelectAll;
end;
procedure TFormMain.b_SelectAllClick(Sender: TObject);
begin
SelectDeselectAllSourceFiles(true);
end;
procedure TFormMain.SelectDeselectAllSourceFiles(Selected: Boolean);
begin
try
for var i := 0 to CheckListBoxSource.Items.Count - 1 do
FProject.ProgramSourceFiles.ChangeSelected(i, Selected);
if Selected then
CheckListBoxSource.CheckAll(TCheckBoxState.cbChecked, false, false)
else
CheckListBoxSource.CheckAll(TCheckBoxState.cbUnchecked, false, false);
except
on e:exception do
MessageDlg(Format(rSelectionError, [e.Message]), mtError, [mbOK], -1);
end;
end;
procedure TFormMain.b_DeselectAllClassPrefixExcludedClick(Sender: TObject);
begin
MemoClassPrefixExcluded.ClearSelection;
end;
procedure TFormMain.b_DeselectAllClick(Sender: TObject);
begin
SelectDeselectAllSourceFiles(false);
end;
procedure TFormMain.b_RefreshSourceFilesClick(Sender: TObject);
begin
FProject.ProgramSourceFiles.UpdateSourceFilesList;
DisplaySourceFiles;
end;
procedure TFormMain.b_DeleteSelectedClassExclusionMasksClick(Sender: TObject);
begin
MemoClassPrefixExcluded.SelText := '';
end;
procedure TFormMain.ButtonAboutClick(Sender: TObject);
var
FormAbout : TFormAbout;
begin
FormAbout := TFormAbout.Create(self, FLogic.GetFileVersion(Application.ExeName));
try
FormAbout.ShowModal;
finally
FormAbout.Free;
end;
end;
procedure TFormMain.ButtonBackToProjectClick(Sender: TObject);
begin
cp_Main.ActiveCard := crd_EditSettings;
end;
procedure TFormMain.ButtonBrowserBackClick(Sender: TObject);
begin
try
EdgeBrowser.GoBack;
UpdateBrowserNavigationButtons;
except
// going back from the first page cannot be done, but there seems no way
// to find out if we are on the first page
end;
end;
procedure TFormMain.ButtonBrowserNextClick(Sender: TObject);
begin
try
EdgeBrowser.GoForward;
UpdateBrowserNavigationButtons;
except
// going back from the first page cannot be done, but there seems no way
// to find out if we are on the first page
end;
end;
procedure TFormMain.UpdateBrowserNavigationButtons;
begin
ButtonBrowserNext.Enabled := EdgeBrowser.CanGoForward;
ButtonBrowserBack.Enabled := EdgeBrowser.CanGoBack;
end;
procedure TFormMain.ButtonCancelClick(Sender: TObject);
begin
cp_Main.ActiveCard := crd_Start;
end;
procedure TFormMain.ButtonDeleteSelectedClick(Sender: TObject);
begin
for var i := ListViewProjects.Items.Count - 1 downto 0 do
begin
if ListViewProjects.Items[i].Selected then
FSettings.DeleteRecentProject(i);
end;
ListViewProjects.DeleteSelected;
end;
procedure TFormMain.ButtonGroup1ButtonClicked(Sender: TObject; Index: Integer);
begin
SetActiveWizardCardImageIndex(cp_Wizard.Cards[cp_Wizard.ActiveCardIndex].Tag);
case Index of
0 : begin
cp_Wizard.ActiveCard := crd_UnitTestExecutable;
ButtonNext.Enabled := FProject.IsExeAndMapDefined;
crd_UnitTestExecutableEnter(Sender);
end;
1 : begin
cp_Wizard.ActiveCard := crd_Source;
ButtonNext.Enabled := FProject.IsSourcePathAndFilesDefined;
crd_SourceEnter(Sender);
end;
2 : begin
cp_Wizard.ActiveCard := crd_Output;
ButtonNext.Enabled := FProject.IsOutputSettingsDefined;
crd_OutputEnter(Sender);
end;
3 : begin
cp_Wizard.ActiveCard := crd_MiscSettings;
crd_MiscSettings.Tag := cImgCompletedPage;
ButtonNext.Enabled := true;
PrepareScriptOutputPathDisplay;
crd_MiscSettingsEnter(Sender);
end;
4 : DisplaySaveAndRunScreen;
else
MessageDlg(Format(rUnknownMenu, [Index]), mtError, [mbOK], -1);
end;
SetActiveWizardCardImageIndex(cImgActivePage);
end;
procedure TFormMain.DisplaySaveAndRunScreen;
begin
cp_Wizard.ActiveCard := crd_SaveAndRun;
ButtonNext.Enabled := false;
ButtonCancel.Enabled := false;
ButtonSave.Enabled := not FProject.FileName.IsEmpty;
crd_SaveAndRunEnter(self);
end;
procedure TFormMain.ButtonHomeClick(Sender: TObject);
begin
cp_Main.ActiveCard := crd_Start;
end;
procedure TFormMain.ButtonNewClick(Sender: TObject);
begin
if FProject.IsAnyDataDefined then
if MessageDlg(rClearWizard, mtConfirmation, [mbYes, mbNo], -1) = mrYes then
begin
ClearWizardFields;
FProject := nil;
CreateProjectSettings;
end;
cp_Main.ActiveCard := crd_EditSettings;
cp_Wizard.ActiveCardIndex := 0;
ButtonPrevious.Enabled := false;
ButtonNext.Enabled := true;
ButtonPrevious.Enabled := true;
PreInitCodeCoverageExe;
for var Item in ButtonGroup1.Items do
(Item as TGrpButtonItem).ImageIndex := -1;
ButtonGroup1.Items[0].ImageIndex := cImgActivePage;
end;
procedure TFormMain.ButtonNextClick(Sender: TObject);
begin
if (cp_Wizard.ActiveCardIndex < cp_Wizard.CardCount-1) then
begin
SetActiveWizardCardImageIndex(cp_Wizard.Cards[cp_Wizard.ActiveCardIndex].Tag);
cp_Wizard.ActiveCardIndex := cp_Wizard.ActiveCardIndex + 1;
SetActiveWizardCardImageIndex(cImgActivePage);
ButtonPrevious.Enabled := true;
if (cp_Wizard.ActiveCardIndex = cp_Wizard.CardCount-1) then
ButtonNext.Enabled := false;
if cp_Wizard.ActiveCard = crd_MiscSettings then
PrepareScriptOutputPathDisplay;
SetMiscSettingsCheckIfActive;
SetFocusToFirstProjectCardControl;
end;
end;
procedure TFormMain.PMRemoveInexistingClick(Sender: TObject);
var
Projects : TStrings;
begin
Projects := FSettings.GetRecentProjects;
try
try
FLogic. DeleteNonExistingRecentProjects(Projects, FSettings.DeleteRecentProject);
DisplayRecentProjects;
except
on e:exception do
MessageDlg(Format(rRemoveFailed, [e.Message]), mtError, [mbOK], -1);
end;
finally
Projects.Free;
end;
end;
procedure TFormMain.PreInitCodeCoverageExe;
var
Path : string;
begin
if (EditCodeCoverageExe.Text = '') then
begin
Path := TPath.GetDirectoryName(Application.ExeName);
// go up 2 directories
Path := Path.Remove(Path.LastIndexOf(TPath.DirectorySeparatorChar));
Path := Path.Remove(Path.LastIndexOf(TPath.DirectorySeparatorChar));
EditCodeCoverageExe.Text := TPath.Combine(Path, 'CodeCoverage.exe');
end;
end;
procedure TFormMain.PrepareScriptOutputPathDisplay;
begin
LabelPath.Caption := FProject.ScriptsOutputPath;
MemoScriptPreview.Lines.Clear;
DisplayScriptOutputPaths;
end;
procedure TFormMain.SetMiscSettingsCheckIfActive;
begin
if cp_Wizard.ActiveCard = crd_MiscSettings then
crd_MiscSettings.Tag := cImgCompletedPage;
end;
procedure TFormMain.ButtonOpenClick(Sender: TObject);
begin
if FileOpenDialogProject.Execute then
begin
LoadProjectFile(FileOpenDialogProject.FileName);
end;
end;
procedure TFormMain.ListViewProjectsDblClick(Sender: TObject);
begin
LoadSelectedFileFromListView;
end;
procedure TFormMain.LoadProjectFile(const FileName: string);
var
OnChangeBackup : TNotifyEvent;
begin
Assert(not FileName.IsEmpty, 'No file name given!');
try
FProject.LoadFromXML(FileName);
AddAndUpdateRecentProjects(FileName);
EditExeFile.Text := FProject.ExecutableToAnalyze;
EditCommandLineParams.Text := FProject.ExeCommandLineParams;
EditMapFile.Text := FProject.MapFile;
CheckBoxUseApplicationWorkingDir.Checked := FProject.UseExeDirAsWorkDir;
OnChangeBackup := EditSourcePath.OnChange;
EditSourcePath.OnChange := nil;
try
EditSourcePath.Text := FProject.ProgramSourceBasePath;
finally
EditSourcePath.OnChange := OnChangeBackup;
end;
EditCodePage.Text := FProject.CodePage.ToString;
EditScriptOutputFolder.Text := FProject.ScriptsOutputPath;
EditReportOutputFolder.Text := FProject.ReportOutputPath;
EditCodeCoverageExe.Text := FProject.CodeCoverageExePath;
CheckBoxEMMA.Checked := ofEMMA in FProject.OutputFormats;
CheckBoxMeta.Checked := ofMeta in FProject.OutputFormats;
CheckBoxEMMA21.Checked := ofEMMA21 in FProject.OutputFormats;
CheckBoxXML.Checked := ofXML in FProject.OutputFormats;
CheckBoxHTML.Checked := ofHTML in FProject.OutputFormats;
CheckBoxOpenEMMAFileExtern.Checked := FProject.DisplayEMMAFileExt;
CheckBoxOpenXMLFileExtern.Checked := FProject.DisplayXMLFileExt;
CheckBoxOpenHTMLFileExtern.Checked := FProject.DisplayHTMLFileExt;
CheckBoxXMLLines.Checked := FProject.AddLineNumbersToXML;
CheckBoxXMLCombineMultiple.Checked := FProject.CombineXMLCoverage;
CheckBoxXMLJacocoFormat.Checked := FProject.XMLJacocoFormat;
CheckBoxLogToFile.Checked := FProject.LogToTextFile;
CheckBoxLogPerAPI.Checked := FProject.LogToOutputDebugString;
CheckBoxPassThroughExitCode.Checked := FProject.PassTroughExitCode;
CheckBoxRelativePaths.Checked := FProject.RelativeToScriptPath;
EditAdditionalParameter.Text := FProject.AdditionalParameter;
EditAdditionalParamIndex.Text := FProject.AdditionalParIndex.ToString;
UpdateEMMACheckBoxEnableStates;
UpdateXMLCheckBoxEnableStates;
UpdateHTMLCheckBoxEnableStates;
// Misc settings is always declared as completed
crd_MiscSettings.Tag := cImgCompletedPage;
LabelPath.Caption := FProject.ScriptsOutputPath;
ButtonGroup1.Items[0].ImageIndex := -1;
DisplaySourceFiles;
DisplayExeMapInputStatus;
DisplaySourceFilesStatus;
DisplayOutputSettingsStatus;
DisplayButtonIcons;
cp_Main.ActiveCard := crd_EditSettings;
DisplaySaveAndRunScreen;
SetActiveWizardCardImageIndex(cImgActivePage);
except
on e:exception do
MessageDlg(Format(rLoadFileError, [e.Message, FileName]), mtError, [mbOK], -1);
end;
end;
procedure TFormMain.DisplayButtonIcons;
begin
ButtonGroup1.Items[0].ImageIndex := crd_UnitTestExecutable.Tag;
ButtonGroup1.Items[1].ImageIndex := crd_Source.Tag;
ButtonGroup1.Items[2].ImageIndex := crd_Output.Tag;
ButtonGroup1.Items[3].ImageIndex := crd_MiscSettings.Tag;
ButtonGroup1.Items[4].ImageIndex := crd_SaveAndRun.Tag;
end;
procedure TFormMain.ButtonOpenCodeCoverageClick(Sender: TObject);
begin
if EditCodeCoverageExe.Text <> '' then
FileOpenDialogCoverage.FileName := EditCodeCoverageExe.Text;
if FileOpenDialogCoverage.Execute then
EditCodeCoverageExe.Text := FileOpenDialogCoverage.FileName;
end;
procedure TFormMain.ButtonOpenExeClick(Sender: TObject);
begin
if EditExeFile.Text <> '' then
FileOpenDialogExe.FileName := EditExeFile.Text;
if FileOpenDialogExe.Execute then
EditExeFile.Text := FileOpenDialogExe.FileName;
end;
procedure TFormMain.ButtonOpenMapClick(Sender: TObject);
begin
if EditMapFile.Text <> '' then
FileOpenDialogMap.FileName := EditMapFile.Text;
if FileOpenDialogMap.Execute then
EditMapFile.Text := FileOpenDialogMap.FileName;
end;
procedure TFormMain.ButtonOpenRecentClick(Sender: TObject);
begin
LoadSelectedFileFromListView;
end;
procedure TFormMain.LoadSelectedFileFromListView;
var
Item : TListItem;
begin
Item := ListViewProjects.Items[ListViewProjects.ItemIndex];
if Assigned(Item) and (Item.SubItems.Count >= 1) and
not Item.Caption.IsEmpty then
LoadProjectFile(TPath.Combine(Item.Caption, Item.SubItems[0]));
end;
procedure TFormMain.MemoClassPrefixExcludedChange(Sender: TObject);
begin
FProject.ExcludedClassPrefixes := MemoClassPrefixExcluded.Lines.Text;
end;
procedure TFormMain.NumberBoxLineExecutionCountChangeValue(Sender: TObject);
begin
if Assigned(FProject) then
FProject.NumberOfLineExecutes := (Sender as TNumberBox).ValueInt;
end;
procedure TFormMain.ButtonPreviousClick(Sender: TObject);
begin
if (cp_Wizard.ActiveCardIndex > 0) then
begin
SetActiveWizardCardImageIndex(cp_Wizard.Cards[cp_Wizard.ActiveCardIndex].Tag);
cp_Wizard.ActiveCardIndex := cp_Wizard.ActiveCardIndex - 1;
SetActiveWizardCardImageIndex(cImgActivePage);
ButtonNext.Enabled := true;
if (cp_Wizard.ActiveCardIndex = 0) then
ButtonPrevious.Enabled := false;
SetMiscSettingsCheckIfActive;
SetFocusToFirstProjectCardControl;
end;
end;
procedure TFormMain.ButtonReportOutputFolderClick(Sender: TObject);
begin
if EditReportOutputFolder.Text <> '' then
FolderOpenDialogReport.FileName := EditReportOutputFolder.Text;
if FolderOpenDialogReport.Execute then
EditReportOutputFolder.Text := FolderOpenDialogReport.FileName;
end;
procedure TFormMain.ButtonRunClick(Sender: TObject);
begin
if FileOpenDialogProject.Execute then