mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 21:20:30 +02:00
PoChecker: a new standalone project for PoChecker. Uses the same sources as the package
git-svn-id: trunk@34556 -
This commit is contained in:
parent
39b307cc08
commit
5f873dafd8
5
.gitattributes
vendored
5
.gitattributes
vendored
@ -1938,6 +1938,11 @@ components/plotfunction/regplotpanel.pp svneol=native#text/plain
|
|||||||
components/plotfunction/tplotexpressionpanel.png -text svneol=unset#image/png
|
components/plotfunction/tplotexpressionpanel.png -text svneol=unset#image/png
|
||||||
components/plotfunction/tplotfunctionpanel.png -text svneol=unset#image/png
|
components/plotfunction/tplotfunctionpanel.png -text svneol=unset#image/png
|
||||||
components/pochecker/.directory svneol=native#text/plain
|
components/pochecker/.directory svneol=native#text/plain
|
||||||
|
components/pochecker/Proj/README.txt svneol=native#text/plain
|
||||||
|
components/pochecker/Proj/pochecker.lpi svneol=native#text/plain
|
||||||
|
components/pochecker/Proj/pochecker.lpr svneol=native#text/plain
|
||||||
|
components/pochecker/Proj/pocheckermain.lfm svneol=native#text/plain
|
||||||
|
components/pochecker/Proj/pocheckermain.pp svneol=native#text/plain
|
||||||
components/pochecker/README.txt svneol=native#text/plain
|
components/pochecker/README.txt svneol=native#text/plain
|
||||||
components/pochecker/pochecker.lpk svneol=native#text/plain
|
components/pochecker/pochecker.lpk svneol=native#text/plain
|
||||||
components/pochecker/pochecker.pas svneol=native#text/plain
|
components/pochecker/pochecker.pas svneol=native#text/plain
|
||||||
|
2
components/pochecker/Proj/README.txt
Normal file
2
components/pochecker/Proj/README.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
A standalone application to checks the validity of translated PO files.
|
||||||
|
Uses the same source files than the PoChecker package, except for the main form.
|
108
components/pochecker/Proj/pochecker.lpi
Normal file
108
components/pochecker/Proj/pochecker.lpi
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<CONFIG>
|
||||||
|
<ProjectOptions>
|
||||||
|
<Version Value="9"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<General>
|
||||||
|
<SessionStorage Value="InProjectDir"/>
|
||||||
|
<MainUnit Value="0"/>
|
||||||
|
<ResourceType Value="res"/>
|
||||||
|
<UseXPManifest Value="True"/>
|
||||||
|
<Icon Value="0"/>
|
||||||
|
</General>
|
||||||
|
<i18n>
|
||||||
|
<EnableI18N LFM="False"/>
|
||||||
|
</i18n>
|
||||||
|
<VersionInfo>
|
||||||
|
<StringTable ProductVersion=""/>
|
||||||
|
</VersionInfo>
|
||||||
|
<BuildModes Count="1">
|
||||||
|
<Item1 Name="Default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
|
<PublishOptions>
|
||||||
|
<Version Value="2"/>
|
||||||
|
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||||
|
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||||
|
</PublishOptions>
|
||||||
|
<RunParams>
|
||||||
|
<local>
|
||||||
|
<FormatVersion Value="1"/>
|
||||||
|
</local>
|
||||||
|
</RunParams>
|
||||||
|
<RequiredPackages Count="2">
|
||||||
|
<Item1>
|
||||||
|
<PackageName Value="SynEdit"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<PackageName Value="LCL"/>
|
||||||
|
</Item2>
|
||||||
|
</RequiredPackages>
|
||||||
|
<Units Count="5">
|
||||||
|
<Unit0>
|
||||||
|
<Filename Value="pochecker.lpr"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="pochecker"/>
|
||||||
|
</Unit0>
|
||||||
|
<Unit1>
|
||||||
|
<Filename Value="pocheckermain.pp"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<HasResources Value="True"/>
|
||||||
|
<UnitName Value="pocheckermain"/>
|
||||||
|
</Unit1>
|
||||||
|
<Unit2>
|
||||||
|
<Filename Value="..\pofamilies.pp"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="pofamilies"/>
|
||||||
|
</Unit2>
|
||||||
|
<Unit3>
|
||||||
|
<Filename Value="..\resultdlg.pp"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<HasResources Value="True"/>
|
||||||
|
<UnitName Value="resultdlg"/>
|
||||||
|
</Unit3>
|
||||||
|
<Unit4>
|
||||||
|
<Filename Value="..\simplepofiles.pp"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="simplepofiles"/>
|
||||||
|
</Unit4>
|
||||||
|
</Units>
|
||||||
|
</ProjectOptions>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="pochecker"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<OtherUnitFiles Value=".."/>
|
||||||
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<Linking>
|
||||||
|
<Options>
|
||||||
|
<Win32>
|
||||||
|
<GraphicApplication Value="True"/>
|
||||||
|
</Win32>
|
||||||
|
</Options>
|
||||||
|
</Linking>
|
||||||
|
<Other>
|
||||||
|
<CompilerMessages>
|
||||||
|
<MsgFileName Value=""/>
|
||||||
|
</CompilerMessages>
|
||||||
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
|
</Other>
|
||||||
|
</CompilerOptions>
|
||||||
|
<Debugging>
|
||||||
|
<Exceptions Count="3">
|
||||||
|
<Item1>
|
||||||
|
<Name Value="EAbort"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<Name Value="ECodetoolError"/>
|
||||||
|
</Item2>
|
||||||
|
<Item3>
|
||||||
|
<Name Value="EFOpenError"/>
|
||||||
|
</Item3>
|
||||||
|
</Exceptions>
|
||||||
|
</Debugging>
|
||||||
|
</CONFIG>
|
20
components/pochecker/Proj/pochecker.lpr
Normal file
20
components/pochecker/Proj/pochecker.lpr
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
program pochecker;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
uses
|
||||||
|
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||||
|
cthreads,
|
||||||
|
{$ENDIF}{$ENDIF}
|
||||||
|
Interfaces, // this includes the LCL widgetset
|
||||||
|
Forms, pocheckermain, pofamilies, resultdlg, simplepofiles;
|
||||||
|
|
||||||
|
{$R *.res}
|
||||||
|
|
||||||
|
begin
|
||||||
|
RequireDerivedFormResource := True;
|
||||||
|
Application.Initialize;
|
||||||
|
Application.CreateForm(TPoCheckerForm, PoCheckerForm);
|
||||||
|
Application.Run;
|
||||||
|
end.
|
||||||
|
|
192
components/pochecker/Proj/pocheckermain.lfm
Normal file
192
components/pochecker/Proj/pocheckermain.lfm
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
object PoCheckerForm: TPoCheckerForm
|
||||||
|
Left = 349
|
||||||
|
Height = 311
|
||||||
|
Top = 189
|
||||||
|
Width = 581
|
||||||
|
Caption = 'GUI Po-file checking tool'
|
||||||
|
ClientHeight = 311
|
||||||
|
ClientWidth = 581
|
||||||
|
OnCreate = FormCreate
|
||||||
|
OnDestroy = FormDestroy
|
||||||
|
LCLVersion = '0.9.31'
|
||||||
|
Visible = True
|
||||||
|
object TestListBox: TCheckListBox
|
||||||
|
AnchorSideLeft.Control = SelectTestLabel
|
||||||
|
AnchorSideTop.Control = SelectTestLabel
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 201
|
||||||
|
Height = 169
|
||||||
|
Top = 33
|
||||||
|
Width = 373
|
||||||
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
|
BorderSpacing.Top = 6
|
||||||
|
Enabled = False
|
||||||
|
ItemHeight = 0
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object SelectTestLabel: TLabel
|
||||||
|
AnchorSideLeft.Control = OpenBtn
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
Left = 201
|
||||||
|
Height = 19
|
||||||
|
Top = 8
|
||||||
|
Width = 144
|
||||||
|
BorderSpacing.Left = 9
|
||||||
|
Caption = 'Select test types'
|
||||||
|
Font.Style = [fsBold]
|
||||||
|
ParentColor = False
|
||||||
|
ParentFont = False
|
||||||
|
end
|
||||||
|
object OpenBtn: TBitBtn
|
||||||
|
Left = 8
|
||||||
|
Height = 63
|
||||||
|
Top = 33
|
||||||
|
Width = 184
|
||||||
|
Caption = '&Open a po-file'
|
||||||
|
Glyph.Data = {
|
||||||
|
36040000424D3604000000000000360000002800000010000000100000000100
|
||||||
|
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00005E8E8D005D
|
||||||
|
8CBD005D8CBD005D8CBD005D8CBD005D8CBD005D8CBD005D8CBD005D8CBD005D
|
||||||
|
8CBD005D8CBD005D8CBD005D8CBD005E8E8D005B8900005B890000679AB06AB7
|
||||||
|
DAFF82CCEDFF82CCEDFF82CCEDFF82CCEDFF82CCEDFF82CCEDFF82CCEDFF82CC
|
||||||
|
EDFF82CCEDFF82CCEDFF83CDEEFF318DB9C9005E8E40005F8F000070A9A256AA
|
||||||
|
CEFF80CBEAFF7EC9E9FF7EC9E9FF7EC9E9FF7EC9E9FF7EC9E9FF7EC9E9FF7EC9
|
||||||
|
E9FF7EC9E9FF7EC9E9FF7EC9E9FF57AFD6D90066996E006699000074AD9D44A1
|
||||||
|
CBFF8AD3EFFF83CDEBFF83CDEBFF83CDEBFF83CDEBFF83CDEBFF83CDEBFF83CD
|
||||||
|
EBFF83CDEBFF83CDEBFF83CDEBFF81CDEBF2006FA8930071AB010076B29952B0
|
||||||
|
D7FF85D2EDFF89D2EEFF89D2EEFF89D2EEFF89D2EEFF89D2EEFF89D2EEFF89D2
|
||||||
|
EEFF89D2EEFF89D2EEFF89D2EEFF90D8F1FF228EC1AA0077B31D0079B69574CA
|
||||||
|
E8FF75CAE8FF90D8F2FF8FD7F1FF8FD7F1FF8FD7F1FF8FD7F1FF8FD7F1FF8FD7
|
||||||
|
F1FF8FD7F1FF8FD7F1FF8FD7F1FF91D8F2FF4FB1DAC2007FBD46007CBA928FDD
|
||||||
|
F4FF63C0E5FFA8EEFAFFA8EEFAFFA8EEFAFFA8EEFAFFA8EEFAFFA8EEFAFFA8EE
|
||||||
|
FAFFA8EEFAFFA8EEFAFFA8EEFAFFA8EEFAFF86D8EFDE0083C571007FBD8EA6EC
|
||||||
|
FCFF64C2E9FF4FB5E2FF4DB4E2FF4CB3E1FF4BB2E0FF49B1DFFF48B0DFFF47AE
|
||||||
|
DEFF45ADDDFF44ACDDFF46AEDFFF0084C6C70087CB810087CB610081C18BABF0
|
||||||
|
FEFFA4E9FCFFA2E7FBFF9FE5FAFF9CE3F8FF9AE1F7FF97DEF6FF94DCF4FF91D9
|
||||||
|
F3FF8ED7F1FF8BD4F0FF90D8F3FF0081C18B0087CA000087CB000083C488ADF1
|
||||||
|
FFFFA6EBFDFFA4E9FCFFA2E7FBFF9FE5FAFF9CE3F8FF9AE1F7FF97DEF6FF94DC
|
||||||
|
F4FF91D9F3FF8ED7F1FF93DAF4FF0083C4880083C4000085C8000085C785B0F4
|
||||||
|
FFFFADF1FFFFABF0FEFFA9EEFDFFA7ECFCFFA5EAFBFFA2E8FAFFA0E6F9FF9DE3
|
||||||
|
F8FF9AE1F7FF98DFF6FF99E0F7FF0085C7850085C7000085C7000087CA620087
|
||||||
|
CA830087CA830087CA830087CA830087CA830087CA83FEFEFDFFF5F5EEFFEBEB
|
||||||
|
DDFFFEC941FFF4B62EFF0087CA830087CA620086C9000086C9000087CA000087
|
||||||
|
CA000087CA000087CA000087CA000087CA000088CC2E0088CC810088CC810088
|
||||||
|
CC810088CC810088CC810088CC2E0087CA000086C9000086C900FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
|
||||||
|
}
|
||||||
|
OnClick = OpenBtnClick
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
object RunBtn: TBitBtn
|
||||||
|
AnchorSideLeft.Control = OpenBtn
|
||||||
|
AnchorSideTop.Control = OpenBtn
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
AnchorSideRight.Control = OpenBtn
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
Left = 8
|
||||||
|
Height = 63
|
||||||
|
Top = 102
|
||||||
|
Width = 184
|
||||||
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
BorderSpacing.Top = 6
|
||||||
|
Caption = '&Run Selected Tests'
|
||||||
|
Enabled = False
|
||||||
|
Kind = bkOK
|
||||||
|
OnClick = RunBtnClick
|
||||||
|
TabOrder = 2
|
||||||
|
end
|
||||||
|
object StatusPanel: TPanel
|
||||||
|
Left = 0
|
||||||
|
Height = 49
|
||||||
|
Top = 262
|
||||||
|
Width = 581
|
||||||
|
Align = alBottom
|
||||||
|
BevelOuter = bvLowered
|
||||||
|
ClientHeight = 49
|
||||||
|
ClientWidth = 581
|
||||||
|
TabOrder = 3
|
||||||
|
object CurTestHeaderLabel: TLabel
|
||||||
|
Left = 8
|
||||||
|
Height = 19
|
||||||
|
Top = 8
|
||||||
|
Width = 96
|
||||||
|
Caption = 'Current Test:'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object CurPoHeaderLabel: TLabel
|
||||||
|
AnchorSideLeft.Control = CurTestHeaderLabel
|
||||||
|
AnchorSideTop.Control = CurTestHeaderLabel
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 8
|
||||||
|
Height = 19
|
||||||
|
Top = 27
|
||||||
|
Width = 111
|
||||||
|
Caption = 'Current po-file:'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object CurTestLabel: TLabel
|
||||||
|
AnchorSideLeft.Control = CurTestHeaderLabel
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = CurTestHeaderLabel
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 110
|
||||||
|
Height = 19
|
||||||
|
Top = 8
|
||||||
|
Width = 95
|
||||||
|
BorderSpacing.Around = 6
|
||||||
|
Caption = 'CurTestLabel'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object CurPoLabel: TLabel
|
||||||
|
AnchorSideLeft.Control = CurPoHeaderLabel
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = CurPoHeaderLabel
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 125
|
||||||
|
Height = 19
|
||||||
|
Top = 27
|
||||||
|
Width = 82
|
||||||
|
BorderSpacing.Around = 6
|
||||||
|
Caption = 'CurPoLabel'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object NoErrLabel: TLabel
|
||||||
|
Left = 8
|
||||||
|
Height = 24
|
||||||
|
Top = 232
|
||||||
|
Width = 171
|
||||||
|
Anchors = [akLeft, akBottom]
|
||||||
|
Caption = 'No errors found'
|
||||||
|
Font.Color = clGreen
|
||||||
|
Font.Height = -19
|
||||||
|
Font.Style = [fsBold]
|
||||||
|
ParentColor = False
|
||||||
|
ParentFont = False
|
||||||
|
end
|
||||||
|
object SelectAllCheckBox: TCheckBox
|
||||||
|
AnchorSideLeft.Control = TestListBox
|
||||||
|
AnchorSideTop.Control = TestListBox
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 201
|
||||||
|
Height = 23
|
||||||
|
Top = 208
|
||||||
|
Width = 97
|
||||||
|
BorderSpacing.Top = 6
|
||||||
|
Caption = 'Select All'
|
||||||
|
Enabled = False
|
||||||
|
OnClick = SelectAllCheckBoxClick
|
||||||
|
TabOrder = 4
|
||||||
|
end
|
||||||
|
object OpenDialog: TOpenDialog
|
||||||
|
Filter = 'po-files (*.po)|*.po|all files|*'
|
||||||
|
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]
|
||||||
|
left = 40
|
||||||
|
top = 512
|
||||||
|
end
|
||||||
|
end
|
336
components/pochecker/Proj/pocheckermain.pp
Normal file
336
components/pochecker/Proj/pocheckermain.pp
Normal file
@ -0,0 +1,336 @@
|
|||||||
|
{
|
||||||
|
This source is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 2 of the License, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This code is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
details.
|
||||||
|
|
||||||
|
A copy of the GNU General Public License is available on the World Wide Web
|
||||||
|
at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
|
||||||
|
to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||||
|
MA 02111-1307, USA.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Original version made by Bart Broersma
|
||||||
|
|
||||||
|
unit pocheckermain;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, FileUtil, SynEdit, Forms, Controls, Graphics, Dialogs,
|
||||||
|
StdCtrls, LCLProc, CheckLst, Buttons, ExtCtrls, IDEIntf, MenuIntf,
|
||||||
|
SimplePoFiles, PoFamilies, ResultDlg;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TPoCheckerForm }
|
||||||
|
|
||||||
|
TPoCheckerForm = class(TForm)
|
||||||
|
SelectAllCheckBox: TCheckBox;
|
||||||
|
CurTestHeaderLabel: TLabel;
|
||||||
|
CurPoHeaderLabel: TLabel;
|
||||||
|
CurTestLabel: TLabel;
|
||||||
|
CurPoLabel: TLabel;
|
||||||
|
NoErrLabel: TLabel;
|
||||||
|
StatusPanel: TPanel;
|
||||||
|
RunBtn: TBitBtn;
|
||||||
|
OpenBtn: TBitBtn;
|
||||||
|
Button3: TButton;
|
||||||
|
SelectTestLabel: TLabel;
|
||||||
|
OpenDialog: TOpenDialog;
|
||||||
|
TestListBox: TCheckListBox;
|
||||||
|
procedure FormCreate(Sender: TObject);
|
||||||
|
procedure FormDestroy(Sender: TObject);
|
||||||
|
procedure OpenBtnClick(Sender: TObject);
|
||||||
|
procedure RunBtnClick(Sender: TObject);
|
||||||
|
procedure SelectAllCheckBoxClick(Sender: TObject);
|
||||||
|
private
|
||||||
|
PoFamily: TPoFamily;
|
||||||
|
FChoosenMasterName: String;
|
||||||
|
FChoosenChildName: String;
|
||||||
|
procedure OnTestStart(const ATestName, APoFileName: String);
|
||||||
|
procedure OnTestEnd(const ATestName: String; const ErrorCount: Integer);
|
||||||
|
procedure FillTestListBox;
|
||||||
|
function GetOptionsFromListBox: TPoTestOptions;
|
||||||
|
procedure ShowError(const Msg: String);
|
||||||
|
function TrySelectFile: Boolean;
|
||||||
|
procedure RunSelectedTests;
|
||||||
|
procedure ClearAndDisableStatusPanel;
|
||||||
|
public
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
resourcestring
|
||||||
|
rsPoChecker = 'PO File Checker';
|
||||||
|
sSelectAllTests = 'Select all tests';
|
||||||
|
sUnSelectAllTests = 'Unselect all tests';
|
||||||
|
sCannotFindMaster = 'Cannot find master po file:' + LineEnding + '%s' + LineEnding + 'for selected file' + LineEnding + '%s';
|
||||||
|
sNotAProperFileName = 'Selected filename' + LineEnding + '%s' + LineEnding + 'does not seem to be a proper name for a po-file';
|
||||||
|
sErrorOnCreate = 'Error creating an instance of TPoFamily:' + LineEnding + '%s';
|
||||||
|
sErrorOnCleanup = 'An unrecoverable error occurred' + LineEnding + '%s' + LineEnding + 'Please close the program';
|
||||||
|
|
||||||
|
sTotalErrors = 'Total errors found: %d';
|
||||||
|
//sNoErrorsFound = 'No errors found.';
|
||||||
|
sNoTestSelected = 'There are no tests selected.';
|
||||||
|
|
||||||
|
var
|
||||||
|
PoCheckerForm: TPoCheckerForm;
|
||||||
|
|
||||||
|
procedure Register;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
|
procedure ShowPoCheckerForm();
|
||||||
|
begin
|
||||||
|
if not Assigned(PoCheckerForm) then
|
||||||
|
PoCheckerForm := TPoCheckerForm.Create(Application);
|
||||||
|
PoCheckerForm.Show;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TPoCheckerForm }
|
||||||
|
|
||||||
|
procedure TPoCheckerForm.FormCreate(Sender: TObject);
|
||||||
|
begin
|
||||||
|
FillTestListBox;
|
||||||
|
ClearAndDisableStatusPanel;
|
||||||
|
NoErrLabel.Visible := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPoCheckerForm.FormDestroy(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if Assigned(PoFamily) then PoFamily.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPoCheckerForm.OpenBtnClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if TrySelectFile then
|
||||||
|
begin
|
||||||
|
RunBtn.Enabled := True;
|
||||||
|
TestListBox.Enabled := True;
|
||||||
|
SelectAllCheckBox.Enabled := True;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
RunBtn.Enabled := False;
|
||||||
|
TestListBox.Enabled := False;
|
||||||
|
SelectAllCheckBox.Enabled := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPoCheckerForm.RunBtnClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
RunSelectedTests;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPoCheckerForm.SelectAllCheckBoxClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
cb: TCheckBox;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
cb := Sender as TCheckBox;
|
||||||
|
// Caption text : select all / unselect all
|
||||||
|
if cb.Checked then
|
||||||
|
cb.Caption := sUnSelectAllTests
|
||||||
|
else
|
||||||
|
cb.Caption := sSelectAllTests;
|
||||||
|
// Set / reset all CheckListBox items.
|
||||||
|
for i := 0 to TestListBox.Count - 1 do
|
||||||
|
TestListBox.Checked[i] := cb.Checked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPoCheckerForm.OnTestStart(const ATestName, APoFileName: String);
|
||||||
|
begin
|
||||||
|
//debugln('OnTestStart: ATestName = "',AtestName,'" APoFileName = "',APoFileName);
|
||||||
|
CurTestLabel.Caption := ATestName;
|
||||||
|
CurPoLabel.Caption := APoFileName;
|
||||||
|
Application.ProcessMessages;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPoCheckerForm.OnTestEnd(const ATestName: String; const ErrorCount: Integer);
|
||||||
|
begin
|
||||||
|
//CurTestLabel.Caption := '';
|
||||||
|
//CurPoLabel.Caption := '';
|
||||||
|
debugln('OnTestEnd [',ATestName,']: ErrorCount = ',DbgS(ErrorCount));
|
||||||
|
//Application.ProcessMessages;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPoCheckerForm.FillTestListBox;
|
||||||
|
var
|
||||||
|
Opt: TPoTestOption;
|
||||||
|
begin
|
||||||
|
for Opt := Low(PoTestOptionNames) to High(PoTestOptionNames) do
|
||||||
|
TestListBox.Items.Add(PoTestOptionNames[Opt]);
|
||||||
|
SelectAllCheckBox.Caption := sSelectAllTests;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TPoCheckerForm.GetOptionsFromListBox: TPoTestOptions;
|
||||||
|
var
|
||||||
|
Opt: TPoTestOption;
|
||||||
|
Index: Integer;
|
||||||
|
begin
|
||||||
|
Result := [];
|
||||||
|
for Opt := Low(TpoTestOption) to High(TPoTestOption) do
|
||||||
|
begin
|
||||||
|
Index := Ord(Opt);
|
||||||
|
if (Index < TestListBox.Count) then
|
||||||
|
begin
|
||||||
|
if TestListBox.Checked[Index] then
|
||||||
|
Result := Result + [Opt];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPoCheckerForm.ShowError(const Msg: String);
|
||||||
|
begin
|
||||||
|
MessageDlg('GPoCheck', Msg, mtError, [mbOk], 0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TPoCheckerForm.TrySelectFile: Boolean;
|
||||||
|
var
|
||||||
|
Fn: String;
|
||||||
|
ShortFn: String;
|
||||||
|
OK: Boolean;
|
||||||
|
begin
|
||||||
|
NoErrLabel.Visible := False;
|
||||||
|
OK := False;
|
||||||
|
if OpenDialog.Execute then
|
||||||
|
begin
|
||||||
|
Fn := OpenDialog.FileName;
|
||||||
|
ShortFn := ExtractFileName(Fn);
|
||||||
|
if IsMasterPoName(Fn) then
|
||||||
|
begin
|
||||||
|
FChoosenMasterName := Fn;
|
||||||
|
FChoosenChildName := '';
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin //not a mastername, may be a child
|
||||||
|
FChoosenChildName := Fn;
|
||||||
|
FChoosenMasterName := ExtractMasterNameFromChildName(Fn);
|
||||||
|
if (FChoosenMasterName = '') then
|
||||||
|
begin
|
||||||
|
FChoosenMasterName := '';
|
||||||
|
FChoosenChildName := '';
|
||||||
|
ShowError(Format(sNotAProperFileName,[ShortFn]));
|
||||||
|
end
|
||||||
|
else if not FileExistsUtf8(FChoosenMasterName) then
|
||||||
|
begin
|
||||||
|
FChoosenMasterName := '';
|
||||||
|
FChoosenChildName := '';
|
||||||
|
ShowError(Format(sCannotFindMaster,[ShortFn]));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
OK := (FChoosenMasterName <> '');
|
||||||
|
if OK then
|
||||||
|
begin
|
||||||
|
if Assigned(PoFamily) then
|
||||||
|
PoFamily.Free;
|
||||||
|
try
|
||||||
|
PoFamily := TPoFamily.Create(FChoosenMasterName, FChoosenChildName);
|
||||||
|
PoFamily.OnTestStart := @OnTestStart;
|
||||||
|
PoFamily.OnTestEnd := @OnTestEnd;
|
||||||
|
except
|
||||||
|
on E: Exception do
|
||||||
|
begin
|
||||||
|
OK := False;
|
||||||
|
ShowError(Format(sErrorOnCreate,[E.Message]));
|
||||||
|
if Assigned(PoFamily) then
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
PoFamily.Free;
|
||||||
|
except
|
||||||
|
on E: Exception do
|
||||||
|
begin
|
||||||
|
ShowError(Format(sErrorOnCleanUp,[E.Message]));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Result := OK;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPoCheckerForm.RunSelectedTests;
|
||||||
|
var
|
||||||
|
Options: TPoTestOptions;
|
||||||
|
ErrorCount: Integer;
|
||||||
|
SL: TStrings;
|
||||||
|
ResultDlg: TResultDlgForm;
|
||||||
|
begin
|
||||||
|
Options := GetOptionsFromListBox;
|
||||||
|
if (Options = []) then
|
||||||
|
begin
|
||||||
|
ShowError(sNoTestSelected);
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
NoErrLabel.Visible := False;
|
||||||
|
Application.ProcessMessages;
|
||||||
|
SL := TStringList.Create;
|
||||||
|
try
|
||||||
|
StatusPanel.Enabled := True;
|
||||||
|
if (not (ptoFindAllChilds in Options)) and Assigned(PoFamily.Child)
|
||||||
|
and (PoFamily.ChildName <> FChoosenChildName) then
|
||||||
|
PoFamily.ChildName := FChoosenChildName;
|
||||||
|
PoFamily.RunTests(Options, ErrorCount, SL);
|
||||||
|
if (ErrorCount > 0) then
|
||||||
|
begin
|
||||||
|
debugln('RunSelectedTests: ',Format(sTotalErrors,[ErrorCount]));
|
||||||
|
SL.Add(Format(sTotalErrors,[ErrorCount]));
|
||||||
|
ResultDlg := TResultDlgForm.Create(Nil);
|
||||||
|
try
|
||||||
|
ResultDlg.Log.Assign(SL);
|
||||||
|
FreeAndNil(SL); //No need to keep 2 copies of this data
|
||||||
|
ResultDlg.ShowModal;
|
||||||
|
finally
|
||||||
|
ResultDlg.Free;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else //no errors
|
||||||
|
NoErrLabel.Visible := True;
|
||||||
|
finally
|
||||||
|
if Assigned(SL) then
|
||||||
|
SL.Free;
|
||||||
|
ClearAndDisableStatusPanel;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPoCheckerForm.ClearAndDisableStatusPanel;
|
||||||
|
begin
|
||||||
|
CurTestLabel.Caption := '';
|
||||||
|
CurPoLabel.Caption := '';
|
||||||
|
StatusPanel.Enabled := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function SameItem(Item1, Item2: TPoFileItem): Boolean;
|
||||||
|
begin
|
||||||
|
Result := (Item1.Identifier = Item2.Identifier) and
|
||||||
|
(Item1.Original = Item2.Original) and
|
||||||
|
(Item1.Context = Item2.Context) and
|
||||||
|
(Item1.Flags = Item2.Flags) and
|
||||||
|
(Item1.PreviousID = Item2.PreviousID) and
|
||||||
|
(Item1.Translation = Item2.Translation);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure IDEMenuClicked(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ShowPoCheckerForm;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Register;
|
||||||
|
begin
|
||||||
|
RegisterIDEMenuCommand(itmSecondaryTools, 'mnuPoChecker', rsPoChecker, nil, @IDEMenuClicked);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user