-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDPM.Creator.MainForm.pas
1703 lines (1546 loc) · 49.8 KB
/
DPM.Creator.MainForm.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
unit DPM.Creator.MainForm;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
System.ImageList,
Vcl.ImgList,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.ComCtrls,
Vcl.StdCtrls,
Vcl.CheckLst,
Vcl.Menus,
Vcl.WinXPanels,
Vcl.ExtCtrls,
Vcl.Grids,
Vcl.ValEdit,
System.RegularExpressions,
Spring.Collections,
DosCommand,
DPM.Core.Types,
DPM.Core.Logging,
DPM.Core.Spec.Interfaces,
DPM.Creator.TemplateTreeNode,
DPM.Creator.Dspec.FileHandler
;
type
TDSpecCreatorForm = class(TForm)
PageControl: TPageControl;
tsInfo: TTabSheet;
edtId: TEdit;
lblId: TLabel;
lblVersion: TLabel;
edtVersion: TEdit;
mmoDescription: TMemo;
lblDescription: TLabel;
lblProjectURL: TLabel;
edtProjectURL: TEdit;
lblRepositoryURL: TLabel;
edtRepositoryURL: TEdit;
lblLicense: TLabel;
cboLicense: TComboBox;
tsPlatforms: TTabSheet;
lblTags: TLabel;
edtTags: TEdit;
clbCompilers: TCheckListBox;
tsTemplates: TTabSheet;
MainMenu: TMainMenu;
File1: TMenuItem;
miNew: TMenuItem;
miOpen: TMenuItem;
miSave: TMenuItem;
miSaveAs: TMenuItem;
miPrint: TMenuItem;
miPrintSetup: TMenuItem;
miExit: TMenuItem;
N1: TMenuItem;
N2: TMenuItem;
cboTemplate: TComboBox;
clbPlatforms: TCheckListBox;
lblTemplate: TLabel;
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
btnAddTemplate: TButton;
btnDeleteTemplate: TButton;
tvTemplates: TTreeView;
CardPanel: TCardPanel;
crdSource: TCard;
crdSearchPaths: TCard;
lblSrc: TLabel;
edtFileEntrySource: TEdit;
chkFileEntryFlatten: TCheckBox;
lblDest: TLabel;
edtFileEntryDest: TEdit;
lbFileEntryExclude: TListBox;
btnAddExclude: TButton;
btnDeleteExclude: TButton;
crdBuild: TCard;
crdRuntimeOrDesignBpl: TCard;
lblSearchPaths: TLabel;
lblRuntime: TLabel;
lblBuild: TLabel;
lblBuildId: TLabel;
edtBuildId: TEdit;
lblProject: TLabel;
edtProject: TEdit;
lblRuntimeSrc: TLabel;
edtBPLEntrySrc: TEdit;
lblRuntimeBuildId: TLabel;
edtBPLEntryBuildId: TEdit;
chkCopyLocal: TCheckBox;
PopupMenu: TPopupMenu;
BalloonHint1: TBalloonHint;
tsGenerate: TTabSheet;
lblCompilers: TLabel;
lblPlatform: TLabel;
lblTemplateView: TLabel;
edtSearchPath: TEdit;
miOptions: TMenuItem;
lblAuthor: TLabel;
edtAuthor: TEdit;
crdDependencies: TCard;
Label1: TLabel;
lblDependencyId: TLabel;
edtDependencyId: TEdit;
edtDependencyVersion: TEdit;
ImageList1: TImageList;
GridPanel1: TGridPanel;
Panel1: TPanel;
btnBuildPackages: TButton;
Memo1: TMemo;
edtPackageOutputPath: TEdit;
Label2: TLabel;
edtConfiguration: TEdit;
lblConfiguration: TLabel;
chkBuildForDesign: TCheckBox;
chkDesignOnly: TCheckBox;
btnDuplicateTemplate: TButton;
crdTemplates: TCard;
edtTemplateName: TEdit;
lblTemplateName: TLabel;
tsLogging: TTabSheet;
Memo2: TMemo;
chkInstall: TCheckBox;
VariablesList: TValueListEditor;
procedure FormDestroy(Sender: TObject);
procedure btnAddExcludeClick(Sender: TObject);
procedure btnAddTemplateClick(Sender: TObject);
procedure btnBuildPackagesClick(Sender: TObject);
procedure btnDeleteExcludeClick(Sender: TObject);
procedure btnDeleteTemplateClick(Sender: TObject);
procedure btnDuplicateTemplateClick(Sender: TObject);
procedure cboLicenseChange(Sender: TObject);
procedure cboTemplateChange(Sender: TObject);
procedure chkBuildForDesignClick(Sender: TObject);
procedure chkCopyLocalClick(Sender: TObject);
procedure chkDesignInstallClick(Sender: TObject);
procedure chkDesignOnlyClick(Sender: TObject);
procedure clbCompilersClick(Sender: TObject);
procedure clbCompilersClickCheck(Sender: TObject);
procedure clbPlatformsClickCheck(Sender: TObject);
procedure DosCommandNewLine(ASender: TObject; const ANewLine: string; AOutputType: TOutputType);
procedure DosCommandTerminated(Sender: TObject);
procedure edtAuthorChange(Sender: TObject);
procedure edtBuildIdChange(Sender: TObject);
procedure edtConfigurationChange(Sender: TObject);
procedure edtDependencyIdChange(Sender: TObject);
procedure edtDependencyVersionChange(Sender: TObject);
procedure edtDesignBuildIdChange(Sender: TObject);
procedure edtDesignSrcChange(Sender: TObject);
procedure edtFileEntrySourceChange(Sender: TObject);
procedure edtFileEntryDestChange(Sender: TObject);
procedure edtIdChange(Sender: TObject);
procedure edtProjectChange(Sender: TObject);
procedure edtProjectURLChange(Sender: TObject);
procedure edtRepositoryURLChange(Sender: TObject);
procedure edtBPLEntryBuildIdOnChange(Sender: TObject);
procedure edtBPLEntrySrcChange(Sender: TObject);
procedure edtSearchPathChange(Sender: TObject);
procedure edtTagsChange(Sender: TObject);
procedure edtTemplateNameChange(Sender: TObject);
procedure edtVersionChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure miExitClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure mmoDescriptionChange(Sender: TObject);
procedure miNewClick(Sender: TObject);
procedure miOpenClick(Sender: TObject);
procedure miOptionsClick(Sender: TObject);
procedure miSaveAsClick(Sender: TObject);
procedure miSaveClick(Sender: TObject);
procedure tvTemplatesChange(Sender: TObject; Node: TTreeNode);
procedure tvTemplatesCollapsing(Sender: TObject; Node: TTreeNode; var AllowCollapse: Boolean);
procedure tvTemplatesContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
procedure tvTemplatesCreateNodeClass(Sender: TCustomTreeView; var NodeClass: TTreeNodeClass);
procedure PopupAddBuildItem(Sender: TObject);
procedure PopupDeleteBuildItem(Sender: TObject);
procedure PopupAddRuntimeItem(Sender: TObject);
procedure PopupDeleteRuntimeItem(Sender: TObject);
procedure PopupAddDesignItem(Sender: TObject);
procedure PopupDeleteDesignItem(Sender: TObject);
procedure PopupAddSourceItem(Sender: TObject);
procedure PopupDeleteSourceItem(Sender: TObject);
procedure PopupAddFileItem(Sender: TObject);
procedure PopupDeleteFileItem(Sender: TObject);
procedure PopupAddLibItem(Sender: TObject);
procedure PopupDeleteLibItem(Sender: TObject);
procedure PopupAddSearchPathItem(Sender: TObject);
procedure PopupDeleteSearchPathItem(Sender: TObject);
procedure PopupAddDependencyItem(Sender: TObject);
procedure PopupDeleteDependencyItem(Sender: TObject);
procedure tvTemplatesEdited(Sender: TObject; Node: TTreeNode; var S: string);
procedure tvTemplatesEditing(Sender: TObject; Node: TTreeNode; var AllowEdit: Boolean);
procedure VariablesListStringsChange(Sender: TObject);
private
{ Private declarations }
FtmpFilename : string;
FOpenFile : TDSpecFile;
FDosCommand : TDosCommand;
FTemplate : ISpecTemplate;
FSavefilename : string;
FLogger: ILogger;
FInVariableUpdate: Boolean;
procedure LoadTemplates;
procedure EnableDisablePlatform(compilerVersion : TCompilerVersion);
function ReplaceVars(inputStr: String; compiler: TCompilerVersion): string;
function AddRootTemplateNode(template: ISpecTemplate): TTemplateTreeNode;
procedure AddFileEntryNode(node: TTemplateTreeNode; template: ISpecTemplate; fileList: IList<ISpecFileEntry>; NodeName: string);
procedure AddSearchPathNodes(node: TTemplateTreeNode; template: ISpecTemplate);
procedure AddBuildNode(node: TTemplateTreeNode; template: ISpecTemplate);
procedure AddBPLNode(node: TTemplateTreeNode; template: ISpecTemplate; fileList: IList<ISpecBPLEntry>; nodeName: string);
procedure AddDependencyNode(node: TTemplateTreeNode; template: ISpecTemplate);
procedure UpdatePlatformCheckListbox(vplatform: ISpecTargetPlatform; platformName: string; platformListboxName: string = '');
public
{ Public declarations }
procedure LoadDspecStructure;
procedure SaveDspecStructure(const filename: string);
function SelectedPlatform: ISpecTargetPlatform;
end;
var
DSpecCreatorForm: TDSpecCreatorForm;
implementation
{$R *.dfm}
uses
System.UITypes,
System.IOUtils,
DPM.Core.Dependency.Version,
DPM.Creator.TemplateForm,
DPM.Creator.FileForm,
DPM.Creator.BuildForm,
DPM.Creator.RuntimeForm,
DPM.Creator.SearchPathForm,
DPM.Creator.OptionsForm,
DPM.Creator.DependencyForm,
DPM.Creator.Logger,
DPM.Creator.Dspec.Replacer
;
procedure TDSpecCreatorForm.btnDeleteExcludeClick(Sender: TObject);
var
exclude : string;
itemToDelete: Integer;
entry: ISpecFileEntry;
begin
if lbFileEntryExclude.ItemIndex < 0 then
Exit;
if Assigned(tvTemplates.Selected) then
begin
entry := (tvTemplates.Selected as TTemplateTreeNode).FileEntry;
if not Assigned(entry) then
Exit;
exclude := lbFileEntryExclude.Items[lbFileEntryExclude.ItemIndex];
lbFileEntryExclude.DeleteSelected;
itemToDelete := entry.Exclude.IndexOf(exclude);
entry.Exclude.Delete(itemToDelete);
end;
end;
procedure TDSpecCreatorForm.btnAddExcludeClick(Sender: TObject);
var
src : string;
entry: ISpecFileEntry;
begin
Src := InputBox('Add Exclude','Exclude to Add','');
if Assigned(tvTemplates.Selected) then
begin
entry := (tvTemplates.Selected as TTemplateTreeNode).FileEntry;
if not Assigned(entry) then
Exit;
entry.Exclude.Add(src);
lbFileEntryExclude.Items.Add(src);
end;
end;
procedure TDSpecCreatorForm.btnAddTemplateClick(Sender: TObject);
var
templateName : string;
TemplateForm: TTemplateForm;
begin
TemplateForm := TTemplateForm.Create(nil);
try
if not FOpenFile.DoesTemplateExist('default') then
TemplateForm.edtTemplate.Text := 'default';
if TemplateForm.ShowModal = mrCancel then
Exit;
templateName := TemplateForm.edtTemplate.Text;
if templateName.IsEmpty then
Exit;
finally
FreeAndNil(TemplateForm);
end;
FOpenfile.spec.NewTemplate(templateName);
LoadTemplates;
end;
procedure TDSpecCreatorForm.btnBuildPackagesClick(Sender: TObject);
var
guid: TGUID;
begin
guid := TGUID.NewGuid;
FtmpFilename := FOpenFile.WorkingDir;
FtmpFilename := TPath.Combine(FtmpFilename, guid.ToString);
FtmpFilename := ChangeFileExt(FtmpFilename, '.dspec');
TFile.WriteAllText(FtmpFilename, FOpenFile.AsString);
if DirectoryExists(edtPackageOutputPath.Text) then
FDosCommand.CommandLine := 'dpm pack ' + FtmpFilename + ' -o=' + edtPackageOutputPath.Text;
FDosCommand.Execute;
end;
procedure TDSpecCreatorForm.DosCommandNewLine(ASender: TObject; const ANewLine: string; AOutputType: TOutputType);
begin
if AOutputType = otEntireLine then
Memo1.Lines.Add(ANewLine);
end;
procedure TDSpecCreatorForm.DosCommandTerminated(Sender: TObject);
begin
TFile.Delete(FtmpFilename);
FtmpFilename := '';
end;
procedure TDSpecCreatorForm.btnDeleteTemplateClick(Sender: TObject);
var
templateName: string;
begin
if not Assigned(tvTemplates.Selected) then
raise Exception.Create('Select Template to delete');
templateName := (tvTemplates.Selected as TTemplateTreeNode).Template.Name;
FOpenFile.DeleteTemplate(templateName);
LoadTemplates;
end;
procedure TDSpecCreatorForm.btnDuplicateTemplateClick(Sender: TObject);
var
newTemplateName : string;
sourceTemplate : ISpecTemplate;
begin
if not Assigned(tvTemplates.Selected) then
Exit;
sourceTemplate := (tvTemplates.Selected as TTemplateTreeNode).Template;
newTemplateName := sourceTemplate.name + Random(100).ToString;
if not FOpenFile.DoesTemplateExist(newTemplateName) then
begin
FOpenFile.DuplicateTemplate(sourceTemplate, newTemplateName);
end;
LoadTemplates;
end;
procedure TDSpecCreatorForm.cboLicenseChange(Sender: TObject);
begin
FOpenFile.spec.metadata.license := cboLicense.Text;
end;
procedure TDSpecCreatorForm.cboTemplateChange(Sender: TObject);
var
templateName: string;
vPlatform : ISpecTargetPlatform;
begin
templateName := cboTemplate.Items[cboTemplate.ItemIndex];
if templateName = 'Create New Template...' then
begin
PageControl.ActivePage := tsTemplates;
btnAddTemplateClick(Sender);
cboTemplate.ItemIndex := -1;
Exit;
end;
if clbCompilers.ItemIndex < 0 then
raise Exception.Create('Please select a compiler before trying to set the template');
vPlatform := FOpenfile.GetPlatform(clbCompilers.Items[clbCompilers.ItemIndex]);
if not Assigned(vPlatform) then
begin
vPlatform := FOpenFile.AddCompiler(clbCompilers.Items[clbCompilers.ItemIndex]);
end;
vPlatform.TemplateName := templateName;
cboTemplate.ItemIndex := cboTemplate.Items.IndexOf(templateName);
end;
procedure TDSpecCreatorForm.chkBuildForDesignClick(Sender: TObject);
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).build.buildForDesign := chkBuildForDesign.Checked;
end;
end;
procedure TDSpecCreatorForm.chkCopyLocalClick(Sender: TObject);
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).bplEntry.copyLocal := chkCopyLocal.Checked;
end;
end;
procedure TDSpecCreatorForm.chkDesignInstallClick(Sender: TObject);
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).bplEntry.Install := chkInstall.Checked;
end;
end;
procedure TDSpecCreatorForm.chkDesignOnlyClick(Sender: TObject);
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).build.designOnly := chkDesignOnly.Checked;
end;
end;
procedure TDSpecCreatorForm.clbCompilersClick(Sender: TObject);
var
j : Integer;
vplatform : ISpecTargetPlatform;
compilerVersion : TCompilerVersion;
begin
FInVariableUpdate := True;
try
VariablesList.Strings.Clear;
finally
FInVariableUpdate := False;
end;
if clbCompilers.ItemIndex < 0 then
begin
cboTemplate.ItemIndex := -1;
Exit;
end;
vplatform := FOpenFile.GetPlatform(clbCompilers.Items[clbCompilers.ItemIndex]);
compilerVersion := StringToCompilerVersion(clbCompilers.Items[clbCompilers.ItemIndex]);
EnableDisablePlatform(compilerVersion);
if clbCompilers.Checked[clbCompilers.ItemIndex] and not Assigned(vplatform) then
begin
vplatform := FOpenFile.AddCompiler(clbCompilers.Items[clbCompilers.ItemIndex]);
end;
if Assigned(vplatform) then
begin
for j := 0 to clbPlatforms.Count - 1 do
begin
clbPlatforms.Checked[j] := False;
end;
cboTemplate.ItemIndex := cboTemplate.Items.IndexOf(vplatform.TemplateName);
end;
if not Assigned(vplatform) then
begin
cboTemplate.ItemIndex := -1;
Exit;
end;
UpdatePlatformCheckListbox(vplatform, 'Win32');
UpdatePlatformCheckListbox(vplatform, 'Win64');
UpdatePlatformCheckListbox(vplatform, 'Android32', 'Android');
UpdatePlatformCheckListbox(vplatform, 'Android');
UpdatePlatformCheckListbox(vplatform, 'Android64');
UpdatePlatformCheckListbox(vplatform, 'LinuxIntel64', 'Linux');
UpdatePlatformCheckListbox(vplatform, 'iOS64');
UpdatePlatformCheckListbox(vplatform, 'OSX64');
FInVariableUpdate := True;
try
VariablesList.Strings.Clear;
VariablesList.Strings.AddStrings(vplatform.Variables);
finally
FInVariableUpdate := False;
end;
cboTemplate.Clear;
LoadTemplates;
cboTemplate.ItemIndex := cboTemplate.Items.IndexOf(vplatform.TemplateName);
end;
procedure TDSpecCreatorForm.clbCompilersClickCheck(Sender: TObject);
var
vPlatform : ISpecTargetPlatform;
compiler : string;
begin
if clbCompilers.ItemIndex < 0 then
Exit;
compiler := clbCompilers.Items[clbCompilers.ItemIndex];
vPlatform := FOpenfile.GetPlatform(compiler);
if clbCompilers.Checked[clbCompilers.ItemIndex] and not Assigned(vPlatform) then
begin
vPlatform := FOpenFile.AddCompiler(compiler);
end
else if Assigned(vPlatform) and (clbCompilers.Checked[clbCompilers.ItemIndex] = False) then
begin
FOpenFile.DeleteCompiler(compiler);
end;
end;
procedure TDSpecCreatorForm.clbPlatformsClickCheck(Sender: TObject);
var
vPlatform : ISpecTargetPlatform;
compiler : string;
platformString : string;
dpmPlatform: TDPMPlatform;
i, j: Integer;
platformCount: Integer;
newPlatforms: TArray<TDPMPlatform>;
begin
if clbCompilers.ItemIndex < 0 then
begin
raise Exception.Create('You must select a compiler before you can select platforms');
end;
if clbPlatforms.ItemIndex < 0 then
Exit;
compiler := clbCompilers.Items[clbCompilers.ItemIndex];
vPlatform := FOpenfile.GetPlatform(compiler);
platformCount := 0;
for i := 0 to clbPlatforms.Count - 1 do
begin
if clbPlatforms.Checked[i] then
begin
platformString := clbPlatforms.Items[i];
if platformString = 'Linux' then
platformString := 'Linux64';
dpmPlatform := StringToDPMPlatform(platformString);
if dpmPlatform = TDPMPlatform.UnknownPlatform then
continue;
Inc(platformCount);
end;
end;
SetLength(newPlatforms, platformCount);
j := 0;
for i := 0 to clbPlatforms.Count - 1 do
begin
if not clbPlatforms.Checked[i] then
continue;
platformString := clbPlatforms.Items[i];
if platformString = 'Linux' then
platformString := 'Linux64';
dpmPlatform := StringToDPMPlatform(platformString);
if dpmPlatform = TDPMPlatform.UnknownPlatform then
continue;
newPlatforms[j] := dpmPlatform;
Inc(j);
end;
vPlatform.platforms := newPlatforms;
end;
procedure TDSpecCreatorForm.edtAuthorChange(Sender: TObject);
begin
FOpenFile.spec.metadata.authors := edtAuthor.Text;
end;
procedure TDSpecCreatorForm.edtBuildIdChange(Sender: TObject);
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).build.id := edtBuildId.Text;
(tvTemplates.Selected as TTemplateTreeNode).Text := edtBuildId.Text;
end;
end;
procedure TDSpecCreatorForm.edtConfigurationChange(Sender: TObject);
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).build.Config := edtConfiguration.Text;
end;
end;
procedure TDSpecCreatorForm.edtDependencyIdChange(Sender: TObject);
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).dependency.id := edtDependencyId.Text;
(tvTemplates.Selected as TTemplateTreeNode).Text := edtDependencyId.Text + ' - ' + edtDependencyVersion.Text;
end;
end;
procedure TDSpecCreatorForm.edtDependencyVersionChange(Sender: TObject);
var
ver : TVersionRange;
begin
if Assigned(tvTemplates.Selected) then
begin
if length(edtDependencyVersion.Text) > 0 then
begin
if TVersionRange.TryParse(edtDependencyVersion.Text, ver) then
begin
(tvTemplates.Selected as TTemplateTreeNode).dependency.version := ver;
(tvTemplates.Selected as TTemplateTreeNode).Text := edtDependencyId.Text + ' - ' + edtDependencyVersion.Text;
end;
end;
end;
end;
procedure TDSpecCreatorForm.edtDesignSrcChange(Sender: TObject);
var
str : string;
compiler : TCompilerVersion;
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).bplEntry.Source := edtBPLEntrySrc.Text;
str := 'Possible Expanded Paths:' + System.sLineBreak;
for compiler := Low(TCompilerVersion) to High(TCompilerVersion) do
begin
if compiler = TCompilerVersion.UnknownVersion then
continue;
str := str + System.sLineBreak + ReplaceVars(edtBPLEntrySrc.Text, compiler);
end;
edtBPLEntrySrc.Hint := str;
end;
end;
procedure TDSpecCreatorForm.edtDesignBuildIdChange(Sender: TObject);
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).bplEntry.buildId := edtBPLEntryBuildId.Text;
(tvTemplates.Selected as TTemplateTreeNode).Text := edtBPLEntryBuildId.Text;
end;
end;
procedure TDSpecCreatorForm.edtFileEntryDestChange(Sender: TObject);
var
str : string;
compiler : TCompilerVersion;
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).FileEntry.Destination := edtFileEntryDest.Text;
str := 'Possible Expanded Paths:' + System.sLineBreak;
for compiler := Low(TCompilerVersion) to High(TCompilerVersion) do
begin
if compiler = TCompilerVersion.UnknownVersion then
continue;
str := str + System.sLineBreak + ReplaceVars(edtFileEntryDest.Text, compiler);
end;
edtFileEntryDest.Hint := str;
end;
end;
function TDSpecCreatorForm.AddRootTemplateNode(template: ISpecTemplate): TTemplateTreeNode;
begin
cboTemplate.Items.Add(template.name);
Result := tvTemplates.Items.Add(nil, template.name) as TTemplateTreeNode;
Result.NodeType := ntTemplateHeading;
Result.Template := template;
Result.ImageIndex := 5;
Result.SelectedIndex := 5;
Result.TemplateHeading := True;
end;
procedure TDSpecCreatorForm.AddFileEntryNode(node: TTemplateTreeNode; template: ISpecTemplate; fileList: IList<ISpecFileEntry>; NodeName: string);
var
nodeSource: TTemplateTreeNode;
sourceNode: TTemplateTreeNode;
j: Integer;
iconIndex : Integer;
lNodeType : TNodeType;
lOnNewText : string;
lOnDeleteText : string;
lOnNewClick : TNotifyEvent;
lOnDeleteClick : TNotifyEvent;
begin
lOnNewClick := nil;
lOnDeleteClick := nil;
if NodeName = 'Source' then
begin
iconIndex := 2;
lNodeType := ntSourceHeading;
lOnNewText := 'Add Source Item';
lOnNewClick := PopupAddSourceItem;
lOnDeleteText := 'Delete Source Item';
lOnDeleteClick := PopupDeleteSourceItem;
end
else if NodeName = 'Files' then
begin
iconIndex := 2;
lNodeType := ntFileHeading;
lOnNewText := 'Add File Item';
lOnNewClick := PopupAddFileItem;
lOnDeleteText := 'Delete File Item';
lOnDeleteClick := PopupDeleteFileItem;
end
else if NodeName = 'Lib' then
begin
iconIndex := 2;
lNodeType := ntLibHeading;
lOnNewText := 'Add Library Item';
lOnNewClick := PopupAddLibItem;
lOnDeleteText := 'Delete Library Item';
lOnDeleteClick := PopupDeleteLibItem;
end
else
raise Exception.Create('nodeName must be either Source, Files or Lib. Was [' + NodeName + ']');
nodeSource := tvTemplates.Items.AddChild(node, NodeName) as TTemplateTreeNode;
nodeSource.Template := template;
nodeSource.NodeType := lNodeType;
nodeSource.ImageIndex := iconIndex;
nodeSource.SelectedIndex := iconIndex;
nodeSource.OnNewText := lOnNewText;
nodeSource.OnNewClick := lOnNewClick;
nodeSource.OnDeleteText := lOnDeleteText;
nodeSource.OnDeleteClick := lOnDeleteClick;
for j := 0 to fileList.Count - 1 do
begin
sourceNode := tvTemplates.Items.AddChild(nodeSource, fileList[j].Source) as TTemplateTreeNode;
sourceNode.fileEntry := fileList[j];
if NodeName = 'Source' then
begin
sourceNode.NodeType := ntSource;
end
else if NodeName = 'Files' then
begin
sourceNode.NodeType := ntFile;
end
else if NodeName = 'Lib' then
begin
sourceNode.NodeType := ntLib;
end;
sourceNode.Template := template;
sourceNode.ImageIndex := iconIndex;
sourceNode.SelectedIndex := iconIndex;
end;
end;
procedure TDSpecCreatorForm.AddSearchPathNodes(node: TTemplateTreeNode; template: ISpecTemplate);
var
nodeSearchPath: TTemplateTreeNode;
searchPathNode: TTemplateTreeNode;
j: Integer;
begin
nodeSearchPath := tvTemplates.Items.AddChild(node, 'SearchPaths') as TTemplateTreeNode;
nodeSearchPath.Template := template;
nodeSearchPath.ImageIndex := 3;
nodeSearchPath.SelectedIndex := 3;
nodeSearchPath.NodeType := ntSeachPathHeading;
nodeSearchPath.OnNewText := 'Add SearchPath Item';
nodeSearchPath.OnNewClick := PopupAddSearchPathItem;
nodeSearchPath.OnDeleteText := 'Delete SearchPath Item';
nodeSearchPath.OnDeleteClick := PopupDeleteSearchPathItem;
for j := 0 to template.searchPaths.Count - 1 do
begin
searchPathNode := tvTemplates.Items.AddChild(nodeSearchPath, template.searchPaths[j].path) as TTemplateTreeNode;
searchPathNode.searchpath := template.searchPaths[j];
searchPathNode.Template := template;
searchPathNode.NodeType := ntSeachPath;
searchPathNode.ImageIndex := 3;
searchPathNode.SelectedIndex := 3;
end;
end;
procedure TDSpecCreatorForm.AddBuildNode(node: TTemplateTreeNode; template: ISpecTemplate);
var
nodeBuild: TTemplateTreeNode;
buildNode: TTemplateTreeNode;
j: Integer;
begin
nodeBuild := tvTemplates.Items.AddChild(node, 'Build') as TTemplateTreeNode;
nodeBuild.Template := template;
nodeBuild.ImageIndex := 0;
nodeBuild.SelectedIndex := 0;
nodeBuild.NodeType := ntBuildHeading;
nodeBuild.OnNewText := 'Add Build Item';
nodeBuild.OnNewClick := PopupAddBuildItem;
nodeBuild.OnDeleteText := 'Delete Source Item';
nodeBuild.OnDeleteClick := PopupDeleteBuildItem;
for j := 0 to template.BuildEntries.Count - 1 do
begin
buildNode := tvTemplates.Items.AddChild(nodeBuild, template.BuildEntries[j].id) as TTemplateTreeNode;
buildNode.build := template.BuildEntries[j];
buildNode.Template := template;
buildNode.ImageIndex := 0;
buildNode.SelectedIndex := 0;
buildNode.NodeType := ntBuild;
end;
end;
procedure TDSpecCreatorForm.AddBPLNode(node: TTemplateTreeNode; template: ISpecTemplate; fileList: IList<ISpecBPLEntry>; nodeName: string);
var
nodeDesign: TTemplateTreeNode;
designNode: TTemplateTreeNode;
j: Integer;
iconIndex : Integer;
lNodeType : TNodeType;
lOnNewText : string;
lOnDeleteText : string;
lOnNewClick : TNotifyEvent;
lOnDeleteClick : TNotifyEvent;
begin
if nodeName = 'Design' then
begin
iconIndex := 6;
lNodeType := ntDesignHeading;
lOnNewText := 'Add Design Item';
lOnNewClick := PopupAddDesignItem;
lOnDeleteText := 'Delete Design Item';
lOnDeleteClick := PopupDeleteDesignItem;
end
else if nodeName = 'Runtime' then
begin
iconIndex := 1;
lNodeType := ntRuntimeHeading;
lOnNewText := 'Add Runtime Item';
lOnNewClick := PopupAddRuntimeItem;
lOnDeleteText := 'Delete Runtime Item';
lOnDeleteClick := PopupDeleteRuntimeItem;
end
else
raise Exception.Create('Nodetype must be either Design or Runtime - was [' + nodeName + ']');
nodeDesign := tvTemplates.Items.AddChild(node, nodeName) as TTemplateTreeNode;
nodeDesign.Template := template;
nodeDesign.NodeType := lNodeType;
nodeDesign.ImageIndex := iconIndex;
nodeDesign.SelectedIndex := iconIndex;
nodeDesign.OnNewText := lOnNewText;
nodeDesign.OnNewClick := lOnNewClick;
nodeDesign.OnDeleteText := lOnDeleteText;
nodeDesign.OnDeleteClick := lOnDeleteClick;
for j := 0 to fileList.Count - 1 do
begin
designNode := tvTemplates.Items.AddChild(nodeDesign, fileList[j].BuildId) as TTemplateTreeNode;
designNode.bplEntry := fileList[j];
if nodeName = 'Design' then
begin
designNode.NodeType := ntDesign;
end
else if nodeName = 'Runtime' then
begin
designNode.NodeType := ntRuntime;
end;
designNode.Template := template;
designNode.ImageIndex := iconIndex;
designNode.SelectedIndex := iconIndex;
end;
end;
procedure TDSpecCreatorForm.AddDependencyNode(node: TTemplateTreeNode; template: ISpecTemplate);
var
nodeDependency: TTemplateTreeNode;
dependencyNode: TTemplateTreeNode;
j: Integer;
begin
nodeDependency := tvTemplates.Items.AddChild(node, 'Dependencies') as TTemplateTreeNode;
nodeDependency.Template := template;
nodeDependency.ImageIndex := 4;
nodeDependency.SelectedIndex := 4;
nodeDependency.NodeType := ntDependencyHeading;
nodeDependency.OnNewText := 'Add Dependency Item';
nodeDependency.OnNewClick := PopupAddDependencyItem;
nodeDependency.OnDeleteText := 'Delete Dependency Item';
nodeDependency.OnDeleteClick := PopupDeleteDependencyItem;
for j := 0 to template.dependencies.Count - 1 do
begin
dependencyNode := tvTemplates.Items.AddChild(nodeDependency, template.dependencies[j].id) as TTemplateTreeNode;
dependencyNode.dependency := template.dependencies[j];
dependencyNode.Template := template;
dependencyNode.ImageIndex := 4;
dependencyNode.SelectedIndex := 4;
dependencyNode.NodeType := ntDependency;
end;
end;
procedure TDSpecCreatorForm.LoadTemplates;
var
node: TTemplateTreeNode;
i : Integer;
template: ISpecTemplate;
begin
tvTemplates.Items.Clear;
cboTemplate.Clear;
for i := 0 to FOpenFile.spec.templates.Count - 1 do
begin
template := FOpenFile.spec.templates[i];
node := AddRootTemplateNode(template);
AddFileEntryNode(node, template, template.SourceFiles, 'Source');
AddFileEntryNode(node, template, template.Files, 'Files');
AddFileEntryNode(node, template, template.LibFiles, 'Lib');
AddSearchPathNodes(node, template);
AddBuildNode(node, template);
AddBPLNode(node, template, template.DesignFiles, 'Design');
AddBPLNode(node, template, template.RuntimeFiles, 'Runtime');
AddDependencyNode(node, template);
node.Expand(True);
end;
cboTemplate.Items.Add('Create New Template...');
end;
procedure TDSpecCreatorForm.edtIdChange(Sender: TObject);
begin
FOpenFile.spec.metadata.id := edtId.Text;
end;
procedure TDSpecCreatorForm.edtProjectChange(Sender: TObject);
var
str : string;
compiler : TCompilerVersion;
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).build.project := edtProject.Text;
str := 'Possible Expanded Paths:' + System.sLineBreak;
for compiler := Low(TCompilerVersion) to High(TCompilerVersion) do
begin
if compiler = TCompilerVersion.UnknownVersion then
continue;
str := str + System.sLineBreak + ReplaceVars(edtProject.Text, compiler);
end;
edtProject.Hint := str;
end;
end;
procedure TDSpecCreatorForm.edtProjectURLChange(Sender: TObject);
begin
FOpenFile.spec.metadata.projectUrl := edtProjectURL.Text;
end;
procedure TDSpecCreatorForm.edtRepositoryURLChange(Sender: TObject);
begin
FOpenFile.spec.metadata.repositoryUrl := edtRepositoryURL.Text;
end;
procedure TDSpecCreatorForm.edtBPLEntryBuildIdOnChange(Sender: TObject);
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).bplEntry.Source := edtBPLEntrySrc.Text;
(tvTemplates.Selected as TTemplateTreeNode).Text := edtBPLEntryBuildId.Text;
end;
end;
function TDSpecCreatorForm.ReplaceVars(inputStr: String; compiler: TCompilerVersion): string;
begin
Result := TClassReplacer.ReplaceVars(inputStr, compiler, FOpenFile.spec);
end;
procedure TDSpecCreatorForm.edtBPLEntrySrcChange(Sender: TObject);
var
str : string;
compiler : TCompilerVersion;
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).bplEntry.Source := edtBPLEntrySrc.Text;
str := 'Possible Expanded Paths:' + System.sLineBreak;
for compiler := Low(TCompilerVersion) to High(TCompilerVersion) do
begin
if compiler = TCompilerVersion.UnknownVersion then
continue;
str := str + System.sLineBreak + ReplaceVars(edtBPLEntrySrc.Text, compiler);
end;
edtBPLEntrySrc.Hint := str;
end;
end;
procedure TDSpecCreatorForm.edtSearchPathChange(Sender: TObject);
begin
if Assigned(tvTemplates.Selected) then
begin
(tvTemplates.Selected as TTemplateTreeNode).searchpath.path:= edtSearchPath.Text;