pochecker: unselect all, select basic button, issue #26395, from Vaclav Valicek

git-svn-id: trunk@45671 -
This commit is contained in:
mattias 2014-06-26 20:35:15 +00:00
parent 0217554726
commit d9cea06d08
4 changed files with 175 additions and 106 deletions

View File

@ -97,11 +97,7 @@
</Options>
</Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CustomOptions Value="-dPoCheckerStandAlone"/>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>

View File

@ -1,36 +1,37 @@
object PoCheckerForm: TPoCheckerForm
Left = 349
Left = 318
Height = 311
Top = 189
Top = 163
Width = 581
Caption = 'GUI Po-file checking tool'
ClientHeight = 311
ClientWidth = 581
OnCreate = FormCreate
OnDestroy = FormDestroy
LCLVersion = '0.9.31'
LCLVersion = '1.3'
Visible = True
object TestListBox: TCheckListBox
AnchorSideLeft.Control = SelectTestLabel
AnchorSideTop.Control = SelectTestLabel
AnchorSideTop.Side = asrBottom
Left = 201
Height = 150
Top = 28
Height = 152
Top = 26
Width = 373
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 6
Enabled = False
ItemHeight = 0
TabOrder = 0
TopIndex = -1
end
object SelectTestLabel: TLabel
AnchorSideLeft.Control = OpenBtn
AnchorSideLeft.Side = asrBottom
Left = 201
Height = 14
Height = 12
Top = 8
Width = 97
Width = 84
BorderSpacing.Left = 9
Caption = 'Select test types'
Font.Style = [fsBold]
@ -114,9 +115,9 @@ object PoCheckerForm: TPoCheckerForm
TabOrder = 3
object CurTestHeaderLabel: TLabel
Left = 8
Height = 14
Height = 12
Top = 8
Width = 66
Width = 61
Caption = 'Current Test:'
ParentColor = False
end
@ -125,9 +126,9 @@ object PoCheckerForm: TPoCheckerForm
AnchorSideTop.Control = CurTestHeaderLabel
AnchorSideTop.Side = asrBottom
Left = 8
Height = 14
Top = 22
Width = 75
Height = 12
Top = 20
Width = 72
Caption = 'Current po-file:'
ParentColor = False
end
@ -136,10 +137,10 @@ object PoCheckerForm: TPoCheckerForm
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CurTestHeaderLabel
AnchorSideTop.Side = asrCenter
Left = 80
Height = 14
Left = 75
Height = 12
Top = 8
Width = 64
Width = 61
BorderSpacing.Around = 6
Caption = 'CurTestLabel'
ParentColor = False
@ -149,10 +150,10 @@ object PoCheckerForm: TPoCheckerForm
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CurPoHeaderLabel
AnchorSideTop.Side = asrCenter
Left = 89
Height = 14
Top = 22
Width = 55
Left = 86
Height = 12
Top = 20
Width = 53
BorderSpacing.Around = 6
Caption = 'CurPoLabel'
ParentColor = False
@ -160,9 +161,9 @@ object PoCheckerForm: TPoCheckerForm
end
object NoErrLabel: TLabel
Left = 8
Height = 24
Top = 232
Width = 152
Height = 22
Top = 234
Width = 145
Anchors = [akLeft, akBottom]
Caption = 'No errors found'
Font.Color = clGreen
@ -171,32 +172,60 @@ object PoCheckerForm: TPoCheckerForm
ParentColor = False
ParentFont = False
end
object SelectAllCheckBox: TCheckBox
object FindAllPOsCheckBox: TCheckBox
AnchorSideLeft.Control = TestListBox
AnchorSideTop.Control = SelectBasicBtn
AnchorSideTop.Side = asrBottom
Left = 201
Height = 24
Top = 215
Width = 149
BorderSpacing.Top = 6
Caption = 'Find all translated PO files'
TabOrder = 4
end
object SelectBasicBtn: TButton
AnchorSideLeft.Control = TestListBox
AnchorSideTop.Control = TestListBox
AnchorSideTop.Side = asrBottom
Left = 201
Height = 17
Height = 25
Top = 184
Width = 61
Width = 115
BorderSpacing.Top = 6
Caption = 'Select All'
Caption = 'Select Basic Tests'
Enabled = False
OnClick = SelectAllCheckBoxClick
TabOrder = 4
end
object FindAllPOsCheckBox: TCheckBox
AnchorSideLeft.Control = SelectAllCheckBox
AnchorSideTop.Control = SelectAllCheckBox
AnchorSideTop.Side = asrBottom
Left = 201
Height = 17
Top = 207
Width = 142
BorderSpacing.Top = 6
Caption = 'Find all translated PO files'
OnClick = SelectBasicBtnClick
TabOrder = 5
end
object SelectAllBtn: TButton
AnchorSideLeft.Control = SelectBasicBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = SelectBasicBtn
Left = 320
Height = 25
Top = 184
Width = 115
BorderSpacing.Left = 4
Caption = 'Select All Tests'
Enabled = False
OnClick = SelectAllBtnClick
TabOrder = 6
end
object UnselectAllBtn: TButton
AnchorSideLeft.Control = SelectAllBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = SelectAllBtn
Left = 439
Height = 25
Top = 184
Width = 115
BorderSpacing.Left = 4
Caption = 'Unselect All Tests'
Enabled = False
OnClick = UnselectAllBtnClick
TabOrder = 7
end
object OpenDialog: TOpenDialog
Filter = 'po-files (*.po)|*.po|all files|*'
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]

View File

@ -38,8 +38,10 @@ type
{ TPoCheckerForm }
TPoCheckerForm = class(TForm)
UnselectAllBtn: TButton;
SelectAllBtn: TButton;
SelectBasicBtn: TButton;
FindAllPOsCheckBox: TCheckBox;
SelectAllCheckBox: TCheckBox;
CurTestHeaderLabel: TLabel;
CurPoHeaderLabel: TLabel;
CurTestLabel: TLabel;
@ -56,22 +58,24 @@ type
procedure FormDestroy(Sender: TObject);
procedure OpenBtnClick(Sender: TObject);
procedure RunBtnClick(Sender: TObject);
procedure SelectAllCheckBoxClick(Sender: TObject);
procedure SelectAllBtnClick(Sender: TObject);
procedure SelectBasicBtnClick(Sender: TObject);
procedure UnselectAllBtnClick(Sender: TObject);
private
PoFamily: TPoFamily;
FChosenMasterName: String;
FChosenChildName: String;
procedure OnTestStart(const ATestName, APoFileName: String);
procedure OnTestEnd(const ATestName: String; const ErrorCount: Integer);
FChosenMasterName: string;
FChosenChildName: 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 ShowError(const Msg: string);
function TrySelectFile: boolean;
procedure RunSelectedTests;
procedure ClearAndDisableStatusPanel;
public
end;
end;
var
PoCheckerForm: TPoCheckerForm;
@ -106,8 +110,12 @@ begin
if Lang <> '' then
begin
Lang := copy(Lang, 1, 2);
Translations.TranslateUnitResourceStrings('PoCheckerConsts', '..'+DirectorySeparator+'languages'+DirectorySeparator+'pocheckerconsts.'+Lang+'.po');
Translations.TranslateUnitResourceStrings('LCLStrConsts', '..'+DirectorySeparator+'languages'+DirectorySeparator+'lclstrconsts.'+Lang+'.po');
Translations.TranslateUnitResourceStrings('PoCheckerConsts',
'..' + DirectorySeparator + 'languages' + DirectorySeparator +
'pocheckerconsts.' + Lang + '.po');
Translations.TranslateUnitResourceStrings('LCLStrConsts',
'..' + DirectorySeparator + 'languages' + DirectorySeparator +
'lclstrconsts.' + Lang + '.po');
end;
{$ENDIF}
@ -124,80 +132,108 @@ begin
CurPoHeaderLabel.Caption := sCurrentPoFile;
end;
procedure TPoCheckerForm.FormDestroy(Sender: TObject);
begin
if Assigned(PoFamily) then PoFamily.Free;
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;
SelectAllBtn.Enabled := True;
SelectBasicBtn.Enabled := True;
UnselectAllBtn.Enabled := True;
end
else begin
else
begin
RunBtn.Enabled := False;
TestListBox.Enabled := False;
SelectAllCheckBox.Enabled := False;
SelectAllBtn.Enabled := False;
SelectBasicBtn.Enabled := False;
UnselectAllBtn.Enabled := False;
end;
end;
procedure TPoCheckerForm.RunBtnClick(Sender: TObject);
begin
RunSelectedTests;
end;
procedure TPoCheckerForm.SelectAllCheckBoxClick(Sender: TObject);
var
cb: TCheckBox;
i: Integer;
procedure TPoCheckerForm.SelectAllBtnClick(Sender: TObject);
begin
cb := Sender as TCheckBox;
// Set / reset "basic" CheckListBox items.
for i := 0 to TestListBox.Count - 3 do
TestListBox.Checked[i] := cb.Checked;
TestListBox.CheckAll(cbChecked, False, False);
end;
procedure TPoCheckerForm.OnTestStart(const ATestName, APoFileName: String);
procedure TPoCheckerForm.SelectBasicBtnClick(Sender: TObject);
var
i: integer;
begin
// Set / reset "basic" CheckListBox items.
for i := 0 to TestListBox.Count - 3 do
TestListBox.Checked[i] := True;
end;
procedure TPoCheckerForm.UnselectAllBtnClick(Sender: TObject);
begin
TestListBox.CheckAll(cbUnchecked, False, False);
end;
procedure TPoCheckerForm.OnTestStart(const ATestName, APoFileName: string);
begin
//debugln('OnTestStart: ATestName = "',AtestName,'" APoFileName = "',APoFileName);
CurTestLabel.Caption := ATestName;
CurPoLabel.Caption := APoFileName;
CurPoLabel.Caption := APoFileName;
Application.ProcessMessages;
end;
procedure TPoCheckerForm.OnTestEnd(const ATestName: String; const ErrorCount: Integer);
procedure TPoCheckerForm.OnTestEnd(const ATestName: string;
const ErrorCount: integer);
begin
//CurTestLabel.Caption := '';
//CurPoLabel.Caption := '';
debugln('OnTestEnd [',ATestName,']: ErrorCount = ',DbgS(ErrorCount));
debugln('OnTestEnd [', ATestName, ']: ErrorCount = ', DbgS(ErrorCount));
//Application.ProcessMessages;
end;
procedure TPoCheckerForm.FillTestListBox;
var
Opt: TPoTestOption;
begin
for Opt := Low(PoTestOptionNames) to Pred(High(PoTestOptionNames)) do
case Opt of
ptoCheckNrOfItems: TestListBox.Items.Add(sCheckNumberOfItems);
ptoCheckFormatArgs: TestListBox.Items.Add(sCheckForIncompatibleFormatArguments);
ptoCheckMissingIdentifiers: TestListBox.Items.Add(sCheckMissingIdentifiers);
ptoCheckMismatchedOriginals: TestListBox.Items.Add(sCheckForMismatchesInUntranslatedStrings);
ptoCheckDuplicateOriginals: TestListBox.Items.Add(sCheckForDuplicateUntranslatedValues);
ptoCheckStatistics: TestListBox.Items.Add(sCheckStatistics);
ptoCheckNrOfItems:
TestListBox.Items.Add(sCheckNumberOfItems);
ptoCheckFormatArgs:
TestListBox.Items.Add(sCheckForIncompatibleFormatArguments);
ptoCheckMissingIdentifiers:
TestListBox.Items.Add(sCheckMissingIdentifiers);
ptoCheckMismatchedOriginals:
TestListBox.Items.Add(sCheckForMismatchesInUntranslatedStrings);
ptoCheckDuplicateOriginals:
TestListBox.Items.Add(sCheckForDuplicateUntranslatedValues);
ptoCheckStatistics:
TestListBox.Items.Add(sCheckStatistics);
else
TestListBox.Items.Add(PoTestOptionNames[Opt]);
end;
SelectAllCheckBox.Caption := sSelectBasicTests;
end;
function TPoCheckerForm.GetOptionsFromListBox: TPoTestOptions;
var
Opt: TPoTestOption;
Index: Integer;
Index: integer;
begin
Result := [];
for Opt := Low(TpoTestOption) to Pred(High(TPoTestOption)) do
@ -213,16 +249,18 @@ begin
Result := Result + [High(TPoTestOption)];
end;
procedure TPoCheckerForm.ShowError(const Msg: String);
procedure TPoCheckerForm.ShowError(const Msg: string);
begin
MessageDlg('Po-checker', Msg, mtError, [mbOk], 0);
MessageDlg('Po-checker', Msg, mtError, [mbOK], 0);
end;
function TPoCheckerForm.TrySelectFile: Boolean;
function TPoCheckerForm.TrySelectFile: boolean;
var
Fn: String;
ShortFn: String;
OK: Boolean;
Fn: string;
ShortFn: string;
OK: boolean;
begin
NoErrLabel.Visible := False;
OK := False;
@ -243,11 +281,13 @@ begin
begin
FChosenMasterName := '';
FChosenChildName := '';
ShowError(Format(sNotAProperFileName,[ShortFn]));
ShowError(Format(sNotAProperFileName, [ShortFn]));
end
else if not FileExistsUtf8(FChosenMasterName) then
else
if not FileExistsUtf8(FChosenMasterName) then
begin
ShowError(Format(sCannotFindMaster,[ExtractFileName(FChosenMasterName), ShortFn]));
ShowError(Format(sCannotFindMaster,
[ExtractFileName(FChosenMasterName), ShortFn]));
FChosenMasterName := '';
FChosenChildName := '';
end;
@ -265,7 +305,7 @@ begin
on E: Exception do
begin
OK := False;
ShowError(Format(sErrorOnCreate,[E.Message]));
ShowError(Format(sErrorOnCreate, [E.Message]));
if Assigned(PoFamily) then
begin
try
@ -273,7 +313,7 @@ begin
except
on E: Exception do
begin
ShowError(Format(sErrorOnCleanUp,[E.Message]));
ShowError(Format(sErrorOnCleanUp, [E.Message]));
end;
end;
end;
@ -284,10 +324,11 @@ begin
Result := OK;
end;
procedure TPoCheckerForm.RunSelectedTests;
var
Options: TPoTestOptions;
ErrorCount, WarningCount: Integer;
ErrorCount, WarningCount: integer;
SL: TStrings;
ResultDlg: TResultDlgForm;
begin
@ -302,17 +343,18 @@ begin
SL := TStringList.Create;
try
StatusPanel.Enabled := True;
if (not (ptoFindAllChildren in Options)) and Assigned(PoFamily.Child)
and (PoFamily.ChildName <> FChosenChildName) then
if (not (ptoFindAllChildren in Options)) and Assigned(PoFamily.Child) and
(PoFamily.ChildName <> FChosenChildName) then
PoFamily.ChildName := FChosenChildName;
PoFamily.RunTests(Options, ErrorCount, WarningCount, SL);
debugln('RunSelectedTests: ',Format(sTotalErrors,[ErrorCount]));
debugln(' ',Format(sTotalWarnings,[WarningCount]));
if (ErrorCount > 0) or (WarningCount > 0) or (ptoCheckStatistics in Options) then
debugln('RunSelectedTests: ', Format(sTotalErrors, [ErrorCount]));
debugln(' ', Format(sTotalWarnings, [WarningCount]));
if (ErrorCount > 0) or (WarningCount > 0) or
(ptoCheckStatistics in Options) then
begin
SL.Add(Format(sTotalErrors,[ErrorCount]));
SL.Add(Format(sTotalWarnings,[WarningCount]));
ResultDlg := TResultDlgForm.Create(Nil);
SL.Add(Format(sTotalErrors, [ErrorCount]));
SL.Add(Format(sTotalWarnings, [WarningCount]));
ResultDlg := TResultDlgForm.Create(nil);
try
ResultDlg.Log.Assign(SL);
FreeAndNil(SL); //No need to keep 2 copies of this data
@ -329,6 +371,7 @@ begin
end;
end;
procedure TPoCheckerForm.ClearAndDisableStatusPanel;
begin
CurTestLabel.Caption := '';
@ -337,27 +380,27 @@ begin
end;
function SameItem(Item1, Item2: TPoFileItem): Boolean;
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);
(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
{$IFNDEF POCHECKERSTANDALONE}
RegisterIDEMenuCommand(itmSecondaryTools, 'mnuPoChecker', rsPoChecker, nil, @IDEMenuClicked);
RegisterIDEMenuCommand(itmSecondaryTools, 'mnuPoChecker',
rsPoChecker, nil, @IDEMenuClicked);
{$ENDIF}
end;
end.

View File

@ -635,6 +635,7 @@ begin
ErrorLog.Add('');
ErrorLog.Add('');
end;
WarningCount := NrTotal;
DoTestEnd(PoTestOptionNames[ptoCheckFormatArgs], WarningCount);
//debugln('TPoFamily.CheckIncompatibleFormatArgs: ',Dbgs(ErrorCount),' Errors');
end;