PageRenderTime 43ms CodeModel.GetById 20ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 1ms

/ide/makeresstrdlg.pas

http://github.com/graemeg/lazarus
Pascal | 636 lines | 513 code | 58 blank | 65 comment | 46 complexity | 9f245b269efac2c7050a320303012f7d MD5 | raw file
  1{
  2 /***************************************************************************
  3                            makeresstrdlg.pas
  4                            -----------------
  5
  6
  7 ***************************************************************************/
  8
  9 ***************************************************************************
 10 *                                                                         *
 11 *   This source is free software; you can redistribute it and/or modify   *
 12 *   it under the terms of the GNU General Public License as published by  *
 13 *   the Free Software Foundation; either version 2 of the License, or     *
 14 *   (at your option) any later version.                                   *
 15 *                                                                         *
 16 *   This code is distributed in the hope that it will be useful, but      *
 17 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 18 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 19 *   General Public License for more details.                              *
 20 *                                                                         *
 21 *   A copy of the GNU General Public License is available on the World    *
 22 *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
 23 *   obtain it by writing to the Free Software Foundation,                 *
 24 *   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.        *
 25 *                                                                         *
 26 ***************************************************************************
 27 
 28 Author: Mattias Gaertner
 29 
 30 Abstract:
 31   TMakeResStrDialog is the dialog to setup how to convert a string constant
 32   into a pascal resourcestring.
 33 
 34}
 35unit MakeResStrDlg;
 36
 37{$mode objfpc}{$H+}
 38
 39interface
 40
 41uses
 42  Classes, SysUtils, LCLProc, Forms, Controls, Buttons, StdCtrls,
 43  Dialogs, ExtCtrls, ButtonPanel, IDEWindowIntf,
 44  SynHighlighterPas, SynEdit,
 45  CodeToolManager, CodeToolsStructs, CodeCache,
 46  IDEHelpIntf, IDEDialogs,
 47  LazarusIDEStrConsts,
 48  EditorOptions, InputHistory, MiscOptions, IDEProcs;
 49
 50type
 51
 52  { TMakeResStrDialog }
 53
 54  TMakeResStrDialog = class(TForm)
 55    ButtonPanel1: TButtonPanel;
 56    CustomIdentifierCheckBox: TCheckBox;
 57    IdentifierGroupBox: TGroupBox;
 58    IdentifierEdit: TEdit;
 59    IdentLengthComboBox: TComboBox;
 60    IdentLengthLabel: TLabel;
 61    IdentPrefixComboBox: TComboBox;
 62    IdentPrefixLabel: TLabel;
 63    
 64    // options
 65    ConversionGroupBox: TGroupBox;
 66    CodePanel: TPanel;
 67    // resourcestring section
 68    ResStrSectionLabel: TLabel;
 69    ResStrSectionComboBox: TComboBox;
 70    // resourcestrings with same value
 71    ResStrWithSameValueLabel: TLabel;
 72    ResStrWithSameValuesCombobox: TComboBox;
 73    // insert position type
 74    AppendResStrRadioButton: TRadioButton;
 75    InsertAlphabeticallyResStrRadioButton: TRadioButton;
 76    InsertContextSensitiveRadioButton: TRadioButton;
 77
 78    Splitter1: TSplitter;
 79    SrcPreviewGroupBox: TGroupBox;
 80    SrcPreviewSynEdit: TSynEdit;
 81    StringConstGroupBox: TGroupBox;
 82    StringConstSynEdit: TSynEdit;
 83
 84    // highlighter
 85    SynPasSyn: TSynPasSyn;
 86
 87
 88    procedure CustomIdentifierCheckBoxClick(Sender: TObject);
 89    procedure HelpButtonClick(Sender: TObject);
 90    procedure IdentLengthComboBoxChange(Sender: TObject);
 91    procedure IdentPrefixComboBoxChange(Sender: TObject);
 92    procedure IdentifierEditChange(Sender: TObject);
 93    procedure OkButtonClick(Sender: TObject);
 94    procedure ResStrSectionComboBoxChange(Sender: TObject);
 95    procedure ResStrWithSameValuesComboboxChange(Sender: TObject);
 96  private
 97    procedure SetupComponents;
 98  public
 99    DefaultIdentifier: string;
100    Code: TCodeBuffer;
101    StartPos, EndPos: TPoint;
102    Positions: TCodeXYPositions;
103    constructor Create(TheOwner: TComponent); override;
104    destructor Destroy; override;
105    procedure FillResourceStringSections(NewPositions: TCodeXYPositions);
106    procedure FillIdentPrefixes;
107    procedure FillIdentLengths;
108    procedure FillStringsWithSameValue;
109    procedure UpdateIdentifier;
110    procedure UpdateSourcePreview;
111    function GetIdentifier: string;
112    function GetDefaultIdentifier: string;
113    procedure SetSource(NewCode: TCodeBuffer;
114      const NewStartPos, NewEndPos: TPoint);
115    function ResStrExistsInCurrentSection(const Identifier: string): boolean;
116    function ResStrExistsInAnySection(const Identifier: string): boolean;
117    function ResStrExistsWithSameValue(const Identifier: string): boolean;
118    procedure GetNewSource(out NewSource, ResourceStringValue: string);
119    procedure Init;
120    procedure SaveHistories;
121    procedure SaveIdentPrefixes;
122    procedure SaveIdentLengths;
123    procedure Save;
124  end;
125  
126function ShowMakeResStrDialog(
127  const StartPos, EndPos: TPoint; Code: TCodeBuffer;
128  out NewIdentifier, NewIdentifierValue: string;
129  out NewSourceLines: string;
130  out ResStrSectionCode: TCodeBuffer;
131  out ResStrSectionXY: TPoint;
132  out InsertPolicy: TResourcestringInsertPolicy): TModalResult;
133
134implementation
135
136{$R *.lfm}
137
138
139function ShowMakeResStrDialog(const StartPos, EndPos: TPoint;
140  Code: TCodeBuffer; out NewIdentifier, NewIdentifierValue: string; out
141  NewSourceLines: string; out ResStrSectionCode: TCodeBuffer; out
142  ResStrSectionXY: TPoint; out InsertPolicy: TResourcestringInsertPolicy
143  ): TModalResult;
144var
145  MakeResStrDialog: TMakeResStrDialog;
146  Section: PCodeXYPosition;
147  ResourcestringSectionID: Integer;
148begin
149  //debugln('ShowMakeResStrDialog StartPos=',dbgs(StartPos),' EndPos=',dbgs(EndPos),' ');
150  NewIdentifier:='';
151  NewIdentifierValue:='';
152  NewSourceLines:='';
153  ResStrSectionCode:=nil;
154  ResStrSectionXY:=Point(0,0);
155  InsertPolicy:=rsipNone;
156
157  MakeResStrDialog:=TMakeResStrDialog.Create(nil);
158  MakeResStrDialog.Positions:=CodeToolBoss.Positions.CreateCopy;
159  MakeResStrDialog.SetSource(Code,StartPos,EndPos);
160  MakeResStrDialog.Init;
161
162  // show dialog
163  Result:=MakeResStrDialog.ShowModal;
164  if Result=mrOk then begin
165    // return results
166    NewIdentifier:=MakeResStrDialog.GetIdentifier;
167    MakeResStrDialog.GetNewSource(NewSourceLines,NewIdentifierValue);
168    if MakeResStrDialog.ResStrExistsWithSameValue(NewIdentifier) then
169      InsertPolicy:=rsipNone
170    else begin
171      if MakeResStrDialog.InsertAlphabeticallyResStrRadioButton.Checked then
172        InsertPolicy:=rsipAlphabetically
173      else if MakeResStrDialog.InsertContextSensitiveRadioButton.Checked then
174        InsertPolicy:=rsipContext
175      else
176        InsertPolicy:=rsipAppend;
177    end;
178    ResourcestringSectionID:=MakeResStrDialog.ResStrSectionComboBox.ItemIndex;
179    Section:=CodeToolBoss.Positions[ResourcestringSectionID];
180    ResStrSectionCode:=Section^.Code;
181    ResStrSectionXY:=Point(Section^.X,Section^.Y);
182  end;
183
184  // save settings and clean up
185  IDEDialogLayoutList.SaveLayout(MakeResStrDialog);
186
187  MakeResStrDialog.Positions.Free;
188  MakeResStrDialog.Free;
189end;
190
191{ TMakeResStrDialog }
192
193procedure TMakeResStrDialog.CustomIdentifierCheckBoxClick(Sender: TObject);
194begin
195  UpdateIdentifier;
196end;
197
198procedure TMakeResStrDialog.HelpButtonClick(Sender: TObject);
199begin
200  LazarusHelp.ShowHelpForIDEControl(Self);
201end;
202
203procedure TMakeResStrDialog.IdentLengthComboBoxChange(Sender: TObject);
204begin
205  UpdateIdentifier;
206  UpdateSourcePreview;
207end;
208
209procedure TMakeResStrDialog.IdentPrefixComboBoxChange(Sender: TObject);
210begin
211  UpdateIdentifier;
212  UpdateSourcePreview;
213end;
214
215procedure TMakeResStrDialog.IdentifierEditChange(Sender: TObject);
216begin
217  UpdateIdentifier;
218  UpdateSourcePreview;
219end;
220
221procedure TMakeResStrDialog.OkButtonClick(Sender: TObject);
222var
223  Index: Integer;
224begin
225  Index:=ResStrSectionComboBox.ItemIndex;
226  if (Index<0) or (Index>=Positions.Count) then begin
227    IDEMessageDialog(lisMakeResStrInvalidResourcestringSect,
228      lisMakeResStrPleaseChooseAResourcestring,
229      mtError,[mbCancel]);
230    exit;
231  end;
232  if ResStrExistsInAnySection(IdentifierEdit.Text)
233  and (not ResStrExistsWithSameValue(IdentifierEdit.Text)) then begin
234    if IDEMessageDialog(lisMakeResStrResourcestringAlreadyExis,
235      Format(lisMakeResStrChooseAnotherName,[IdentifierEdit.Text,LineEnding,LineEnding]),
236      mtWarning,[mbOk,mbIgnore]) = mrOk
237    then
238      exit;
239  end;
240  Save;
241  ModalResult:=mrOk;
242end;
243
244procedure TMakeResStrDialog.ResStrSectionComboBoxChange(Sender: TObject);
245begin
246  UpdateIdentifier;
247  UpdateSourcePreview;
248end;
249
250procedure TMakeResStrDialog.ResStrWithSameValuesComboboxChange(Sender: TObject);
251var
252  NewIdentifier: String;
253  i: Integer;
254begin
255  NewIdentifier:=ResStrWithSameValuesCombobox.Text;
256  i:=ResStrWithSameValuesCombobox.Items.IndexOf(NewIdentifier);
257  if i<0 then exit;
258  IdentifierEdit.Text:=NewIdentifier;
259end;
260
261procedure TMakeResStrDialog.SetupComponents;
262begin
263  // source
264  AppendResStrRadioButton.Caption:=lisMakeResStrAppendToSection;
265  ConversionGroupBox.Caption:=lisMakeResStrConversionOptions;
266  CustomIdentifierCheckBox.Caption:=lisMakeResStrCustomIdentifier;
267  IdentifierGroupBox.Caption := lisMakeResStrDialogIdentifier;
268  IdentLengthLabel.Caption:=lisMakeResStrIdentifierLength;
269  IdentPrefixLabel.Caption:=lisMakeResStrIdentifierPrefix;
270  InsertAlphabeticallyResStrRadioButton.Caption:=lisMakeResStrInsertAlphabetically;
271  InsertContextSensitiveRadioButton.Caption:=lisMakeResStrInsertContexttSensitive;
272  ResStrSectionLabel.Caption:=lisMakeResStrResourcestringSection;
273  ResStrWithSameValueLabel.Caption:=lisMakeResStrStringsWithSameValue;
274  SrcPreviewGroupBox.Caption:=lisMakeResStrSourcePreview;
275  StringConstGroupBox.Caption:=lisMakeResStrStringConstantInSource;
276
277  // OK, Cancel, Help buttons
278  ButtonPanel1.OkButton.Caption:=lisMenuOk;
279  ButtonPanel1.CancelButton.Caption:=lisCancel;
280  ButtonPanel1.HelpButton.Caption:=lisMenuHelp;
281end;
282
283constructor TMakeResStrDialog.Create(TheOwner: TComponent);
284begin
285  inherited Create(TheOwner);
286
287  Caption := lisMakeResourceString;
288  SetupComponents;
289
290  IDEDialogLayoutList.ApplyLayout(Self,550,400);
291
292  EditorOpts.GetHighlighterSettings(SynPasSyn);
293  EditorOpts.GetSynEditSettings(StringConstSynEdit);
294  StringConstSynEdit.ReadOnly:=true;
295  StringConstSynEdit.Gutter.Visible:=false;
296  EditorOpts.GetSynEditSettings(SrcPreviewSynEdit);
297  SrcPreviewSynEdit.ReadOnly:=true;
298  SrcPreviewSynEdit.Gutter.Visible:=false;
299end;
300
301destructor TMakeResStrDialog.Destroy;
302begin
303  inherited Destroy;
304end;
305
306procedure TMakeResStrDialog.FillResourceStringSections(
307  NewPositions: TCodeXYPositions);
308var
309  i: Integer;
310  p: PCodeXYPosition;
311  s: String;
312begin
313  Positions:=NewPositions;
314  // the history list contains the filenames plus the
315  with ResStrSectionComboBox do begin
316    Text:='';
317    Items.BeginUpdate;
318    for i:=0 to Positions.Count-1 do begin
319      p:=Positions[i];
320      s:=p^.Code.Filename+' ('+IntToStr(p^.Y)+','+IntToStr(p^.X)+')';
321      if i<Items.Count then
322        Items[i]:=s
323      else
324        Items.Add(s);
325    end;
326    while Items.Count>Positions.Count do
327      Items.Delete(Items.Count-1);
328    Items.EndUpdate;
329    ItemIndex:=0;
330  end;
331end;
332
333procedure TMakeResStrDialog.FillIdentPrefixes;
334var
335  HistoryList: THistoryList;
336begin
337  // get the Prefixes history list
338  HistoryList:=
339         InputHistories.HistoryLists.GetList(hlMakeResourceStringPrefixes,true,
340                                             rltCaseSensitive);
341  IdentPrefixComboBox.Items.Assign(HistoryList);
342  if IdentPrefixComboBox.Items.Count>0 then
343    IdentPrefixComboBox.Text:=IdentPrefixComboBox.Items[0]
344  else
345    IdentPrefixComboBox.Text:='rs';
346end;
347
348procedure TMakeResStrDialog.FillIdentLengths;
349var
350  HistoryList: THistoryList;
351begin
352  // get the Length history list
353  HistoryList:=
354    InputHistories.HistoryLists.GetList(hlMakeResourceStringLengths,true,
355                                        rltCaseSensitive);
356  IdentLengthComboBox.Items.Assign(HistoryList);
357  if IdentLengthComboBox.Items.Count>0 then
358    IdentLengthComboBox.Text:=IdentLengthComboBox.Items[0]
359  else begin
360    with IdentLengthComboBox.Items do begin
361      Add('8');
362      Add('12');
363      Add('20');
364      Add('50');
365    end;
366    IdentLengthComboBox.Text:='12';
367  end;
368end;
369
370procedure TMakeResStrDialog.FillStringsWithSameValue;
371var
372  i: Integer;
373  CurSection: TCodeXYPosition;
374  NewSource, ResourceStringValue: string;
375  StringConstPositions: TCodeXYPositions;
376  ExistingIdentifier: string;
377begin
378  // get value of the new resourcestring
379  GetNewSource(NewSource, ResourceStringValue);
380  // get all existing resourcestrings with same value
381  StringConstPositions:=TCodeXYPositions.Create;
382  for i:=0 to Positions.Count-1 do begin
383    CurSection:=Positions[i]^;
384    CodeToolBoss.GatherResourceStringsWithValue(
385      CurSection.Code,CurSection.X,CurSection.Y,
386      ResourceStringValue,StringConstPositions);
387  end;
388  // fill combobox
389  ResStrWithSameValuesCombobox.Items.Clear;
390  for i:=0 to StringConstPositions.Count-1 do begin
391    CurSection:=StringConstPositions[i]^;
392    CodeToolBoss.GetIdentifierAt(CurSection.Code,CurSection.X,CurSection.Y,
393                                 ExistingIdentifier);
394    if ExistingIdentifier<>'' then
395      ResStrWithSameValuesCombobox.Items.Add(ExistingIdentifier);
396  end;
397  // enable components for selection
398  if ResStrWithSameValuesCombobox.Items.Count>0 then begin
399    ResStrWithSameValuesCombobox.Text:=ResStrWithSameValuesCombobox.Items[0];
400    ResStrWithSameValuesCombobox.Enabled:=true;
401  end else begin
402    ResStrWithSameValuesCombobox.Text:='';
403    ResStrWithSameValuesCombobox.Enabled:=false;
404  end;
405  ResStrWithSameValueLabel.Enabled:=ResStrWithSameValuesCombobox.Enabled;
406  // clean up
407  StringConstPositions.Free;
408end;
409
410procedure TMakeResStrDialog.UpdateIdentifier;
411var
412  CustomIdent: Boolean;
413begin
414  CustomIdent:=CustomIdentifierCheckBox.Checked;
415  IdentifierEdit.Enabled:=CustomIdent;
416  IdentPrefixLabel.Enabled:=not CustomIdent;
417  IdentPrefixComboBox.Enabled:=not CustomIdent;
418  IdentLengthLabel.Enabled:=not CustomIdent;
419  IdentLengthComboBox.Enabled:=not CustomIdent;
420  if not CustomIdent then
421    IdentifierEdit.Text:=GetDefaultIdentifier;
422end;
423
424procedure TMakeResStrDialog.UpdateSourcePreview;
425var
426  NewSource, NewValue: string;
427begin
428  GetNewSource(NewSource,NewValue);
429  SrcPreviewSynEdit.Text:=NewSource+LineEnding
430     +StringOfChar('-',
431                  CodeToolBoss.SourceChangeCache.BeautifyCodeOptions.LineLength)
432     +LineEnding
433     +CodeToolBoss.SourceChangeCache.BeautifyCodeOptions.BeautifyStatement(
434        GetIdentifier+' = '''+NewValue+'''',0);
435end;
436
437function TMakeResStrDialog.GetIdentifier: string;
438begin
439  Result:=IdentifierEdit.Text;
440  if Result='' then Result:=GetDefaultIdentifier;
441end;
442
443function TMakeResStrDialog.GetDefaultIdentifier: string;
444var
445  DefIdenLength: Integer;
446  i: Integer;
447begin
448  if ResStrWithSameValuesCombobox.Items.Count>0 then begin
449    Result:=ResStrWithSameValuesCombobox.Items[0];
450    exit;
451  end;
452  DefIdenLength:=StrToIntDef(IdentLengthComboBox.Text,8);
453  if DefIdenLength<1 then DefIdenLength:=1;
454  if DefIdenLength>80 then DefIdenLength:=80;
455  Result:=IdentPrefixComboBox.Text+copy(DefaultIdentifier,1,DefIdenLength);
456  if ResStrExistsInCurrentSection(Result) then begin
457    i:=2;
458    while ResStrExistsInCurrentSection(Result+IntToStr(i)) do inc(i);
459    Result:=Result+IntToStr(i);
460  end;
461end;
462
463procedure TMakeResStrDialog.SetSource(NewCode: TCodeBuffer; const NewStartPos,
464  NewEndPos: TPoint);
465begin
466  Code:=NewCode;
467  StartPos:=NewStartPos;
468  EndPos:=NewEndPos;
469end;
470
471function TMakeResStrDialog.ResStrExistsInCurrentSection(const Identifier: string
472  ): boolean;
473var
474  CodeXY: PCodeXYPosition;
475  Index: Integer;
476begin
477  Result:=false;
478  Index:=ResStrSectionComboBox.ItemIndex;
479  if (Index<0) or (Index>=Positions.Count) then exit;
480  CodeXY:=Positions.Items[Index];
481  Result:=CodeToolBoss.IdentifierExistsInResourceStringSection(
482                                CodeXY^.Code,CodeXY^.X,CodeXY^.Y,Identifier);
483end;
484
485function TMakeResStrDialog.ResStrExistsInAnySection(const Identifier: string
486  ): boolean;
487var
488  CodeXY: PCodeXYPosition;
489  Index: Integer;
490begin
491  Result:=false;
492  for Index:=0 to Positions.Count-1 do begin
493    CodeXY:=Positions.Items[Index];
494    Result:=CodeToolBoss.IdentifierExistsInResourceStringSection(
495                                   CodeXY^.Code,CodeXY^.X,CodeXY^.Y,Identifier);
496    if Result then exit;
497  end;
498end;
499
500function TMakeResStrDialog.ResStrExistsWithSameValue(const Identifier: string
501  ): boolean;
502var
503  i: Integer;
504begin
505  if Identifier<>'' then begin
506    for i:=0 to ResStrWithSameValuesCombobox.Items.Count-1 do begin
507      if CompareText(Identifier,ResStrWithSameValuesCombobox.Items[i])=0
508      then begin
509        Result:=true;
510        exit;
511      end;
512    end;
513  end;
514  Result:=false;
515end;
516
517procedure TMakeResStrDialog.GetNewSource(out NewSource,
518  ResourceStringValue: string);
519var
520  FormatStringConstant: string;
521  FormatParameters: string;
522  LeftSide: String;
523  LastLine: string;
524  NewString: String;
525  RightSide: String;
526  StartInStringConst, EndInStringConst: boolean;
527begin
528  NewSource:='';
529  ResourceStringValue:='';
530  if not CodeToolBoss.StringConstToFormatString(Code,StartPos.X,StartPos.Y,
531     Code,EndPos.X,EndPos.Y,FormatStringConstant,FormatParameters,
532     StartInStringConst,EndInStringConst)
533  then begin
534    SrcPreviewSynEdit.Text:=lisCCOErrorCaption+':'#13+CodeToolBoss.ErrorMessage;
535    exit;
536  end;
537  if FormatParameters='' then
538    NewString:=GetIdentifier
539  else
540    NewString:='Format('+GetIdentifier+',['+FormatParameters+'])';
541  if StartInStringConst then
542    NewString:='''+'+NewString;
543  if EndInStringConst then
544    NewString:=NewString+'+''';
545  LeftSide:=copy(StringConstSynEdit.Lines[0],1,StartPos.X-1);
546  LastLine:=StringConstSynEdit.Lines[EndPos.Y-StartPos.Y];
547  RightSide:=copy(LastLine,EndPos.X,length(LastLine)-EndPos.X+1);
548
549  NewSource:=LeftSide+NewString+RightSide;
550  with CodeToolBoss.SourceChangeCache.BeautifyCodeOptions do
551    NewSource:=BeautifyStatement(NewSource,0);
552
553  ResourceStringValue:=FormatStringConstant;
554end;
555
556procedure TMakeResStrDialog.Init;
557var
558  InsertPolicy: TResourcestringInsertPolicy;
559begin
560  // string constant
561  StringConstSynEdit.Text:=Code.GetLines(StartPos.Y,EndPos.Y);
562  // reachable resourcestring sections
563  FillResourceStringSections(Positions);
564  // identifier prefixes
565  FillIdentPrefixes;
566  // identifier lengths
567  FillIdentLengths;
568  // existing resource strings with same value
569  FillStringsWithSameValue;
570  // identifier
571  CustomIdentifierCheckBox.Checked:=false;
572  CodeToolBoss.CreateIdentifierFromStringConst(Code,StartPos.X,StartPos.Y,
573     Code,EndPos.X,EndPos.Y,DefaultIdentifier,50);
574  UpdateIdentifier;
575  // insert policy
576  InsertPolicy:=MiscellaneousOptions.MakeResourceStringInsertPolicy;
577  case InsertPolicy of
578  rsipAlphabetically: InsertAlphabeticallyResStrRadioButton.Checked:=true;
579  rsipContext:        InsertContextSensitiveRadioButton.Checked:=true;
580  else                AppendResStrRadioButton.Checked:=true;
581  end;
582  // show new source
583  UpdateSourcePreview;
584end;
585
586procedure TMakeResStrDialog.SaveHistories;
587begin
588  SaveIdentPrefixes;
589  SaveIdentLengths;
590end;
591
592procedure TMakeResStrDialog.SaveIdentPrefixes;
593var
594  HistoryList: THistoryList;
595begin
596  if CustomIdentifierCheckBox.Checked
597  or (IdentPrefixComboBox.Text='') then
598    exit;
599  HistoryList:=
600    InputHistories.HistoryLists.GetList(hlMakeResourceStringPrefixes,true,rltCaseSensitive);
601  if HistoryList.Count=0 then
602    HistoryList.Assign(IdentPrefixComboBox.Items);
603  HistoryList.Push(IdentPrefixComboBox.Text);
604end;
605
606procedure TMakeResStrDialog.SaveIdentLengths;
607var
608  HistoryList: THistoryList;
609begin
610  if CustomIdentifierCheckBox.Checked
611  or (IdentLengthComboBox.Text='') then
612    exit;
613  HistoryList:=
614    InputHistories.HistoryLists.GetList(hlMakeResourceStringLengths,true,rltCaseSensitive);
615  if HistoryList.Count=0 then
616    HistoryList.Assign(IdentLengthComboBox.Items);
617  HistoryList.Push(IdentLengthComboBox.Text);
618end;
619
620procedure TMakeResStrDialog.Save;
621var
622  InsertPolicy: TResourcestringInsertPolicy;
623begin
624  SaveHistories;
625  if InsertContextSensitiveRadioButton.Checked then
626    InsertPolicy:=rsipContext
627  else if InsertAlphabeticallyResStrRadioButton.Checked then
628    InsertPolicy:=rsipAlphabetically
629  else
630    InsertPolicy:=rsipAppend;
631  MiscellaneousOptions.MakeResourceStringInsertPolicy:=InsertPolicy;
632  MiscellaneousOptions.Save;
633end;
634
635end.
636