@@ -69,6 +69,7 @@ TSWAGImportDlg = class(TWizardDlg, INoPublicConstruct)
69
69
btnBrowse: TButton;
70
70
actBrowse: TAction;
71
71
frmIntro: THTMLTpltDlgFrame;
72
+ lblVersionNumber: TLabel;
72
73
// / <summary>Handles clicks on the check boxes next to packets in the
73
74
// / packet selection list box by selecting and deselecting packets for
74
75
// / inclusion in the import.</summary>
@@ -243,6 +244,7 @@ implementation
243
244
// Project
244
245
FmPreviewDlg,
245
246
FmWaitDlg,
247
+ SWAG.UVersion,
246
248
UBrowseForFolderDlg,
247
249
UColours,
248
250
UConsts,
@@ -254,6 +256,7 @@ implementation
254
256
UMessageBox,
255
257
UStrUtils,
256
258
UUrl,
259
+ UVersionInfo,
257
260
UWaitForThreadUI;
258
261
259
262
{ $R *.dfm}
@@ -319,7 +322,7 @@ procedure TSWAGImportDlg.ArrangeForm;
319
322
lblCategoriesDesc.Width := tsCategories.ClientWidth;
320
323
lblCategoriesDesc.Top := 3 ;
321
324
TCtrlArranger.AlignLefts(
322
- [lblCategoriesDesc, lblCategories, lbCategories], 0
325
+ [lblCategoriesDesc, lblCategories, lbCategories, lblVersionNumber ], 0
323
326
);
324
327
TCtrlArranger.AlignTops(
325
328
[lblCategories, lblSelectPackets],
@@ -333,6 +336,11 @@ procedure TSWAGImportDlg.ArrangeForm;
333
336
[btnDisplayCategory, btnDisplayPacket],
334
337
TCtrlArranger.BottomOf([lbCategories, clbSelectPackets], 8 )
335
338
);
339
+ TCtrlArranger.MoveBelow(
340
+ [btnDisplayCategory, btnDisplayPacket],
341
+ lblVersionNumber,
342
+ 8
343
+ );
336
344
TCtrlArranger.AlignHCentresTo([lbCategories], [btnDisplayCategory]);
337
345
TCtrlArranger.AlignHCentresTo([clbSelectPackets], [btnDisplayPacket]);
338
346
@@ -604,28 +612,23 @@ function TSWAGImportDlg.HeadingText(const PageIdx: Integer): string;
604
612
end ;
605
613
606
614
procedure TSWAGImportDlg.InitSelectionPage ;
607
- // resourcestring
608
- // sDefaultWaitMsg = 'Accessing SWAG database...';
609
615
var
610
616
Cats: TList<TSWAGCategory>;
611
617
Idx: Integer;
618
+ VerNumStr: string;
619
+ resourcestring
620
+ sLblVersionNumberCaption = ' SWAG version %s' ;
612
621
begin
622
+ lblVersionNumber.Caption := Format(
623
+ sLblVersionNumberCaption,
624
+ [string(TSWAGVersion.GetVersion(GetDirNameFromEditCtrl))]
625
+ );
626
+
613
627
Application.ProcessMessages;
614
628
615
629
if (lbCategories.Count > 0 ) then
616
630
Exit;
617
631
618
- // fPrevSWAGDir := GetDirNameFromEditCtrl;
619
- //
620
- // FreeAndNil(fSWAGReader);
621
- // fSWAGReader := TSWAGReader.Create(
622
- // GetDirNameFromEditCtrl,
623
- // procedure (CallProc: TProc)
624
- // begin
625
- // WaitWrapper(Self, CallProc, sDefaultWaitMsg);
626
- // end
627
- // );
628
- //
629
632
Cats := TList<TSWAGCategory>.Create;
630
633
try
631
634
fSWAGReader.GetCategories(Cats);
@@ -856,11 +859,23 @@ procedure TSWAGImportDlg.ValidatePage(const PageIdx: Integer);
856
859
sNoFolder = ' Please enter the directory where you downloaded the SWAG '
857
860
+ ' database.' ;
858
861
sBadFolder = ' Directory "%s" does not exist. Please specify a valid one.' ;
862
+ sBadVersion = ' %s.' + EOL2
863
+ + ' Please specify a directory containing a supported version.' ;
864
+ sCorrupt = ' Not a valid SWAG database (%s). ' + EOL2
865
+ + ' Please specify a different directory.' ;
859
866
begin
860
867
if GetDirNameFromEditCtrl = ' ' then
861
- raise EDataEntry.Create(sNoFolder);
868
+ raise EDataEntry.Create(sNoFolder, edPath );
862
869
if not TDirectory.Exists(GetDirNameFromEditCtrl, False) then
863
- raise EDataEntry.CreateFmt(sBadFolder, [GetDirNameFromEditCtrl]);
870
+ raise EDataEntry.CreateFmt(sBadFolder, [GetDirNameFromEditCtrl], edPath);
871
+ try
872
+ TSWAGVersion.ValidateVersionFile(GetDirNameFromEditCtrl);
873
+ except
874
+ on E: ECorruptSWAGVersion do
875
+ raise EDataEntry.CreateFmt(sCorrupt, [E.Message], edPath);
876
+ on E: EUnsupportedSWAGVersion do
877
+ raise EDataEntry.CreateFmt(sBadVersion, [E.Message], edPath);
878
+ end ;
864
879
end ;
865
880
866
881
procedure ValidateSelectionPage ;
0 commit comments