-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDW.OTA.ProjectConfigComboBox.pas
More file actions
90 lines (77 loc) · 2.67 KB
/
DW.OTA.ProjectConfigComboBox.pas
File metadata and controls
90 lines (77 loc) · 2.67 KB
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
unit DW.OTA.ProjectConfigComboBox;
{*******************************************************}
{ }
{ TOTAL - Terrific Open Tools API Library }
{ }
{*******************************************************}
interface
uses
ToolsAPI, PlatformAPI,
DW.OTA.BaseProjectConfigComboBox;
type
TOTAProjectConfigComboBox = class(TBaseProjectConfigComboBox)
private
FPlatforms: IOTAProjectPlatforms;
FConfigs: TArray<IOTABuildConfiguration>;
procedure AddConfig(const AConfig: IOTABuildConfiguration);
procedure AddConfigPlatform(const AConfig: IOTABuildConfiguration);
function GetSelectedConfig: IOTABuildConfiguration;
protected
procedure DoLoadTargets; override;
public
procedure Clear; override;
property SelectedConfig: IOTABuildConfiguration read GetSelectedConfig;
end;
implementation
uses
System.SysUtils,
DW.Proj.Types,
DW.OTA.Helpers, DW.OTA.Types;
{ TOTAProjectConfigComboBox }
procedure TOTAProjectConfigComboBox.AddConfigPlatform(const AConfig: IOTABuildConfiguration);
var
LTarget: TProjectTarget;
LProjectPlatform: TProjectPlatform;
begin
LProjectPlatform := TProjectPlatform.Win32;
TProjectPlatformHelper.FindProjectPlatform(AConfig.Platform, LProjectPlatform);
LTarget := TProjectTarget.Create(TProjConfig.Create(AConfig.Name, ''), LProjectPlatform, AConfig.Platform = '');
Targets.Add(LTarget);
Items.Add(LTarget.GetDisplayValue(True));
FConfigs := FConfigs + [AConfig];
end;
procedure TOTAProjectConfigComboBox.Clear;
begin
inherited;
FConfigs := [];
end;
procedure TOTAProjectConfigComboBox.AddConfig(const AConfig: IOTABuildConfiguration);
var
I: Integer;
LPlatform: string;
begin
AddConfigPlatform(AConfig);
for LPlatform in FPlatforms.EnabledPlatforms do
AddConfigPlatform(AConfig.PlatformConfiguration[LPlatform]);
for I := 0 to AConfig.ChildCount -1 do
AddConfig(AConfig.Children[I]);
end;
procedure TOTAProjectConfigComboBox.DoLoadTargets;
var
LProject: IOTAProject;
LConfigs: IOTAProjectOptionsConfigurations;
begin
LProject := TOTAHelper.GetActiveProject;
if (LProject <> nil) and Supports(LProject, IOTAProjectPlatforms, FPlatforms)
and Supports(LProject.ProjectOptions, IOTAProjectOptionsConfigurations, LConfigs) then
begin
AddConfig(LConfigs.BaseConfiguration);
end;
end;
function TOTAProjectConfigComboBox.GetSelectedConfig: IOTABuildConfiguration;
begin
Result := nil;
if (ItemIndex > -1) and (ItemIndex < Length(FConfigs)) then
Result := FConfigs[ItemIndex];
end;
end.