@@ -69,6 +69,7 @@ TSWAGImportDlg = class(TWizardDlg, INoPublicConstruct)
6969 btnBrowse: TButton;
7070 actBrowse: TAction;
7171 frmIntro: THTMLTpltDlgFrame;
72+ lblVersionNumber: TLabel;
7273 // / <summary>Handles clicks on the check boxes next to packets in the
7374 // / packet selection list box by selecting and deselecting packets for
7475 // / inclusion in the import.</summary>
@@ -243,6 +244,7 @@ implementation
243244 // Project
244245 FmPreviewDlg,
245246 FmWaitDlg,
247+ SWAG.UVersion,
246248 UBrowseForFolderDlg,
247249 UColours,
248250 UConsts,
@@ -254,6 +256,7 @@ implementation
254256 UMessageBox,
255257 UStrUtils,
256258 UUrl,
259+ UVersionInfo,
257260 UWaitForThreadUI;
258261
259262{ $R *.dfm}
@@ -319,7 +322,7 @@ procedure TSWAGImportDlg.ArrangeForm;
319322 lblCategoriesDesc.Width := tsCategories.ClientWidth;
320323 lblCategoriesDesc.Top := 3 ;
321324 TCtrlArranger.AlignLefts(
322- [lblCategoriesDesc, lblCategories, lbCategories], 0
325+ [lblCategoriesDesc, lblCategories, lbCategories, lblVersionNumber ], 0
323326 );
324327 TCtrlArranger.AlignTops(
325328 [lblCategories, lblSelectPackets],
@@ -333,6 +336,11 @@ procedure TSWAGImportDlg.ArrangeForm;
333336 [btnDisplayCategory, btnDisplayPacket],
334337 TCtrlArranger.BottomOf([lbCategories, clbSelectPackets], 8 )
335338 );
339+ TCtrlArranger.MoveBelow(
340+ [btnDisplayCategory, btnDisplayPacket],
341+ lblVersionNumber,
342+ 8
343+ );
336344 TCtrlArranger.AlignHCentresTo([lbCategories], [btnDisplayCategory]);
337345 TCtrlArranger.AlignHCentresTo([clbSelectPackets], [btnDisplayPacket]);
338346
@@ -604,28 +612,23 @@ function TSWAGImportDlg.HeadingText(const PageIdx: Integer): string;
604612end ;
605613
606614procedure TSWAGImportDlg.InitSelectionPage ;
607- // resourcestring
608- // sDefaultWaitMsg = 'Accessing SWAG database...';
609615var
610616 Cats: TList<TSWAGCategory>;
611617 Idx: Integer;
618+ VerNumStr: string;
619+ resourcestring
620+ sLblVersionNumberCaption = ' SWAG version %s' ;
612621begin
622+ lblVersionNumber.Caption := Format(
623+ sLblVersionNumberCaption,
624+ [string(TSWAGVersion.GetVersion(GetDirNameFromEditCtrl))]
625+ );
626+
613627 Application.ProcessMessages;
614628
615629 if (lbCategories.Count > 0 ) then
616630 Exit;
617631
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- //
629632 Cats := TList<TSWAGCategory>.Create;
630633 try
631634 fSWAGReader.GetCategories(Cats);
@@ -856,11 +859,23 @@ procedure TSWAGImportDlg.ValidatePage(const PageIdx: Integer);
856859 sNoFolder = ' Please enter the directory where you downloaded the SWAG '
857860 + ' database.' ;
858861 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.' ;
859866 begin
860867 if GetDirNameFromEditCtrl = ' ' then
861- raise EDataEntry.Create(sNoFolder);
868+ raise EDataEntry.Create(sNoFolder, edPath );
862869 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 ;
864879 end ;
865880
866881 procedure ValidateSelectionPage ;
0 commit comments