-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathProjectFormDocWizard.pas
1608 lines (1536 loc) · 56.8 KB
/
ProjectFormDocWizard.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/// Documentation editor full Wizard form
// - this unit is part of SynProject, under GPL 3.0 license; version 1.7
unit ProjectFormDocWizard;
(*
This file is part of SynProject.
Synopse SynProject. Copyright (C) 2008-2023 Arnaud Bouchez
Synopse Informatique - https://synopse.info
SynProject 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 3 of the License, or (at
your option) any later version.
SynProject 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 Lesser General Public License for more details.
You should have received a copy of the GNU General Public License
along with SynProject. If not, see <http://www.gnu.org/licenses/>.
*)
interface
{$define USEGDIPLUSFORIMAGES}
// if defined, GDI+ library will be used for reading jpeg and png images
// (requires Windows XP and later - or GdiPlus.dll in program folder)
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, Buttons, ExtCtrls, SynMemoEx,
ProjectMemoExSyntax, ProjectEditor, ProjectTypes,
{$ifdef USEGDIPLUSFORIMAGES}
SynGdiPlus,
{$endif}
Menus, ProjectSections, ProjectRTF, ProjectFrameRisk;
type
TProjectDocWizard = class(TForm)
BtnPrev: TBitBtn;
BtnNext: TBitBtn;
BtnCancel: TBitBtn;
PanelTop: TPanel;
Pages: TPanel;
BtnWelcome: TBitBtn;
BtnSave: TBitBtn;
PopupMenu: TPopupMenu;
procedure BtnNextClick(Sender: TObject);
procedure BtnPrevClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BtnWelcomeClick(Sender: TObject);
procedure BtnSaveClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
CreateEditX, CreateEditY, CreateEditW, CreateEditTop, CreateEditH,
LastCreateEditY,
CreateComponentFirstIndex,
CreateListComponentIndex: integer;
CreateEditSec: TSection;
SubDirDefPath: string;
fData: TSectionsStorage; // =nil -> new release wizard
fPeopleText: string;
fPageCount: integer;
fActivePageIndex: integer;
fPageTitle: string;
LabelVersion: TLabel;
fDefault: TSection;
FTitle: string; // contains [Default] of default.ini (from ProjectRes.RES)
FDefPROLines: string;
procedure SetActivePageIndex(const Value: integer);
procedure SetData(const Value: TSectionsStorage);
procedure SetfPeopleText;
procedure CreateEnoughPlace(Height: integer=48);
procedure WelcomeButtonClick(Sender: TObject);
procedure ImportClick(Sender: TObject);
procedure VersionMgmentClick(Sender: TObject);
function VersionLabel(Sec: TSection): string;
procedure CreateListClick(Sender: TObject);
procedure CreatePeoplesMenu(aEdit: TLabeledEdit; P: PChar);
procedure CreateDirectoryClick(Sender: TObject);
procedure CreatePeoplesClick(Sender: TObject);
procedure CreateCommitClick(Sender: TObject);
procedure MemoSetText(Memo: TMemoEx; const aValueName: string);
function UpdateDataFromActivePage(dontAsk: boolean): boolean;
procedure SetTitle(const Value: string);
procedure CreateComponentsMessage(var Message: TMessage); message WM_USER;
procedure CreateDocFromResource;
public
DVSFileName: string; // <>'' if BtnSaveClick() has created a new project
DVSParams: TSection; // <>nil before Show with Data=nil -> Commits [Params] section
procedure CreateEditInit(const SecName: string; AddDocumentFields: boolean=false;
NoItem: boolean=false; NoRevision: boolean=false; NoReviewOrApprov: boolean=false);
function CreateEdit(const aValueName, aCaption: string): TLabeledEdit;
function CreateCombo(const aValueName, aCaption, aValues: string): TComboBox;
function CreateMemo(const aValueName, aCaption: string; BodySyntax: boolean;
MemoHeight: integer = 240): TMemoEx;
function CreateList: TListBox;
function CreateOption(const aValueName, aCaption: string): TCheckBox;
function CreateButton(const aCaption: string; OnClick: TNotifyEvent; Width: integer = 0): TButton;
function CreatePeoples(const aValueName, aCaption: string): TLabeledEdit;
function CreateDirectory(const aValueName, aCaption: string; SubDir: boolean=false): TLabeledEdit;
function CreateLabel(const aCaption: string): TLabel;
function CreateRisk(const aValueName, aCaption: string): TFrameRisk;
procedure CreateVersion;
function DoCreateReleaseNew: boolean;
property Data: TSectionsStorage read fData write SetData; // Data=nil -> new Release
property ActivePageIndex: integer read fActivePageIndex write SetActivePageIndex;
property PageCount: integer read fPageCount;
property Title: string read FTitle write SetTitle;
end;
var
ProjectDocWizard: TProjectDocWizard;
resourcestring
sDocumentPurpose = 'Document purpose (must begin with a verb - "Create description..")';
sDocDisplayName = 'Document Name for display (same as Document name if left blank)';
sItemName = 'Short Item Name for display';
sDocNameForDoc = 'Document Name for .doc creation';
sDocNameForDocNotItem = 'Document Name for .doc (used instead of Item Name)';
sClickToVersionN = 'Click to manage version for this "%s" document';
sRightClickToAddName = 'Right click on the field to display add menu';
sReleaseVersion = 'Release Version number (2.1 e.g.)';
sNoRiskDisplay = 'Text to display in case of no Risk assessment';
sOldWordOpen = 'Word 97/2000 compatibility Hack';
sDestDir = 'Destination directory for all generated documents';
sWarningMessage = 'Warning message';
sWarningOvewriteExisting = 'Warning:'#13#10+
'This will rewrite the file content according to the current source code '+
'state'#13#10'(your hand-made descriptions should remain, '+
'if the item names didn''t change).'#13#10#13#10+
'Do you want to continue?';
sPeopleList = 'People list (Name=Function,Detailled function)';
sDefaultPreparedBy = '"Prepared by" default value';
sDILayout = 'Design Input order (lines beginning with : are main titles)';
sPreparedByDefault = 'Prepared by - blank if default "%s"';
sRequest = 'Associated Request ("SCR #23") - with version and severity for bug fix ("SCR #52,EIA 2.0+IFA 2.0,Low")';
sInputLevel = 'Prority Level ("Must have" if left blank)';
sDescriptionIfNoBody = 'Item Description (if no text in body below)';
sShortItemName = 'Short Item Name for display';
sItemBody = 'Item Body (long description)';
sSourceModules = 'Source SAD-* project executable modules, separated by ","';
sSourceModulesHint = 'The SAD document will look for [SAD-*] sections and for @*\filename.ext@';
sDefaultPath = 'Global default directory (trimmed in the text)';
sRequirementsForTest = 'Requirements for Test (blank if same as Display Name)';
sSourcePathN = 'Source Path to search in (default parent is "%s")';
sSourceFiles = 'Delphi Source Files to be parsed (separated by ";")';
sIncludePath = 'Include Path for Delphi parser (separated by ";")';
sDirectives = 'Compilation Directives for Delphi parser';
sGraphIgnore = 'Units names without graphs (separated by ",")';
sExternalDescription = 'External code description in separate .sae file';
sModuleDescription = 'Module description';
sExcludeFromSummary = 'If checked, the V&&V plan won''t show this entry';
sTestDescription = 'Test Description (must begin with a verb), leave blank if no new document';
sTestDocName = '"Test *" document name to use instead of section name';
sTestProtocol = 'Test protocol';
sIntroductionTextN = '%s introduction text';
sContentN = '%s content';
sSoftwareVersion = 'Software version for this release';
sSoftwareHistory = 'Product Software History';
sKnownIssues = 'Known Issues';
sSOUP = 'SOUP items';
sDocFirstPart = 'Document first part';
sRightClickToAdd = '(right click to add)';
sStepNumber = '(step %d/%d)';
sFieldChangeUpdateQuery = 'At least one field has been updated.'#13+
'Do you want to save the changes?';
sSectionNewCreateQuery = 'The [%s] section doesn''t exist yet.'#13+
'Do you want to create it now?';
sChangeDirectory = 'Browse for folder';
sImportValues = 'Import values from another release';
sGlobalCompany = 'Main Company Name (local Company Name will be provided later)';
sProduct = 'Full Product Name, as inserted into the documentation';
sProductPath = 'Shorter Product Name for path/file creation';
sReleaseName = 'Release Name / Commits Name for this Product';
sDefaultAuthor = 'Default Author name of this documentation';
sDefaultAuthorFunction = 'Default Author responsability ("function,function details")';
sSRSORDER = 'SWRS has its own sub items (not follow strictly the DI order)';
sDefaultPathRelease = 'Root directory for all files (source and documentation)';
sNoDocumentation = 'Release has NO Design Input: don''t create .pro documentation';
sDocumentsPath = '(Sub) Directory containing all documentation related files';
// sSourcePathPossible = 'Sub directory containing the source files (can be blank)';
sBackupPathLocal = 'Local directory for backups';
sBackupPathDistant = 'Distant directory for backups (can be blank)';
sCommitIgnorePath = 'Directory names to ignore (separated by ",")';
sCommitIgnoreFile = 'File extension begining to ignore (".~" will ignore *.~* files)';
sCommitFilterDefault = 'File extensions to scan for commit (.pas.php..)';
sCommitFileNameNN = '%s file name (root directory is "%s") - can be blank';
sCommitUpdate = 'Commit module ("Display Name;Path;Filter,Filter,..") #%d';
sCommitEditionN = 'Commit module edition #%d';
sDoCreateReleaseNewQueryN = 'Do you want to create a new "%s" release,'#13+
'with all associated files and directories?';
sCreateDirectoryQueryN = 'The "%s" directory doesn''t exist yet.'#13#13+
'Do you want to force its creation?';
sOverwriteFileQueryN = 'The "%s" file already exists.'#13#13+
'Do you want to overwrite it (and loose its contents)?';
sFileCreateNewQueryN = 'The file "%s" doesn''t exist yet.'#13#13+
'Do you want to create a new one now?';
sProjectDocWizardTitles =
'Direct access to a page,General,Design Input,Design Input details,'+
'Design FMEA,Design FMEA details,SWRS,SWRS details,'+
'Risk Assessment,SDD,SDD details,Software Architecture,Software Architecture details,'+
'Software Architecture modules,V&V plan,Test protocols,Test protocols report,'+
'Tests details,Versions,Issues,SCRS,Release Notes';
sProjectNewReleaseWizardTitles =
'Creating a new project,Software Commits Settings,Creating a new documentation';
function LoadTextFromResource(const ResName: string): string;
// load from embedded resource (not zip but as normal text resource)
// default := LoadTextFromResource('default');
function MessageDlgFmt(const Msg: string; const Args: array of const;
DlgType: TMsgDlgType = mtConfirmation; Buttons: TMsgDlgButtons = mbYesNoCancel;
HelpCtx: Longint = 0): Integer;
// result := MessageDlg(Format(Msg,Args), mtConfirmation, mbYesNoCancel, 0);
procedure MessageErrFmt(const Format, Value: string);
implementation
uses
SysConst,
ProjectCommons,
ProjectVersionSCR, // for notVoid()
ProjectVersioning,
ProjectDiff,
SynZip, // TZipRead to read embedded ProjectRes.zip
ProjectEditorRelease, ProjectVersionMain, ProjectTrackerLogin,
ProjectEditorCommit;
{$R *.dfm}
function MessageDlgFmt(const Msg: string; const Args: array of const;
DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;
begin
result := MessageDlg(Format(Msg,Args), DlgType, Buttons, HelpCtx);
end;
procedure MessageErrFmt(const Format, Value: string);
begin
MessageDlgFmt(Format, [Value], mtError, [mbOK], 0);
end;
{$R ProjectRes.RES}
// contains wizard2.png, default.ini, and the embedded ProjectRes.zip
function LoadTextFromResource(const ResName: string): string;
// load from embedded resource (not zip but as normal text resource)
// default := LoadTextFromResource('default');
begin
with TResourceStream.Create(HInstance,ResName,'TXT') do
try
SetString(result,PAnsiChar(Memory),Size);
finally
Free;
end;
end;
function NameValidate(const aName: string): string;
// make aName compatible with TComponent.Name (['0'..'9','A'..'Z','_'])
var i: integer;
begin
result := aName;
for i := length(result) downto 1 do begin
case result[i] of
'_': insert('_',result,i+1);
'-': insert('A',result,i+1);
'.': insert('B',result,i+1);
' ': insert('C',result,i+1);
'a'..'z','A'..'Z','0'..'9': continue;
end;
result[i] := '_';
end;
end;
function NameUnValidate(const aNameValidated: string): string;
// make aName compatible with TComponent.Name (['0'..'9','A'..'Z','_'])
var i: integer;
begin
result := aNameValidated;
for i := length(result)-1 downto 1 do
if result[i]='_' then begin
delete(result,i,1);
case result[i] of
'A': result[i] := '-';
'B': result[i] := '.';
'C': result[i] := ' ';
end;
end;
end;
procedure TProjectDocWizard.BtnNextClick(Sender: TObject);
begin
ActivePageIndex := ActivePageIndex+1;
end;
procedure TProjectDocWizard.BtnPrevClick(Sender: TObject);
begin
ActivePageIndex := ActivePageIndex-1;
end;
procedure TProjectDocWizard.FormShow(Sender: TObject);
var i: integer;
begin
if CreateComponentFirstIndex>0 then
for i := ComponentCount-1 downto CreateComponentFirstIndex do
Components[i].Free;
CreateComponentFirstIndex := 0; // force recreate
DVSFileName := '';
BtnSave.Enabled := DVSParams<>nil;
CreateEditSec := nil;
BtnWelcome.Visible := Data<>nil;
fActivePageIndex := 0; // UpdateDataFromActivePage will accept following line
ActivePageIndex := 0;
end;
function TProjectDocWizard.CreateEdit(const aValueName, aCaption: string): TLabeledEdit;
begin
CreateEnoughPlace;
result := TLabeledEdit.Create(self);
result.Parent := Pages;
result.Left := CreateEditX;
result.Top := CreateEditY;
result.Width := CreateEditW;
result.LabelPosition := lpAbove;
result.EditLabel.Caption := aCaption+':';
if result.EditLabel.Width>CreateEditW then begin
result.EditLabel.Hint := aCaption;
result.EditLabel.ShowHint := true;
end;
result.Name := NameValidate(aValueName); // Data[Name] := .. to update modified value
result.Text := CreateEditSec[aValueName];
inc(CreateEditY,48);
end;
function TProjectDocWizard.CreateRisk(const aValueName, aCaption: string): TFrameRisk;
begin
result := TFrameRisk.Create(self);
result.Parent := Pages;
CreateEnoughPlace(result.GroupBoxRisk.Height);
result.Left := CreateEditX;
result.Top := CreateEditY-16;
if CreateEditW>result.GroupBoxRisk.Width then
result.Width := CreateEditW;
result.GroupBoxRisk.Width := CreateEditW;
result.Name := NameValidate(aValueName); // Data[Name] := .. to update modified value
CreatePeoplesMenu(result.LabeledEditEvaluatedBy,pointer(fPeopleText));
inc(CreateEditY,result.GroupBoxRisk.Height);
end;
function TProjectDocWizard.CreateCombo(const aValueName, aCaption, aValues: string): TComboBox;
var i: integer;
s: string;
begin
CreateEnoughPlace;
with TLabel.Create(self) do begin
Parent := Pages;
Left := CreateEditX;
Top := CreateEditY-16;
Caption := aCaption+':';
end;
result := TComboBox.Create(self);
result.Parent := Pages;
result.Left := CreateEditX;
result.Top := CreateEditY;
result.Width := CreateEditW;
result.Style := csDropDownList; // user may not enter manually a value
result.Items.Text := aValues;
s := CreateEditSec[aValueName];
i := result.Items.IndexOf(s);
if i>=0 then
result.ItemIndex := i else
result.Text := s;
result.Name := NameValidate(aValueName); // Data[Name] := .. to update modified value
inc(CreateEditY,48);
end;
function TProjectDocWizard.CreatePeoples(const aValueName, aCaption: string): TLabeledEdit;
begin
result := CreateEdit(aValueName,aCaption+' '+sRightClickToAdd);
CreatePeoplesMenu(result,pointer(fPeopleText));
end;
function TProjectDocWizard.CreateDirectory(const aValueName, aCaption: string; SubDir: boolean): TLabeledEdit;
begin
result := CreateEdit(aValueName,aCaption);
result.Width := result.Width-48;
with TButton.Create(self) do begin
Parent := Pages;
Left := result.Left+CreateEditW-(48-8);
Top := result.Top;
Height := result.Height;
Width := 48-8;
Caption := '...';
Hint := sChangeDirectory;
ShowHint := true;
OnClick := CreateDirectoryClick;
Tag := integer(SubDir);
Name := result.Name+'2'; // TLabeledEdit.Name=copy(Name,1,length(Name)-1)
end;
end;
procedure TProjectDocWizard.CreateDirectoryClick(Sender: TObject);
var Dir, DefPath: string;
Btn: TButton absolute Sender;
Edit: TLabeledEdit;
begin
if not Sender.InheritsFrom(TButton) then exit;
DefPath := '';
if SubDirDefPath='' then begin
Edit := FindComponent('DefaultPath') as TLabeledEdit;
if (Edit<>nil) and not IdemPChar(pointer(Btn.Name),'DEFAULTPATH') then
DefPath := Trim(Edit.Text);
end else
DefPath := SubDirDefPath;
if DefPath<>'' then
DefPath := IncludeTrailingPathDelimiter(UpperCase(DefPath));
Edit := FindComponent(copy(Btn.Name,1,length(Btn.Name)-1)) as TLabeledEdit;
if Edit=nil then exit;
Dir := Edit.Text;
if (DefPath<>'') and not DirectoryExists(Dir) then
if DirectoryExists(DefPath+Dir) then
Dir := DefPath+Dir else
Dir := DefPath; // if not a valid directory, start with DefPath
if SelectDirectory(Handle,Edit.EditLabel.Caption,Dir) then begin
if (DefPath<>'') and IdemPChar(pointer(Dir),pointer(DefPath)) then
Delete(Dir,1,length(DefPath));
Edit.Text := Dir;
end;
end;
procedure TProjectDocWizard.CreatePeoplesMenu(aEdit: TLabeledEdit; P: PChar);
var Menu: TPopupMenu;
Item: TMenuItem;
begin
if aEdit=nil then exit;
Menu := TPopupMenu.Create(self);
if aEdit.Hint<>'' then
aEdit.Hint := aEdit.Hint+' ('+sRightClickToAddName+')' else
aEdit.Hint := sRightClickToAddName;
aEdit.ShowHint := true;
aEdit.PopupMenu := Menu;
if P<>nil then
while P^<>#0 do begin
Item := TMenuItem.Create(self);
Item.Caption := GetNextLine(P,P);
Item.Hint := NameUnValidate(aEdit.Name); // Hint = ComponentName = aValueName
Item.OnClick := CreatePeoplesClick;
Menu.Items.Add(Item);
end;
end;
procedure TProjectDocWizard.CreatePeoplesClick(Sender: TObject);
var Menu: TMenuItem absolute Sender;
C: TComponent;
L: TLabeledEdit absolute C;
text, name: string;
Plus: char;
begin
if not Sender.InheritsFrom(TMenuItem) then exit;
if Menu.Hint='LabeledEditEvaluatedBy' then begin
Plus := '+';
C := FindComponent('Risk');
if (C<>nil) and C.InheritsFrom(TFrameRisk) then
C := TFrameRisk(C).LabeledEditEvaluatedBy;
end else begin
Plus := ',';
C := FindComponent(Menu.Hint);
end;
if (C=nil) or not C.InheritsFrom(TLabeledEdit) then exit;
name := StringReplaceAll(Menu.Caption,'&','');
text := L.Text;
if not CSVContains(text,name,Plus) then
if text='' then
L.Text := name else
L.Text := text+Plus+name;
end;
procedure TProjectDocWizard.CreateEnoughPlace(Height: integer);
begin
if (Height>=0) and (CreateEditY+Height<=Pages.ClientHeight) then exit;
LastCreateEditY := CreateEditY;
CreateEditY := CreateEditTop;
inc(CreateEditX,CreateEditW+32);
end;
function TProjectDocWizard.CreateMemo(const aValueName, aCaption: string;
BodySyntax: boolean; MemoHeight: integer = 240): TMemoEx;
begin
if MemoHeight=-1 then // Height = -1 -> force full next column
MemoHeight := CreateEditH else
if MemoHeight=0 then // Height = 0 -> force till end of column
if CreateEditY>=Pages.ClientHeight then
MemoHeight := CreateEditH else
MemoHeight := Pages.ClientHeight-CreateEditY;
CreateEnoughPlace(MemoHeight);
inc(MemoHeight,16);
with TLabel.Create(self) do begin
Parent := Pages;
Left := CreateEditX;
Top := CreateEditY-16;
if aCaption='' then
Caption := format(sIntroductionTextN,[fPageTitle])+' :' else
Caption := aCaption+':';
end;
result := TMemoEx.Create(self);
result.Parent := Pages;
result.Left := CreateEditX;
result.Top := CreateEditY;
result.Width := CreateEditW;
result.Height := MemoHeight-32;
if Screen.Fonts.IndexOf('Consolas')>=0 then
result.Font.Name := 'Consolas';
result.Font.Size := 9;
if BodySyntax then begin
result.RightMargin := (CreateEditW div result.CellRect.Width)-4;
result.OnGetLineAttr := TProjectSyntax.BodyGetLineAttr;
end else
result.OnGetLineAttr := TProjectSyntax.IniGetLineAttr;
result.WordWrap := BodySyntax;
MemoSetText(result,aValueName); // set result.Name
inc(CreateEditY,MemoHeight);
end;
procedure TProjectDocWizard.MemoSetText(Memo: TMemoEx; const aValueName: string);
var s, L: string;
BodySyntax: boolean;
begin
BodySyntax := Memo.WordWrap;
Data.ReadOpen(aValueName,not BodySyntax);
s := '';
if BodySyntax then begin
while not Data.ReadEof do
s := s+Data.ReadLine(true)+#13#10;
end else
while not Data.ReadEof do begin
L := Data.ReadLine(true);
if L='' then
break else
s := s+L+#13#10;
end;
Memo.Lines.Text := trim(s);
Memo.Modified := false;
Memo.Name := NameValidate(aValueName); // Data[Name] := ..
end;
function TProjectDocWizard.CreateOption(const aValueName, aCaption: string): TCheckBox;
begin
CreateEnoughPlace(48-24);
result := TCheckBox.Create(self);
result.Parent := Pages;
result.Left := CreateEditX;
result.Top := CreateEditY-16;
result.Width := CreateEditW;
result.Caption := aCaption;
result.Checked := isTrue(CreateEditSec[aValueName]);
result.Name := NameValidate(aValueName); // Data[Name] := .. to update modified value
inc(CreateEditY,48-24);
end;
function TProjectDocWizard.CreateButton(const aCaption: string; OnClick: TNotifyEvent;
Width: integer = 0): TButton;
begin
CreateEnoughPlace(48-24);
result := TButton.Create(self);
result.Parent := Pages;
result.Left := CreateEditX;
result.Top := CreateEditY-16;
result.Height := 48-24;
if width=0 then
result.Width := CreateEditW div 2 else
result.Width := width;
result.Caption := aCaption;
result.OnClick := OnClick;
inc(CreateEditY,48-16);
end;
function TProjectDocWizard.CreateLabel(const aCaption: string): TLabel;
begin
CreateEnoughPlace(48-32);
result := TLabel.Create(self);
result.Parent := Pages;
result.Left := CreateEditX;
result.Top := CreateEditY-16;
result.AutoSize := false;
result.Width := CreateEditW;
result.Caption := aCaption;
inc(CreateEditY,48-32);
end;
function TProjectDocWizard.CreateList: TListBox;
var H, i: integer;
order: string; // Order=.. document value
par: string; // Parent=.. value for each item
source: string; // Source=EIA,IFA,LIS in [SAD] section
P: PChar;
begin
if (CreateEditSec=nil) or // section must be a true document
(CreateEditSec.SectionNameKind<>CreateEditSec.SectionNameValue) then begin
result := nil;
exit;
end;
H := Pages.ClientHeight-CreateEditY;
if H<0 then
H := CreateEditH;
CreateEnoughPlace(H);
with TLabel.Create(self) do begin
Parent := Pages;
Left := CreateEditX;
Top := CreateEditY-16;
Caption := CreateEditSec.ItemName+' items:';
end;
result := TListBox.Create(self);
result.Parent := Pages;
result.Left := CreateEditX;
result.Top := CreateEditY;
result.Width := 128;
result.Height := H-16;
result.Items.BeginUpdate;
source := CreateEditSec['Source']; // Source=Firmware,EIA,IFA,LIS,Builder
if source='' then begin // normal section: DI,SRS,SDD,Test... by Order=
order := CreateEditSec['Order'];
if order='' then // default self-ordered
order := CreateEditSec.SectionName;
par := '';
if order='DI' then begin
for i := 0 to Data.Sections.Count-1 do
with Data.Sections.Items[i] do
if (SectionNameKind<>SectionNameValue) and SameText(SectionNameKind,'DI') then
if CreateEditSec.SectionName='DI' then
result.Items.Add(SectionName) else // 'DI-4.1'
result.Items.Add(CreateEditSec.SectionName+'-'+SectionName); // 'SRS-DI-4.1'
end else
for i := 0 to Data.Sections.Count-1 do
with Data.Sections.Items[i] do
if (SectionNameKind<>SectionNameValue) and SameText(SectionNameKind,order) then begin
if Data[SectionNameValue]<>nil then // SRS-DI-4.1 -> DI-4.1
par := SectionNameValue else // default Parent is last DI
if Value['Parent']<>'' then // SRS-MENU01->DI-4.1
par := Value['Parent'];
if par<>'' then
if order=CreateEditSec.SectionName then // self-ordered
result.Items.Add(SectionName) else
result.Items.Add(CreateEditSec.SectionName+'-'+SectionNameValue) else
result.Items.Add(SectionName);
end;
end else begin // Source<>'' -> SAD document
P := pointer(source);
repeat // Source=Firmware,EIA,IFA,LIS,Builder
result.Items.Add(CreateEditSec.SectionName+'-'+GetNextItem(P));
until P=nil;
end;
result.Items.EndUpdate;
result.OnClick := CreateListClick;
CreateListComponentIndex := ComponentCount;
CreateEditY := CreateEditTop;
CreateEditW := (Pages.ClientWidth-result.Width-result.Left)div 2-32;
CreateEditX := result.Left+result.Width+16;
CreateEditSec := nil; // by default, all detail fields are empty
end;
procedure TProjectDocWizard.CreateEditInit(const SecName: string;
AddDocumentFields, NoItem, NoRevision, NoReviewOrApprov: boolean);
begin
LabelVersion := nil;
CreateListComponentIndex := 0;
CreateComponentFirstIndex := ComponentCount;
CreateEditSec := Data[SecName]; // Data=nil (new Release) -> CreateEditSec=nil
CreateEditTop := 24;
CreateEditX := 48;
CreateEditY := CreateEditTop;
CreateEditW := Pages.ClientWidth div 2-(48+12);
CreateEditH := Pages.ClientHeight-CreateEditTop-8;
SubDirDefPath := '';
if not AddDocumentFields then
exit; // code below are common document properties edit
CreateEdit('Name',sDocumentName);
CreateEdit('Purpose',sDocumentPurpose);
CreateEdit('DisplayName',sDocDisplayName);
if not NoItem then
CreateEdit('ItemName',sItemName);
if NoItem then
CreateEdit('DocName',sDocNameForDoc) else
CreateEdit('DocName',sDocNameForDocNotItem);
if not NoRevision then
CreateVersion;
CreatePeoples('PreparedBy',sPreparedBy);
if not NoReviewOrApprov then begin
CreatePeoples('ReviewedBy',sReviewedBy);
CreatePeoples('ApprovedBy',sApprovedBy);
end;
end;
procedure TProjectDocWizard.CreateVersion;
begin
LabelVersion := CreateLabel(VersionLabel(CreateEditSec));
LabelVersion.Font.Style := [fsItalic];
LabelVersion.ShowHint := true;
LabelVersion.Hint := format(sClickToVersionN,[fPageTitle]);
LabelVersion.OnClick := VersionMgmentClick;
inc(CreateEditY,8);
end;
procedure TProjectDocWizard.SetData(const Value: TSectionsStorage);
var def: string;
i: integer;
begin
// init properties
FDefPROLines := '';
CreateEditSec := nil;
if not visible and (fDefault<>nil) then begin // clear memory from closed New Release
FreeAndNil(fDefault);
if Data<>nil then // temp fData has been created in SetActivePageIndex(1)
FreeAndNil(fData);
end;
fData := Value;
SetfPeopleText;
Title := '';
if Value=nil then begin // Data=nil -> new release wizard
def := LoadTextFromResource('default');
fDefault := TSection.Create('Default');
i := pos('Company=',def);
if i=0 then
Raise Exception.Create(fDefault.SectionName);
fDefault.ReadSection(@def[i]);
if DVSParams<>nil then begin
fDefault['Company'] := DVSParams['COMPANY'];
fDefault['Product'] := DVSParams['Product'];
fDefault['ProductPath'] := DVSParams['ProductPath'];
fDefault['ReleaseName'] := DVSParams['ReleaseName'];
fDefault['DefaultAuthor'] := DVSParams['DefaultAuthor'];
fDefault['DefaultPath'] := DVSParams['DefaultPath'];
fPageCount := 1;
end else
fPageCount := 2;
end else
if not Visible then
fPageCount := 22;
end;
procedure TProjectDocWizard.SetfPeopleText;
var N, V: string;
begin
fPeopleText := '';
Data.ReadOpen('People',true);
while Data.ReadNextNameValue(N,V) do
if fPeopleText='' then
fPeopleText := N else
fPeopleText := fPeopleText+#13#10+N;
end;
procedure TProjectDocWizard.SetActivePageIndex(const Value: integer);
var i: integer;
begin
// 0. save updated values
if (Value<0) or (Value>=PageCount) then exit;
if not UpdateDataFromActivePage(false) then exit;
fActivePageIndex := Value;
// 1. erase existing data-aware components
if CreateComponentFirstIndex>0 then
for i := ComponentCount-1 downto CreateComponentFirstIndex do
Components[i].Free;
CreateComponentFirstIndex := 0;
Application.ProcessMessages;
// 2. need a message after erasing components (Windows hangs otherwise)
PostMessage(Handle,WM_USER,Value,0);
end;
procedure TProjectDocWizard.CreateComponentsMessage(var Message: TMessage);
var i, j: integer;
s, Titles: string;
P: PChar;
B: TButton;
withDoc: boolean;
begin
assert(Message.wParam=fActivePageIndex);
// 1. init buttons and property value
BtnPrev.Enabled := fActivePageIndex>0;
BtnNext.Enabled := fActivePageIndex<PageCount-1;
if DVSParams=nil then
if fDefault=nil then
Titles := sProjectDocWizardTitles else
Titles := sProjectNewReleaseWizardTitles else
Titles := ValAt(sProjectNewReleaseWizardTitles,2);
fPageTitle := ValAt(Titles,ActivePageIndex);
BtnPrev.Hint := ValAt(Titles,fActivePageIndex-1);
BtnNext.Hint := ValAt(Titles,fActivePageIndex+1);
// 2. add components
if fDefault<>nil then // new release wizard:
case fActivePageIndex of
0: begin
CreateEditInit('');
CreateEditSec := fDefault;
inc(CreateEditY,8);
CreateButton(sImportValues,ImportClick,CreateEditW);
inc(CreateEditY,8);
CreateEdit('Company',sGlobalCompany);
CreateEdit('Product',sProduct);
CreateEdit('ProductPath',sProductPath);
CreateEdit('ReleaseName',sReleaseName);
CreateEdit('DefaultAuthor',sDefaultAuthor);
CreateEdit('DefaultAuthorFunction',sDefaultAuthorFunction);
if DVSParams=nil then begin
CreateDirectory('BackupPathLocal',sBackupPathLocal);
CreateDirectory('BackupPathDistant',sBackupPathDistant);
CreateDirectory('DefaultPath',sDefaultPathRelease);
// commits will be stored in $DefaultPath$\$ReleaseName$.dvs
CreateOption('NoDoc',sNoDocumentation);
end;
CreateDirectory('DocumentsPath',sDocumentsPath,true);
with CreateEdit('SADModules',sSourceModules) do begin
ShowHint := true;
Hint := sSourceModulesHint;
end;
if DVSParams=nil then begin
CreateOption('SRSOwnORDER',sSRSORDER);
CreateMemo('DILayout',sDILayout,false,0,).Lines.Text :=
StringReplaceAll(fDefault['DILayout'],'\',#13#10);
end else begin
if fDefault['PRO']='' then begin
s := fDefault['ReleaseName'];
fDefault['PRO'] := fDefault['DocumentsPath']+'\'+fDefault['ProductPath']+
'\'+s+'\'+s+'.pro';
end;
CreateEdit('PRO',format(sCommitFileNameNN,['PRO',fDefault['DefaultPath']]));
CreateEnoughPlace(CreateEditH);
CreateMemo('DILayout',sDILayout,false,CreateEditH div 2).Lines.Text :=
StringReplaceAll(fDefault['DILayout'],'\',#13#10);
CreateOption('SRSOwnORDER',sSRSORDER);
CreateMemo('SRSORDER',sSRSORDER,false,0);
end;
end;
1: begin
withDoc := not isTrue(fDefault['NoDoc']);
if Data=nil then begin
CreateDocFromResource;
if not withDoc then
Data['Params']['Update2'] := ''; // Update2=$ReleaseName$ Documentation;...
if DVSParams<>nil then
with Data['Params'] do begin
Value['SCR'] := DVSParams['SCR'];
Value['MAN'] := DVSParams['MAN'];
end;
end;
CreateEditInit('Params');
s := fDefault['DefaultPath'];
CreateEdit('IgnorePath',sCommitIgnorePath);
CreateEdit('IgnoreFile',sCommitIgnoreFile);
CreateEdit('FilterDefault',sCommitFilterDefault);
CreateEdit('SCR',format(sCommitFileNameNN,['SCR',s]));
CreateEdit('MAN',format(sCommitFileNameNN,['MAN',s]));
if withDoc then
CreateEdit('PRO',format(sCommitFileNameNN,['PRO',s]));
for i := 0 to 9 do // Display Name;Path;Filter,Filter,..
with CreateEdit('Update'+IntToStr(i),format(sCommitUpdate,[i])) do begin
Width := Width-48;
B := TButton.Create(self);
B.Parent := Pages;
B.SetBounds(Left+Width+8,Top,40,Height);
B.Caption := '...';
B.OnClick := CreateCommitClick;
B.Tag := i;
end;
if withDoc then
if isTrue(fDefault['SRSOwnORDER']) then begin
if Data['SRSORDER']=nil then
Data.GetOrCreateSection('SRSORDER',true).ReadSection(pointer(
'DI-'+StringReplaceAll(fDefault['DILayout'],'\',#13#10'DI-')));
CreateMemo('SRSORDER',sSRSORDER,false,0);
end;
end;
end else
// fDefault=nil -> document full wizard:
case fActivePageIndex of
0: begin
CreateEditInit('');
with TImage.Create(self) do begin
Parent := Pages;
AutoSize := true;
Picture.Graphic := TPngImage.Create;
TPngImage(Picture.Graphic).LoadFromResourceName(HInstance,'wizard2');
Left := CreateEditX+(CreateEditW-Picture.Width)div 2;
Top := CreateEditY-8;
CreateEditY := Top+Height+32;
end;
P := pointer(Titles);
BtnWelcome.Hint := GetNextItem(P);
i := 1;
while P<>nil do begin
B := CreateButton(IntToStr(i)+' - '+StringReplaceAll(GetNextItem(P),'&','&&'),
WelcomeButtonClick,CreateEditW);
inc(i);
if CreateEditX>CreateEditW then begin // we flipped to next page
CreateEditY := LastCreateEditY-(fPageCount-i+1)*(48-16);
B.Top := CreateEditY-16;
inc(CreateEditY,48-16);
end;
end;
end;
1: begin
CreateEditInit('Project');
CreateEdit('Company',sCompany);
CreateEdit('Name',sProjectName);
CreateEdit('ReleaseVersion',sReleaseVersion);
CreateEdit('ReleaseDate','Release Date');
CreateCombo('Manager','Project Manager',fPeopleText);
CreateEdit('NoRiskDisplay',sNoRiskDisplay);
CreateOption('OldWordOpen',sOldWordOpen);
CreateDirectory('DestinationDir',sDestDir);
CreateMemo('Project',sWarningMessage,true,0);
CreateMemo('People',sPeopleList,false,-1);
end;
2: begin
CreateEditInit('DI',true);
CreateCombo('DefaultPreparedBy',sDefaultPreparedBy,fPeopleText);
CreateMemo('DILayout',sDILayout,false,-1);
end;
3: begin
CreateEditInit('DI');
CreateList;
CreateEditW := CreateEditW*2;
CreateEdit('Ident',sDescription);
CreatePeoples('PreparedBy',format(sPreparedByDefault,
[Data['DI']['DefaultPreparedBy']]));
CreateEdit('InputLevel',sInputLevel);
CreateEdit('Request',sRequest);
CreateRisk('Risk',sRiskAssessment);
end;
4: begin
CreateEditInit('RK',true);
CreateMemo('RK','',true,-1);
end;
5: begin
CreateEditInit('RK');
CreateList;
CreateEditW := CreateEditW*2;
CreateEdit('Ident',sDescription);
CreateRisk('Risk',sRiskAssessment);
CreateMemo('',sItemBody,true,0);
end;
6: begin
CreateEditInit('SRS',true);
CreateMemo('SRS','',true,-1);
end;
7: begin
CreateEditInit('SRS');
CreateList;
CreateEditW := CreateEditW*2;
CreateEdit('Description',sDescriptionIfNoBody);
CreateEdit('ShortName',sShortItemName);
CreateMemo('',sItemBody,true,0);
end;
8: begin
CreateEditInit('Risk',true,true);
end;
9: begin
CreateEditInit('SDD',true,true);
CreateMemo('SDD','',true,-1);
end;
10: begin
CreateEditInit('SDD');
CreateList;
CreateEditW := CreateEditW*2;
CreateMemo('',sItemBody,true,0);
end;
11: begin
CreateEditInit('SAD',true);
CreateMemo('SAD','',true,-1);
end;
12: begin
CreateEditInit('SAD');
with CreateEdit('Source',sSourceModules) do begin
ShowHint := true;
Hint := sSourceModulesHint;
end;
CreateDirectory('DefaultPath',sDefaultPath);
CreateEditW := CreateEditW*2; // full width
CreateMemo('SAD-Source',format(sIntroductionTextN,[sDocFirstPart]),true,0);
end;
13: begin
CreateEditInit('SAD');
SubDirDefPath := CreateEditSec['DefaultPath'];
CreateList;
CreateEdit('DisplayName',sDisplayName);
CreateEdit('Version',sVersion);
CreateEdit('Requirements',sRequirementsForTest);
CreateDirectory('SourcePath',format(sSourcePathN,[SubDirDefPath]),true);
CreateEdit('SourceFile',sSourceFiles);